diff --git a/.htaccess b/.htaccess
index 360a61895f3faef0a040323291df04e674bce22d..365054378918f76b0da55fcdcb256e7f6f9fb822 100644
--- a/.htaccess
+++ b/.htaccess
@@ -180,4 +180,4 @@
 ## If running in cluster environment, uncomment this
 ## http://developer.yahoo.com/performance/rules.html#etags
 
-    #FileETag none
+    #FileETag none
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34e9246bff5008a6b90df8ef0e845175453f1e7f..370a2aca824777b47035baf31f04fc04990cb044 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,40 @@
+2.0.0.0-dev65
+=============
+* Fixed bugs:
+  * Fixed inability to execute System Backup, Database Backup, and Media Backup
+* Indexer implementation:
+  * Implemented a new optimized Catalog Category Flat Indexer
+* Cron improvements:
+  * Added the ability to divide cron tasks into groups
+  * Added the ability to run cron groups in separate processes
+* Caching improvements:
+  * Added a new mechanism to identify uniquely page content (hash-key for cache storage)
+  * Added a tab for Page Cache mechanism in System Configuration
+  * Implemented the ability to configure the Varnish caching server settings and download it as a .vcl file
+* LESS pre-processing to CSS
+  * LESS files in library, theme, module are automatically compiled to CSS during materialization
+  * LESS files compilation caching mechanism added in Developer mode
+* Modularity improvements:
+  * Moved the Shortcut Buttons abstraction from PayPal to Catalog
+  * Moved the Recurring Profile functionality to a separate module
+  * Moved the Billing Agreements functionality to the PayPal module
+* Improvements in code coverage calculation:
+  * Added code coverage calculation in the clover xml format for unit tests
+* GitHub requests:
+ * [#377] (https://github.com/magento/magento2/issues/377) Remove and avoid javascript eval() calls 
+ * [#319] (https://github.com/magento/magento2/issues/319) No message was displayed when product added to shopping cart.
+ * [#367] (https://github.com/magento/magento2/issues/367) Improve the error message from the contact form
+ * [#469] (https://github.com/magento/magento2/issues/469) Can't change prices on different websites for custom options
+* Updated the Customer service exception handling, and added tests
+* Added usage of the Customer service to the Customer module, replacing some direct usage of the Customer model
+* Updated various PHPDoc with the parameter and return types
+
 2.0.0.0-dev64
 =============
 * Modularity improvements:
   * Moved abstract shopping cart logic from the Paypal module to the Payments module
 * Caching improvements:
   * Added a new mechanism to uniquely identify page content (a hash-key for cache storage)
-  * Replaced the "magentoZoom" plugin with two widgets: the "gallery" and "zoom"
 * Fixed bugs:
   * Fixed an issue with inserting an image in WYSIWYG editor where the selected folder was stored in session
   * Fixed an issue with CMS Page Links not being shown because of the empty text in the link
@@ -17,6 +47,7 @@
 * Created the architecture for the email template library
 * Introduced a consistent approach for using the Config scope
 * Fixed an issue with the dependency static test
+* Replaced the "magentoZoom" plugin with two widgets: the "gallery" and "zoom"
 
 2.0.0.0-dev63
 =============
diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php
index d4b41ceff5ca8186acb85cc215f75c1b39fa6e07..89b189239c9be1c62737e7470108166596402ccf 100644
--- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php
+++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php
@@ -27,7 +27,7 @@ class Security
     implements \Magento\AdminNotification\Model\System\MessageInterface
 {
     /**
-     * Cache kay for saving verification result
+     * Cache key for saving verification result
      */
     const VERIFICATION_RESULT_CACHE_KEY = 'configuration_files_access_level_verification';
 
diff --git a/app/code/Magento/AdminNotification/view/adminhtml/system/messages.phtml b/app/code/Magento/AdminNotification/view/adminhtml/system/messages.phtml
index 302955e401eb43887e55ed65bdc072bf4f863932..941013895d70b7d77999d120a81bec6814e5e8aa 100644
--- a/app/code/Magento/AdminNotification/view/adminhtml/system/messages.phtml
+++ b/app/code/Magento/AdminNotification/view/adminhtml/system/messages.phtml
@@ -43,7 +43,7 @@
                <span class="warning"><a href="#" title="<?php echo $this->escapeHtml(__('Major System Messages'));?>"><?php echo $this->getMajorCount();?></a></span>
             <?php endif;?>
         </div>
-        <div id="message-system-all" title="<?php echo $this->escapeHtml(__('System messages'));?>" data-mage-init="<?php echo $this->escapeHtml($this->getSystemMessageDialogJson());?>"></div>
+        <div id="message-system-all" title="<?php echo $this->escapeHtml(__('System messages'));?>" data-mage-init='<?php echo $this->escapeHtml($this->getSystemMessageDialogJson());?>'></div>
     </div>
 </div>
 
diff --git a/app/code/Magento/AdminNotification/view/adminhtml/system/notification.js b/app/code/Magento/AdminNotification/view/adminhtml/system/notification.js
index 47603554cb0925c665c44b985eef846667a6ee80..d03b59581ec80565abdd435a5e0dd1d95e9758fb 100644
--- a/app/code/Magento/AdminNotification/view/adminhtml/system/notification.js
+++ b/app/code/Magento/AdminNotification/view/adminhtml/system/notification.js
@@ -21,7 +21,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 /*jshint jquery:true*/
-(function ($) {
+jQuery(function ($) {
     $.template(
         'systemMessageDialog',
         '<li class="{{if severity == 1}}error{{else}}warning{{/if}}">{{html text}}</li>'
@@ -69,5 +69,5 @@
             $('#message-system-all').systemMessageDialog('open', 2);
         });
     });
-})(jQuery);
+});
 
diff --git a/app/code/Magento/Authorizenet/Helper/Backend.php b/app/code/Magento/Authorizenet/Helper/Backend.php
index c30b972e3393936b4adfea816501d8d7cb9e629c..9d95af65de8e5af3afefdc48d65ec2d15a58a121 100644
--- a/app/code/Magento/Authorizenet/Helper/Backend.php
+++ b/app/code/Magento/Authorizenet/Helper/Backend.php
@@ -104,7 +104,7 @@ class Backend extends Data
      */
     public function getRelyUrl($storeId = null)
     {
-        return $this->_storeManager->getDefaultStoreView()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LINK)
+        return $this->_storeManager->getDefaultStoreView()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK)
             . 'authorizenet/directpost_payment/backendResponse';
     }
 }
diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php
index 0cc27f6694c84b0d119708eff9ae2f87229d6967..4f7ffbe3bc97688975a20c103c2b87074fed425a 100644
--- a/app/code/Magento/Authorizenet/Helper/Data.php
+++ b/app/code/Magento/Authorizenet/Helper/Data.php
@@ -331,7 +331,7 @@ class Data extends \Magento\App\Helper\AbstractHelper implements HelperInterface
      */
     public function getRelyUrl($storeId = null)
     {
-        return $this->_storeManager->getStore($storeId)->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LINK)
+        return $this->_storeManager->getStore($storeId)->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK)
             . 'authorizenet/directpost_payment/response';
     }
 }
diff --git a/pub/lib/mage/directpost.js b/app/code/Magento/Authorizenet/view/adminhtml/js/direct-post.js
similarity index 100%
rename from pub/lib/mage/directpost.js
rename to app/code/Magento/Authorizenet/view/adminhtml/js/direct-post.js
diff --git a/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml
index d5fe24b53fc0ba433510532437e0cec4146c2fdc..a67d411e3e3835064ce56304390825b68b806a1b 100644
--- a/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml
+++ b/app/code/Magento/Authorizenet/view/adminhtml/layout/sales_order_create_index.xml
@@ -25,9 +25,9 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceBlock name="head">
-        <block class="Magento\Theme\Block\Html\Head\Script" name="magento-directpost-js">
+        <block class="Magento\Theme\Block\Html\Head\Script" name="magento-authorizenet-js-direct-post-js">
             <arguments>
-                <argument name="file" xsi:type="string">mage/directpost.js</argument>
+                <argument name="file" xsi:type="string">Magento_Authorizenet::js/direct-post.js</argument>
             </arguments>
         </block>
     </referenceBlock>
diff --git a/app/code/Magento/Authorizenet/view/frontend/directpost/form.phtml b/app/code/Magento/Authorizenet/view/frontend/directpost/form.phtml
index 6cac0c3c0743bff087185cb8f5d534cd4ae693b6..48833474be34d89a5fb4c639f14b05809e23d585 100644
--- a/app/code/Magento/Authorizenet/view/frontend/directpost/form.phtml
+++ b/app/code/Magento/Authorizenet/view/frontend/directpost/form.phtml
@@ -38,7 +38,7 @@ $_orderUrl = $this->helper('Magento\Authorizenet\Helper\Data')->getPlaceOrderFro
 
 <!-- IFRAME for request to Authorize.net -->
 <iframe id="directpost-iframe" data-container="authorize-net-iframe" allowtransparency="true" frameborder="0"  name="iframeDirectPost" style="display:none;width:100%;background-color:transparent" src="<?php echo $this->getViewFileUrl('blank.html') ?>"></iframe>
-<form class="form" id="co-directpost-form" action="#" method="post" data-mage-init="{directpost: {methodCode:'<?php echo $_code ?>', controller:'<?php echo $_controller ?>', orderSaveUrl:'<?php echo $_orderUrl ?>', cgiUrl:'<?php echo $_method->getCgiUrl() ?>', nativeAction:'<?php echo $this->getUrl('checkout/onepage/saveOrder', array('_secure' => $this->getRequest()->isSecure())) ?>'}, validation: []}">
+<form class="form" id="co-directpost-form" action="#" method="post" data-mage-init='{"directpost":{"methodCode":"<?php echo $_code ?>", "controller":"<?php echo $_controller ?>", "orderSaveUrl":"<?php echo $_orderUrl ?>", "cgiUrl":"<?php echo $_method->getCgiUrl() ?>", "nativeAction":"<?php echo $this->getUrl('checkout/onepage/saveOrder', array('_secure' => $this->getRequest()->isSecure())) ?>"}, "validation":[]}'>
     <fieldset class="fieldset ccard <?php echo $_code ?>" id="payment_form_<?php echo $_code ?>">
         <legend class="legend"><span><?php echo __('Credit Card Information') ?></span></legend><br />
         <div class="field required type">
@@ -92,10 +92,10 @@ $_orderUrl = $this->helper('Magento\Authorizenet\Helper\Data')->getPlaceOrderFro
             <div class="control">
                 <input type="number" title="<?php echo __('Card Verification Number') ?>" data-container="cc-cvv" class="input-text cvv" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" data-validate='{required:true, "validate-cc-cvn":"#<?php echo $_code ?>_cc_type"}' autocomplete="off"/>
                 <div class="note">
-                    <a href="#" id="directpost-cvv-what-is-this" class="action cvv" data-mage-init='{toggleAdvanced: {toggleContainers:"#directpost-tool-tip"}}'><span><?php echo __('What is this?') ?></span></a>
+                    <a href="#" id="directpost-cvv-what-is-this" class="action cvv" data-mage-init='{"toggleAdvanced": {"toggleContainers":"#directpost-tool-tip"}}'><span><?php echo __('What is this?') ?></span></a>
                 </div>
                 <div class="tooltip hidden" id="directpost-tool-tip">
-                    <a href="#" id="directpost-tool-tip-close" title="<?php echo __('Close') ?>" data-mage-init='{toggleAdvanced: {toggleContainers:"#directpost-tool-tip"}}' class="action close">
+                    <a href="#" id="directpost-tool-tip-close" title="<?php echo __('Close') ?>" data-mage-init='{"toggleAdvanced": {"toggleContainers":"#directpost-tool-tip"}}' class="action close">
                         <span><?php echo __('Close') ?></span>
                     </a>
                     <div class="content"><img src="<?php echo $this->getViewFileUrl('Magento_Checkout::cvv.gif') ?>" alt="<?php echo __('Card Verification Number Visual Reference') ?>" title="<?php echo __('Card Verification Number Visual Reference') ?>" /></div>
diff --git a/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml b/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml
index 6d818bec2cabd0bf9478715adf3b436d83e86ad8..b15d7c62deb02a19279a4b17099e516625de131a 100644
--- a/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml
+++ b/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml
@@ -25,8 +25,9 @@
  */
 ?>
 
+<dl class="payment method">
 <?php if (!$this->getHideTitle()): ?>
-    <p><strong><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></strong></p>
+    <dt class="title"><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></dt>
 <?php endif; ?>
 
 <?php
@@ -34,21 +35,23 @@
     $showCount = count($cards) > 1;
 ?>
 
-<dl class="cards items">
+    <dl class="cards items">
 <?php foreach ($cards as $key => $card): ?>
 
     <?php if ($showCount): ?>
         <dt><?php echo sprintf(__('Credit Card %s'), $key + 1); ?></dt>
     <?php endif; ?>
-
-    <dd>
-        <dl class="card item">
-        <?php foreach ($card as $_label => $_value): ?>
-            <dt><?php echo $this->escapeHtml($_label); ?>:</dt>
-            <dd><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n")); ?></dd>
-        <?php endforeach; ?>
-        </dl>
+    <dd class="content">
+        <table class="data table">
+            <?php foreach ($card as $_label => $_value): ?>
+                <tr>
+                    <th><?php echo $this->escapeHtml($_label) ?></th>
+                    <td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n")) ?></td>
+                </tr>
+            <?php endforeach; ?>
+        </table>
     </dd>
 
 <?php endforeach; ?>
+    </dl>
 </dl>
diff --git a/app/code/Magento/Authorizenet/view/frontend/js/directpost.js b/app/code/Magento/Authorizenet/view/frontend/js/direct-post.js
similarity index 100%
rename from app/code/Magento/Authorizenet/view/frontend/js/directpost.js
rename to app/code/Magento/Authorizenet/view/frontend/js/direct-post.js
diff --git a/app/code/Magento/Authorizenet/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Authorizenet/view/frontend/layout/checkout_onepage_index.xml
index efa0a49ff3aaf36277d3238a49e886781ab37a89..a67d411e3e3835064ce56304390825b68b806a1b 100644
--- a/app/code/Magento/Authorizenet/view/frontend/layout/checkout_onepage_index.xml
+++ b/app/code/Magento/Authorizenet/view/frontend/layout/checkout_onepage_index.xml
@@ -25,9 +25,9 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceBlock name="head">
-        <block class="Magento\Theme\Block\Html\Head\Script" name="mage-centinel-centinel-authenticate-js">
+        <block class="Magento\Theme\Block\Html\Head\Script" name="magento-authorizenet-js-direct-post-js">
             <arguments>
-                <argument name="file" xsi:type="string">Magento_Authorizenet::js/directpost.js</argument>
+                <argument name="file" xsi:type="string">Magento_Authorizenet::js/direct-post.js</argument>
             </arguments>
         </block>
     </referenceBlock>
diff --git a/app/code/Magento/Backend/App/AbstractAction.php b/app/code/Magento/Backend/App/AbstractAction.php
index 0ca05ec35cb09294b244993e9d4da4d6fa41a449..c6b5a29ad22d5e069861801d9b1d7febbc31272a 100644
--- a/app/code/Magento/Backend/App/AbstractAction.php
+++ b/app/code/Magento/Backend/App/AbstractAction.php
@@ -119,6 +119,9 @@ abstract class AbstractAction extends \Magento\App\Action\Action
         $this->_session = $context->getSession();
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return true;
@@ -144,8 +147,9 @@ abstract class AbstractAction extends \Magento\App\Action\Action
 
     /**
      * Define active menu item in menu block
+     *
      * @param string $itemId current active menu item
-     * @return \Magento\Backend\App\AbstractAction
+     * @return $this
      */
     protected function _setActiveMenu($itemId)
     {
@@ -162,10 +166,10 @@ abstract class AbstractAction extends \Magento\App\Action\Action
     }
 
     /**
-     * @param $label
-     * @param $title
-     * @param null $link
-     * @return \Magento\Backend\App\AbstractAction
+     * @param string $label
+     * @param string $title
+     * @param string|null $link
+     * @return $this
      */
     protected function _addBreadcrumb($label, $title, $link=null)
     {
@@ -175,7 +179,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
 
     /**
      * @param \Magento\View\Element\AbstractBlock $block
-     * @return \Magento\Backend\App\AbstractAction
+     * @return $this
      */
     protected function _addContent(\Magento\View\Element\AbstractBlock $block)
     {
@@ -184,7 +188,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
 
     /**
      * @param \Magento\View\Element\AbstractBlock $block
-     * @return \Magento\Backend\App\AbstractAction
+     * @return $this
      */
     protected function _addLeft(\Magento\View\Element\AbstractBlock $block)
     {
@@ -193,7 +197,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
 
     /**
      * @param \Magento\View\Element\AbstractBlock $block
-     * @return \Magento\Backend\App\AbstractAction
+     * @return $this
      */
     protected function _addJs(\Magento\View\Element\AbstractBlock $block)
     {
@@ -207,7 +211,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
      *
      * @param \Magento\View\Element\AbstractBlock $block
      * @param string $containerName
-     * @return \Magento\Backend\App\AbstractAction
+     * @return $this
      */
     private function _moveBlockToContainer(\Magento\View\Element\AbstractBlock $block, $containerName)
     {
@@ -291,7 +295,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
      * Set session locale,
      * process force locale set through url params
      *
-     * @return \Magento\Backend\App\AbstractAction
+     * @return $this
      */
     protected function _processLocaleSettings()
     {
@@ -307,6 +311,9 @@ abstract class AbstractAction extends \Magento\App\Action\Action
         return $this;
     }
 
+    /**
+     * @return void
+     */
     public function deniedAction()
     {
         $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
@@ -322,6 +329,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
      * No route action
      *
      * @param null $coreRoute
+     * @return void
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function norouteAction($coreRoute = null)
@@ -337,7 +345,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action
      *
      * @param   string $path
      * @param   array $arguments
-     * @return \Magento\Backend\App\AbstractAction
+     * @return \Magento\App\ResponseInterface
      */
     protected function _redirect($path, $arguments=array())
     {
@@ -346,6 +354,13 @@ abstract class AbstractAction extends \Magento\App\Action\Action
         return $this->getResponse();
     }
 
+    /**
+     * @param string $action
+     * @param string|null $controller
+     * @param string|null $module
+     * @param array|null $params
+     * @return void
+     */
     protected function _forward($action, $controller = null, $module = null, array $params = null)
     {
         $this->_getSession()->setIsUrlNotice($this->_actionFlag->get('', self::FLAG_IS_URLS_CHECKED));
diff --git a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php
index 3fbb8bb3eb834b7b01cb1bc96b150d2f6599df1f..7f093c09c0891e1b39a1d4f03ecb65b4656a29cd 100644
--- a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php
+++ b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php
@@ -34,7 +34,7 @@ class Authentication
     protected $_auth;
 
     /**
-     * @var array
+     * @var string[]
      */
     protected $_openActions = array(
         'forgotpassword',
@@ -112,6 +112,7 @@ class Authentication
      * Process not logged in user data
      *
      * @param \Magento\App\RequestInterface $request
+     * @return void
      */
     protected function _processNotLoggedInUser(\Magento\App\RequestInterface $request)
     {
diff --git a/app/code/Magento/Backend/App/Config.php b/app/code/Magento/Backend/App/Config.php
index 2a6fba19fa2cca2e1ec31188e6ffcfe9b1735025..506195f5c987cd525e3a99f336490b7f94b10223 100644
--- a/app/code/Magento/Backend/App/Config.php
+++ b/app/code/Magento/Backend/App/Config.php
@@ -59,6 +59,7 @@ class Config implements ConfigInterface
      *
      * @param string $path
      * @param mixed $value
+     * @return void
      */
     public function setValue($path, $value)
     {
@@ -67,6 +68,8 @@ class Config implements ConfigInterface
 
     /**
      * Reinitialize configuration
+     *
+     * @return void
      */
     public function reinit()
     {
diff --git a/app/code/Magento/Backend/App/Router/DefaultRouter.php b/app/code/Magento/Backend/App/Router/DefaultRouter.php
index 7b581c8d4082bde1a258b659e60932bb6c9f2fd0..33e9e5ff88d558ac41296a8a5170b7ff23f1e414 100644
--- a/app/code/Magento/Backend/App/Router/DefaultRouter.php
+++ b/app/code/Magento/Backend/App/Router/DefaultRouter.php
@@ -43,6 +43,19 @@ class DefaultRouter extends \Magento\Core\App\Router\Base
      */
     protected $_coreConfig;
 
+    /**
+     * List of required request parameters
+     * Order sensitive
+     *
+     * @var string[]
+     */
+    protected $_requiredParams = array(
+        'areaFrontName',
+        'moduleFrontName',
+        'controllerName',
+        'actionName',
+    );
+
     /**
      * @param \Magento\App\ActionFactory $actionFactory
      * @param \Magento\App\DefaultPathInterface $defaultPath
@@ -90,18 +103,6 @@ class DefaultRouter extends \Magento\Core\App\Router\Base
         $this->_url = $url;
     }
 
-    /**
-     * List of required request parameters
-     * Order sensitive
-     * @var array
-     */
-    protected $_requiredParams = array(
-        'areaFrontName',
-        'moduleFrontName',
-        'controllerName',
-        'actionName',
-    );
-
     /**
      * Get router default request path
      * @return string
diff --git a/app/code/Magento/Backend/Block/Cache.php b/app/code/Magento/Backend/Block/Cache.php
index 02b5467a3e26a23db078640f0d3bd412b35ad15d..6aca4f561530b7fffbe6b8002647437e30141c4f 100644
--- a/app/code/Magento/Backend/Block/Cache.php
+++ b/app/code/Magento/Backend/Block/Cache.php
@@ -23,13 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block;
 
 class Cache extends \Magento\Backend\Block\Widget\Grid\Container
 {
     /**
      * Class constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -53,6 +54,8 @@ class Cache extends \Magento\Backend\Block\Widget\Grid\Container
 
     /**
      * Get url for clean cache storage
+     *
+     * @return string
      */
     public function getFlushStorageUrl()
     {
@@ -61,6 +64,8 @@ class Cache extends \Magento\Backend\Block\Widget\Grid\Container
 
     /**
      * Get url for clean cache storage
+     *
+     * @return string
      */
     public function getFlushSystemUrl()
     {
diff --git a/app/code/Magento/Backend/Block/Cache/Additional.php b/app/code/Magento/Backend/Block/Cache/Additional.php
index 31610883e0ce1e8d7fce6cc1556aa3e3ac5deb2d..a565ce0cddd4c7abda3a16dd0648459d961b62f7 100644
--- a/app/code/Magento/Backend/Block/Cache/Additional.php
+++ b/app/code/Magento/Backend/Block/Cache/Additional.php
@@ -23,16 +23,21 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\Cache;
 
 class Additional extends \Magento\Backend\Block\Template
 {
+    /**
+     * @return string
+     */
     public function getCleanImagesUrl()
     {
         return $this->getUrl('*/*/cleanImages');
     }
 
+    /**
+     * @return string
+     */
     public function getCleanMediaUrl()
     {
         return $this->getUrl('*/*/cleanMedia');
diff --git a/app/code/Magento/Backend/Block/Dashboard.php b/app/code/Magento/Backend/Block/Dashboard.php
index aabe91c6ce811a9a3a4e1b27e2173b379747dea4..acced031a83715609bda5fb2f48e90da7d297719 100644
--- a/app/code/Magento/Backend/Block/Dashboard.php
+++ b/app/code/Magento/Backend/Block/Dashboard.php
@@ -28,6 +28,9 @@ namespace Magento\Backend\Block;
 
 class Dashboard extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var \Magento\Core\Model\LocaleInterface
+     */
     protected $_locale;
 
     /**
@@ -35,8 +38,14 @@ class Dashboard extends \Magento\Backend\Block\Template
      */
     const XML_PATH_ENABLE_CHARTS = 'admin/dashboard/enable_charts';
 
+    /**
+     * @var string
+     */
     protected $_template = 'dashboard/index.phtml';
 
+    /**
+     * @return void
+     */
     protected function _prepareLayout()
     {
         $this->addChild('lastOrders', 'Magento\Backend\Block\Dashboard\Orders\Grid');
@@ -63,6 +72,9 @@ class Dashboard extends \Magento\Backend\Block\Template
         parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getSwitchUrl()
     {
         if ($url = $this->getData('switch_url')) {
diff --git a/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php b/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php
index 240f52ff9fe021f45eaa4d1a29e3643f1676d006..07e3bfb6b8827ff2c685061a92fe765cead8404d 100644
--- a/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php
+++ b/app/code/Magento/Backend/Block/Dashboard/AbstractDashboard.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
+
+use Magento\Core\Model\Resource\Db\Collection\AbstractCollection;
 
 /**
  * Adminhtml dashboard tab abstract
@@ -31,9 +34,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
 abstract class AbstractDashboard extends \Magento\Backend\Block\Widget
 {
     /**
@@ -60,11 +60,17 @@ abstract class AbstractDashboard extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return array|AbstractCollection|\Magento\Eav\Model\Entity\Collection\Abstract
+     */
     public function getCollection()
     {
         return $this->getDataHelper()->getCollection();
     }
 
+    /**
+     * @return int
+     */
     public function getCount()
     {
         return $this->getDataHelper()->getCount();
@@ -80,11 +86,17 @@ abstract class AbstractDashboard extends \Magento\Backend\Block\Widget
         return $this->_dataHelper;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareData()
     {
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->_prepareData();
diff --git a/app/code/Magento/Backend/Block/Dashboard/Bar.php b/app/code/Magento/Backend/Block/Dashboard/Bar.php
index 770b4eb89732378edb5e4aea47249ed91269ba8a..41a50928414f54e7238f55bb85cc20723964d689 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Bar.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Bar.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
 
 /**
  * Adminhtml dashboard bar block
@@ -31,19 +32,32 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
 class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
 {
+    /**
+     * @var array
+     */
     protected $_totals = array();
+
+    /**
+     * @var \Magento\Directory\Model\Currency|null
+     */
     protected $_currentCurrencyCode = null;
 
+    /**
+     * @return array
+     */
     protected function getTotals()
     {
         return $this->_totals;
     }
 
+    /**
+     * @param string $label
+     * @param float $value
+     * @param bool $isQuantity
+     * @return $this
+     */
     public function addTotal($label, $value, $isQuantity=false)
     {
         /*if (!$isQuantity) {
@@ -68,9 +82,9 @@ class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
     }
 
     /**
-     * Formating value specific for this store
+     * Formatting value specific for this store
      *
-     * @param decimal $price
+     * @param float $price
      * @return string
      */
     public function format($price)
@@ -82,6 +96,7 @@ class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
      * Setting currency model
      *
      * @param \Magento\Directory\Model\Currency $currency
+     * @return void
      */
     public function setCurrency($currency)
     {
diff --git a/app/code/Magento/Backend/Block/Dashboard/Diagrams.php b/app/code/Magento/Backend/Block/Dashboard/Diagrams.php
index c0ae8129fb7fd5cf79346b1b7cef9090dc137465..ccb23fab2e34ba0be8f83c06275d7642d54e02eb 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Diagrams.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Diagrams.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
 
 /**
  * Adminhtml dashboard diagram tabs
@@ -31,14 +32,16 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
 class Diagrams extends \Magento\Backend\Block\Widget\Tabs
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/tabshoriz.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -46,6 +49,9 @@ class Diagrams extends \Magento\Backend\Block\Widget\Tabs
         $this->setDestElementId('diagram_tab_content');
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->addTab('orders', array(
diff --git a/app/code/Magento/Backend/Block/Dashboard/Graph.php b/app/code/Magento/Backend/Block/Dashboard/Graph.php
index 52202fdea138e58df7396e67fe24ecd7db5fc437..3c2b2dd1624500ca7c6444edc6f8edfc81fab083 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Graph.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Graph.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
 
 /**
  * Adminhtml dashboard google chart block
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
 class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
 {
     /**
@@ -111,6 +109,9 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
      */
     protected $_htmlId = '';
 
+    /**
+     * @var string
+     */
     protected $_template = 'dashboard/graph.phtml';
 
     /**
@@ -149,7 +150,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
     /**
      * Set data rows
      *
-     * @param mixed $rows
+     * @param array $rows
      * @return void
      */
     public function setDataRows($rows)
@@ -173,7 +174,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
      * Get series
      *
      * @param string $seriesId
-     * @return mixed
+     * @return array|false
      */
     public function getSeries($seriesId)
     {
@@ -554,6 +555,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
 
     /**
      * @param \Magento\Backend\Helper\Dashboard\AbstractDashboard $dataHelper
+     * @return void
      */
     public function setDataHelper(\Magento\Backend\Helper\Dashboard\AbstractDashboard $dataHelper)
     {
diff --git a/app/code/Magento/Backend/Block/Dashboard/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Grid.php
index 139cae91913c544511401a4fcbe887f796fd35f0..1cb3495772755dd37cb2a2d340fc5f98b18daef9 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Grid.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Grid.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
 
 /**
  * Adminhtml dashboard grid
@@ -31,15 +32,17 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
 class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 {
+    /**
+     * @var string
+     */
     protected $_template = 'dashboard/grid.phtml';
 
     /**
      * Setting default for every grid on dashboard
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/Dashboard/Grids.php b/app/code/Magento/Backend/Block/Dashboard/Grids.php
index 4593996bab6c7bd134328f64f6a712dc08d1f255..5acdae077da1bf9870f8c163ff1a89b3356b54c0 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Grids.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Grids.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
 
 /**
  * Adminhtml dashboard bottom tabs
@@ -31,14 +32,16 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
 class Grids extends \Magento\Backend\Block\Widget\Tabs
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/tabshoriz.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -58,7 +61,7 @@ class Grids extends \Magento\Backend\Block\Widget\Tabs
      *     2) specify url (BE CAREFUL)
      *     3) specify class 'ajax'
      *
-     * @return \Magento\Backend\Block\Dashboard\Grids
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
index 1ec575ae10baa4d502c95e85767841999d1f3128..d26165a72446c96ef250e043f7421376bdba3aad 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Orders;
 
 /**
  * Adminhtml dashboard recent orders grid
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Orders;
-
 class Grid extends \Magento\Backend\Block\Dashboard\Grid
 {
     /**
@@ -65,12 +63,18 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('lastOrdersGrid');
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareCollection()
     {
         if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
@@ -114,6 +118,9 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid
 //        $this->getCollection()->setCurPage($this->getParam($this->getVarNamePage(), $this->_defaultPage));
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('customer', array(
@@ -148,6 +155,9 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getRowUrl($row)
     {
         return $this->getUrl('sales/order/view', array('order_id'=>$row->getId()));
diff --git a/app/code/Magento/Backend/Block/Dashboard/Sales.php b/app/code/Magento/Backend/Block/Dashboard/Sales.php
index 64ce31d932b5397c81e684016200dff2e617f324..57b2e31ddb7ec8406b26dab62b277fe1dfbcb194 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Sales.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Sales.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard;
+
+use Magento\Backend\Block\Widget;
 
 /**
  * Adminhtml dashboard sales statistics bar
@@ -31,13 +34,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard;
-
-use Magento\Backend\Block\Widget;
-
 class Sales extends \Magento\Backend\Block\Dashboard\Bar
 {
+    /**
+     * @var string
+     */
     protected $_template = 'dashboard/salebar.phtml';
 
     /**
@@ -46,9 +47,9 @@ class Sales extends \Magento\Backend\Block\Dashboard\Bar
     protected $_moduleManager;
 
     /**
-     * @param \Magento\Module\Manager $moduleManager
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory
+     * @param \Magento\Module\Manager $moduleManager
      * @param array $data
      */
     public function __construct(
@@ -61,6 +62,9 @@ class Sales extends \Magento\Backend\Block\Dashboard\Bar
         parent::__construct($context, $collectionFactory, $data);
     }
 
+    /**
+     * @return $this|void
+     */
     protected function _prepareLayout()
     {
         if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
diff --git a/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php b/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php
index d4806307300aa61b4cafa9012030ed6971d58d1c..3171952eb757eabddaaa3b46296760655088a5b2 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Searches;
 
 /**
  * Adminhtml dashboard last search keywords block
@@ -31,11 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Searches;
-
 class Last extends \Magento\Backend\Block\Dashboard\Grid
 {
+    /**
+     * @var \Magento\CatalogSearch\Model\Resource\Query\Collection
+     */
     protected $_collection;
 
     /**
@@ -67,12 +68,18 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('lastSearchGrid');
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareCollection()
     {
         if (!$this->_moduleManager->isEnabled('Magento_CatalogSearch')) {
@@ -96,6 +103,9 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareCollection();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('search_query', array(
@@ -125,6 +135,9 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getRowUrl($row)
     {
         return $this->getUrl('catalog/search/edit', array('id'=>$row->getId()));
diff --git a/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php b/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php
index 2f7eea8b353e9857435222a18d48eb1b9df97fef..7371b5be2f7d2eb5dc5dcc649eaa64ddd3ed5a04 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Searches;
 
 /**
  * Adminhtml dashboard last search keywords block
@@ -31,11 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Searches;
-
 class Top extends \Magento\Backend\Block\Dashboard\Grid
 {
+    /**
+     * @var \Magento\CatalogSearch\Model\Resource\Query\Collection
+     */
     protected $_collection;
 
     /**
@@ -67,12 +68,18 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('topSearchGrid');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareCollection()
     {
         if (!$this->_moduleManager->isEnabled('Magento_CatalogSearch')) {
@@ -98,6 +105,9 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareCollection();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('search_query', array(
@@ -127,6 +137,9 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getRowUrl($row)
     {
         return $this->getUrl('catalog/search/edit', array('id'=>$row->getId()));
diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php
index 8f2e5535c8e4d57823ee44789e2742d34343e906..36c76d4670b5732845baf22b6751955412197566 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Tab\Customers;
 
 /**
  * Adminhtml dashboard most active buyers
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Tab\Customers;
-
 class Most extends \Magento\Backend\Block\Dashboard\Grid
 {
     /**
@@ -57,12 +55,18 @@ class Most extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('customersMostGrid');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareCollection()
     {
         $collection = $this->_collectionFactory->create();
@@ -92,6 +96,9 @@ class Most extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareCollection();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('name', array(
@@ -134,6 +141,9 @@ class Most extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getRowUrl($row)
     {
         return $this->getUrl('customer/index/edit', array('id'=>$row->getCustomerId()));
diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php
index 50c99dd435904a918a5091e743078e5ec2887558..1a1fff2f4bcf744a2ec2a2445fe29771b095709f 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Tab\Customers;
 
 /**
  * Adminhtml dashboard most recent customers grid
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Tab\Customers;
-
 class Newest extends \Magento\Backend\Block\Dashboard\Grid
 {
     /**
@@ -57,12 +55,18 @@ class Newest extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('customersNewestGrid');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareCollection()
     {
         $collection = $this->_collectionFactory->create()
@@ -88,6 +92,9 @@ class Newest extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareCollection();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('name', array(
@@ -132,6 +139,9 @@ class Newest extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getRowUrl($row)
     {
         return $this->getUrl('customer/index/edit', array('id'=>$row->getId()));
diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php
index e8d1231a282764c47a2d6e1a0b3454f5f8c378a4..bc4ba8677417188aa10350fcacae278041d01d7c 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Tab\Products;
 
 /**
  * Adminhtml dashboard most ordered products grid
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Tab\Products;
-
 class Ordered extends \Magento\Backend\Block\Dashboard\Grid
 {
     /**
@@ -65,12 +63,18 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('productsOrderedGrid');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareCollection()
     {
         if (!$this->_moduleManager->isEnabled('Magento_Sales')) {
@@ -96,6 +100,9 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareCollection();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareColumns()
     {
 
@@ -130,12 +137,11 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
-    /*
+    /**
      * Returns row url to show in admin dashboard
      * $row is bestseller row wrapped in Product model
      *
      * @param \Magento\Catalog\Model\Product $row
-     *
      * @return string
      */
     public function getRowUrl($row)
diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php
index abadcd927e474b4ae8ab620c1d45b41c6b03cf60..0e820e1b313a645ce4edd0027704dac05fb54e51 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Dashboard\Tab\Products;
 
 /**
  * Adminhtml dashboard most viewed products grid
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Dashboard\Tab\Products;
-
 class Viewed extends \Magento\Backend\Block\Dashboard\Grid
 {
     /**
@@ -57,12 +55,18 @@ class Viewed extends \Magento\Backend\Block\Dashboard\Grid
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setId('productsReviewedGrid');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareCollection()
     {
         if ($this->getParam('website')) {
@@ -85,6 +89,9 @@ class Viewed extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareCollection();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('name', array(
@@ -117,6 +124,9 @@ class Viewed extends \Magento\Backend\Block\Dashboard\Grid
         return parent::_prepareColumns();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getRowUrl($row)
     {
         $params = array('id'=>$row->getId());
diff --git a/app/code/Magento/Backend/Block/Dashboard/Totals.php b/app/code/Magento/Backend/Block/Dashboard/Totals.php
index 01db45efc83ea4f0659f303df6f68b98cf2d8d1c..7b2dae21cbc73cca907ee3831b081073bf1da2b4 100644
--- a/app/code/Magento/Backend/Block/Dashboard/Totals.php
+++ b/app/code/Magento/Backend/Block/Dashboard/Totals.php
@@ -38,6 +38,9 @@ use Magento\Backend\Block\Widget;
 
 class Totals extends \Magento\Backend\Block\Dashboard\Bar
 {
+    /**
+     * @var string
+     */
     protected $_template = 'dashboard/totalbar.phtml';
 
     /**
@@ -46,9 +49,9 @@ class Totals extends \Magento\Backend\Block\Dashboard\Bar
     protected $_moduleManager;
 
     /**
-     * @param \Magento\Module\Manager $moduleManager
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory
+     * @param \Magento\Module\Manager $moduleManager
      * @param array $data
      */
     public function __construct(
@@ -61,6 +64,9 @@ class Totals extends \Magento\Backend\Block\Dashboard\Bar
         parent::__construct($context, $collectionFactory, $data);
     }
 
+    /**
+     * @return $this|void
+     */
     protected function _prepareLayout()
     {
         if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
diff --git a/app/code/Magento/Backend/Block/Denied.php b/app/code/Magento/Backend/Block/Denied.php
index c7335e47820620b848bd32ff37ba603f96cf997f..7e81c18ce443d4ba0619b8e9b4aac0a995611bd7 100644
--- a/app/code/Magento/Backend/Block/Denied.php
+++ b/app/code/Magento/Backend/Block/Denied.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block;
 
 class Denied extends \Magento\Backend\Block\Template
@@ -47,6 +46,9 @@ class Denied extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return bool
+     */
     public function hasAvailableResources()
     {
         $user = $this->_authSession->getUser();
diff --git a/app/code/Magento/Backend/Block/Media/Uploader.php b/app/code/Magento/Backend/Block/Media/Uploader.php
index 232f040e49f5ecdf4421c57ec0038cff51488fb9..d46fe5e318e75c207b76d4bfe8ce47d5128e75ee 100644
--- a/app/code/Magento/Backend/Block/Media/Uploader.php
+++ b/app/code/Magento/Backend/Block/Media/Uploader.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Media;
 
 /**
  * Adminhtml media library uploader
  */
-namespace Magento\Backend\Block\Media;
-
 class Uploader extends \Magento\Backend\Block\Widget
 {
     /**
@@ -60,6 +59,9 @@ class Uploader extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -99,7 +101,7 @@ class Uploader extends \Magento\Backend\Block\Widget
     /**
      * Prepares layout and set element renderer
      *
-     * @return \Magento\Backend\Block\Media\Uploader
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -156,7 +158,6 @@ class Uploader extends \Magento\Backend\Block\Widget
      * Now uploader can be only in the same URL where backend located
      *
      * @param string $url url to uploader in current theme
-     *
      * @return string full URL
      */
     public function getUploaderUrl($url)
diff --git a/app/code/Magento/Backend/Block/Menu.php b/app/code/Magento/Backend/Block/Menu.php
index 2ed7d5a50f7e275b166d050c69bf847e63f1db93..279e1eb4ab02ae2f51cb10f5f259f1d70285139d 100644
--- a/app/code/Magento/Backend/Block/Menu.php
+++ b/app/code/Magento/Backend/Block/Menu.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block;
 
 /**
  * Backend menu block
@@ -30,8 +31,6 @@
  * @method \Magento\Backend\Block\Menu setAdditionalCacheKeyInfo(array $cacheKeyInfo)
  * @method array getAdditionalCacheKeyInfo()
  */
-namespace Magento\Backend\Block;
-
 class Menu extends \Magento\Backend\Block\Template
 {
     const CACHE_TAGS = 'BACKEND_MAINMENU';
@@ -100,6 +99,8 @@ class Menu extends \Magento\Backend\Block\Template
 
     /**
      * Initialize template and cache settings
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -249,7 +250,7 @@ class Menu extends \Magento\Backend\Block\Template
     /**
      * Replace Callback Secret Key
      *
-     * @param array $match
+     * @param string[] $match
      * @return string
      */
     protected function _callbackSecretKey($match)
@@ -351,7 +352,7 @@ class Menu extends \Magento\Backend\Block\Template
      *
      * @param \Magento\Backend\Model\Menu $items
      * @param int $limit
-     * @return array
+     * @return array|void
      * @todo: Add Depth Level limit, and better logic for columns
      */
     protected function _columnBrake($items, $limit)
@@ -388,9 +389,9 @@ class Menu extends \Magento\Backend\Block\Template
     /**
      * Add sub menu HTML code for current menu item
      *
-     * @param $menuItem \Magento\Backend\Model\Menu\Item
-     * @param $level int
-     * @param $limit int
+     * @param \Magento\Backend\Model\Menu\Item $menuItem
+     * @param int $level
+     * @param int $limit
      * @return string HTML code
      */
     protected function _addSubMenu($menuItem, $level, $limit)
diff --git a/app/code/Magento/Backend/Block/Page.php b/app/code/Magento/Backend/Block/Page.php
index cc269148d0a3b148d1ac2088eba4692af9ffc569..1c0405fe230f30d4a120d1a1588e15dad61c375a 100644
--- a/app/code/Magento/Backend/Block/Page.php
+++ b/app/code/Magento/Backend/Block/Page.php
@@ -35,11 +35,15 @@ namespace Magento\Backend\Block;
 
 class Page extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'admin/page.phtml';
 
     /**
      * Class constructor
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -51,7 +55,7 @@ class Page extends \Magento\Backend\Block\Template
     /**
      * Get current language
      *
-     * @return unknown
+     * @return string
      */
     public function getLang()
     {
@@ -65,7 +69,7 @@ class Page extends \Magento\Backend\Block\Template
      * Add CSS class to page body tag
      *
      * @param string $className
-     * @return \Magento\Backend\Block\Page
+     * @return $this
      */
     public function addBodyClass($className)
     {
diff --git a/app/code/Magento/Backend/Block/Page/Footer.php b/app/code/Magento/Backend/Block/Page/Footer.php
index b15466c36b76ee29e244b84f483e3b70d4012b5e..94c8130a011fd2845e22f669f740add463471c75 100644
--- a/app/code/Magento/Backend/Block/Page/Footer.php
+++ b/app/code/Magento/Backend/Block/Page/Footer.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\Page;
 
 /**
  * Adminhtml footer block
@@ -32,12 +32,16 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Page;
-
 class Footer extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'page/footer.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->setShowProfiler(true);
diff --git a/app/code/Magento/Backend/Block/Page/Header.php b/app/code/Magento/Backend/Block/Page/Header.php
index 3c84782158c299fbebe8459c4deb2793e099fcbe..e5ecdc3ea589c9aa1e23443d0d101c3177e6fe83 100644
--- a/app/code/Magento/Backend/Block/Page/Header.php
+++ b/app/code/Magento/Backend/Block/Page/Header.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Page;
 
 /**
  * Adminhtml header block
@@ -31,10 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Page;
-
 class Header extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'page/header.phtml';
 
     /**
@@ -66,16 +68,25 @@ class Header extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return string
+     */
     public function getHomeLink()
     {
         return $this->_backendData->getHomePageUrl();
     }
 
+    /**
+     * @return \Magento\User\Model\User|null
+     */
     public function getUser()
     {
         return $this->_authSession->getUser();
     }
 
+    /**
+     * @return string
+     */
     public function getLogoutLink()
     {
         return $this->getUrl('adminhtml/auth/logout');
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 59e0995bc1180e2f1dd8ffe0414e997d7563592c..39d674f4b3f0cc07f2c0150388492315f8a6086c 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
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Page\System\Config\Robots;
 
 /**
  * "Reset to Defaults" button renderer
@@ -31,8 +32,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Page\System\Config\Robots;
-
 class Reset extends \Magento\Backend\Block\System\Config\Form\Field
 {
     /**
@@ -61,8 +60,10 @@ class Reset extends \Magento\Backend\Block\System\Config\Form\Field
         parent::__construct($context, $data);
     }
 
-    /*
+    /**
      * Set template
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/Store/Switcher.php b/app/code/Magento/Backend/Block/Store/Switcher.php
index 2f687abd07a9c924339894620cfacbd764a5483a..708023496019c051ef5d7665b83cefa6e16c2f2a 100644
--- a/app/code/Magento/Backend/Block/Store/Switcher.php
+++ b/app/code/Magento/Backend/Block/Store/Switcher.php
@@ -115,6 +115,9 @@ class Switcher extends \Magento\Backend\Block\Template
         $this->_storeFactory = $storeFactory;
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -142,7 +145,7 @@ class Switcher extends \Magento\Backend\Block\Template
     /**
      * Get websites
      *
-     * @return array
+     * @return \Magento\Core\Model\Website[]
      */
     public function getWebsites()
     {
@@ -204,7 +207,7 @@ class Switcher extends \Magento\Backend\Block\Template
      * Get store views for specified store group
      *
      * @param \Magento\Core\Model\Store\Group|int $group
-     * @return array
+     * @return \Magento\Core\Model\Store[]
      */
     public function getStores($group)
     {
@@ -235,7 +238,7 @@ class Switcher extends \Magento\Backend\Block\Template
 
     /**
      * @param string $varName
-     * @return \Magento\Backend\Block\Store\Switcher
+     * @return $this
      */
     public function setStoreVarName($varName)
     {
@@ -269,7 +272,7 @@ class Switcher extends \Magento\Backend\Block\Template
 
     /**
      * @param array $storeIds
-     * @return \Magento\Backend\Block\Store\Switcher
+     * @return $this
      */
     public function setStoreIds($storeIds)
     {
diff --git a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php
index 1bc61e38c3c68835b6c9559ae48bdcdc6fc4428d..b9a101a18903c660aeb29fc1bc33d6cfd4feec5b 100644
--- a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php
+++ b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Store\Switcher\Form\Renderer;
 
 /**
  * Form fieldset renderer
  */
-namespace Magento\Backend\Block\Store\Switcher\Form\Renderer;
-
 class Fieldset
     extends \Magento\Backend\Block\Template implements \Magento\Data\Form\Element\Renderer\RendererInterface
 {
@@ -39,6 +38,9 @@ class Fieldset
      */
     protected $_element;
 
+    /**
+     * @var string
+     */
     protected $_template = 'store/switcher/form/renderer/fieldset.phtml';
 
     /**
diff --git a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php
index 2bb9eb8451d1c9a59dbdac3debdc1d750fa5716c..94da07c9d2e9e3488a49ca912b885aa5af82fce5 100644
--- a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php
+++ b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php
@@ -23,12 +23,11 @@
  * @copyright  Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset;
 
 /**
  * Form fieldset renderer
  */
-namespace Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset;
-
 class Element
     extends \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element
     implements \Magento\Data\Form\Element\Renderer\RendererInterface
@@ -40,6 +39,9 @@ class Element
      */
     protected $_element;
 
+    /**
+     * @var string
+     */
     protected $_template = 'store/switcher/form/renderer/fieldset/element.phtml';
 
     /**
diff --git a/app/code/Magento/Backend/Block/System/Account/Edit.php b/app/code/Magento/Backend/Block/System/Account/Edit.php
index fa6aa23feb38f94a85f9a689ce8a6bb7fd81cf5a..e9a11fd76a66227cc3fe42ecbbe11c0771ea76f9 100644
--- a/app/code/Magento/Backend/Block/System/Account/Edit.php
+++ b/app/code/Magento/Backend/Block/System/Account/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Account;
 
 /**
  * Adminhtml edit admin user account
@@ -31,11 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Account;
-
 class Edit extends \Magento\Backend\Block\Widget\Form\Container
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -47,6 +48,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         $this->_removeButton('back');
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderText()
     {
         return __('My Account');
diff --git a/app/code/Magento/Backend/Block/System/Account/Edit/Form.php b/app/code/Magento/Backend/Block/System/Account/Edit/Form.php
index a5c1290585766a10185f5cdd32734caa8bb1e7c6..d4e506fa7aa9bcb714dc93c41e9d5bf4801be378 100644
--- a/app/code/Magento/Backend/Block/System/Account/Edit/Form.php
+++ b/app/code/Magento/Backend/Block/System/Account/Edit/Form.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Account\Edit;
 
 /**
  * Adminhtml edit admin user account form
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Account\Edit;
-
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
     /**
@@ -67,6 +65,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
         parent::__construct($context, $registry, $formFactory, $data);
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareForm()
     {
         $userId = $this->_authSession->getUser()->getId();
diff --git a/app/code/Magento/Backend/Block/System/Cache/Edit.php b/app/code/Magento/Backend/Block/System/Cache/Edit.php
index 7d0fc01776c29b7e086614a3382e1d6a0b1c1339..19e54aef18bb8724089d547e5ea7250612b14a13 100644
--- a/app/code/Magento/Backend/Block/System/Cache/Edit.php
+++ b/app/code/Magento/Backend/Block/System/Cache/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Cache;
 
 /**
  * Cache management edit page
@@ -31,13 +32,16 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Cache;
-
 class Edit extends \Magento\Backend\Block\Widget
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::system/cache/edit.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -45,6 +49,9 @@ class Edit extends \Magento\Backend\Block\Widget
         $this->setTitle('Cache Management');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $this->addChild('save_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -59,16 +66,25 @@ class Edit extends \Magento\Backend\Block\Widget
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getSaveButtonHtml()
     {
         return $this->getChildHtml('save_button');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveUrl()
     {
         return $this->getUrl('adminhtml/*/save', array('_current'=>true));
     }
 
+    /**
+     * @return $this
+     */
     public function initForm()
     {
         $this->setChild('form',
diff --git a/app/code/Magento/Backend/Block/System/Cache/Form.php b/app/code/Magento/Backend/Block/System/Cache/Form.php
index 007e8cde9f50d1c18ef0691f9b9ff4ec7c3dff4e..f665699c45abccb574e0c0b45bc5cff064a1966e 100644
--- a/app/code/Magento/Backend/Block/System/Cache/Form.php
+++ b/app/code/Magento/Backend/Block/System/Cache/Form.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\System\Cache;
 
 /**
  * Cache management form page
@@ -32,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Cache;
-
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
     /**
@@ -42,10 +40,10 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     protected $_coreData;
 
     /**
-     * @param \Magento\Core\Helper\Data $coreData
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Data\FormFactory $formFactory
+     * @param \Magento\Core\Helper\Data $coreData
      * @param array $data
      */
     public function __construct(
@@ -62,7 +60,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Initialize cache management form
      *
-     * @return \Magento\Backend\Block\System\Cache\Form
+     * @return $this
      */
     public function initForm()
     {
diff --git a/app/code/Magento/Backend/Block/System/Config/Dwstree.php b/app/code/Magento/Backend/Block/System/Config/Dwstree.php
index b6311e4e52cf4ca1a2a6ee6b545e036190c1bc84..ffa288f97c94119580db76381a179fec02b5d789 100644
--- a/app/code/Magento/Backend/Block/System/Config/Dwstree.php
+++ b/app/code/Magento/Backend/Block/System/Config/Dwstree.php
@@ -31,6 +31,9 @@ namespace Magento\Backend\Block\System\Config;
 
 class Dwstree extends \Magento\Backend\Block\Widget\Tabs
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -39,7 +42,7 @@ class Dwstree extends \Magento\Backend\Block\Widget\Tabs
     }
 
     /**
-     * @return \Magento\Backend\Block\System\Config\Dwstree
+     * @return $this
      */
     public function initTabs()
     {
diff --git a/app/code/Magento/Backend/Block/System/Config/Form.php b/app/code/Magento/Backend/Block/System/Config/Form.php
index c9db61e9776870892161330037c52f8b3858427b..d8be9a45baa302e3ef6fb055a529f886c31b3707 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Backend\Block\System\Config;
 
 /**
@@ -35,7 +33,6 @@ namespace Magento\Backend\Block\System\Config;
  */
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
-
     const SCOPE_DEFAULT = 'default';
     const SCOPE_WEBSITES = 'websites';
     const SCOPE_STORES   = 'stores';
@@ -90,7 +87,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     protected $_configFactory;
 
     /**
-     * \Magento\Data\FormFactory
+     * Magento\Data\FormFactory
      *
      * @var \Magento\Data\FormFactory
      */
@@ -163,7 +160,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Initialize objects required to render config form
      *
-     * @return \Magento\Backend\Block\System\Config\Form
+     * @return $this
      */
     protected function _initObjects()
     {
@@ -184,7 +181,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Initialize form
      *
-     * @return \Magento\Backend\Block\System\Config\Form
+     * @return $this
      */
     public function initForm()
     {
@@ -210,6 +207,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * @param \Magento\Backend\Model\Config\Structure\Element\Group $group
      * @param \Magento\Backend\Model\Config\Structure\Element\Section $section
      * @param \Magento\Data\Form\AbstractForm $form
+     * @return void
      */
     protected function _initGroup(
         \Magento\Backend\Model\Config\Structure\Element\Group $group,
@@ -276,7 +274,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * @param \Magento\Backend\Model\Config\Structure\Element\Section $section
      * @param string $fieldPrefix
      * @param string $labelPrefix
-     * @return \Magento\Backend\Block\System\Config\Form
+     * @return $this
      */
     public function initFields(
         \Magento\Data\Form\Element\Fieldset $fieldset,
@@ -317,9 +315,10 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      *
      * @param \Magento\Backend\Model\Config\Structure\Element\Field $field
      * @param \Magento\Data\Form\Element\Fieldset $fieldset
-     * @param $path
+     * @param string $path
      * @param string $fieldPrefix
      * @param string $labelPrefix
+     * @return void
      */
     protected function _initElement(
         \Magento\Backend\Model\Config\Structure\Element\Field $field,
@@ -403,6 +402,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * @param array $dependencies
      * @param string $elementId
      * @param string $elementName
+     * @return void
      */
     protected function _populateDependenciesBlock(array $dependencies, $elementId, $elementName)
     {
@@ -457,9 +457,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     *
-     *
-     * @return \Magento\Backend\Block\Widget\Form|\Magento\View\Element\AbstractBlock|void
+     * @return \Magento\Backend\Block\Widget\Form|\Magento\View\Element\AbstractBlock
      */
     protected function _beforeToHtml()
     {
@@ -670,7 +668,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * Get css class for "requires" functionality
      *
      * @param \Magento\Backend\Model\Config\Structure\Element\Field $field
-     * @param $fieldPrefix
+     * @param string $fieldPrefix
      * @return string
      */
     protected function _getRequiresCssClass(\Magento\Backend\Model\Config\Structure\Element\Field $field, $fieldPrefix)
diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php
index e5b778297d3d0bccbc785b0f258740e71334e798..905d981dc61a3dd9c89e3358c9a3e02bbc211329 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php
@@ -23,15 +23,20 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Config\Form\Field;
+
+use Magento\Data\Form\Element\AbstractElement;
 
 /**
  * Backend system config datetime field renderer
  */
-namespace Magento\Backend\Block\System\Config\Form\Field;
-
 class Datetime extends \Magento\Backend\Block\System\Config\Form\Field
 {
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(AbstractElement $element)
     {
         $format = $this->_app->getLocale()->getDateTimeFormat(
             \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM
diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php
index c3f5672d8c7d38107be5be99171fba2c689d3969..08724b5b555fb363694cbb58de4b63d794ce50b0 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Config\Form\Field;
 
 /**
  * Export CSV button for shipping table rates
@@ -31,8 +32,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Config\Form\Field;
-
 class Export extends \Magento\Data\Form\Element\AbstractElement
 {
     /**
@@ -58,6 +57,9 @@ class Export extends \Magento\Data\Form\Element\AbstractElement
         parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
     }
 
+    /**
+     * @return string
+     */
     public function getElementHtml()
     {
         /** @var \Magento\Backend\Block\Widget\Button $buttonBlock  */
diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php
index 7b89be502a46c04cf1f6a2437bf53275a783b2ab..49d5adcc7b793adf56537f986091bea1b48038c3 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Config\Form\Field\FieldArray;
 
 /**
  * Backend system config array field renderer
@@ -31,10 +32,7 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Config\Form\Field\FieldArray;
-
-abstract class AbstractFieldArray
-    extends \Magento\Backend\Block\System\Config\Form\Field
+abstract class AbstractFieldArray extends \Magento\Backend\Block\System\Config\Form\Field
 {
     /**
      * Grid columns
@@ -71,11 +69,15 @@ abstract class AbstractFieldArray
      */
     protected $_isPreparedToRender = false;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::system/config/form/field/array.phtml';
 
     /**
      * Check if columns are defined, set template
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -83,7 +85,7 @@ abstract class AbstractFieldArray
             $this->_addButtonLabel = __('Add');
         }
         parent::_construct();
-        
+
     }
 
     /**
@@ -91,6 +93,7 @@ abstract class AbstractFieldArray
      *
      * @param string $name
      * @param array $params
+     * @return void
      */
     public function addColumn($name, $params)
     {
@@ -111,8 +114,8 @@ abstract class AbstractFieldArray
      *
      * @param array $params
      * @param string $paramName
-     * @param mixed $defaultValue
-     * @return mixed
+     * @param string|bool $defaultValue
+     * @return string|bool
      */
     protected function _getParam($params, $paramName, $defaultValue = null)
     {
@@ -136,7 +139,8 @@ abstract class AbstractFieldArray
     /**
      * Prepare existing row data object
      *
-     * @param \Magento\Object
+     * @param \Magento\Object $row
+     * @return void
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     protected function _prepareArrayRow(\Magento\Object $row)
@@ -204,6 +208,7 @@ abstract class AbstractFieldArray
      *
      * @param string $columnName
      * @return string
+     * @throws \Exception
      */
     public function renderCellTemplate($columnName)
     {
@@ -230,6 +235,8 @@ abstract class AbstractFieldArray
 
     /**
      * Prepare to render
+     *
+     * @return void
      */
     protected function _prepareToRender()
     {
@@ -240,6 +247,7 @@ abstract class AbstractFieldArray
      * Render block HTML
      *
      * @return string
+     * @throws \Exception
      */
     protected function _toHtml()
     {
diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php
index ade14ae073c80b92f0fc50509e46993a91807da5..b569cc095e3687162c103032862a0e34ebaaae9a 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\System\Config\Form\Field;
 
 /**
  * Custom import CSV file field for shipping table rates
@@ -32,11 +32,11 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Config\Form\Field;
-
 class Import extends \Magento\Data\Form\Element\AbstractElement
 {
-
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php
index 3e44ae85aaeb42aa6c431d1cd207ec0afad1bbee..cfac0de5299dbc6ebb3e678c4da2f8b17214c5be 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php
@@ -23,15 +23,20 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Config\Form\Field;
+
+use Magento\Data\Form\Element\AbstractElement;
 
 /**
  * Backend system config datetime field renderer
  */
-namespace Magento\Backend\Block\System\Config\Form\Field;
-
 class Notification extends \Magento\Backend\Block\System\Config\Form\Field
 {
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(AbstractElement $element)
     {
         $element->setValue($this->_app->loadCache('admin_notifications_lastcheck'));
         $format = $this->_app->getLocale()->getDateTimeFormat(
diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Regexceptions.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Regexceptions.php
index 078e91c002b40e52548835dae250b4c15e20e438..25be167d3307279969b2ce665b01f1215b86ee3a 100644
--- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Regexceptions.php
+++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Regexceptions.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Config\Form\Field;
 
 /**
  * Backend system config array field renderer
  */
-namespace Magento\Backend\Block\System\Config\Form\Field;
-
 class Regexceptions
     extends \Magento\Backend\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
 {
@@ -61,6 +60,8 @@ class Regexceptions
 
     /**
      * Initialise form fields
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/System/Config/System/Storage/Media/Synchronize.php b/app/code/Magento/Backend/Block/System/Config/System/Storage/Media/Synchronize.php
index 9899370ddd499fc49ae7bab8966a5ad197bc4bf5..a6555d8c280203d1a5929294e8e3aceccbabd0b3 100644
--- a/app/code/Magento/Backend/Block/System/Config/System/Storage/Media/Synchronize.php
+++ b/app/code/Magento/Backend/Block/System/Config/System/Storage/Media/Synchronize.php
@@ -23,15 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Config\System\Storage\Media;
 
 /**
  * Synchronize button renderer
  */
-namespace Magento\Backend\Block\System\Config\System\Storage\Media;
-
 class Synchronize
     extends \Magento\Backend\Block\System\Config\Form\Field
 {
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::system/config/system/storage/media/synchronize.phtml';
 
     /**
diff --git a/app/code/Magento/Backend/Block/System/Design.php b/app/code/Magento/Backend/Block/System/Design.php
index c0312810538bc96517b03552e06d3f930fd45ba9..fefb50adb9e667c50ff7e8af619d387482bc29c1 100644
--- a/app/code/Magento/Backend/Block/System/Design.php
+++ b/app/code/Magento/Backend/Block/System/Design.php
@@ -23,12 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Backend\Block\System;
 
 class Design extends \Magento\Backend\Block\Template
 {
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $this->setTemplate('Magento_Backend::system/design/index.phtml');
diff --git a/app/code/Magento/Backend/Block/System/Design/Edit.php b/app/code/Magento/Backend/Block/System/Design/Edit.php
index ea160abd7fa47df5bd756e9bd8150b8383819150..3a2403bd5ea9f4df42b08cbf80259b6d0adc9096 100644
--- a/app/code/Magento/Backend/Block/System/Design/Edit.php
+++ b/app/code/Magento/Backend/Block/System/Design/Edit.php
@@ -23,12 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\System\Design;
 
 class Edit extends \Magento\Backend\Block\Widget
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::system/design/edit.phtml';
 
     /**
@@ -52,6 +53,9 @@ class Edit extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -59,6 +63,9 @@ class Edit extends \Magento\Backend\Block\Widget
         $this->setId('design_edit');
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $this->addChild('back_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -85,26 +92,41 @@ class Edit extends \Magento\Backend\Block\Widget
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getDesignChangeId()
     {
         return $this->_coreRegistry->registry('design')->getId();
     }
 
+    /**
+     * @return string
+     */
     public function getDeleteUrl()
     {
         return $this->getUrl('adminhtml/*/delete', array('_current'=>true));
     }
 
+    /**
+     * @return string
+     */
     public function getSaveUrl()
     {
         return $this->getUrl('adminhtml/*/save', array('_current'=>true));
     }
 
+    /**
+     * @return string
+     */
     public function getValidationUrl()
     {
         return $this->getUrl('adminhtml/*/validate', array('_current'=>true));
     }
 
+    /**
+     * @return string
+     */
     public function getHeader()
     {
         if ($this->_coreRegistry->registry('design')->getId()) {
diff --git a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php
index 2f9a255ecee62c7178fc0fd52e123d07611a58a5..4f9de6c30cfa6b942de0880da017cf307eb81de7 100644
--- a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php
+++ b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php
@@ -61,7 +61,7 @@ class General extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Initialise form fields
      *
-     * @return \Magento\Backend\Block\System\Design\Edit\Tab\General
+     * @return void
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Backend/Block/System/Design/Edit/Tabs.php b/app/code/Magento/Backend/Block/System/Design/Edit/Tabs.php
index 1e1a0e11c7a519ffe4b1063df0748a520de8e4c4..928ef2d74f3a91fd71d1631db68ed1a4e3e9ba2b 100644
--- a/app/code/Magento/Backend/Block/System/Design/Edit/Tabs.php
+++ b/app/code/Magento/Backend/Block/System/Design/Edit/Tabs.php
@@ -23,11 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\System\Design\Edit;
 
 class Tabs extends \Magento\Backend\Block\Widget\Tabs
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -36,6 +38,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
         $this->setTitle(__('Design Change'));
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $this->addTab('general', array(
diff --git a/app/code/Magento/Backend/Block/System/Store/Delete.php b/app/code/Magento/Backend/Block/System/Store/Delete.php
index ff2a4c3022b99fab713a0e7ea89ce8d2bdff1425..a0a8899b83d17c9f2e216b18b8c9b6e408d4f5e3 100644
--- a/app/code/Magento/Backend/Block/System/Store/Delete.php
+++ b/app/code/Magento/Backend/Block/System/Store/Delete.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\System\Store;
 
 /**
  * Store / store view / website delete form container
@@ -32,14 +32,12 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Store;
-
 class Delete extends \Magento\Backend\Block\Widget\Form\Container
 {
-
     /**
      * Class constructor
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -83,7 +81,7 @@ class Delete extends \Magento\Backend\Block\Widget\Form\Container
      * Set store type title
      *
      * @param string $title
-     * @return \Magento\Backend\Block\System\Store\Delete
+     * @return $this
      */
     public function setStoreTypeTitle($title)
     {
@@ -95,7 +93,7 @@ class Delete extends \Magento\Backend\Block\Widget\Form\Container
      * Set back URL for "Cancel" and "Back" buttons
      *
      * @param string $url
-     * @return \Magento\Backend\Block\System\Store\Delete
+     * @return $this
      */
     public function setBackUrl($url)
     {
diff --git a/app/code/Magento/Backend/Block/System/Store/Delete/Form.php b/app/code/Magento/Backend/Block/System/Store/Delete/Form.php
index b6aad787a02268cf40fe62ebc29a893254a4be37..1103fd834e37b380296e1fdd832c3a7198931bf9 100644
--- a/app/code/Magento/Backend/Block/System/Store/Delete/Form.php
+++ b/app/code/Magento/Backend/Block/System/Store/Delete/Form.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\System\Store\Delete;
 
 /**
  * Adminhtml cms block edit form
@@ -32,13 +32,13 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Store\Delete;
-
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
 
     /**
      * Init form
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -47,6 +47,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
         $this->setTitle(__('Block Information'));
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareForm()
     {
         $dataObject = $this->getDataObject();
diff --git a/app/code/Magento/Backend/Block/System/Store/Delete/Group.php b/app/code/Magento/Backend/Block/System/Store/Delete/Group.php
index 952c8f0db8678e3804599223b0fe2faa55405c25..815fce45b50420f7857d9d58596beb965c7def32 100644
--- a/app/code/Magento/Backend/Block/System/Store/Delete/Group.php
+++ b/app/code/Magento/Backend/Block/System/Store/Delete/Group.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Delete;
 
 /**
  * Adminhtml store delete group block
@@ -31,11 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Store\Delete;
-
 class Group extends \Magento\Backend\Block\Template
 {
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $itemId = $this->getRequest()->getParam('group_id');
diff --git a/app/code/Magento/Backend/Block/System/Store/Delete/Website.php b/app/code/Magento/Backend/Block/System/Store/Delete/Website.php
index 7621bf4f1b2179ed6e231852b76fe40fa50dc101..eea32caaa165fb9d738cf22a9fd64472a3d06574 100644
--- a/app/code/Magento/Backend/Block/System/Store/Delete/Website.php
+++ b/app/code/Magento/Backend/Block/System/Store/Delete/Website.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Delete;
 
 /**
  * Adminhtml store delete group block
@@ -31,11 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\System\Store\Delete;
-
 class Website extends \Magento\Backend\Block\Template
 {
-
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $itemId = $this->getRequest()->getParam('website_id');
diff --git a/app/code/Magento/Backend/Block/System/Store/Edit.php b/app/code/Magento/Backend/Block/System/Store/Edit.php
index 4301880aa49e89345a843f110769e0ee1dadc56e..f11bee0abbdf653e2a4471f2510b0cca9fc6b3bb 100644
--- a/app/code/Magento/Backend/Block/System/Store/Edit.php
+++ b/app/code/Magento/Backend/Block/System/Store/Edit.php
@@ -23,13 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store;
 
 /**
  * Adminhtml store edit
  */
-
-namespace Magento\Backend\Block\System\Store;
-
 class Edit extends \Magento\Backend\Block\Widget\Form\Container
 {
     /**
@@ -56,6 +54,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
     /**
      * Init class
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php b/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php
index d8865e2969e9a45ad1d03acb001062ee0e50e7a2..4dc4f4d1b361e5f9b487cda848f6420ee5eb9a4d 100644
--- a/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php
+++ b/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\System\Store\Edit;
 
 /**
@@ -40,6 +39,7 @@ abstract class AbstractForm extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Class constructor
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -50,7 +50,7 @@ abstract class AbstractForm extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form data
      *
-     * return \Magento\Backend\Block\Widget\Form
+     * @return \Magento\Backend\Block\Widget\Form
      */
     protected function _prepareForm()
     {
@@ -89,8 +89,9 @@ abstract class AbstractForm extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Build store type specific fieldset
      *
-     * @abstract
      * @param \Magento\Data\Form $form
+     * @return void
+     * @abstract
      */
     abstract protected function _prepareStoreFieldset(\Magento\Data\Form $form);
 }
diff --git a/app/code/Magento/Backend/Block/System/Store/Edit/Form/Group.php b/app/code/Magento/Backend/Block/System/Store/Edit/Form/Group.php
index 409473822baf2a5f73d0b08aa5c354166a0c9b4c..43cf0d2329499a682c4e4c4b09909e6553500ca4 100644
--- a/app/code/Magento/Backend/Block/System/Store/Edit/Form/Group.php
+++ b/app/code/Magento/Backend/Block/System/Store/Edit/Form/Group.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Edit\Form;
 
 /**
  * Adminhtml store edit form for group
@@ -30,10 +31,7 @@
  * @category    Magento
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
- */
-namespace Magento\Backend\Block\System\Store\Edit\Form;
-
-/**
+ *
  * @SuppressWarnings(PHPMD.DepthOfInheritance)
  */
 class Group
@@ -82,6 +80,7 @@ class Group
      * Prepare group specific fieldset
      *
      * @param \Magento\Data\Form $form
+     * @return void
      */
     protected function _prepareStoreFieldset(\Magento\Data\Form $form)
     {
diff --git a/app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php b/app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php
index b80f0554f9192afbc2a58ba03f3f5d492e5102c2..61818b498f8e1f6725030a6a754a1203bf02b69d 100644
--- a/app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php
+++ b/app/code/Magento/Backend/Block/System/Store/Edit/Form/Store.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Edit\Form;
 
 /**
  * Adminhtml store edit form for store
@@ -30,10 +31,7 @@
  * @category    Magento
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
- */
-namespace Magento\Backend\Block\System\Store\Edit\Form;
-
-/**
+ *
  * @SuppressWarnings(PHPMD.DepthOfInheritance)
  */
 class Store
@@ -74,6 +72,7 @@ class Store
      * Prepare store specific fieldset
      *
      * @param \Magento\Data\Form $form
+     * @return void
      */
     protected function _prepareStoreFieldset(\Magento\Data\Form $form)
     {
diff --git a/app/code/Magento/Backend/Block/System/Store/Edit/Form/Website.php b/app/code/Magento/Backend/Block/System/Store/Edit/Form/Website.php
index 634da32b0465b36f0e1079aada3594cbd7463c12..54e44698bd4de2ad8539400364c9e17141df8cbf 100644
--- a/app/code/Magento/Backend/Block/System/Store/Edit/Form/Website.php
+++ b/app/code/Magento/Backend/Block/System/Store/Edit/Form/Website.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Edit\Form;
 
 /**
  * Adminhtml store edit form for website
@@ -30,10 +31,7 @@
  * @category    Magento
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
- */
-namespace Magento\Backend\Block\System\Store\Edit\Form;
-
-/**
+ *
  * @SuppressWarnings(PHPMD.DepthOfInheritance)
  */
 class Website
@@ -66,6 +64,7 @@ class Website
      * Prepare website specific fieldset
      *
      * @param \Magento\Data\Form $form
+     * @return void
      */
     protected function _prepareStoreFieldset(\Magento\Data\Form $form)
     {
diff --git a/app/code/Magento/Backend/Block/System/Store/Grid/Render/Group.php b/app/code/Magento/Backend/Block/System/Store/Grid/Render/Group.php
index d8c91313ae5952ccdadbdfacab7a1c63bb695650..07287f0cc5ead465b455e2b9c8b8dcefe0aeb08f 100644
--- a/app/code/Magento/Backend/Block/System/Store/Grid/Render/Group.php
+++ b/app/code/Magento/Backend/Block/System/Store/Grid/Render/Group.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Grid\Render;
 
 /**
  * Store render group
@@ -31,12 +32,12 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Store\Grid\Render;
-
 class Group
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * {@inheritdoc}
+     */
     public function render(\Magento\Object $row)
     {
         if (!$row->getData($this->getColumn()->getIndex())) {
diff --git a/app/code/Magento/Backend/Block/System/Store/Grid/Render/Store.php b/app/code/Magento/Backend/Block/System/Store/Grid/Render/Store.php
index 8046a304606761461517fba6c172471f1534a43e..493436ac8b4868197a5bc2f802e3b3df22fd857b 100644
--- a/app/code/Magento/Backend/Block/System/Store/Grid/Render/Store.php
+++ b/app/code/Magento/Backend/Block/System/Store/Grid/Render/Store.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Grid\Render;
 
 /**
  * Store render store
@@ -31,12 +32,12 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Store\Grid\Render;
-
 class Store
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * {@inheritdoc}
+     */
     public function render(\Magento\Object $row)
     {
         if (!$row->getData($this->getColumn()->getIndex())) {
diff --git a/app/code/Magento/Backend/Block/System/Store/Grid/Render/Website.php b/app/code/Magento/Backend/Block/System/Store/Grid/Render/Website.php
index 905c1a63eeb513ad0deadb3dbe48f7c2b9162ab8..031d43a7822df2fa95fb34ea2915e1f06796b068 100644
--- a/app/code/Magento/Backend/Block/System/Store/Grid/Render/Website.php
+++ b/app/code/Magento/Backend/Block/System/Store/Grid/Render/Website.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store\Grid\Render;
 
 /**
  * Store render website
@@ -31,13 +32,12 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Store\Grid\Render;
-
 class Website
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
-
+    /**
+     * {@inheritdoc}
+     */
     public function render(\Magento\Object $row)
     {
         return '<a title="' . __('Edit Web Site') . '"
diff --git a/app/code/Magento/Backend/Block/System/Store/Store.php b/app/code/Magento/Backend/Block/System/Store/Store.php
index 520821f7a38b4ca04aa49bbcdc00a63334f8d83c..e53f8bd621e130ff4d09a58b42f8183655bb73b2 100644
--- a/app/code/Magento/Backend/Block/System/Store/Store.php
+++ b/app/code/Magento/Backend/Block/System/Store/Store.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Store;
 
 /**
  * Adminhtml store content block
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System\Store;
-
 class Store extends \Magento\Backend\Block\Widget\Grid\Container
 {
     /**
@@ -41,6 +39,9 @@ class Store extends \Magento\Backend\Block\Widget\Grid\Container
      */
     protected $_blockGroup = 'Magento_Adminhtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_blockGroup = 'Magento_Backend';
@@ -49,6 +50,9 @@ class Store extends \Magento\Backend\Block\Widget\Grid\Container
         parent::_construct();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         /* Update default add button to add website button */
diff --git a/app/code/Magento/Backend/Block/System/Variable.php b/app/code/Magento/Backend/Block/System/Variable.php
index 4081c278f43009c0b3abb5dbc9f9cb9bee902a6d..05432949a6ac34c476fcaa2106c7d9fef1ef40c2 100644
--- a/app/code/Magento/Backend/Block/System/Variable.php
+++ b/app/code/Magento/Backend/Block/System/Variable.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System;
 
 /**
  * Custom Variable Block
@@ -31,13 +32,12 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\System;
-
 class Variable extends \Magento\Backend\Block\Widget\Grid\Container
 {
     /**
      * Block constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/System/Variable/Edit.php b/app/code/Magento/Backend/Block/System/Variable/Edit.php
index d712342cb1346cd097cb83ac32f7d8dabce162de..77d33830057276406645601fda39664885e28e09 100644
--- a/app/code/Magento/Backend/Block/System/Variable/Edit.php
+++ b/app/code/Magento/Backend/Block/System/Variable/Edit.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\System\Variable;
 
 /**
  * Custom Variable Edit Container
  */
-namespace Magento\Backend\Block\System\Variable;
-
 class Edit extends \Magento\Backend\Block\Widget\Form\Container
 {
     /**
@@ -55,6 +54,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
     /**
      * Internal constructor
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -79,7 +79,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
      * Prepare layout.
      * Adding save_and_continue button
      *
-     * @return \Magento\Backend\Block\System\Variable\Edit
+     * @return $this
      */
     protected function _preparelayout()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite.php b/app/code/Magento/Backend/Block/Urlrewrite.php
index 283c19cca6ecc8833f49430a51accb804be3520f..dec0feda62f09db3457ffeec51357d339b503dff 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block;
 
 /**
  * Block for Urlrewrites grid container
@@ -34,8 +35,6 @@
  * @package     Magento_Adminhtml
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block;
-
 class Urlrewrite extends \Magento\Backend\Block\Widget\Grid\Container
 {
     /**
@@ -67,6 +66,7 @@ class Urlrewrite extends \Magento\Backend\Block\Widget\Grid\Container
     /**
      * Set custom labels and headers
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php
index 3d3032280f28520e17e8b6b334d57bb00c8aa3d9..623f2ae901b96f45617b436f2b96f7a60f69e4ac 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Catalog\Category;
 
 /**
  * Block for Catalog Category URL rewrites
@@ -35,8 +36,6 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite\Catalog\Category;
-
 class Edit
     extends \Magento\Backend\Block\Urlrewrite\Edit
 {
@@ -65,6 +64,8 @@ class Edit
 
     /**
      * Prepare layout for URL rewrite creating for category
+     *
+     * @return void
      */
     protected function _prepareLayoutFeatures()
     {
@@ -99,6 +100,8 @@ class Edit
 
     /**
      * Add child category link block
+     *
+     * @return void
      */
     private function _addCategoryLinkBlock()
     {
@@ -111,6 +114,8 @@ class Edit
 
     /**
      * Add child category tree block
+     *
+     * @return void
      */
     private function _addCategoryTreeBlock()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Tree.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Tree.php
index 2e0a049c0481c9e48c9d44df9589a4c14b4def3c..33656740e9b1fd0e54e5540f8f2d60f8865ece94 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Tree.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Tree.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Catalog\Category;
 
 /**
  * Categories tree block for URL rewrites editing process
@@ -31,17 +32,18 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite\Catalog\Category;
-
 class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
 {
     /**
      * List of allowed category ids
      *
-     * @var array|null
+     * @var int[]|null
      */
     protected $_allowedCategoryIds = null;
 
+    /**
+     * @var string
+     */
     protected $_template = 'urlrewrite/categories.phtml';
 
     /**
@@ -68,9 +70,9 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
 
     /**
      * @param \Magento\Backend\Block\Template\Context $context
-     * @param \Magento\Json\EncoderInterface $jsonEncoder
      * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTree
      * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\Json\EncoderInterface $jsonEncoder
      * @param \Magento\Catalog\Model\ProductFactory $productFactory
      * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
      * @param \Magento\Backend\Helper\Data $adminhtmlData
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php
index 913544c1c32575157b3b2b570fcd322d317dc129..e402cd32452acadeab4a25680a60ac7dc1fdfc35 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Catalog\Product;
 
 /**
  * Block for Catalog Category URL rewrites editing
@@ -38,8 +39,6 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite\Catalog\Product;
-
 class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 {
     /**
@@ -75,6 +74,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Prepare layout for URL rewrite creating for product
+     *
+     * @return void
      */
     protected function _prepareLayoutFeatures()
     {
@@ -139,6 +140,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child product link block
+     *
+     * @return void
      */
     private function _addProductLinkBlock()
     {
@@ -151,6 +154,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child category link block
+     *
+     * @return void
      */
     private function _addCategoryLinkBlock()
     {
@@ -164,6 +169,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child products grid block
+     *
+     * @return void
      */
     private function _addProductsGridBlock()
     {
@@ -172,6 +179,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child Categories Tree block
+     *
+     * @return void
      */
     private function _addCategoriesTreeBlock()
     {
@@ -180,6 +189,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child Skip Categories block
+     *
+     * @return void
      */
     private function _addSkipCategoriesBlock()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Grid.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Grid.php
index 33891524d575f3ce157e27d15b87e7cc660d373e..0969e7893d5f6d34ec34bdd5c709beda46173b42 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Grid.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Grid.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Catalog\Product;
 
 /**
  * Products grid for URL rewrites editing
@@ -31,14 +32,12 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite\Catalog\Product;
-
 class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
 {
     /**
      * Disable massaction
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Catalog\Product\Grid
+     * @return $this
      */
     protected function _prepareMassaction()
     {
@@ -48,7 +47,7 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
     /**
      * Prepare columns layout
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Catalog\Product\Grid
+     * @return $this
      */
     protected function _prepareColumns()
     {
@@ -95,7 +94,7 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
     /**
      * Return row url for js event handlers
      *
-     * @param \Magento\Catalog\Model\Product|\Magento\Object
+     * @param \Magento\Catalog\Model\Product|\Magento\Object $row
      * @return string
      */
     public function getRowUrl($row)
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php
index d663392372a0dc2a9589a6e72cdf4769789271ab..9784658aaae2e883ea42dbf5b1dc910cb74f86d8 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Cms\Page;
 
 /**
  * Block for CMS pages URL rewrites
@@ -34,8 +35,6 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite\Cms\Page;
-
 class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 {
     /**
@@ -63,6 +62,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Prepare layout for URL rewrite creating for CMS page
+     *
+     * @return void
      */
     protected function _prepareLayoutFeatures()
     {
@@ -97,6 +98,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child CMS page link block
+     *
+     * @return void
      */
     private function _addCmsPageLinkBlock()
     {
@@ -109,6 +112,8 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit
 
     /**
      * Add child CMS page block
+     *
+     * @return void
      */
     private function _addCmsPageGridBlock()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Grid.php b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Grid.php
index 525ab46f94f24c5739cf330379138075dc4d551b..e32c1542c52732c4b4b43d68feeeab1ea4d6c2a3 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Grid.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Grid.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Cms\Page;
 
 /**
  * CMS pages grid for URL rewrites
@@ -31,12 +32,12 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite\Cms\Page;
-
 class Grid extends \Magento\Cms\Block\Adminhtml\Page\Grid
 {
     /**
      * Constructor
+     *
+     * @return void
      */
     public function _construct()
     {
@@ -47,7 +48,7 @@ class Grid extends \Magento\Cms\Block\Adminhtml\Page\Grid
     /**
      * Disable massaction
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Cms\Page\Grid
+     * @return $this
      */
     protected function _prepareMassaction()
     {
@@ -57,7 +58,7 @@ class Grid extends \Magento\Cms\Block\Adminhtml\Page\Grid
     /**
      * Prepare columns layout
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Cms\Page\Grid
+     * @return $this
      */
     protected function _prepareColumns()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Edit.php
index 7aa83674596f07c1aeb575cf041c7669e28448ed..14d95def038c465fb8c31db4eb907b5a603f37bc 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Edit.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite;
 
 /**
  * Block for URL rewrites edit page
@@ -34,8 +35,6 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite;
-
 class Edit extends \Magento\Backend\Block\Widget\Container
 {
     /**
@@ -89,7 +88,7 @@ class Edit extends \Magento\Backend\Block\Widget\Container
     /**
      * Prepare URL rewrite editing layout
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Edit
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -103,6 +102,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Prepare featured blocks for layout of URL rewrite editing
+     *
+     * @return void
      */
     protected function _prepareLayoutFeatures()
     {
@@ -121,6 +122,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Add child edit form block
+     *
+     * @return void
      */
     protected function _addEditFormBlock()
     {
@@ -136,6 +139,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Add reset button
+     *
+     * @return void
      */
     protected function _addResetButton()
     {
@@ -149,6 +154,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Add back button
+     *
+     * @return void
      */
     protected function _addBackButton()
     {
@@ -164,6 +171,7 @@ class Edit extends \Magento\Backend\Block\Widget\Container
      * Update Back button location link
      *
      * @param string $link
+     * @return void
      */
     protected function _updateBackButtonLink($link)
     {
@@ -172,6 +180,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Add delete button
+     *
+     * @return void
      */
     protected function _addDeleteButton()
     {
@@ -189,6 +199,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Add save button
+     *
+     * @return void
      */
     protected function _addSaveButton()
     {
@@ -220,6 +232,8 @@ class Edit extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Add child URL rewrite selector block
+     *
+     * @return void
      */
     protected function _addUrlRewriteSelectorBlock()
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php
index b064a0972273b5faf44eb5d0424efe5096e955f3..3bf816589709980871e675adb0378539ec3debb0 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite\Edit;
 
 /**
  * URL rewrites edit form
@@ -34,10 +35,7 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  *
- */
-namespace Magento\Backend\Block\Urlrewrite\Edit;
-
-/**
+ *
  * @SuppressWarnings(PHPMD.DepthOfInheritance)
  */
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
@@ -124,6 +122,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Set form id and title
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -136,7 +135,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * Initialize form values
      * Set form data either from model values or from session
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Edit\Form
+     * @return $this
      */
     protected function _initFormValues()
     {
@@ -165,7 +164,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare the form layout
      *
-     * @return \Magento\Backend\Block\Urlrewrite\Edit\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -255,6 +254,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * Prepare store element
      *
      * @param \Magento\Data\Form\Element\Fieldset $fieldset
+     * @return void
      */
     protected function _prepareStoreElement($fieldset)
     {
@@ -286,7 +286,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * Form post init
      *
      * @param \Magento\Data\Form $form
-     * @return \Magento\Backend\Block\Urlrewrite\Edit\Form
+     * @return $this
      */
     protected function _formPostInit($form)
     {
diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Selector.php b/app/code/Magento/Backend/Block/Urlrewrite/Selector.php
index 2c3f70728a84d8876937c73d9fcb17eb6cddddbd..ef3f650a3582f98c55cc363b46ed34629d0e9423 100644
--- a/app/code/Magento/Backend/Block/Urlrewrite/Selector.php
+++ b/app/code/Magento/Backend/Block/Urlrewrite/Selector.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Urlrewrite;
 
 /**
  * Modes selector for URL rewrites modes
@@ -31,8 +32,6 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Urlrewrite;
-
 class Selector extends \Magento\View\Element\Template
 {
     /**
@@ -43,11 +42,15 @@ class Selector extends \Magento\View\Element\Template
      */
     protected $_modes;
 
+    /**
+     * @var string
+     */
     protected $_template = 'urlrewrite/selector.phtml';
 
     /**
      * Set block template and get available modes
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/Widget.php b/app/code/Magento/Backend/Block/Widget.php
index f4c001d19fe3b4a8a2ffbd0e1a71d8ff29447834..3b740ff393b7a37c00185965c85b296344770be7 100644
--- a/app/code/Magento/Backend/Block/Widget.php
+++ b/app/code/Magento/Backend/Block/Widget.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block;
 
 /**
  * Base widget class
@@ -31,14 +32,13 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  *
- */
-namespace Magento\Backend\Block;
-
-/**
  * @SuppressWarnings(PHPMD.NumberOfChildren)
  */
 class Widget extends \Magento\Backend\Block\Template
 {
+    /**
+     * @return string
+     */
     public function getId()
     {
         if (null === $this->getData('id')) {
@@ -58,6 +58,9 @@ class Widget extends \Magento\Backend\Block\Template
         return "{$this->getId()}_{$suffix}";
     }
 
+    /**
+     * @return string
+     */
     public function getHtmlId()
     {
         return $this->getId();
@@ -77,6 +80,12 @@ class Widget extends \Magento\Backend\Block\Template
         return $this->getUrl('*/*/*', $params);
     }
 
+    /**
+     * @param string $label
+     * @param string|null $title
+     * @param string|null $link
+     * @return void
+     */
     protected function _addBreadcrumb($label, $title=null, $link=null)
     {
         $this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link);
@@ -106,6 +115,9 @@ class Widget extends \Magento\Backend\Block\Template
             ->toHtml();
     }
 
+    /**
+     * @return string
+     */
     public function getGlobalIcon()
     {
         return '<img src="' . $this->getViewFileUrl('images/fam_link.gif')
diff --git a/app/code/Magento/Backend/Block/Widget/Accordion.php b/app/code/Magento/Backend/Block/Widget/Accordion.php
index e3826b25776db02711501ca89d70e56d5609c218..fa20d1c8096ec90494b5d9e525c934c06530e81a 100644
--- a/app/code/Magento/Backend/Block/Widget/Accordion.php
+++ b/app/code/Magento/Backend/Block/Widget/Accordion.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget;
 
 /**
  * Magento_Backend accordion widget
@@ -31,10 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget;
-
 class Accordion extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var string[]
+     */
     protected $_items = array();
 
     /**
@@ -42,11 +44,19 @@ class Accordion extends \Magento\Backend\Block\Widget
      */
     protected $_template = 'Magento_Backend::widget/accordion.phtml';
 
+    /**
+     * @return string[]
+     */
     public function getItems()
     {
         return $this->_items;
     }
-    
+
+    /**
+     * @param string $itemId
+     * @param array $config
+     * @return $this
+     */
     public function addItem($itemId, $config)
     {
         $this->_items[$itemId] = $this->getLayout()
@@ -60,7 +70,7 @@ class Accordion extends \Magento\Backend\Block\Widget
         if (isset($config['content']) && $config['content'] instanceof \Magento\View\Element\AbstractBlock) {
             $this->_items[$itemId]->setChild($itemId.'_content', $config['content']);
         }
-            
+
         $this->setChild($itemId, $this->_items[$itemId]);
         return $this;
     }
diff --git a/app/code/Magento/Backend/Block/Widget/Accordion/Item.php b/app/code/Magento/Backend/Block/Widget/Accordion/Item.php
index 9ee9b8772d01d7c1edeaff7c15878d986b96e1df..94c8d2eaec7109f4b4662923239e0e6dc1da0a57 100644
--- a/app/code/Magento/Backend/Block/Widget/Accordion/Item.php
+++ b/app/code/Magento/Backend/Block/Widget/Accordion/Item.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Accordion;
+
+use Magento\Backend\Block\Widget\Accordion;
 
 /**
  * Accordion item
@@ -31,23 +34,34 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Accordion;
-
 class Item extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var Accordion
+     */
     protected $_accordion;
 
+    /**
+     * @param Accordion $accordion
+     * @return $this
+     */
     public function setAccordion($accordion)
     {
         $this->_accordion = $accordion;
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getTarget()
     {
         return ($this->getAjax()) ? 'ajax' : '';
     }
 
+    /**
+     * @return string
+     */
     public function getTitle()
     {
         $title = $this->getData('title');
@@ -58,6 +72,9 @@ class Item extends \Magento\Backend\Block\Widget
         return $title;
     }
 
+    /**
+     * @return null|string
+     */
     public function getContent()
     {
         $content = $this->getData('content');
@@ -70,6 +87,9 @@ class Item extends \Magento\Backend\Block\Widget
         return null;
     }
 
+    /**
+     * @return string
+     */
     public function getClass()
     {
         $class = $this->getData('class');
@@ -79,6 +99,9 @@ class Item extends \Magento\Backend\Block\Widget
         return $class;
     }
 
+    /**
+     * @return string
+     */
     protected function _toHtml()
     {
         $content = $this->getContent();
diff --git a/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php b/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php
index 6c8d739d7e94da11456cc59b157f1081f42846ea..60083219f367f05508b13c18e38746cce07f5cf2 100644
--- a/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php
+++ b/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget;
 
 /**
  * Magento_Backend page breadcrumbs
@@ -31,19 +32,23 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget;
-
 class Breadcrumbs extends \Magento\Backend\Block\Template
 {
     /**
-     * breadcrumbs links
+     * Breadcrumbs links
      *
      * @var array
      */
     protected $_links = array();
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/breadcrumbs.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->addLink(__('Home'),
@@ -51,6 +56,12 @@ class Breadcrumbs extends \Magento\Backend\Block\Template
         );
     }
 
+    /**
+     * @param string $label
+     * @param string|null $title
+     * @param string|null $url
+     * @return $this
+     */
     public function addLink($label, $title=null, $url=null)
     {
         if (empty($title)) {
@@ -64,6 +75,9 @@ class Breadcrumbs extends \Magento\Backend\Block\Template
         return $this;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _beforeToHtml()
     {
         // TODO - Moved to Beta 2, no breadcrumbs displaying in Beta 1
diff --git a/app/code/Magento/Backend/Block/Widget/Button.php b/app/code/Magento/Backend/Block/Widget/Button.php
index defb000b04f7055d6da696ae2bd6106cee33f7df..630a3cc54e0eb35c842852663eb8054fbcddfb50 100644
--- a/app/code/Magento/Backend/Block/Widget/Button.php
+++ b/app/code/Magento/Backend/Block/Widget/Button.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget;
 
 /**
  * Button widget
@@ -31,12 +32,12 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget;
-
 class Button extends \Magento\Backend\Block\Widget
 {
     /**
      * Define block template
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php b/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php
index 17937637564fe3c50f2fc1c864e08fd9221e971a..5ffa7824d3c332dce71b55fa86938f5943eed5b2 100644
--- a/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php
+++ b/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Button;
 
 /**
  * Split button widget
@@ -36,12 +37,12 @@
  * @method string getStyle()
  * @method array getDataAttribute()
  */
-namespace Magento\Backend\Block\Widget\Button;
-
 class SplitButton extends \Magento\Backend\Block\Widget
 {
     /**
      * Define block template
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -205,7 +206,8 @@ class SplitButton extends \Magento\Backend\Block\Widget
      * Add data attributes to $attributes array
      *
      * @param array $data
-     * @param array $attributes
+     * @param array &$attributes
+     * @return void
      */
     protected function _getDataAttributes($data, &$attributes)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Container.php b/app/code/Magento/Backend/Block/Widget/Container.php
index a4e635b4a182d7d3437c5652ce2cb46075391e94..9753603ac9b93a6e91c25386f88c025cadac379a 100644
--- a/app/code/Magento/Backend/Block/Widget/Container.php
+++ b/app/code/Magento/Backend/Block/Widget/Container.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget;
 
 /**
  * Backend container block
@@ -31,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget;
-
 class Container extends \Magento\Backend\Block\Template
 {
     /**#@+
@@ -52,7 +51,6 @@ class Container extends \Magento\Backend\Block\Template
     /**
      * Array of buttons
      *
-     *
      * @var array
      */
     protected $_buttons = array(
@@ -70,6 +68,8 @@ class Container extends \Magento\Backend\Block\Template
 
     /**
      * Initialize "controller" and "header text"
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -89,8 +89,8 @@ class Container extends \Magento\Backend\Block\Template
      * @param array $data
      * @param integer $level
      * @param integer $sortOrder
-     * @param string|null $region, that button should be displayed in ('header', 'footer', null)
-     * @return \Magento\Backend\Block\Widget\Container
+     * @param string|null $region That button should be displayed in ('header', 'footer', null)
+     * @return $this
      */
     protected function _addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region = 'header')
     {
@@ -120,8 +120,8 @@ class Container extends \Magento\Backend\Block\Template
      * @param array $data
      * @param integer $level
      * @param integer $sortOrder
-     * @param string|null $region, that button should be displayed in ('header', 'footer', null)
-     * @return \Magento\Backend\Block\Widget\Container
+     * @param string|null $region That button should be displayed in ('header', 'footer', null)
+     * @return $this
      */
     public function addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region = 'header')
     {
@@ -132,7 +132,7 @@ class Container extends \Magento\Backend\Block\Template
      * Remove existing button
      *
      * @param string $buttonId
-     * @return \Magento\Backend\Block\Widget\Container
+     * @return $this
      */
     protected function _removeButton($buttonId)
     {
@@ -148,7 +148,7 @@ class Container extends \Magento\Backend\Block\Template
      * Public wrapper for the _removeButton() method
      *
      * @param string $buttonId
-     * @return \Magento\Backend\Block\Widget\Container
+     * @return $this
      */
     public function removeButton($buttonId)
     {
@@ -160,8 +160,8 @@ class Container extends \Magento\Backend\Block\Template
      *
      * @param string $buttonId
      * @param string|null $key
-     * @param mixed $data
-     * @return \Magento\Backend\Block\Widget\Container
+     * @param string $data
+     * @return $this
      */
     protected function _updateButton($buttonId, $key, $data)
     {
@@ -191,8 +191,8 @@ class Container extends \Magento\Backend\Block\Template
      *
      * @param string $buttonId
      * @param string|null $key
-     * @param mixed $data
-     * @return \Magento\Backend\Block\Widget\Container
+     * @param string $data
+     * @return $this
      */
     public function updateButton($buttonId, $key, $data)
     {
@@ -202,7 +202,7 @@ class Container extends \Magento\Backend\Block\Template
     /**
      * Preparing child blocks for each added button
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Form.php b/app/code/Magento/Backend/Block/Widget/Form.php
index 0ddfb678c2094ed5f924430b7620ae72f1e816fb..0c0d7d6cd51516842a3b43e312440ba2c149d7f1 100644
--- a/app/code/Magento/Backend/Block/Widget/Form.php
+++ b/app/code/Magento/Backend/Block/Widget/Form.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\Widget;
 
 /**
@@ -40,6 +39,9 @@ class Form extends \Magento\Backend\Block\Widget
      */
     protected $_form;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form.phtml';
 
     /**
@@ -62,6 +64,7 @@ class Form extends \Magento\Backend\Block\Widget
     /**
      * Class constructor
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -76,7 +79,7 @@ class Form extends \Magento\Backend\Block\Widget
      *
      * You can redefine this method in child classes for changing layout
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -129,7 +132,7 @@ class Form extends \Magento\Backend\Block\Widget
      * Set form object
      *
      * @param \Magento\Data\Form $form
-     * @return \Magento\Backend\Block\Widget\Form
+     * @return $this
      */
     public function setForm(\Magento\Data\Form $form)
     {
@@ -142,7 +145,7 @@ class Form extends \Magento\Backend\Block\Widget
     /**
      * Prepare form before rendering HTML
      *
-     * @return \Magento\Backend\Block\Widget\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -152,7 +155,7 @@ class Form extends \Magento\Backend\Block\Widget
     /**
      * This method is called before rendering HTML
      *
-     * @return \Magento\Backend\Block\Widget\Form|\Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _beforeToHtml()
     {
@@ -165,7 +168,7 @@ class Form extends \Magento\Backend\Block\Widget
      * Initialize form fields values
      * Method will be called after prepareForm and can be used for field values initialization
      *
-     * @return \Magento\Backend\Block\Widget\Form
+     * @return $this
      */
     protected function _initFormValues()
     {
@@ -178,6 +181,7 @@ class Form extends \Magento\Backend\Block\Widget
      * @param array $attributes attributes that are to be added
      * @param \Magento\Data\Form\Element\Fieldset $fieldset
      * @param array $exclude attributes that should be skipped
+     * @return void
      */
     protected function _setFieldset($attributes, $fieldset, $exclude=array())
     {
@@ -233,6 +237,7 @@ class Form extends \Magento\Backend\Block\Widget
      * @param string $inputType
      * @param \Magento\Data\Form\Element\AbstractElement $element
      * @param \Magento\Eav\Model\Entity\Attribute $attribute
+     * @return void
      */
     protected function _applyTypeSpecificConfig($inputType, $element, \Magento\Eav\Model\Entity\Attribute $attribute)
     {
@@ -260,6 +265,7 @@ class Form extends \Magento\Backend\Block\Widget
      * Add new element type
      *
      * @param \Magento\Data\Form\AbstractForm $baseElement
+     * @return void
      */
     protected function _addElementTypes(\Magento\Data\Form\AbstractForm $baseElement)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Form/Container.php b/app/code/Magento/Backend/Block/Widget/Form/Container.php
index b493dd153fa42b2641d1cd95c395a0d31cd9907a..7e12d739fd22f30b8bf401e902b82b58400a642e 100644
--- a/app/code/Magento/Backend/Block/Widget/Form/Container.php
+++ b/app/code/Magento/Backend/Block/Widget/Form/Container.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Form;
 
 /**
  * Backend form container block
@@ -31,20 +32,41 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Widget\Form;
-
 class Container extends \Magento\Backend\Block\Widget\Container
 {
+    /**
+     * @var string
+     */
     protected $_objectId = 'id';
+
+    /**
+     * @var string[]
+     */
     protected $_formScripts = array();
+
+    /**
+     * @var string[]
+     */
     protected $_formInitScripts = array();
+
+    /**
+     * @var string
+     */
     protected $_mode = 'edit';
+
+    /**
+     * @var string
+     */
     protected $_blockGroup = 'Magento_Backend';
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form/container.phtml';
 
-
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -84,7 +106,7 @@ class Container extends \Magento\Backend\Block\Widget\Container
     /**
      * Create form block
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -122,6 +144,9 @@ class Container extends \Magento\Backend\Block\Widget\Container
         return $this->getUrl('*/*/');
     }
 
+    /**
+     * @return string
+     */
     public function getDeleteUrl()
     {
         return $this->getUrl('*/*/delete', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
@@ -151,12 +176,18 @@ class Container extends \Magento\Backend\Block\Widget\Container
         return $this->getUrl('*/*/save');
     }
 
+    /**
+     * @return string
+     */
     public function getFormHtml()
     {
         $this->getChildBlock('form')->setData('action', $this->getSaveUrl());
         return $this->getChildHtml('form');
     }
 
+    /**
+     * @return string
+     */
     public function getFormInitScripts()
     {
         if ( !empty($this->_formInitScripts) && is_array($this->_formInitScripts) ) {
@@ -165,6 +196,9 @@ class Container extends \Magento\Backend\Block\Widget\Container
         return '';
     }
 
+    /**
+     * @return string
+     */
     public function getFormScripts()
     {
         if ( !empty($this->_formScripts) && is_array($this->_formScripts) ) {
@@ -173,16 +207,25 @@ class Container extends \Magento\Backend\Block\Widget\Container
         return '';
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderWidth()
     {
         return '';
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderCssClass()
     {
         return 'icon-head head-' . strtr($this->_controller, '_', '-');
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderHtml()
     {
         return '<h3 class="' . $this->getHeaderCssClass() . '">' . $this->getHeaderText() . '</h3>';
@@ -192,7 +235,7 @@ class Container extends \Magento\Backend\Block\Widget\Container
      * Set data object and pass it to form
      *
      * @param \Magento\Object $object
-     * @return \Magento\Backend\Block\Widget\Form\Container
+     * @return $this
      */
     public function setDataObject($object)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Form/Element.php b/app/code/Magento/Backend/Block/Widget/Form/Element.php
index 9b1e31a296a20a8e4d6cdae459678c8b93e685b5..5dad6c7612fa4052e332379e966ddbba0792cc58 100644
--- a/app/code/Magento/Backend/Block/Widget/Form/Element.php
+++ b/app/code/Magento/Backend/Block/Widget/Form/Element.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Form;
+
+use Magento\Data\Form;
 
 /**
  * Form element widget block
@@ -31,34 +34,61 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Form;
-
 class Element extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_element;
+
+    /**
+     * @var Form
+     */
     protected $_form;
+
+    /**
+     * @var \Magento\Object
+     */
     protected $_formBlock;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form/element.phtml';
 
+    /**
+     * @param string $element
+     * @return $this
+     */
     public function setElement($element)
     {
         $this->_element = $element;
         return $this;
     }
 
+    /**
+     * @param Form $form
+     * @return $this
+     */
     public function setForm($form)
     {
         $this->_form = $form;
         return $this;
     }
 
+    /**
+     * @param \Magento\Object $formBlock
+     * @return $this
+     */
     public function setFormBlock($formBlock)
     {
         $this->_formBlock = $formBlock;
         return $this;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _beforeToHtml()
     {
         $this->assign('form', $this->_form);
diff --git a/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php b/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php
index 28a0448725fbed4674e851438f2638e06a187305..77a114b28cdc24d4ec0fd56bfc84317e9a1a2804 100644
--- a/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php
+++ b/app/code/Magento/Backend/Block/Widget/Form/Element/Gallery.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Form\Element;
+
+use Magento\Data\Form\Element\AbstractElement;
 
 /**
  * Backend image gallery item renderer
@@ -31,38 +34,58 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Form\Element;
-
 class Gallery extends \Magento\Backend\Block\Template
     implements \Magento\Data\Form\Element\Renderer\RendererInterface
 {
-
+    /**
+     * @var AbstractElement|null
+     */
     protected $_element = null;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form/element/gallery.phtml';
 
-    public function render(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    public function render(AbstractElement $element)
     {
         $this->setElement($element);
         return $this->toHtml();
     }
 
-    public function setElement(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return $this
+     */
+    public function setElement(AbstractElement $element)
     {
         $this->_element = $element;
         return $this;
     }
 
+    /**
+     * @return AbstractElement|null
+     */
     public function getElement()
     {
         return $this->_element;
     }
 
+    /**
+     * @return array
+     */
     public function getValues()
     {
         return $this->getElement()->getValue();
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $this->addChild('delete_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -79,11 +102,18 @@ class Gallery extends \Magento\Backend\Block\Template
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getAddButtonHtml()
     {
         return $this->getChildHtml('add_button');
     }
 
+    /**
+     * @param string $image
+     * @return string|string[]
+     */
     public function getDeleteButtonHtml($image)
     {
         return str_replace('#image#', $image, $this->getChildHtml('delete_button'));
diff --git a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php
index b1debe60c7e39959ade0c79b9b3dd7813bb39d2d..5862e34a85b99ac360bd9fe90ca40292bea4e79e 100644
--- a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php
+++ b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Form\Renderer;
+
+use Magento\Data\Form\Element\AbstractElement;
 
 /**
  * Form element default renderer
@@ -31,21 +34,32 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Form\Renderer;
-
 class Element extends \Magento\Backend\Block\Template
     implements \Magento\Data\Form\Element\Renderer\RendererInterface
 {
+    /**
+     * @var AbstractElement
+     */
     protected $_element;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form/renderer/element.phtml';
 
+    /**
+     * @return AbstractElement
+     */
     public function getElement()
     {
         return $this->_element;
     }
 
-    public function render(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    public function render(AbstractElement $element)
     {
         $this->_element = $element;
         return $this->toHtml();
diff --git a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php
index 167f02148e37a5b0b635790836ecf8768bcd5a6c..4a311c40e89e93cf94436ae6cc0ed97ab3f43fff 100644
--- a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php
+++ b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Form\Renderer;
+
+use Magento\Data\Form\Element\AbstractElement;
 
 /**
  * Form fieldset default renderer
@@ -31,21 +34,32 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Form\Renderer;
-
 class Fieldset extends \Magento\Backend\Block\Template
     implements \Magento\Data\Form\Element\Renderer\RendererInterface
 {
+    /**
+     * @var AbstractElement
+     */
     protected $_element;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form/renderer/fieldset.phtml';
 
+    /**
+     * @return AbstractElement
+     */
     public function getElement()
     {
         return $this->_element;
     }
 
-    public function render(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    public function render(AbstractElement $element)
     {
         $this->_element = $element;
         return $this->toHtml();
diff --git a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php
index 01162f67448d3373d4a01ee252ea4b885eb69b80..32e38d77b363cc4b4198228f2672b61e4f5106d5 100644
--- a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php
+++ b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Form\Renderer\Fieldset;
+
+use Magento\Data\Form\Element\AbstractElement;
 
 /**
  * Fieldset element renderer
@@ -31,21 +34,32 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Form\Renderer\Fieldset;
-
 class Element extends \Magento\Backend\Block\Template
     implements \Magento\Data\Form\Element\Renderer\RendererInterface
 {
+    /**
+     * @var AbstractElement
+     */
     protected $_element;
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/form/renderer/fieldset/element.phtml';
 
+    /**
+     * @return AbstractElement
+     */
     public function getElement()
     {
         return $this->_element;
     }
 
-    public function render(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    public function render(AbstractElement $element)
     {
         $this->_element = $element;
         return $this->toHtml();
diff --git a/app/code/Magento/Backend/Block/Widget/Grid.php b/app/code/Magento/Backend/Block/Widget/Grid.php
index 0a469868a0630f4ffb7b9a3bcd198636c5d19f25..2fb5033d6a0d025c874e44f744d57ce29acd5f45 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget;
 
 /**
  * Backend grid widget block
@@ -30,8 +31,6 @@
  * @method string getRowClickCallback() getRowClickCallback()
  * @method \Magento\Backend\Block\Widget\Grid setRowClickCallback() setRowClickCallback(string $value)
  */
-namespace Magento\Backend\Block\Widget;
-
 class Grid extends \Magento\Backend\Block\Widget
 {
     /**
@@ -40,15 +39,50 @@ class Grid extends \Magento\Backend\Block\Widget
      * @var string
      */
     protected $_varNameLimit    = 'limit';
+
+    /**
+     * @var string
+     */
     protected $_varNamePage     = 'page';
+
+    /**
+     * @var string
+     */
     protected $_varNameSort     = 'sort';
+
+    /**
+     * @var string
+     */
     protected $_varNameDir      = 'dir';
+
+    /**
+     * @var string
+     */
     protected $_varNameFilter   = 'filter';
 
+    /**
+     * @var int
+     */
     protected $_defaultLimit    = 20;
+
+    /**
+     * @var int
+     */
     protected $_defaultPage     = 1;
+
+    /**
+     * @var bool|string
+     */
     protected $_defaultSort     = false;
+
+    /**
+     * @var string
+     */
     protected $_defaultDir      = 'desc';
+
+    /**
+     * @var array
+     */
     protected $_defaultFilter   = array();
 
     /**
@@ -103,10 +137,13 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * RSS list
      *
-     * @var array
+     * @var \Magento\Object[]
      */
     protected $_rssLists = array();
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/grid.phtml';
 
     /**
@@ -134,6 +171,9 @@ class Grid extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -176,6 +216,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set collection object
      *
      * @param \Magento\Data\Collection $collection
+     * @return void
      */
     public function setCollection($collection)
     {
@@ -206,7 +247,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Retrieve export block
      *
      * @throws \Magento\Core\Exception
-     * @return \Magento\View\Element\AbstractBlock
+     * @return \Magento\View\Element\AbstractBlock|bool
      */
     public function getExportBlock()
     {
@@ -240,7 +281,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Retrieve column by id
      *
      * @param string $columnId
-     * @return \Magento\View\Element\AbstractBlock
+     * @return \Magento\View\Element\AbstractBlock|bool
      */
     public function getColumn($columnId)
     {
@@ -251,7 +292,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Process column filtration values
      *
      * @param mixed $data
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _setFilterValues($data)
     {
@@ -271,7 +312,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Add column filtering conditions to collection
      *
      * @param \Magento\Backend\Block\Widget\Grid\Column $column
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _addColumnFilterToCollection($column)
     {
@@ -293,7 +334,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Sets sorting order by some column
      *
      * @param \Magento\Backend\Block\Widget\Grid\Column $column
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _setCollectionOrder($column)
     {
@@ -320,7 +361,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Apply sorting and filtering to collection
      *
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
@@ -359,7 +400,8 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Decode URL encoded filter value recursive callback method
      *
-     * @var string $value
+     * @param string &$value
+     * @return void
      */
     protected function _decodeFilter(&$value)
     {
@@ -368,6 +410,8 @@ class Grid extends \Magento\Backend\Block\Widget
 
     /**
      * Apply pagination to collection
+     *
+     * @return void
      */
     protected function _preparePage()
     {
@@ -377,6 +421,8 @@ class Grid extends \Magento\Backend\Block\Widget
 
     /**
      * Initialize grid
+     *
+     * @return void
      */
     protected function _prepareGrid()
     {
@@ -411,6 +457,8 @@ class Grid extends \Magento\Backend\Block\Widget
 
     /**
      * Prepare grid filter buttons
+     *
+     * @return void
      */
     protected function _prepareFilterButtons()
     {
@@ -434,7 +482,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Initialize grid before rendering
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _beforeToHtml()
     {
@@ -496,7 +544,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set Limit request key
      *
      * @param string $name
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setVarNameLimit($name)
     {
@@ -508,7 +556,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set Page request key
      *
      * @param string $name
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setVarNamePage($name)
     {
@@ -520,7 +568,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set Sort request key
      *
      * @param string $name
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setVarNameSort($name)
     {
@@ -532,7 +580,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set Sort Direction request key
      *
      * @param string $name
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setVarNameDir($name)
     {
@@ -544,7 +592,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set Filter request key
      *
      * @param string $name
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setVarNameFilter($name)
     {
@@ -555,8 +603,8 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Set visibility of pager
      *
-     * @param boolean $visible
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @param bool $visible
+     * @return $this
      */
     public function setPagerVisibility($visible = true)
     {
@@ -567,7 +615,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Return visibility of pager
      *
-     * @return boolean
+     * @return bool
      */
     public function getPagerVisibility()
     {
@@ -577,7 +625,8 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Set visibility of message blocks
      *
-     * @param boolean $visible
+     * @param bool $visible
+     * @return void
      */
     public function setMessageBlockVisibility($visible = true)
     {
@@ -587,7 +636,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Return visibility of message blocks
      *
-     * @return boolean
+     * @return bool
      */
     public function getMessageBlockVisibility()
     {
@@ -598,7 +647,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set default limit
      *
      * @param int $limit
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setDefaultLimit($limit)
     {
@@ -610,7 +659,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set default page
      *
      * @param int $page
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setDefaultPage($page)
     {
@@ -622,7 +671,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set default sort
      *
      * @param string $sort
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setDefaultSort($sort)
     {
@@ -634,7 +683,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set default direction
      *
      * @param string $dir
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setDefaultDir($dir)
     {
@@ -646,7 +695,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set default filter
      *
      * @param string $filter
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setDefaultFilter($filter)
     {
@@ -657,7 +706,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Retrieve rss lists types
      *
-     * @return array|bool
+     * @return \Magento\Object[]|false
      */
     public function getRssLists()
     {
@@ -669,7 +718,7 @@ class Grid extends \Magento\Backend\Block\Widget
      *
      * @param   string $url
      * @param   string $label
-     * @return  \Magento\Backend\Block\Widget\Grid
+     * @return  $this
      */
     public function addRssList($url, $label)
     {
@@ -685,7 +734,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Clear rss list in grid
      *
-     * @return  \Magento\Backend\Block\Widget\Grid
+     * @return  $this
      */
     public function clearRss()
     {
@@ -755,7 +804,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set whether grid parameters should be saved in session
      *
      * @param bool $flag
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setSaveParametersInSession($flag)
     {
@@ -776,8 +825,8 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Set count totals
      *
-     * @param boolean $count
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @param bool $count
+     * @return $this
      */
     public function setCountTotals($count = true)
     {
@@ -788,7 +837,7 @@ class Grid extends \Magento\Backend\Block\Widget
     /**
      * Return count totals
      *
-     * @return boolean
+     * @return bool
      */
     public function getCountTotals()
     {
@@ -799,6 +848,7 @@ class Grid extends \Magento\Backend\Block\Widget
      * Set totals
      *
      * @param \Magento\Object $totals
+     * @return void
      */
     public function setTotals(\Magento\Object $totals)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column.php b/app/code/Magento/Backend/Block/Widget/Grid/Column.php
index 2aaf7158a008259919add49a9243e70393cc05b3..d6ff13789fc0f9bb29a0e281a2124e733b99219d 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid;
+
+use Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter;
 
 /**
  * Grid column block
@@ -31,8 +34,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid;
-
 class Column extends \Magento\Backend\Block\Widget
 {
     /**
@@ -52,7 +53,7 @@ class Column extends \Magento\Backend\Block\Widget
     /**
      * Column filter
      *
-     * @var \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
+     * @var AbstractFilter
      */
     protected $_filter;
 
@@ -120,6 +121,9 @@ class Column extends \Magento\Backend\Block\Widget
      */
     protected $_isGrouped = false;
 
+    /**
+     * @return void
+     */
     public function _construct()
     {
         if ($this->hasData('grouped')) {
@@ -143,7 +147,7 @@ class Column extends \Magento\Backend\Block\Widget
      * Set grid block to column
      *
      * @param \Magento\Backend\Block\Widget\Grid $grid
-     * @return \Magento\Backend\Block\Widget\Grid\Column
+     * @return $this
      */
     public function setGrid($grid)
     {
@@ -230,7 +234,8 @@ class Column extends \Magento\Backend\Block\Widget
     /**
      * Set is column sortable
      *
-     * @param boolean $value
+     * @param bool $value
+     * @return void
      */
     public function setSortable($value)
     {
@@ -259,7 +264,9 @@ class Column extends \Magento\Backend\Block\Widget
 
     /**
      * Add css class to column header
-     * @param $className
+     *
+     * @param string $className
+     * @return void
      */
     public function addHeaderCssClass($className)
     {
@@ -379,7 +386,7 @@ class Column extends \Magento\Backend\Block\Widget
      * Set column renderer
      *
      * @param \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer $renderer
-     * @return \Magento\Backend\Block\Widget\Grid\Column
+     * @return $this
      */
     public function setRenderer($renderer)
     {
@@ -392,6 +399,7 @@ class Column extends \Magento\Backend\Block\Widget
      *
      * @param string $type type of renderer
      * @param string $className renderer class name
+     * @return void
      */
     public function setRendererType($type, $className)
     {
@@ -435,6 +443,7 @@ class Column extends \Magento\Backend\Block\Widget
      * Set column filter
      *
      * @param string $filterClass filter class name
+     * @return void
      */
     public function setFilter($filterClass)
     {
@@ -445,8 +454,10 @@ class Column extends \Magento\Backend\Block\Widget
 
     /**
      * Set filter type class name
+     *
      * @param string $type type of filter
      * @param string $className filter class name
+     * @return void
      */
     public function setFilterType($type, $className)
     {
@@ -456,7 +467,7 @@ class Column extends \Magento\Backend\Block\Widget
     /**
      * Get column filter class name by filter type
      *
-     * @return mixed
+     * @return string
      */
     protected function _getFilterByType()
     {
@@ -471,7 +482,7 @@ class Column extends \Magento\Backend\Block\Widget
     /**
      * Get filter block
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter|bool
+     * @return AbstractFilter|false
      */
     public function getFilter()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php
index abb01d9aa26d0ed9659f030d6d0d0cdae37bf8e0..01099b5313071d925848cd761eb1888ba3d6b7fd 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Checkbox.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Checkbox grid column filter
@@ -31,15 +32,19 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
 {
+    /**
+     * @return string
+     */
     public function getHtml()
     {
         return '<span class="head-massaction">' . parent::getHtml() . '</span>';
     }
 
+    /**
+     * @return array
+     */
     protected function _getOptions()
     {
         return array(
@@ -58,6 +63,9 @@ class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
         );
     }
 
+    /**
+     * @return array
+     */
     public function getCondition()
     {
         if ($this->getValue()) {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php
index 374e57d594f8ae55691cd2ed1b7a219bb5582584..0b594036c69d89c104fe0e3d564d14fa42714d82 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Country.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Country grid filter
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Country
     extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
 {
@@ -53,6 +52,9 @@ class Country
         parent::__construct($context, $resourceHelper, $data);
     }
 
+    /**
+     * @return array
+     */
     protected function _getOptions()
     {
         $options = $this->_directoriesFactory->create()->load()->toOptionArray(false);
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php
index d1bcbfc0dde2c9fa45063cb31d710e86d3cf0e5d..fe6204aae176c7e1753e80e99dab6896a8960e35 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Date grid column filter
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Date
     extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
 {
@@ -53,6 +52,9 @@ class Date
         parent::__construct($context, $resourceHelper, $data);
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         if ($head = $this->getLayout()->getBlock('head')) {
@@ -61,6 +63,9 @@ class Date
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getHtml()
     {
         $htmlId = $this->mathRandom->getUniqueHash($this->_getHtmlId());
@@ -95,6 +100,10 @@ class Date
         return $html;
     }
 
+    /**
+     * @param string|null $index
+     * @return string
+     */
     public function getEscapedValue($index=null)
     {
         $value = $this->getValue($index);
@@ -104,6 +113,10 @@ class Date
         return $value;
     }
 
+    /**
+     * @param string|null $index
+     * @return array|string|int|float|null
+     */
     public function getValue($index=null)
     {
         if ($index) {
@@ -119,6 +132,9 @@ class Date
         return $value;
     }
 
+    /**
+     * @return array|string|int|float|null
+     */
     public function getCondition()
     {
         $value = $this->getValue();
@@ -126,6 +142,10 @@ class Date
         return $value;
     }
 
+    /**
+     * @param array|string|int|float $value
+     * @return $this
+     */
     public function setValue($value)
     {
         if (isset($value['locale'])) {
@@ -160,7 +180,7 @@ class Date
      *
      * @param string $date
      * @param string $locale
-     * @return \Zend_Date
+     * @return \Zend_Date|null
      */
     protected function _convertDate($date, $locale)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php
index 3bee092ff4c6d74ce89c77b2a48211cc9ffed13c..d3066beb292fc2255991bc925640ae838ba5eaf1 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Date grid column filter
@@ -32,8 +33,6 @@
  * @author      Magento Core Team <core@magentocommerce.com>
  * @todo        date format
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Datetime
     extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Date
 {
@@ -42,6 +41,9 @@ class Datetime
      */
     const END_OF_DAY_IN_SECONDS = 86399;
 
+    /**
+     * {@inheritdoc}
+     */
     public function getValue($index = null)
     {
         if ($index) {
@@ -67,12 +69,12 @@ class Datetime
         return $value;
     }
 
-    /*
+    /**
      * Convert given date to default (UTC) timezone
      *
      * @param string $date
      * @param string $locale
-     * @return \Zend_Date
+     * @return \Zend_Date|null
      */
     protected function _convertDate($date, $locale)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php
index 85f8ee6f56e4ca01152503b8b5a31675ec000ccc..24e7149f431ca0256a2762ad7195c839d6be2948 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
+
+use Magento\Backend\Block\Widget\Grid\Column;
 
 /**
  * Grid column filter interface
@@ -31,13 +34,21 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 interface FilterInterface
 {
+    /**
+     * @return Column
+     */
     public function getColumn();
 
+    /**
+     * @param Column $column
+     * @return AbstractFilter
+     */
     public function setColumn($column);
 
+    /**
+     * @return string
+     */
     public function getHtml();
 }
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Massaction.php
index d651f5a740761b51fa61eef57bea82edb1e2be0e..f6e0f016d6a5258caea82bf2e4fabe7687859d2f 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Massaction.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Massaction.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Massaction grid column filter
@@ -31,11 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
-class Massaction
-    extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Checkbox
+class Massaction extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Checkbox
 {
+    /**
+     * {@inheritdoc}
+     */
     public function getCondition()
     {
         if ($this->getValue()) {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php
index 88aa917fce4d14d0e1e04bd48da0502819ad4e45..5eb671c93a00d707d1764c796531fbbac40b940d 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Range grid column filter
@@ -31,10 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  *
- */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
-/**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
@@ -105,7 +102,7 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
     /**
      * Retrieve display currency select
      *
-     * @return bool|mixed
+     * @return true|mixed
      */
     public function getDisplayCurrencySelect()
     {
@@ -119,7 +116,7 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
     /**
      * Retrieve currency affect
      *
-     * @return bool|mixed
+     * @return true|mixed
      */
     public function getCurrencyAffect()
     {
@@ -169,7 +166,7 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
      * Retrieve filter value
      *
      * @param null $index
-     * @return mixed|null
+     * @return array|null
      */
     public function getValue($index=null)
     {
@@ -188,7 +185,7 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
     /**
      * Retrieve filter condition
      *
-     * @return array|mixed|null
+     * @return array
      */
     public function getCondition()
     {
@@ -227,8 +224,8 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
     /**
      * Get currency rate
      *
-     * @param $fromRate
-     * @param $toRate
+     * @param string $fromRate
+     * @param string $toRate
      * @return float
      */
     protected function _getRate($fromRate, $toRate)
@@ -239,7 +236,8 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
     /**
      * Prepare currency rates
      *
-     * @param $displayCurrency
+     * @param string $displayCurrency
+     * @return void
      */
     public function prepareRates($displayCurrency)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Radio.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Radio.php
index da0c1383361cf07acc7b29ebbac27312062428cf..46bcf5285b205926a9d92a6bcaab34de9b7ad167 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Radio.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Radio.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Checkbox grid column filter
@@ -31,10 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Radio extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
 {
+    /**
+     * @return array
+     */
     protected function _getOptions()
     {
         return array(
@@ -52,7 +54,10 @@ class Radio extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
             ),
         );
     }
-    
+
+    /**
+     * {@inheritdoc}
+     */
     public function getCondition()
     {
         if ($this->getValue()) {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php
index b4ae67630c2c2ff7a5f66ccd1efed0758c49776a..178cecba13934a994a2aab064d875dc981732c44 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php
@@ -35,6 +35,9 @@ namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 class Range extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
 {
+    /**
+     * @return string
+     */
     public function getHtml()
     {
         $html = '<div class="range"><div class="range-line">'
@@ -51,6 +54,10 @@ class Range extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
         return $html;
     }
 
+    /**
+     * @param string|null $index
+     * @return mixed
+     */
     public function getValue($index=null)
     {
         if ($index) {
@@ -65,6 +72,9 @@ class Range extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFil
         return null;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getCondition()
     {
         $value = $this->getValue();
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php
index d78a3239c12af1e65a635652672312a4aa9ae64e..b03048f3ecb09bf3174f68e51fac0a3ea55c01c8 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Select grid column filter
@@ -31,10 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Select extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
 {
+    /**
+     * {@inheritdoc}
+     */
     protected function _getOptions()
     {
         $emptyOption = array('value' => null, 'label' => '');
@@ -76,6 +78,9 @@ class Select extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFi
             . $this->escapeHtml($option['label']) . '</option>';
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getHtml()
     {
         $html = '<select name="' . $this->_getHtmlName() . '" id="' . $this->_getHtmlId() . '"'
@@ -97,6 +102,9 @@ class Select extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFi
         return $html;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getCondition()
     {
         if (is_null($this->getValue())) {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/SkipList.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/SkipList.php
index 56dd4f1f0f402b2a043e576f2d95cb13f2b4cedd..0492409cd1c50cefddafdc0afe652d7651465e48 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/SkipList.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/SkipList.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Massaction grid column filter
@@ -31,11 +32,12 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class SkipList
     extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
 {
+    /**
+     * {@inheritdoc}
+     */
     public function getCondition()
     {
         return array('nin' => $this->getValue() ?: array(0));
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php
index ddc8ca2a89455c4a96de640dad749518df755121..33d609e9a0a438fd6e1a64808059418a69e62ef7 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
 
 /**
  * Text grid column filter
@@ -31,10 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Filter;
-
 class Text extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter
 {
+    /**
+     * {@inheritdoc}
+     */
     public function getHtml()
     {
         $html = '<div class="field-100"><input type="text" name="'
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php
index e6b73fcfe5a58d149697c79072b9bfc37f6a85cf..909cf45ec52c502af5ea33661f8b91cd9177cccb 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
+
+use Magento\Backend\Block\Widget\Grid\Column;
 
 /**
  * Backend grid item abstract renderer
@@ -31,23 +34,33 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 abstract class AbstractRenderer
     extends \Magento\Backend\Block\AbstractBlock
     implements \Magento\Backend\Block\Widget\Grid\Column\Renderer\RendererInterface
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth;
+
+    /**
+     * @var Column
+     */
     protected $_column;
 
+    /**
+     * @param Column $column
+     * @return $this
+     */
     public function setColumn($column)
     {
         $this->_column = $column;
         return $this;
     }
 
-    /** @return \Magento\Backend\Block\Widget\Grid\Column */
+    /**
+     * @return Column
+     */
     public function getColumn()
     {
         return $this->_column;
@@ -81,6 +94,10 @@ abstract class AbstractRenderer
         return $this->render($row);
     }
 
+    /**
+     * @param \Magento\Object $row
+     * @return mixed
+     */
     protected function _getValue(\Magento\Object $row)
     {
         if ($getter = $this->getColumn()->getGetter()) {
@@ -94,6 +111,10 @@ abstract class AbstractRenderer
         return $row->getData($this->getColumn()->getIndex());
     }
 
+    /**
+     * @param \Magento\Object $row
+     * @return string
+     */
     public function _getInputValueElement(\Magento\Object $row)
     {
         return  '<input type="text" class="input-text '
@@ -102,11 +123,18 @@ abstract class AbstractRenderer
                 . '" value="' . $this->_getInputValue($row) . '"/>';
     }
 
+    /**
+     * @param \Magento\Object $row
+     * @return mixed
+     */
     protected function _getInputValue(\Magento\Object $row)
     {
         return $this->_getValue($row);
     }
 
+    /**
+     * @return string
+     */
     public function renderHeader()
     {
         if (false !== $this->getColumn()->getSortable()) {
@@ -128,6 +156,9 @@ abstract class AbstractRenderer
         return $out;
     }
 
+    /**
+     * @return string
+     */
     public function renderProperty()
     {
         $out = '';
@@ -149,6 +180,9 @@ abstract class AbstractRenderer
         return $out;
     }
 
+    /**
+     * @return string
+     */
     public function renderCss()
     {
         return $this->getColumn()->getCssClass();
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php
index 171767d51b118b7ae04f4c282d4d12312d2941f8..018d54edde98d293e01af9c6a0e8ace1b278848c 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Grid column widget for rendering action grid cells
@@ -31,8 +32,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text
 {
     /**
@@ -91,7 +90,7 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text
     /**
      * Render single action as dropdown option html
      *
-     * @param unknown_type $action
+     * @param array $action
      * @param \Magento\Object $row
      * @return string
      */
@@ -135,10 +134,10 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text
     /**
      * Prepares action data for html render
      *
-     * @param array $action
-     * @param string $actionCaption
+     * @param array &$action
+     * @param string &$actionCaption
      * @param \Magento\Object $row
-     * @return \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
+     * @return $this
      */
     protected function _transformActionData(&$action, &$actionCaption, \Magento\Object $row)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php
index 03f935429f1170a50847f2c7ea5439bcb4de3cdd..eec0c740ed50bde6f7241a2e94f37aab016f0466 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Grid checkbox column renderer
@@ -31,12 +32,17 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Checkbox
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 55;
+
+    /**
+     * @var array
+     */
     protected $_values;
 
     /**
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php
index d27929d23a4736d1fe474264b4fdf961fed230b8..9c4e6ac51e40cd888fe6300bcf40d3671b77bdfb 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Backend grid item renderer currency
@@ -31,16 +32,18 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Currency
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 100;
 
     /**
      * Currency objects cache
+     *
+     * @var \Magento\Object[]
      */
     protected static $_currencies = array();
 
@@ -111,7 +114,7 @@ class Currency
     /**
      * Returns currency code, false on error
      *
-     * @param $row
+     * @param \Magento\Object $row
      * @return string
      */
     protected function _getCurrencyCode($row)
@@ -129,7 +132,7 @@ class Currency
     /**
      * Get rate for current row, 1 by default
      *
-     * @param $row
+     * @param \Magento\Object $row
      * @return float|int
      */
     protected function _getRate($row)
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php
index da479a88c674719e1045d413852fcd68bb35fa55..6ede1067d60c2af3fb603bbbb77349118516cfd3 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php
@@ -23,18 +23,23 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Backend grid item renderer date
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Date
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 160;
+
     /**
      * Date format string
+     *
+     * @var string
      */
     protected static $_format = null;
 
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php
index 5fc88ae600be28b55846f0bb12405dc058ac4f1b..65d3dc021bdccaa02d3a747a897e0098b2b51c98 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php
@@ -34,13 +34,15 @@ class Datetime
 {
     /**
      * Date format string
+     *
+     * @var string
      */
     protected static $_format = null;
 
     /**
      * Retrieve datetime format
      *
-     * @return unknown
+     * @return string|null
      */
     protected function _getFormat()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php
index 8860723a92ea22bb9cbbccfe09d4d72488178487..f9e55d95eb67d78075e7c072c3b91463955fc7c6 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php
@@ -36,6 +36,9 @@ namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 class Input
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var array
+     */
     protected $_values;
 
     /**
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php
index 2cf554333ef454616fca1923c2aa93c199aee358..dd1642d2af45bd1dcce5d277e8f99bde3b865d8d 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Grid widget column renderer massaction
@@ -32,11 +32,12 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Massaction
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkbox
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 20;
 
     /**
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php
index 55a4c538f77b17a8bfbc8cba5097cd7cf0082f53..99d589d6bfdf5fb5f1a62b0ad6f3caa53c35429c 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Backend grid item renderer number
@@ -31,11 +32,12 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Number
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 100;
 
     /**
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php
index bdfb756576e6dcccb0fef8f7cf842a8875235669..f5da304218e77f421ecbb3e55efd8dd1655d7b53 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php
@@ -23,18 +23,23 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Backend grid item renderer currency
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Price
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 100;
+
     /**
      * Currency objects cache
+     *
+     * @var \Magento\Object[]
      */
     protected static $_currencies = array();
 
@@ -65,7 +70,7 @@ class Price
      * Returns currency code for the row, false on error
      *
      * @param \Magento\Object $row
-     * @return string|bool
+     * @return string|false
      */
     protected function _getCurrencyCode($row)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php
index 6b0a7f2fbe8c8937a958e52c9c37dff9314bb3b4..dbccb56cd02215f4bf24e6e9a6cfe882e8a10f9c 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Grid radiogroup column renderer
@@ -31,12 +32,17 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Radio
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var int
+     */
     protected $_defaultWidth = 55;
+
+    /**
+     * @var array
+     */
     protected $_values;
 
     /**
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php
index a5e703eda57109b01ee56493c525137079fd65da..66b647a13a6f75f0d3d2d0fd7d204215ead8cbef 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
+
+use Magento\Backend\Block\Widget\Grid\Column;
 
 /**
  * Backend grid item renderer interface
@@ -31,17 +34,14 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 interface RendererInterface
 {
     /**
      * Set column for renderer
      *
-     * @abstract
-     * @param $column
+     * @param Column $column
      * @return void
+     * @abstract
      */
     public function setColumn($column);
 
@@ -57,6 +57,7 @@ interface RendererInterface
      * Renders grid column
      *
      * @param \Magento\Object $row
+     * @return string
      */
     public function render(\Magento\Object $row);
 }
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php
index 49e2baab2136b7049596a14a1be23d26f36a6873..c969f0014c4e3daec94e9587ff8a7824759209fd 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php
@@ -23,17 +23,22 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
 
 /**
  * Store grid column filter
  */
-namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
-
 class Store
     extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @var bool
+     */
     protected $_skipAllStoresLabel = false;
+
+    /**
+     * @var bool
+     */
     protected $_skipEmptyStoresLabel = false;
 
     /**
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php b/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php
index e394b49d0a5f89029841e1c8917561b5e9487eb9..b682d5a797e166ddf9497e727406cafcb1cdf5d1 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php
@@ -23,15 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid;
 
 /**
  *
  * @category    Magento
  * @package     Magento_Core
- */
-namespace Magento\Backend\Block\Widget\Grid;
-
-/**
+ *
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class ColumnSet extends \Magento\View\Element\Template
@@ -62,10 +60,10 @@ class ColumnSet extends \Magento\View\Element\Template
      */
     protected $_emptyText;
 
-    /****
+    /**
      * Empty grid text CSS class
      *
-     * @var string|null
+     * @var string
      */
     protected $_emptyTextCss    = 'a-center';
 
@@ -93,11 +91,11 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Columns to group by
      *
-     * @var array
+     * @var string[]
      */
     protected $_groupedColumn = array();
 
-    /*
+    /**
      * @var boolean
      */
     protected $_isCollapsed;
@@ -195,7 +193,7 @@ class ColumnSet extends \Magento\View\Element\Template
      * Set sortability flag for columns
      *
      * @param bool $value
-     * @return \Magento\Backend\Block\Widget\Grid\ColumnSet
+     * @return $this
      */
     public function setSortable($value)
     {
@@ -212,7 +210,7 @@ class ColumnSet extends \Magento\View\Element\Template
      *
      * @param string $type
      * @param string $className
-     * @return \Magento\Backend\Block\Widget\Grid\ColumnSet
+     * @return $this
      */
     public function setRendererType($type, $className)
     {
@@ -227,7 +225,7 @@ class ColumnSet extends \Magento\View\Element\Template
      *
      * @param string $type
      * @param string $className
-     * @return \Magento\Backend\Block\Widget\Grid\ColumnSet
+     * @return $this
      */
     public function setFilterType($type, $className)
     {
@@ -240,7 +238,7 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Prepare block for rendering
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return void
      */
     protected function _beforeToHtml()
     {
@@ -338,7 +336,7 @@ class ColumnSet extends \Magento\View\Element\Template
      *
      * @param \Magento\Object $item
      * @param \Magento\Backend\Block\Widget\Grid\Column $column
-     * @return integer|boolean
+     * @return int|false
      */
     public function getRowspan($item, $column)
     {
@@ -354,7 +352,7 @@ class ColumnSet extends \Magento\View\Element\Template
      *
      * @param string|object $column
      * @param string $value
-     * @return boolean|\Magento\Backend\Block\Widget\Grid
+     * @return bool|$this
      */
     public function isColumnGrouped($column, $value = null)
     {
@@ -412,6 +410,7 @@ class ColumnSet extends \Magento\View\Element\Template
      * Set visibility of column headers
      *
      * @param boolean $visible
+     * @return void
      */
     public function setHeadersVisibility($visible = true)
     {
@@ -431,7 +430,8 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Set visibility of filter
      *
-     * @param boolean $visible
+     * @param bool $visible
+     * @return void
      */
     public function setFilterVisibility($visible = true)
     {
@@ -452,7 +452,7 @@ class ColumnSet extends \Magento\View\Element\Template
      * Set empty text CSS class
      *
      * @param string $cssClass
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setEmptyTextClass($cssClass)
     {
@@ -484,7 +484,7 @@ class ColumnSet extends \Magento\View\Element\Template
      * Set label for empty cell
      *
      * @param string $label
-     * @return \Magento\Backend\Block\Widget\Grid\ColumnSet
+     * @return $this
      */
     public function setEmptyCellLabel($label)
     {
@@ -494,8 +494,9 @@ class ColumnSet extends \Magento\View\Element\Template
 
     /**
      * Set flag whether is collapsed
-     * @param $isCollapsed
-     * @return \Magento\Backend\Block\Widget\Grid\ColumnSet
+     *
+     * @param bool $isCollapsed
+     * @return $this
      */
     public function setIsCollapsed($isCollapsed)
     {
@@ -505,7 +506,8 @@ class ColumnSet extends \Magento\View\Element\Template
 
     /**
      * Retrieve flag is collapsed
-     * @return mixed
+     *
+     * @return bool
      */
     public function getIsCollapsed()
     {
@@ -514,6 +516,7 @@ class ColumnSet extends \Magento\View\Element\Template
 
     /**
      * Return grid of current column set
+     *
      * @return \Magento\Backend\Block\Widget\Grid
      */
     public function getGrid()
@@ -523,6 +526,7 @@ class ColumnSet extends \Magento\View\Element\Template
 
     /**
      * Return collection of current grid
+     *
      * @return \Magento\Data\Collection
      */
     public function getCollection()
@@ -533,8 +537,8 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Set subtotals
      *
-     * @param boolean $flag
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @param bool $flag
+     * @return $this
      */
     public function setCountSubTotals($flag = true)
     {
@@ -545,7 +549,7 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Return count subtotals
      *
-     * @return mixed
+     * @return bool
      */
     public function getCountSubTotals()
     {
@@ -555,8 +559,8 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Set totals
      *
-     * @param boolean $flag
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @param bool $flag
+     * @return $this
      */
     public function setCountTotals($flag = true)
     {
@@ -567,7 +571,7 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Return count totals
      *
-     * @return mixed
+     * @return bool
      */
     public function getCountTotals()
     {
@@ -577,7 +581,7 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Retrieve subtotal for item
      *
-     * @param $item \Magento\Object
+     * @param \Magento\Object $item
      * @return \Magento\Object
      */
     public function getSubTotals($item)
@@ -602,7 +606,8 @@ class ColumnSet extends \Magento\View\Element\Template
     /**
      * Update item with first sub-item data
      *
-     * @param $item \Magento\Object
+     * @param \Magento\Object $item
+     * @return void
      */
     public function updateItemByFirstMultiRow(\Magento\Object $item)
     {
@@ -618,6 +623,8 @@ class ColumnSet extends \Magento\View\Element\Template
 
     /**
      * Prepare sub-total object for counting sub-totals
+     *
+     * @return void
      */
     public function _prepareSubTotals()
     {
@@ -633,6 +640,8 @@ class ColumnSet extends \Magento\View\Element\Template
 
     /**
      * Prepare total object for counting totals
+     *
+     * @return void
      */
     public function _prepareTotals()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Container.php b/app/code/Magento/Backend/Block/Widget/Grid/Container.php
index 6ecab84341da9d18597c0690a10b4a6ec8dc1912..9bbc5275dd576c95fcfa05d678ea1ea0956a0ce3 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Container.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Container.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid;
 
 /**
  * Backend grid container block
@@ -31,9 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Block\Widget\Grid;
-
 class Container extends \Magento\Backend\Block\Widget\Container
 {
     /**#@+
@@ -44,14 +42,30 @@ class Container extends \Magento\Backend\Block\Widget\Container
     const PARAM_BUTTON_BACK = 'button_back';
     /**#@-*/
 
+    /**
+     * @var string
+     */
     protected $_addButtonLabel;
+
+    /**
+     * @var string
+     */
     protected $_backButtonLabel;
+
+    /**
+     * @var string
+     */
     protected $_blockGroup = 'Magento_Backend';
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/grid/container.phtml';
 
     /**
      * Initialize object state with incoming parameters
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -78,6 +92,9 @@ class Container extends \Magento\Backend\Block\Widget\Container
         }
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         // check if grid was created through the layout
@@ -96,21 +113,33 @@ class Container extends \Magento\Backend\Block\Widget\Container
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getCreateUrl()
     {
         return $this->getUrl('*/*/new');
     }
 
+    /**
+     * @return string
+     */
     public function getGridHtml()
     {
         return $this->getChildHtml('grid');
     }
 
+    /**
+     * @return string
+     */
     public function getAddButtonLabel()
     {
         return $this->_addButtonLabel;
     }
 
+    /**
+     * @return string
+     */
     public function getBackButtonLabel()
     {
         return $this->_backButtonLabel;
@@ -118,6 +147,8 @@ class Container extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Create "New" button
+     *
+     * @return void
      */
     protected function _addNewButton()
     {
@@ -128,6 +159,9 @@ class Container extends \Magento\Backend\Block\Widget\Container
         ));
     }
 
+    /**
+     * @return void
+     */
     protected function _addBackButton()
     {
         $this->_addButton('back', array(
@@ -137,11 +171,17 @@ class Container extends \Magento\Backend\Block\Widget\Container
         ));
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getHeaderCssClass()
     {
         return 'icon-head ' . parent::getHeaderCssClass();
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderWidth()
     {
         return 'width:50%;';
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Export.php b/app/code/Magento/Backend/Block/Widget/Grid/Export.php
index d597dc13a9bd917a6a488998bcb1182ce2453672..e172643650c701da383eb499b8e06f004b59b0a7 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Export.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Export.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\Widget\Grid;
 
 /**
@@ -36,7 +35,7 @@ class Export
     /**
      * Grid export types
      *
-     * @var array
+     * @var  \Magento\Object[]
      */
     protected $_exportTypes = array();
 
@@ -85,6 +84,10 @@ class Export
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     * @throws \Magento\Core\Exception
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -122,7 +125,7 @@ class Export
     /**
      * Return count totals
      *
-     * @return mixed
+     * @return bool
      */
     public function getCountTotals()
     {
@@ -142,7 +145,7 @@ class Export
     /**
      * Retrieve grid export types
      *
-     * @return array|bool
+     * @return  \Magento\Object[]|false
      */
     public function getExportTypes()
     {
@@ -162,7 +165,7 @@ class Export
     /**
      * Prepare export button
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -192,7 +195,7 @@ class Export
      *
      * @param   string $url
      * @param   string $label
-     * @return  \Magento\Backend\Block\Widget\Grid
+     * @return  $this
      */
     public function addExportType($url, $label)
     {
@@ -219,7 +222,7 @@ class Export
     /**
      * Retrieve Headers row array for Export
      *
-     * @return array
+     * @return string[]
      */
     protected function _getExportHeaders()
     {
@@ -235,7 +238,7 @@ class Export
     /**
      * Retrieve Totals row array for Export
      *
-     * @return array
+     * @return string[]
      */
     protected function _getExportTotals()
     {
@@ -255,7 +258,7 @@ class Export
      *
      * @param string $callback
      * @param array $args additional arguments for callback method
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return void
      */
     public function _exportIterateCollection($callback, array $args)
     {
@@ -291,6 +294,7 @@ class Export
      *
      * @param \Magento\Object $item
      * @param \Magento\Filesystem\File\WriteInterface $stream
+     * @return void
      */
     protected function _exportCsvItem(\Magento\Object $item, \Magento\Filesystem\File\WriteInterface $stream)
     {
@@ -408,7 +412,7 @@ class Export
      *  Get a row data of the particular columns
      *
      * @param \Magento\Object $data
-     * @return array
+     * @return string[]
      */
     public function getRowRecord(\Magento\Object $data)
     {
@@ -549,6 +553,9 @@ class Export
         return $this->_getRowCollection($collection);
     }
 
+    /**
+     * @return int
+     */
     public function getExportPageSize()
     {
         return $this->_exportPageSize;
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Extended.php
index 504e0c61b780a1120d7fb619c8d05cdec016e719..cc1557389badfe71bcba515fe1861ab844b07564 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Extended.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Extended.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Block\Widget\Grid;
 
 class Extended
@@ -63,7 +62,7 @@ class Extended
     /**
      * Grid export types
      *
-     * @var array
+     * @var \Magento\Object[]
      */
     protected $_exportTypes = array();
 
@@ -119,7 +118,7 @@ class Extended
     /**
      * Columns to group by
      *
-     * @var array
+     * @var string[]
      */
     protected $_groupedColumn = array();
 
@@ -151,9 +150,9 @@ class Extended
      */
     protected $_emptyTextCss    = 'a-center';
 
-    /*
-    * @var boolean
-    */
+    /**
+     * @var bool
+     */
     protected $_isCollapsed;
 
     /**
@@ -166,7 +165,7 @@ class Extended
     /**
      * SubTotals
      *
-     * @var array
+     * @var \Magento\Object[]
      */
     protected $_subtotals = array();
 
@@ -187,6 +186,9 @@ class Extended
      */
     protected $_path = 'export';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -198,7 +200,7 @@ class Extended
     /**
      * Initialize child blocks
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -258,7 +260,7 @@ class Extended
      *
      * @param   string $url
      * @param   string $label
-     * @return  \Magento\Backend\Block\Widget\Grid
+     * @return  $this
      */
     public function addExportType($url, $label)
     {
@@ -275,8 +277,9 @@ class Extended
      * Add column to grid
      *
      * @param   string $columnId
-     * @param   array || \Magento\Object $column
-     * @return  \Magento\Backend\Block\Widget\Grid
+     * @param   array|\Magento\Object $column
+     * @return  $this
+     * @throws  \Exception
      */
     public function addColumn($columnId, $column)
     {
@@ -301,7 +304,7 @@ class Extended
      * Remove existing column
      *
      * @param string $columnId
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function removeColumn($columnId)
     {
@@ -320,7 +323,7 @@ class Extended
      * @param   string $columnId
      * @param   array|\Magento\Object $column
      * @param   string $after
-     * @return  \Magento\Backend\Block\Widget\Grid
+     * @return  $this
      */
     public function addColumnAfter($columnId, $column, $after)
     {
@@ -334,7 +337,7 @@ class Extended
      *
      * @param string $columnId
      * @param string $after
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function addColumnsOrder($columnId, $after)
     {
@@ -355,7 +358,7 @@ class Extended
     /**
      * Sort columns by predefined order
      *
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function sortColumnsByOrder()
     {
@@ -385,7 +388,7 @@ class Extended
     /**
      * Initialize grid columns
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return $this
      */
     protected function _prepareColumns()
     {
@@ -396,7 +399,7 @@ class Extended
     /**
      * Prepare grid massaction block
      *
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _prepareMassactionBlock()
     {
@@ -411,7 +414,7 @@ class Extended
     /**
      * Prepare grid massaction actions
      *
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _prepareMassaction()
     {
@@ -421,7 +424,7 @@ class Extended
     /**
      * Prepare grid massaction column
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return $this
      */
     protected function _prepareMassactionColumn()
     {
@@ -454,7 +457,7 @@ class Extended
     /**
      * Apply sorting and filtering to collection
      *
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
@@ -473,7 +476,7 @@ class Extended
     /**
      * Process collection after loading
      *
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _afterLoadCollection()
     {
@@ -483,7 +486,7 @@ class Extended
     /**
      * Initialize grid before rendering
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended|void
+     * @return $this
      */
     protected function _prepareGrid()
     {
@@ -517,7 +520,7 @@ class Extended
      * Set massaction row identifier field
      *
      * @param  string    $idField
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setMassactionIdField($idField)
     {
@@ -539,7 +542,7 @@ class Extended
      * Set massaction row identifier filter
      *
      * @param string $idFilter
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setMassactionIdFilter($idFilter)
     {
@@ -561,7 +564,7 @@ class Extended
      * Set massaction block name
      *
      * @param  string    $blockName
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setMassactionBlockName($blockName)
     {
@@ -572,7 +575,7 @@ class Extended
     /**
      * Retrieve massaction block
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Extended
+     * @return $this
      */
     public function getMassactionBlock()
     {
@@ -631,7 +634,7 @@ class Extended
      * Set label for empty cell
      *
      * @param string $label
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setEmptyCellLabel($label)
     {
@@ -642,7 +645,7 @@ class Extended
     /**
      * Return row url for js event handlers
      *
-     * @param \Magento\Catalog\Model\Product|\Magento\Object
+     * @param \Magento\Catalog\Model\Product|\Magento\Object $item
      * @return string
      */
     public function getRowUrl($item)
@@ -691,7 +694,7 @@ class Extended
      *
      * @param \Magento\Object $item
      * @param \Magento\Backend\Block\Widget\Grid\Column $column
-     * @return integer|boolean
+     * @return int|false
      */
     public function getRowspan($item, $column)
     {
@@ -706,7 +709,7 @@ class Extended
      *
      * @param string|object $column
      * @param string $value
-     * @return boolean|\Magento\Backend\Block\Widget\Grid
+     * @return boolean|$this
      */
     public function isColumnGrouped($column, $value = null)
     {
@@ -746,7 +749,7 @@ class Extended
      * Retrieve subtotal item
      *
      * @param \Magento\Object $item
-     * @return \Magento\Object
+     * @return \Magento\Object|string
      */
     public function getSubTotalItem($item)
     {
@@ -773,7 +776,8 @@ class Extended
     /**
      * Set visibility of column headers
      *
-     * @param boolean $visible
+     * @param bool $visible
+     * @return void
      */
     public function setHeadersVisibility($visible=true)
     {
@@ -793,7 +797,8 @@ class Extended
     /**
      * Set visibility of filter
      *
-     * @param boolean $visible
+     * @param bool $visible
+     * @return void
      */
     public function setFilterVisibility($visible=true)
     {
@@ -814,7 +819,7 @@ class Extended
      * Set empty text for grid
      *
      * @param string $text
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setEmptyText($text)
     {
@@ -836,7 +841,7 @@ class Extended
      * Set empty text CSS class
      *
      * @param string $cssClass
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setEmptyTextClass($cssClass)
     {
@@ -856,8 +861,9 @@ class Extended
 
     /**
      * Set flag whether is collapsed
-     * @param $isCollapsed
-     * @return \Magento\Backend\Block\Widget\Grid\ColumnSet
+     *
+     * @param bool $isCollapsed
+     * @return $this
      */
     public function setIsCollapsed($isCollapsed)
     {
@@ -867,7 +873,8 @@ class Extended
 
     /**
      * Retrieve flag is collapsed
-     * @return mixed
+     *
+     * @return bool
      */
     public function getIsCollapsed()
     {
@@ -888,7 +895,7 @@ class Extended
     /**
      * Retrieve Headers row array for Export
      *
-     * @return array
+     * @return string[]
      */
     protected function _getExportHeaders()
     {
@@ -904,7 +911,7 @@ class Extended
     /**
      * Retrieve Totals row array for Export
      *
-     * @return array
+     * @return string[]
      */
     protected function _getExportTotals()
     {
@@ -924,7 +931,7 @@ class Extended
      *
      * @param string $callback
      * @param array $args additional arguments for callback method
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return void
      */
     public function _exportIterateCollection($callback, array $args)
     {
@@ -959,6 +966,7 @@ class Extended
      *
      * @param \Magento\Object $item
      * @param \Magento\Filesystem\File\WriteInterface $stream
+     * @return void
      */
     protected function _exportCsvItem(\Magento\Object $item, \Magento\Filesystem\File\WriteInterface $stream)
     {
@@ -1090,7 +1098,7 @@ class Extended
      *  Get a row data of the particular columns
      *
      * @param \Magento\Object $data
-     * @return array
+     * @return string[]
      */
     public function getRowRecord(\Magento\Object $data)
     {
@@ -1190,7 +1198,7 @@ class Extended
     /**
      * Retrieve grid export types
      *
-     * @return array|bool
+     * @return \Magento\Object[]|false
      */
     public function getExportTypes()
     {
@@ -1200,6 +1208,7 @@ class Extended
      * Set collection object
      *
      * @param \Magento\Data\Collection $collection
+     * @return void
      */
     public function setCollection($collection)
     {
@@ -1220,7 +1229,7 @@ class Extended
      * Set subtotals
      *
      * @param boolean $flag
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     public function setCountSubTotals($flag = true)
     {
@@ -1241,8 +1250,8 @@ class Extended
     /**
      * Set subtotal items
      *
-     * @param array $items
-     * @return \Magento\Backend\Block\Widget\Grid
+     * @param \Magento\Object[] $items
+     * @return $this
      */
     public function setSubTotals(array $items)
     {
@@ -1253,7 +1262,7 @@ class Extended
     /**
      * Retrieve subtotal items
      *
-     * @return array
+     * @return \Magento\Object[]
      */
     public function getSubTotals()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php
index b1ae15c3b8055da4675a9aaa09cc4abad3a6ddff..49b0ed1e7ce0e2389faa4b486f7ad8921be2792f 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Massaction;
+
+use Magento\View\Element\Template;
 
 /**
  * Grid widget massaction block
@@ -33,10 +36,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Massaction;
-
-use Magento\View\Element\Template;
-
 abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
 {
     /**
@@ -51,6 +50,9 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
      */
     protected $_items = array();
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/grid/massaction.phtml';
 
     /**
@@ -67,11 +69,14 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
 
-        $this->escapeJsQuote(__('Please select items.'));
+        $this->setErrorText($this->escapeJsQuote(__('Please select items.')));
 
         if (null !== $this->getOptions()) {
             foreach ($this->getOptions() as $optionId => $option) {
@@ -84,6 +89,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
     /**
      * Add new massaction item
      *
+     * Item array to be passed in looks like:
      * $item = array(
      *      'label'    => string,
      *      'complete' => string, // Only for ajax enabled grid (optional)
@@ -94,7 +100,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
      *
      * @param string $itemId
      * @param array|\Magento\Object $item
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction
+     * @return $this
      */
     public function addItem($itemId, $item)
     {
@@ -115,7 +121,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
      * Retrieve massaction item with id $itemId
      *
      * @param string $itemId
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item
+     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item|null
      */
     public function getItem($itemId)
     {
@@ -229,7 +235,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
     /**
      * Retrieve array of selected checkboxes
      *
-     * @return array
+     * @return string[]
      */
     public function getSelected()
     {
@@ -251,6 +257,9 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
         return $this->getButtonHtml(__('Submit'), $this->getJsObjectName() . ".apply()");
     }
 
+    /**
+     * @return string
+     */
     public function getJavaScript()
     {
         return " var {$this->getJsObjectName()} = new varienGridMassaction('{$this->getHtmlId()}', "
@@ -263,6 +272,9 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
             . "{$this->getJsObjectName()}.errorText = '{$this->getErrorText()}';";
     }
 
+    /**
+     * @return string
+     */
     public function getGridIdsJson()
     {
         if (!$this->getUseSelectAll()) {
@@ -277,6 +289,9 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
         return '';
     }
 
+    /**
+     * @return string
+     */
     public function getHtmlId()
     {
         return $this->getParentBlock()->getHtmlId() . '_massaction';
@@ -286,7 +301,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
      * Remove existing massaction item by its id
      *
      * @param string $itemId
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction
+     * @return $this
      */
     public function removeItem($itemId)
     {
@@ -311,7 +326,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
      * Retrieve select all functionality flag check
      *
      * @param boolean $flag
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction
+     * @return $this
      */
     public function setUseSelectAll($flag)
     {
@@ -322,7 +337,7 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
     /**
      * Prepare grid massaction column
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return $this
      */
     public function prepareMassactionColumn()
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php
index 517926f35b70b1767bacd1095e958729d785d6ba..a26723d96d053074bc831bc8d129787544451317 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Massaction;
 
 /**
  * Backend widget grid massaction additional action
@@ -31,10 +32,6 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  *
- */
-namespace Magento\Backend\Block\Widget\Grid\Massaction;
-
-/**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class Additional extends \Magento\Backend\Block\Widget\Form\Generic
@@ -66,7 +63,7 @@ class Additional extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form before rendering HTML
      *
-     * @return \Magento\Backend\Block\Widget\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -83,7 +80,8 @@ class Additional extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form item
      *
-     * @param array $item
+     * @param array &$item
+     * @return void
      */
     protected function _prepareFormItem(array &$item)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php
index e08efc02e61ccae6c30ddadd09312b8069d3589a..a16b637f150ae5e82102c32ec5aa208c65afa98b 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid\Massaction;
 
 /**
  * Grid widget massaction block
@@ -34,8 +35,6 @@
  * @author      Magento Core Team <core@magentocommerce.com>
  * @deprecated support Magento 1.x grid massaction implementation
  */
-namespace Magento\Backend\Block\Widget\Grid\Massaction;
-
 class Extended extends \Magento\Backend\Block\Widget
 {
     /**
@@ -83,6 +82,8 @@ class Extended extends \Magento\Backend\Block\Widget
 
     /**
      * Sets Massaction template
+     *
+     * @return void
      */
     public function _construct()
     {
@@ -93,6 +94,7 @@ class Extended extends \Magento\Backend\Block\Widget
     /**
      * Add new massaction item
      *
+     * The item array should look like:
      * $item = array(
      *      'label'    => string,
      *      'complete' => string, // Only for ajax enabled grid (optional)
@@ -103,7 +105,7 @@ class Extended extends \Magento\Backend\Block\Widget
      *
      * @param string $itemId
      * @param array $item
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Extended
+     * @return $this
      */
     public function addItem($itemId, array $item)
     {
@@ -124,7 +126,7 @@ class Extended extends \Magento\Backend\Block\Widget
      * Retrieve massaction item with id $itemId
      *
      * @param string $itemId
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item
+     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item|null
      */
     public function getItem($itemId)
     {
@@ -238,7 +240,7 @@ class Extended extends \Magento\Backend\Block\Widget
     /**
      * Retrieve array of selected checkboxes
      *
-     * @return array
+     * @return string[]
      */
     public function getSelected()
     {
@@ -260,6 +262,9 @@ class Extended extends \Magento\Backend\Block\Widget
         return $this->getButtonHtml(__('Submit'), $this->getJsObjectName() . ".apply()");
     }
 
+    /**
+     * @return string
+     */
     public function getJavaScript()
     {
         return " var {$this->getJsObjectName()} = new varienGridMassaction('{$this->getHtmlId()}', "
@@ -272,6 +277,9 @@ class Extended extends \Magento\Backend\Block\Widget
             . "{$this->getJsObjectName()}.errorText = '{$this->getErrorText()}';";
     }
 
+    /**
+     * @return string
+     */
     public function getGridIdsJson()
     {
         if (!$this->getUseSelectAll()) {
@@ -286,6 +294,9 @@ class Extended extends \Magento\Backend\Block\Widget
         return '';
     }
 
+    /**
+     * @return string
+     */
     public function getHtmlId()
     {
         return $this->getParentBlock()->getHtmlId() . '_massaction';
@@ -295,7 +306,7 @@ class Extended extends \Magento\Backend\Block\Widget
      * Remove existing massaction item by its id
      *
      * @param string $itemId
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Extended
+     * @return $this
      */
     public function removeItem($itemId)
     {
@@ -320,7 +331,7 @@ class Extended extends \Magento\Backend\Block\Widget
      * Retrieve select all functionality flag check
      *
      * @param boolean $flag
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Extended
+     * @return $this
      */
     public function setUseSelectAll($flag)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php
index 7d3926cf86be74fe3d8cc9b462945bf985c53615..222a4bfefc7f040231a9b0ea91113c982984ab38 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\Widget\Grid\Massaction;
 
 /**
  * Grid widget massaction single action item
@@ -32,18 +32,18 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Massaction;
-
 class Item extends \Magento\Backend\Block\Widget
 {
-
+    /**
+     * @var Extended
+     */
     protected $_massaction = null;
 
     /**
      * Set parent massaction block
      *
-     * @param  \Magento\Backend\Block\Widget\Grid\Massaction\Extended $massaction
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item
+     * @param  Extended $massaction
+     * @return $this
      */
     public function setMassaction($massaction)
     {
@@ -54,7 +54,7 @@ class Item extends \Magento\Backend\Block\Widget
     /**
      * Retrieve parent massaction block
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Extended
+     * @return Extended
      */
     public function getMassaction()
     {
@@ -65,7 +65,7 @@ class Item extends \Magento\Backend\Block\Widget
      * Set additional action block for this item
      *
      * @param string|\Magento\View\Element\AbstractBlock $block
-     * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function setAdditionalActionBlock($block)
@@ -82,6 +82,10 @@ class Item extends \Magento\Backend\Block\Widget
         return $this;
     }
 
+    /**
+     * @param array $config
+     * @return \Magento\View\Element\BlockInterface
+     */
     protected function _createFromConfig(array $config)
     {
         $type = isset($config['type']) ? $config['type'] : 'default';
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/AdditionalInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/AdditionalInterface.php
index 4c0b028d3c90c5d0fbb04b6b2d207c5d09d6ec81..ae50c98d3b395f5e3ccab850d6730734e3c6d5b1 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/AdditionalInterface.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/AdditionalInterface.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\Widget\Grid\Massaction\Item\Additional;
 
 /**
  * Backend grid widget massaction item additional action interface
@@ -32,9 +32,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Massaction\Item\Additional;
-
 interface AdditionalInterface
 {
+    /**
+     * @param array $configuration
+     * @return $this
+     */
     public function createFromConfiguration(array $configuration);
 }
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/DefaultAdditional.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/DefaultAdditional.php
index 141814415411495ae64385960023782521a40fa2..71f191109de9aaad176f99e9d0afed413c3d5862 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/DefaultAdditional.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item/Additional/DefaultAdditional.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Block\Widget\Grid\Massaction\Item\Additional;
 
 /**
  * Backend grid widget massaction item additional action default
@@ -32,13 +32,13 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid\Massaction\Item\Additional;
-
 class DefaultAdditional
     extends \Magento\Backend\Block\Widget\Form\Generic
     implements \Magento\Backend\Block\Widget\Grid\Massaction\Item\Additional\AdditionalInterface
 {
-
+    /**
+     * {@inheritdoc}
+     */
     public function createFromConfiguration(array $configuration)
     {
         /** @var \Magento\Data\Form $form */
diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php b/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php
index 42b18c7c4541295ea9e6ffefcb430ee682c1b9b4..2395af1b0bbb22d76c8c87abb47705885309bfa1 100644
--- a/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php
+++ b/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\Grid;
 
 /**
  * @method string|array getInputNames()
@@ -31,8 +32,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Block\Widget\Grid;
-
 class Serializer extends \Magento\View\Element\Template
 {
     /**
@@ -74,6 +73,8 @@ class Serializer extends \Magento\View\Element\Template
 
     /**
      * Set serializer template
+     *
+     * @return void
      */
     public function _construct()
     {
@@ -85,7 +86,6 @@ class Serializer extends \Magento\View\Element\Template
      * Get grid column input names to serialize
      *
      * @param bool $asJSON
-     *
      * @return string|array
      */
     public function getColumnInputNames($asJSON = false)
diff --git a/app/code/Magento/Backend/Block/Widget/Tabs.php b/app/code/Magento/Backend/Block/Widget/Tabs.php
index 057741cfad5d68aa1be85eadd265e0b16a3028d5..ff5df4b429a57d102fd059e8c2f104bbb816b39a 100644
--- a/app/code/Magento/Backend/Block/Widget/Tabs.php
+++ b/app/code/Magento/Backend/Block/Widget/Tabs.php
@@ -23,12 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget;
+
+use Magento\Backend\Block\Widget\Tab\TabInterface;
 
 /**
  * Tabs block
  */
-namespace Magento\Backend\Block\Widget;
-
 class Tabs extends \Magento\Backend\Block\Widget
 {
     /**
@@ -82,7 +83,7 @@ class Tabs extends \Magento\Backend\Block\Widget
     }
 
     /**
-     * retrieve destination html element id
+     * Retrieve destination html element id
      *
      * @return string
      */
@@ -95,7 +96,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      * Set destination element id
      *
      * @param string $elementId
-     * @return \Magento\Backend\Block\Widget\Tabs
+     * @return $this
      */
     public function setDestElementId($elementId)
     {
@@ -109,7 +110,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      * @param   string $tabId new tab Id
      * @param   array|\Magento\Object $tab
      * @param   string $afterTabId
-     * @return  \Magento\Backend\Block\Widget\Tabs
+     * @return  void
      */
     public function addTabAfter($tabId, $tab, $afterTabId)
     {
@@ -122,7 +123,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      *
      * @param   string $tabId
      * @param   array|\Magento\Object|string $tab
-     * @return  \Magento\Backend\Block\Widget\Tabs
+     * @return  $this
      * @throws  \Exception
      */
     public function addTab($tabId, $tab)
@@ -168,6 +169,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      *
      * @param string $tab
      * @param string $tabId
+     * @return void
      * @throws \Exception
      */
     protected function _addTabByName($tab, $tabId)
@@ -183,13 +185,16 @@ class Tabs extends \Magento\Backend\Block\Widget
             $this->_tabs[$tabId] = null;
         }
 
-        if (!($this->_tabs[$tabId] instanceof \Magento\Backend\Block\Widget\Tab\TabInterface)) {
+        if (!($this->_tabs[$tabId] instanceof TabInterface)) {
             throw new \Exception(
                 __('Please correct the tab configuration and try again.')
             );
         }
     }
 
+    /**
+     * @return string
+     */
     public function getActiveTabId()
     {
         return $this->getTabId($this->_tabs[$this->_activeTab]);
@@ -200,7 +205,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      * Tab has to be not hidden and can show
      *
      * @param string $tabId
-     * @return \Magento\Backend\Block\Widget\Tabs
+     * @return $this
      */
     public function setActiveTab($tabId)
     {
@@ -220,7 +225,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      * Set Active Tab
      *
      * @param string $tabId
-     * @return \Magento\Backend\Block\Widget\Tabs
+     * @return $this
      */
     protected function _setActiveTab($tabId)
     {
@@ -234,6 +239,9 @@ class Tabs extends \Magento\Backend\Block\Widget
         return $this;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _beforeToHtml()
     {
         if ($activeTab = $this->getRequest()->getParam('active_tab')) {
@@ -263,11 +271,17 @@ class Tabs extends \Magento\Backend\Block\Widget
         return parent::_beforeToHtml();
     }
 
+    /**
+     * @return string
+     */
     public function getJsObjectName()
     {
         return $this->getId() . 'JsTabs';
     }
 
+    /**
+     * @return string[]
+     */
     public function getTabsIds()
     {
         if (empty($this->_tabs)) {
@@ -277,33 +291,50 @@ class Tabs extends \Magento\Backend\Block\Widget
         return array_keys($this->_tabs);
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @param bool $withPrefix
+     * @return string
+     */
     public function getTabId($tab, $withPrefix = true)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             return ($withPrefix ? $this->getId().'_' : '').$tab->getTabId();
         }
         return ($withPrefix ? $this->getId().'_' : '').$tab->getId();
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return bool
+     */
     public function canShowTab($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             return $tab->canShowTab();
         }
         return true;
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return bool
+     */
     public function getTabIsHidden($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             return $tab->isHidden();
         }
         return $tab->getIsHidden();
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return string
+     */
     public function getTabUrl($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             if (method_exists($tab, 'getTabUrl')) {
                 return $tab->getTabUrl();
             }
@@ -315,17 +346,25 @@ class Tabs extends \Magento\Backend\Block\Widget
         return '#';
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return string
+     */
     public function getTabTitle($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             return $tab->getTabTitle();
         }
         return $tab->getTitle();
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return string
+     */
     public function getTabClass($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             if (method_exists($tab, 'getTabClass')) {
                 return $tab->getTabClass();
             }
@@ -334,18 +373,25 @@ class Tabs extends \Magento\Backend\Block\Widget
         return $tab->getClass();
     }
 
-
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return string
+     */
     public function getTabLabel($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             return $tab->getTabLabel();
         }
         return $tab->getLabel();
     }
 
+    /**
+     * @param \Magento\Object|TabInterface $tab
+     * @return string
+     */
     public function getTabContent($tab)
     {
-        if ($tab instanceof \Magento\Backend\Block\Widget\Tab\TabInterface) {
+        if ($tab instanceof TabInterface) {
             if ($tab->getSkipGenerateContent()) {
                 return '';
             }
@@ -360,7 +406,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      *
      * @param string $tabOneId
      * @param string $tabTwoId
-     * @param string $tabNId...
+     * @return void
      */
     public function bindShadowTabs($tabOneId, $tabTwoId)
     {
@@ -418,7 +464,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      * @param string $tab
      * @param string $key
      * @param mixed $value
-     * @return \Magento\Backend\Block\Widget\Tabs
+     * @return $this
      */
     public function setTabData($tab, $key, $value)
     {
@@ -436,7 +482,7 @@ class Tabs extends \Magento\Backend\Block\Widget
      * Removes tab with passed id from tabs block
      *
      * @param string $tabId
-     * @return \Magento\Backend\Block\Widget\Tabs
+     * @return $this
      */
     public function removeTab($tabId)
     {
diff --git a/app/code/Magento/Backend/Block/Widget/View/Container.php b/app/code/Magento/Backend/Block/Widget/View/Container.php
index 711cee6950736ef2dff0ea66319809d42a59b7ee..0f446b880db9efa3569b9a0a328be679caf18df8 100644
--- a/app/code/Magento/Backend/Block/Widget/View/Container.php
+++ b/app/code/Magento/Backend/Block/Widget/View/Container.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Block\Widget\View;
 
 /**
  * Magento_Backend view container block
@@ -32,18 +33,26 @@
  * @author      Magento Core Team <core@magentocommerce.com>
  * @deprecated is not used in code
  */
-
-namespace Magento\Backend\Block\Widget\View;
-
 class Container extends \Magento\Backend\Block\Widget\Container
 {
+    /**
+     * @var string
+     */
     protected $_objectId = 'id';
 
+    /**
+     * @var string
+     */
     protected $_blockGroup = 'Magento_Backend';
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/view/container.phtml';
 
-
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -62,6 +71,9 @@ class Container extends \Magento\Backend\Block\Widget\Container
 
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _prepareLayout()
     {
         $blockName = $this->_blockGroup
@@ -74,11 +86,17 @@ class Container extends \Magento\Backend\Block\Widget\Container
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getEditUrl()
     {
         return $this->getUrl('*/*/edit', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
     }
 
+    /**
+     * @return string
+     */
     public function getViewHtml()
     {
         return $this->getChildHtml('plane');
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php b/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php
index 174eb6e45019ed30c3ad64bec5a98179cf3d7eeb..f2fce8f1bcab3bfe0b7be1427475954538ab392c 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Ajax.php
@@ -23,10 +23,14 @@
  */
 namespace Magento\Backend\Controller\Adminhtml;
 
-class Ajax extends \Magento\Backend\App\Action
+use Magento\Backend\App\Action;
+
+class Ajax extends Action
 {
     /**
      * Ajax action for inline translation
+     *
+     * @return void
      */
     public function translateAction()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Auth.php b/app/code/Magento/Backend/Controller/Adminhtml/Auth.php
index cdb56ad7a6643cb4e6d2b6eea62ca9748c17bcfb..5a58052942c5106fee415d0092c603c9c6d67a9f 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Auth.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Auth.php
@@ -23,16 +23,19 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml;
+
+use Magento\Backend\App\AbstractAction;
 
 /**
  * Auth backend controller
  */
-namespace Magento\Backend\Controller\Adminhtml;
-
-class Auth extends \Magento\Backend\App\AbstractAction
+class Auth extends AbstractAction
 {
     /**
      * Administrator login action
+     *
+     * @return void
      */
     public function loginAction()
     {
@@ -49,6 +52,8 @@ class Auth extends \Magento\Backend\App\AbstractAction
 
     /**
      * Administrator logout action
+     *
+     * @return void
      */
     public function logoutAction()
     {
@@ -59,6 +64,8 @@ class Auth extends \Magento\Backend\App\AbstractAction
 
     /**
      * Denied JSON action
+     *
+     * @return void
      */
     public function deniedJsonAction()
     {
@@ -80,6 +87,8 @@ class Auth extends \Magento\Backend\App\AbstractAction
 
     /**
      * Denied IFrame action
+     *
+     * @return void
      */
     public function deniedIframeAction()
     {
@@ -88,6 +97,7 @@ class Auth extends \Magento\Backend\App\AbstractAction
 
     /**
      * Retrieve response for deniedIframeAction()
+     *
      * @return string
      */
     protected function _getDeniedIframe()
@@ -99,7 +109,7 @@ class Auth extends \Magento\Backend\App\AbstractAction
     /**
      * Check if user has permissions to access this controller
      *
-     * @return boolean
+     * @return bool
      */
     protected function _isAllowed()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php
index e8fbdc94d0e69e83b1f09ab3fceb5168eb3ef562..e23e500ec4d9492c26cf16a9f1a824d3697fb401 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php
@@ -27,8 +27,9 @@
 namespace Magento\Backend\Controller\Adminhtml;
 
 use Magento\Backend\App\Action;
+use Magento\Core\Exception;
 
-class Cache extends \Magento\Backend\App\Action
+class Cache extends Action
 {
     /**
      * @var \Magento\App\Cache\TypeListInterface
@@ -65,18 +66,22 @@ class Cache extends \Magento\Backend\App\Action
 
     /**
      * Display cache management grid
+     *
+     * @return void
      */
     public function indexAction()
     {
         $this->_title->add(__('Cache Management'));
 
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Adminhtml::system_cache');
+        $this->_setActiveMenu('Magento_Backend::system_cache');
         $this->_view->renderLayout();
     }
 
     /**
      * Flush cache storage
+     *
+     * @return void
      */
     public function flushAllAction()
     {
@@ -93,6 +98,8 @@ class Cache extends \Magento\Backend\App\Action
 
     /**
      * Flush all magento cache
+     *
+     * @return void
      */
     public function flushSystemAction()
     {
@@ -107,6 +114,8 @@ class Cache extends \Magento\Backend\App\Action
 
     /**
      * Mass action for cache enabling
+     *
+     * @return void
      */
     public function massEnableAction()
     {
@@ -129,7 +138,7 @@ class Cache extends \Magento\Backend\App\Action
                     __("%1 cache type(s) enabled.", $updatedTypes)
                 );
             }
-        } catch (\Magento\Core\Exception $e) {
+        } catch (Exception $e) {
             $this->messageManager->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('An error occurred while enabling cache.'));
@@ -139,6 +148,8 @@ class Cache extends \Magento\Backend\App\Action
 
     /**
      * Mass action for cache disabling
+     *
+     * @return void
      */
     public function massDisableAction()
     {
@@ -162,7 +173,7 @@ class Cache extends \Magento\Backend\App\Action
                     __("%1 cache type(s) disabled.", $updatedTypes)
                 );
             }
-        } catch (\Magento\Core\Exception $e) {
+        } catch (Exception $e) {
             $this->messageManager->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->messageManager->addException(
@@ -175,6 +186,8 @@ class Cache extends \Magento\Backend\App\Action
 
     /**
      * Mass action for cache refresh
+     *
+     * @return void
      */
     public function massRefreshAction()
     {
@@ -193,7 +206,7 @@ class Cache extends \Magento\Backend\App\Action
             if ($updatedTypes > 0) {
                 $this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes));
             }
-        } catch (\Magento\Core\Exception $e) {
+        } catch (Exception $e) {
             $this->messageManager->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('An error occurred while refreshing cache.'));
@@ -205,6 +218,8 @@ class Cache extends \Magento\Backend\App\Action
      * Check whether specified cache types exist
      *
      * @param array $types
+     * @return void
+     * @throws Exception
      */
     protected function _validateTypes(array $types)
     {
@@ -214,12 +229,14 @@ class Cache extends \Magento\Backend\App\Action
         $allTypes = array_keys($this->_cacheTypeList->getTypes());
         $invalidTypes = array_diff($types, $allTypes);
         if (count($invalidTypes) > 0) {
-            throw new \Magento\Core\Exception(__("Specified cache type(s) don't exist: " . join(', ', $invalidTypes)));
+            throw new Exception(__("Specified cache type(s) don't exist: " . join(', ', $invalidTypes)));
         }
     }
 
     /**
      * Clean JS/css files cache
+     *
+     * @return void
      */
     public function cleanMediaAction()
     {
@@ -228,7 +245,7 @@ class Cache extends \Magento\Backend\App\Action
                 ->cleanMergedJsCss();
             $this->_eventManager->dispatch('clean_media_cache_after');
             $this->messageManager->addSuccess(__('The JavaScript/CSS cache has been cleaned.'));
-        } catch (\Magento\Core\Exception $e) {
+        } catch (Exception $e) {
             $this->messageManager->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->messageManager->addException(
@@ -241,6 +258,8 @@ class Cache extends \Magento\Backend\App\Action
 
     /**
      * Clean JS/css files cache
+     *
+     * @return void
      */
     public function cleanImagesAction()
     {
@@ -250,7 +269,7 @@ class Cache extends \Magento\Backend\App\Action
             $this->messageManager->addSuccess(
                 __('The image cache was cleaned.')
             );
-        } catch (\Magento\Core\Exception $e) {
+        } catch (Exception $e) {
             $this->messageManager->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->messageManager->addException(
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Dashboard.php b/app/code/Magento/Backend/Controller/Adminhtml/Dashboard.php
index 137446289bbebcc9bc297ff82582568f838f1fdb..82aeb4638aa8555da2d33f7adf39fe8f969f1509 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Dashboard.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Dashboard.php
@@ -43,12 +43,15 @@ class Dashboard extends \Magento\Backend\App\Action
         parent::__construct($context);
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Dashboard'));
 
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Adminhtml::dashboard');
+        $this->_setActiveMenu('Magento_Backend::dashboard');
         $this->_addBreadcrumb(__('Dashboard'), __('Dashboard'));
         $this->_view->renderLayout();
     }
@@ -56,6 +59,7 @@ class Dashboard extends \Magento\Backend\App\Action
     /**
      * Gets most viewed products list
      *
+     * @return void
      */
     public function productsViewedAction()
     {
@@ -66,6 +70,7 @@ class Dashboard extends \Magento\Backend\App\Action
     /**
      * Gets latest customers list
      *
+     * @return void
      */
     public function customersNewestAction()
     {
@@ -76,6 +81,7 @@ class Dashboard extends \Magento\Backend\App\Action
     /**
      * Gets the list of most active customers
      *
+     * @return void
      */
     public function customersMostAction()
     {
@@ -83,6 +89,9 @@ class Dashboard extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function ajaxBlockAction()
     {
         $output   = '';
@@ -104,6 +113,8 @@ class Dashboard extends \Magento\Backend\App\Action
      * Forward request for a graph image to the web-service
      *
      * This is done in order to include the image to a HTTPS-page regardless of web-service settings
+     *
+     * @return void
      */
     public function tunnelAction()
     {
@@ -144,6 +155,9 @@ class Dashboard extends \Magento\Backend\App\Action
             ->setHttpResponseCode($httpCode);
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Adminhtml::dashboard');
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Index.php b/app/code/Magento/Backend/Controller/Adminhtml/Index.php
index ff050ba0ea575a1e1e86ecfdf36308852b7f6bba..74e559b40a1b3c385c8104acbf95a63df465f49e 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Index.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Index.php
@@ -23,15 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Index backend controller
- */
 namespace Magento\Backend\Controller\Adminhtml;
 
 use Magento\App\Action\NotFoundException;
+use Magento\Backend\App\AbstractAction;
 
-class Index extends \Magento\Backend\App\AbstractAction
+/**
+ * Index backend controller
+ */
+class Index extends AbstractAction
 {
     /**
      * Search modules list
@@ -54,6 +54,8 @@ class Index extends \Magento\Backend\App\AbstractAction
 
     /**
      * Global Search Action
+     *
+     * @return void
      */
     public function globalSearchAction()
     {
@@ -107,7 +109,7 @@ class Index extends \Magento\Backend\App\AbstractAction
     /**
      * Check if user has permissions to access this controller
      *
-     * @return boolean
+     * @return bool
      */
     protected function _isAllowed()
     {
@@ -117,6 +119,8 @@ class Index extends \Magento\Backend\App\AbstractAction
     /**
      * Admin area entry point
      * Always redirects to the startup page url
+     *
+     * @return void
      */
     public function indexAction()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Noroute.php b/app/code/Magento/Backend/Controller/Adminhtml/Noroute.php
index c63fc99d152693968b5c129b016dd09314706190..fcabac1f816a5f82df3107e0577b97992e780ea2 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Noroute.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Noroute.php
@@ -28,6 +28,8 @@ class Noroute extends \Magento\Backend\App\Action
 {
     /**
      * Noroute action
+     *
+     * @return void
      */
     public function indexAction()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System.php b/app/code/Magento/Backend/Controller/Adminhtml/System.php
index bd9773194f659e8fc5b502d2a6d004a48cfe688f..6c6a58f57f321a6b09ccd8eff946f7a3b1f8081e 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml;
+
+use Magento\Backend\App\AbstractAction;
 
 /**
  * System admin controller
@@ -31,10 +34,11 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Controller\Adminhtml;
-
-class System extends \Magento\Backend\App\AbstractAction
+class System extends AbstractAction
 {
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_view->loadLayout();
@@ -46,6 +50,9 @@ class System extends \Magento\Backend\App\AbstractAction
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function setStoreAction()
     {
         $storeId = (int) $this->getRequest()->getParam('store');
@@ -55,6 +62,9 @@ class System extends \Magento\Backend\App\AbstractAction
         $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Adminhtml::system');
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php
index 437b2ad11805d6eb5d4a103b3ea11a1e37ff085c..d4458b59328382c101c6bf19e4a56e64fb01d34f 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml\System;
+
+use Magento\Backend\App\Action;
 
 /**
  * Adminhtml account controller
@@ -31,11 +34,11 @@
  * @package    Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Controller\Adminhtml\System;
-
-class Account extends \Magento\Backend\App\Action
+class Account extends Action
 {
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('My Account'));
@@ -46,6 +49,8 @@ class Account extends \Magento\Backend\App\Action
 
     /**
      * Saving edited user information
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -93,6 +98,9 @@ class Account extends \Magento\Backend\App\Action
         $this->getResponse()->setRedirect($this->getUrl("*/*/"));
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Adminhtml::myaccount');
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php
index abf9bba0b9e8a288d6aaf3b55b832b082479cead..336ccfaf4e43bc8ca3921c4deb53b28eeb4c30d3 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php
@@ -23,13 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml\System;
+
+use Magento\App\ResponseInterface;
 
 /**
  * System Configuration controller
  */
-namespace Magento\Backend\Controller\Adminhtml\System;
-
-class Config extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
+class Config extends AbstractConfig
 {
     /**
      * @var \Magento\App\Response\Http\FileFactory
@@ -61,6 +62,7 @@ class Config extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
     /**
      * Index action
      *
+     * @return void
      */
     public function indexAction()
     {
@@ -70,6 +72,7 @@ class Config extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
     /**
      * Edit configuration section
      *
+     * @return void
      */
     public function editAction()
     {
@@ -87,7 +90,7 @@ class Config extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
 
         $this->_view->loadLayout();
 
-        $this->_setActiveMenu('Magento_Adminhtml::system_config');
+        $this->_setActiveMenu('Magento_Backend::system_config');
         $this->_view->getLayout()->getBlock('menu')->setAdditionalCacheKeyInfo(array($current));
 
         $this->_addBreadcrumb(
@@ -101,6 +104,8 @@ class Config extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
 
     /**
      * Save fieldset state through AJAX
+     *
+     * @return void
      */
     public function stateAction()
     {
@@ -117,6 +122,8 @@ class Config extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
 
     /**
      * Export shipping table rates in csv format
+     *
+     * @return ResponseInterface
      */
     public function exportTableratesAction()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php
index 35de6d9055f3ddd9e2c3a4c1ece8b874c9754291..991f107281cc5e9a0a6184f28451630c5b75b698 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Config/Save.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml\System\Config;
+
+use Magento\Backend\Controller\Adminhtml\System\AbstractConfig;
 
 /**
  * System Configuration Save Controller
@@ -30,14 +33,9 @@
  * @category   Magento
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
- *
- */
-namespace Magento\Backend\Controller\Adminhtml\System\Config;
-
-/**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
-class Save extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
+class Save extends AbstractConfig
 {
     /**
      * Backend Config Model Factory
@@ -78,6 +76,8 @@ class Save extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
 
     /**
      * Save configuration
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -182,6 +182,8 @@ class Save extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
 
     /**
      * Custom save logic for section
+     *
+     * @return void
      */
     protected function _saveSection()
     {
@@ -195,6 +197,8 @@ class Save extends \Magento\Backend\Controller\Adminhtml\System\AbstractConfig
 
     /**
      * Advanced save procedure
+     *
+     * @return void
      */
     protected function _saveAdvanced()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php
index 020429f4230209c9cc70c5fc399096eda42f9548..3e52c3cc4496fd3b518eb7917e1e4471e542bec9 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php
@@ -23,10 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Controller\Adminhtml\System;
 
-class Design extends \Magento\Backend\App\Action
+use Magento\Backend\App\Action;
+
+class Design extends Action
 {
     /**
      * Core registry
@@ -55,31 +56,43 @@ class Design extends \Magento\Backend\App\Action
         parent::__construct($context);
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Store Design'));
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Adminhtml::system_design_schedule');
+        $this->_setActiveMenu('Magento_Backend::system_design_schedule');
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function gridAction()
     {
         $this->_view->loadLayout(false);
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function newAction()
     {
         $this->_forward('edit');
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $this->_title->add(__('Store Design'));
 
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Adminhtml::system_design_schedule');
+        $this->_setActiveMenu('Magento_Backend::system_design_schedule');
         $this->_view->getLayout()->getBlock('head')->setCanLoadExtJs(true);
 
         $id  = (int)$this->getRequest()->getParam('id');
@@ -101,6 +114,9 @@ class Design extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function saveAction()
     {
         $data = $this->getRequest()->getPost();
@@ -132,6 +148,9 @@ class Design extends \Magento\Backend\App\Action
         $this->_redirect('adminhtml/*/');
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $id = $this->getRequest()->getParam('id');
@@ -150,6 +169,9 @@ class Design extends \Magento\Backend\App\Action
         $this->getResponse()->setRedirect($this->getUrl('adminhtml/*/'));
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Adminhtml::design');
@@ -158,8 +180,8 @@ class Design extends \Magento\Backend\App\Action
     /**
      * Filtering posted data. Converting localized data if needed
      *
-     * @param array
-     * @return array
+     * @param array $data
+     * @return array|null
      */
     protected function _filterPostData($data)
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php
index a8f3b5e48affe3009b56843e6d79bbaf4cedd50c..f2c28135d3850e2dfa4735560839defdcb8acf62 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml\System;
+
+use Magento\Backend\App\Action;
 
 /**
  * Store controller
@@ -31,9 +34,7 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Controller\Adminhtml\System;
-
-class Store extends \Magento\Backend\App\Action
+class Store extends Action
 {
     /**
      * Core registry
@@ -65,18 +66,21 @@ class Store extends \Magento\Backend\App\Action
     /**
      * Init actions
      *
-     * @return \Magento\Cms\Controller\Adminhtml\Page
+     * @return $this
      */
     protected function _initAction()
     {
         // load layout, set active menu and breadcrumbs
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Adminhtml::system_store')
+        $this->_setActiveMenu('Magento_Backend::system_store')
             ->_addBreadcrumb(__('System'), __('System'))
             ->_addBreadcrumb(__('Manage Stores'), __('Manage Stores'));
         return $this;
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Stores'));
@@ -84,18 +88,27 @@ class Store extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function newWebsiteAction()
     {
         $this->_coreRegistry->register('store_type', 'website');
         $this->_forward('newStore');
     }
 
+    /**
+     * @return void
+     */
     public function newGroupAction()
     {
         $this->_coreRegistry->register('store_type', 'group');
         $this->_forward('newStore');
     }
 
+    /**
+     * @return void
+     */
     public function newStoreAction()
     {
         if (!$this->_coreRegistry->registry('store_type')) {
@@ -105,18 +118,27 @@ class Store extends \Magento\Backend\App\Action
         $this->_forward('editStore');
     }
 
+    /**
+     * @return void
+     */
     public function editWebsiteAction()
     {
         $this->_coreRegistry->register('store_type', 'website');
         $this->_forward('editStore');
     }
 
+    /**
+     * @return void
+     */
     public function editGroupAction()
     {
         $this->_coreRegistry->register('store_type', 'group');
         $this->_forward('editStore');
     }
 
+    /**
+     * @return void
+     */
     public function editStoreAction()
     {
         $this->_title->add(__('Stores'));
@@ -182,6 +204,9 @@ class Store extends \Magento\Backend\App\Action
         }
     }
 
+    /**
+     * @return void
+     */
     public function saveAction()
     {
         if ($this->getRequest()->isPost() && $postData = $this->getRequest()->getPost()) {
@@ -267,6 +292,9 @@ class Store extends \Magento\Backend\App\Action
         $this->_redirect('adminhtml/*/');
     }
 
+    /**
+     * @return void
+     */
     public function deleteWebsiteAction()
     {
         $this->_title->add(__('Delete Web Site'));
@@ -296,6 +324,9 @@ class Store extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function deleteGroupAction()
     {
         $this->_title->add(__('Delete Store'));
@@ -325,6 +356,9 @@ class Store extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function deleteStoreAction()
     {
         $this->_title->add(__('Delete Store View'));
@@ -354,6 +388,9 @@ class Store extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function deleteWebsitePostAction()
     {
         $itemId = $this->getRequest()->getParam('item_id');
@@ -385,6 +422,9 @@ class Store extends \Magento\Backend\App\Action
         $this->_redirect('adminhtml/*/editWebsite', array('website_id' => $itemId));
     }
 
+    /**
+     * @return void
+     */
     public function deleteGroupPostAction()
     {
         $itemId = $this->getRequest()->getParam('item_id');
@@ -418,6 +458,7 @@ class Store extends \Magento\Backend\App\Action
     /**
      * Delete store view post action
      *
+     * @return void
      */
     public function deleteStorePostAction()
     {
@@ -452,6 +493,9 @@ class Store extends \Magento\Backend\App\Action
         $this->_redirect('adminhtml/*/editStore', array('store_id' => $itemId));
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Adminhtml::store');
@@ -462,7 +506,7 @@ class Store extends \Magento\Backend\App\Action
      *
      * @param string $failPath redirect path if backup failed
      * @param array $arguments
-     * @return \Magento\Backend\Controller\Adminhtml\System\Store
+     * @return $this|void
      */
     protected function _backupDatabase($failPath, $arguments=array())
     {
@@ -497,7 +541,7 @@ class Store extends \Magento\Backend\App\Action
      * Add notification on deleting store / store view / website
      *
      * @param string $typeTitle
-     * @return \Magento\Backend\Controller\Adminhtml\System\Store
+     * @return $this
      */
     protected function _addDeletionNotice($typeTitle)
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Variable.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Variable.php
index bc8749b111bfa509b5808a8ead2abcb67bb19c77..ceacf3557d669a12f51b734aac4a800c41c2ecde 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Variable.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Variable.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml\System;
+
+use Magento\Backend\App\Action;
 
 /**
  * Custom Variables admin controller
@@ -31,9 +34,7 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Controller\Adminhtml\System;
-
-class Variable extends \Magento\Backend\App\Action
+class Variable extends Action
 {
     /**
      * Core registry
@@ -57,12 +58,12 @@ class Variable extends \Magento\Backend\App\Action
     /**
      * Initialize Layout and set breadcrumbs
      *
-     * @return \Magento\Backend\Controller\Adminhtml\System\Variable
+     * @return $this
      */
     protected function _initLayout()
     {
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Adminhtml::system_variable')
+        $this->_setActiveMenu('Magento_Backend::system_variable')
             ->_addBreadcrumb(__('Custom Variables'), __('Custom Variables'));
         return $this;
     }
@@ -90,6 +91,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * Index Action
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -101,6 +104,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * New Action (forward to edit action)
+     *
+     * @return void
      */
     public function newAction()
     {
@@ -109,6 +114,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * Edit Action
+     *
+     * @return void
      */
     public function editAction()
     {
@@ -128,6 +135,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * Validate Action
+     *
+     * @return void
      */
     public function validateAction()
     {
@@ -146,6 +155,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * Save Action
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -178,6 +189,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * Delete Action
+     *
+     * @return void
      */
     public function deleteAction()
     {
@@ -200,6 +213,8 @@ class Variable extends \Magento\Backend\App\Action
 
     /**
      * WYSIWYG Plugin Action
+     *
+     * @return void
      */
     public function wysiwygPluginAction()
     {
@@ -212,7 +227,7 @@ class Variable extends \Magento\Backend\App\Action
     /**
      * Check current user permission
      *
-     * @return boolean
+     * @return bool
      */
     protected function _isAllowed()
     {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php b/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php
index 733b80b9d9156d89f82b358c3825fcbacb88d589..90b31739e9ce897fa482085f0a34b4897203b171 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php
@@ -23,6 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Controller\Adminhtml;
+
+use Magento\Backend\App\Action;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Product;
+use Magento\Core\Exception;
+use Magento\Core\Model\Url\Rewrite;
 
 /**
  * URL rewrite adminhtml controller
@@ -31,9 +38,7 @@
  * @package    Magento_Adminhtml
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Controller\Adminhtml;
-
-class Urlrewrite extends \Magento\Backend\App\Action
+class Urlrewrite extends Action
 {
     const ID_MODE = 'id';
     const PRODUCT_MODE = 'product';
@@ -41,12 +46,12 @@ class Urlrewrite extends \Magento\Backend\App\Action
     const CMS_PAGE_MODE = 'cms_page';
 
     /**
-     * @var \Magento\Catalog\Model\Product
+     * @var Product
      */
     private $_product;
 
     /**
-     * @var \Magento\Catalog\Model\Category
+     * @var Category
      */
     private $_category;
 
@@ -56,12 +61,14 @@ class Urlrewrite extends \Magento\Backend\App\Action
     private $_cmsPage;
 
     /**
-     * @var \Magento\Core\Model\Url\Rewrite
+     * @var Rewrite
      */
     private $_urlRewrite;
 
     /**
      * Show URL rewrites index page
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -74,6 +81,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
 
     /**
      * Show urlrewrite edit/create page
+     *
+     * @return void
      */
     public function editAction()
     {
@@ -153,6 +162,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
 
     /**
      * Ajax products grid action
+     *
+     * @return void
      */
     public function productGridAction()
     {
@@ -163,6 +174,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
 
     /**
      * Ajax categories tree loader action
+     *
+     * @return void
      */
     public function categoriesJsonAction()
     {
@@ -175,6 +188,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
 
     /**
      * Ajax CMS pages grid action
+     *
+     * @return void
      */
     public function cmsPageGridAction()
     {
@@ -185,6 +200,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
 
     /**
      * Urlrewrite save action
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -193,7 +210,7 @@ class Urlrewrite extends \Magento\Backend\App\Action
             $session = $this->_objectManager->get('Magento\Backend\Model\Session');
             try {
                 // set basic urlrewrite data
-                /** @var $model \Magento\Core\Model\Url\Rewrite */
+                /** @var $model Rewrite */
                 $model = $this->_getUrlRewrite();
 
                 // Validate request path
@@ -224,7 +241,7 @@ class Urlrewrite extends \Magento\Backend\App\Action
                 $this->messageManager->addSuccess(__('The URL Rewrite has been saved.'));
                 $this->_redirect('adminhtml/*/');
                 return;
-            } catch (\Magento\Core\Exception $e) {
+            } catch (Exception $e) {
                 $this->messageManager->addError($e->getMessage());
                 $session->setUrlrewriteData($data);
             } catch (\Exception $e) {
@@ -238,7 +255,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Call before save urlrewrite handlers
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
+     * @param Rewrite $model
+     * @return void
      */
     protected function _onUrlRewriteSaveBefore($model)
     {
@@ -249,7 +267,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Call after save urlrewrite handlers
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
+     * @param Rewrite $model
+     * @return void
      */
     protected function _onUrlRewriteSaveAfter($model)
     {
@@ -259,7 +278,9 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Override urlrewrite data, basing on current category and product
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
+     * @param Rewrite $model
+     * @return void
+     * @throws Exception
      */
     protected function _handleCatalogUrlRewrite($model)
     {
@@ -277,14 +298,14 @@ class Urlrewrite extends \Magento\Backend\App\Action
             if ($this->_objectManager->get('Magento\Core\Helper\Url\Rewrite')->hasRedirectOptions($model)) {
                 /** @var $rewriteResource \Magento\Catalog\Model\Resource\Url */
                 $rewriteResource = $this->_objectManager->create('Magento\Catalog\Model\Resource\Url');
-                /** @var $rewrite \Magento\Core\Model\Url\Rewrite */
+                /** @var $rewrite Rewrite */
                 $rewrite = $rewriteResource->getRewriteByIdPath($idPath, $model->getStoreId());
                 if (!$rewrite) {
                     if ($product) {
-                        throw new \Magento\Core\Exception(
+                        throw new Exception(
                             __('Chosen product does not associated with the chosen store or category.'));
                     } else {
-                        throw new \Magento\Core\Exception(
+                        throw new Exception(
                             __('Chosen category does not associated with the chosen store.')
                         );
                     }
@@ -302,12 +323,12 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Get product instance applicable for generatePath
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
-     * @return \Magento\Catalog\Model\Product|null
+     * @param Rewrite $model
+     * @return Product|null
      */
     private function _getInitializedProduct($model)
     {
-        /** @var $product \Magento\Catalog\Model\Product */
+        /** @var $product Product */
         $product = $this->_getProduct();
         if ($product->getId()) {
             $model->setProductId($product->getId());
@@ -321,12 +342,12 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Get category instance applicable for generatePath
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
-     * @return \Magento\Catalog\Model\Category|null
+     * @param Rewrite $model
+     * @return Category|null
      */
     private function _getInitializedCategory($model)
     {
-        /** @var $category \Magento\Catalog\Model\Category */
+        /** @var $category Category */
         $category = $this->_getCategory();
         if ($category->getId()) {
             $model->setCategoryId($category->getId());
@@ -339,7 +360,9 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Override URL rewrite data, basing on current CMS page
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
+     * @param Rewrite $model
+     * @return void
+     * @throws Exception
      */
     private function _handleCmsPageUrlRewrite($model)
     {
@@ -359,10 +382,10 @@ class Urlrewrite extends \Magento\Backend\App\Action
         if ($this->_objectManager->get('Magento\Core\Helper\Url\Rewrite')->hasRedirectOptions($model)) {
             /** @var $rewriteResource \Magento\Catalog\Model\Resource\Url */
             $rewriteResource = $this->_objectManager->create('Magento\Catalog\Model\Resource\Url');
-            /** @var $rewrite \Magento\Core\Model\Url\Rewrite */
+            /** @var $rewrite Rewrite */
             $rewrite = $rewriteResource->getRewriteByIdPath($idPath, $model->getStoreId());
             if (!$rewrite) {
-                throw new \Magento\Core\Exception(__('Chosen cms page does not associated with the chosen store.'));
+                throw new Exception(__('Chosen cms page does not associated with the chosen store.'));
             } elseif ($rewrite->getId() && $rewrite->getId() != $model->getId()) {
                 $model->setTargetPath($rewrite->getRequestPath());
                 $generateTarget = false;
@@ -377,7 +400,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Save CMS page URL rewrite additional information
      *
-     * @param \Magento\Core\Model\Url\Rewrite $model
+     * @param Rewrite $model
+     * @return void
      */
     private function _handleCmsPageUrlRewriteSave($model)
     {
@@ -399,6 +423,8 @@ class Urlrewrite extends \Magento\Backend\App\Action
 
     /**
      * URL rewrite delete action
+     *
+     * @return void
      */
     public function deleteAction()
     {
@@ -428,7 +454,7 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Get Category from request
      *
-     * @return \Magento\Catalog\Model\Category
+     * @return Category
      */
     private function _getCategory()
     {
@@ -450,7 +476,7 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Get Product from request
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     private function _getProduct()
     {
@@ -498,7 +524,7 @@ class Urlrewrite extends \Magento\Backend\App\Action
     /**
      * Get URL rewrite from request
      *
-     * @return \Magento\Core\Model\Url\Rewrite
+     * @return Rewrite
      */
     private function _getUrlRewrite()
     {
diff --git a/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php b/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php
index 43c1eb3c6a2a2746d1721ea9bc3f8c4b1b26dc25..a68657827c582233027d8f5e944d908cd2046109 100644
--- a/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php
+++ b/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php
@@ -23,18 +23,20 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Helper\Dashboard;
+
+use Magento\Core\Helper\Data as HelperData;
+use Magento\Core\Model\Resource\Db\Collection\AbstractCollection;
 
 /**
  * Adminhtml abstract  dashboard helper.
  */
-namespace Magento\Backend\Helper\Dashboard;
-
-abstract class AbstractDashboard extends \Magento\Core\Helper\Data
+abstract class AbstractDashboard extends HelperData
 {
     /**
      * Helper collection
      *
-     * @var \Magento\Core\Model\Resource\Db\Collection\AbstractCollection|\Magento\Eav\Model\Entity\Collection\Abstract|array
+     * @var AbstractCollection|array
      */
     protected  $_collection;
 
@@ -45,6 +47,9 @@ abstract class AbstractDashboard extends \Magento\Core\Helper\Data
      */
     protected  $_params = array();
 
+    /**
+     * @return array|AbstractCollection
+     */
     public function getCollection()
     {
         if (is_null($this->_collection)) {
@@ -53,6 +58,9 @@ abstract class AbstractDashboard extends \Magento\Core\Helper\Data
         return $this->_collection;
     }
 
+    /**
+     * @return void
+     */
     abstract protected  function _initCollection();
 
     /**
@@ -65,11 +73,18 @@ abstract class AbstractDashboard extends \Magento\Core\Helper\Data
         return is_array($this->getCollection()) ? $this->getCollection() : $this->getCollection()->getItems();
     }
 
+    /**
+     * @return int
+     */
     public function getCount()
     {
         return sizeof($this->getItems());
     }
 
+    /**
+     * @param string $index
+     * @return array
+     */
     public function getColumn($index)
     {
         $result = array();
@@ -89,16 +104,29 @@ abstract class AbstractDashboard extends \Magento\Core\Helper\Data
         return $result;
     }
 
+    /**
+     * @param string $name
+     * @param mixed $value
+     * @return void
+     */
     public function setParam($name, $value)
     {
         $this->_params[$name] = $value;
     }
 
+    /**
+     * @param array $params
+     * @return void
+     */
     public function setParams(array $params)
     {
         $this->_params = $params;
     }
 
+    /**
+     * @param string $name
+     * @return mixed
+     */
     public function getParam($name)
     {
         if (isset($this->_params[$name])) {
@@ -108,6 +136,9 @@ abstract class AbstractDashboard extends \Magento\Core\Helper\Data
         return null;
     }
 
+    /**
+     * @return array
+     */
     public function getParams()
     {
         return $this->_params;
diff --git a/app/code/Magento/Backend/Helper/Dashboard/Data.php b/app/code/Magento/Backend/Helper/Dashboard/Data.php
index 2d472137eec65df917f507063bb43a11aa524aeb..59ce6aff161197cfc11912040b43b5dd777cec57 100644
--- a/app/code/Magento/Backend/Helper/Dashboard/Data.php
+++ b/app/code/Magento/Backend/Helper/Dashboard/Data.php
@@ -46,7 +46,7 @@ class Data extends \Magento\Core\Helper\Data
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Core\Model\Locale $locale
      * @param \Magento\App\State $appState
-     * @param $installDate
+     * @param string $installDate
      * @param bool $dbCompatibleMode
      */
     public function __construct(
@@ -72,7 +72,7 @@ class Data extends \Magento\Core\Helper\Data
     /**
      * Retrieve stores configured in system.
      *
-     * @return array
+     * @return \Magento\Data\Collection\Db
      */
     public function getStores()
     {
diff --git a/app/code/Magento/Backend/Helper/Dashboard/Order.php b/app/code/Magento/Backend/Helper/Dashboard/Order.php
index 5ae053c61159d5fce175fde10975c93952ec7147..baa27155bc4bb20202b3ba24e3cf6737c8307003 100644
--- a/app/code/Magento/Backend/Helper/Dashboard/Order.php
+++ b/app/code/Magento/Backend/Helper/Dashboard/Order.php
@@ -64,6 +64,9 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard
         );
     }
 
+    /**
+     * @return void
+     */
     protected function _initCollection()
     {
         $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
diff --git a/app/code/Magento/Backend/Helper/Data.php b/app/code/Magento/Backend/Helper/Data.php
index 6af5e8c5dad1cd2eaeaf418be36021d114daa803..4add847c7f488d36e9af3b45b6de18d5d470636e 100644
--- a/app/code/Magento/Backend/Helper/Data.php
+++ b/app/code/Magento/Backend/Helper/Data.php
@@ -23,16 +23,20 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Helper;
 
+use Magento\App\Helper\AbstractHelper;
+
 /**
  * @SuppressWarnings(PHPMD.LongVariable)
  */
-class Data extends \Magento\App\Helper\AbstractHelper
+class Data extends AbstractHelper
 {
-    const XML_PATH_USE_CUSTOM_ADMIN_URL         = 'admin/url/use_custom';
+    const XML_PATH_USE_CUSTOM_ADMIN_URL = 'admin/url/use_custom';
 
+    /**
+     * @var string
+     */
     protected $_pageHelpUrl;
 
     /**
@@ -92,6 +96,9 @@ class Data extends \Magento\App\Helper\AbstractHelper
         $this->mathRandom = $mathRandom;
     }
 
+    /**
+     * @return string
+     */
     public function getPageHelpUrl()
     {
         if (!$this->_pageHelpUrl) {
@@ -100,6 +107,10 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return $this->_pageHelpUrl;
     }
 
+    /**
+     * @param string|null $url
+     * @return $this
+     */
     public function setPageHelpUrl($url = null)
     {
         if (is_null($url)) {
@@ -126,17 +137,29 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return $this;
     }
 
+    /**
+     * @param string $suffix
+     * @return $this
+     */
     public function addPageHelpUrl($suffix)
     {
         $this->_pageHelpUrl = $this->getPageHelpUrl().$suffix;
         return $this;
     }
 
+    /**
+     * @param string $route
+     * @param array $params
+     * @return string
+     */
     public function getUrl($route = '', $params = array())
     {
         return $this->_backendUrl->getUrl($route, $params);
     }
 
+    /**
+     * @return int|bool
+     */
     public function getCurrentUserId()
     {
         if ($this->_auth->getUser()) {
@@ -163,7 +186,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Decode URL encoded filter value recursive callback method
      *
-     * @param string $value
+     * @param string &$value
+     * @return void
      */
     public function decodeFilter(&$value)
     {
diff --git a/app/code/Magento/Backend/Helper/Media/Js.php b/app/code/Magento/Backend/Helper/Media/Js.php
index 6681ca3979c0caa8d7754e57edbec3e769bdfaae..4145fecd85460a6dccefe2dca08e7fb03c576d8c 100644
--- a/app/code/Magento/Backend/Helper/Media/Js.php
+++ b/app/code/Magento/Backend/Helper/Media/Js.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Helper\Media;
 
 /**
  * Media library js helper
@@ -33,12 +33,10 @@
  * @package    Magento_Adminhtml
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Helper\Media;
-
 class Js extends \Magento\Core\Helper\Js
 {
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     protected function _populateTranslateData()
     {
diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php
index e808dc5f45c9f839e9b5dc31edc8fd1a513af7c7..6438a1cabb36cd24f18293abcfd6121cd0723ee6 100644
--- a/app/code/Magento/Backend/Model/Auth.php
+++ b/app/code/Magento/Backend/Model/Auth.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model;
 
 /**
  * Backend Auth model
  */
-namespace Magento\Backend\Model;
-
 class Auth
 {
     /**
@@ -93,7 +92,7 @@ class Auth
      * Set auth storage if it is instance of \Magento\Backend\Model\Auth\StorageInterface
      *
      * @param \Magento\Backend\Model\Auth\StorageInterface $storage
-     * @return \Magento\Backend\Model\Auth
+     * @return $this
      * @throw \Magento\Backend\Model\Auth\Exception if $storage is not correct
      */
     public function setAuthStorage($storage)
@@ -142,7 +141,7 @@ class Auth
     /**
      * Return credential storage object
      *
-     * @return null | \Magento\Backend\Model\Auth\Credential\StorageInterface
+     * @return null|\Magento\Backend\Model\Auth\Credential\StorageInterface
      */
     public function getCredentialStorage()
     {
@@ -154,6 +153,7 @@ class Auth
      *
      * @param string $username
      * @param string $password
+     * @return void
      * @throws \Exception|\Magento\Backend\Model\Auth\Plugin\Exception
      */
     public function login($username, $password)
@@ -208,7 +208,7 @@ class Auth
     /**
      * Check if current user is logged in
      *
-     * @return boolean
+     * @return bool
      */
     public function isLoggedIn()
     {
@@ -218,10 +218,10 @@ class Auth
     /**
      * Throws specific Backend Authentication \Exception
      *
-     * @static
      * @param string $msg
      * @param string $code
      * @throws \Magento\Backend\Model\Auth\Exception
+     * @static
      */
     public static function throwException($msg = null, $code = null)
     {
diff --git a/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php b/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php
index 15785ab22e63f92882637f39e18472ad035f2984..bfb7b19a5ff948749f71cd9ef05a4fd7e474ceb7 100644
--- a/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php
+++ b/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Model\Auth\Credential;
 
 /**
  * Backend Auth Credential Storage interface
@@ -32,31 +32,31 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Auth\Credential;
-
 interface StorageInterface
 {
     /**
      * Authenticate process.
      *
-     * @abstract
      * @param string $username
      * @param string $password
+     * @return bool
      */
     public function authenticate($username, $password);
 
     /**
      * Login action. Check if given username and password are valid
      *
-     * @abstract
      * @param $username
      * @param $password
+     * @return $this
+     * @abstract
      */
     public function login($username, $password);
 
     /**
      * Reload loaded (already authenticated) credential storage
      *
+     * @return $this
      * @abstract
      */
     public function reload();
@@ -64,16 +64,17 @@ interface StorageInterface
     /**
      * Check if user has available resources
      *
-     * @abstract
      * @return bool
+     * @abstract
      */
     public function hasAvailableResources();
 
     /**
      * Set user has available resources
      *
-     * @abstract
      * @param bool $hasResources
+     * @return $this
+     * @abstract
      */
     public function setHasAvailableResources($hasResources);
 }
diff --git a/app/code/Magento/Backend/Model/Auth/Exception.php b/app/code/Magento/Backend/Model/Auth/Exception.php
index bf1d79591f7fdc66d8221a88b46dc009772a5c2b..82c208d0daaff6d733186f34534f0879c2a73a33 100644
--- a/app/code/Magento/Backend/Model/Auth/Exception.php
+++ b/app/code/Magento/Backend/Model/Auth/Exception.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Model\Auth;
 
 /**
  * Backend Auth \Exception model
@@ -32,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Auth;
-
 class Exception extends \Magento\Core\Exception
 {
 }
diff --git a/app/code/Magento/Backend/Model/Auth/Plugin/Exception.php b/app/code/Magento/Backend/Model/Auth/Plugin/Exception.php
index 166d001bb7c9fea23a7506ff32a86f26839d291a..1750f470a3d944d42a7de96775943d3b925187bc 100644
--- a/app/code/Magento/Backend/Model/Auth/Plugin/Exception.php
+++ b/app/code/Magento/Backend/Model/Auth/Plugin/Exception.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Model\Auth\Plugin;
 
 /**
  * Backend Auth \Exception Plugin model. Must be thrown in modules that plug in to authentication process
@@ -32,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Auth\Plugin;
-
 class Exception extends \Magento\Backend\Model\Auth\Exception
 {
 }
diff --git a/app/code/Magento/Backend/Model/Auth/StorageInterface.php b/app/code/Magento/Backend/Model/Auth/StorageInterface.php
index 0e38761b656bc087bb6a88245d46a97a327e8a6f..e0c69cd560727c58000373d2ff469ef662d0cf14 100644
--- a/app/code/Magento/Backend/Model/Auth/StorageInterface.php
+++ b/app/code/Magento/Backend/Model/Auth/StorageInterface.php
@@ -23,18 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Model\Auth;
 
 /**
  * Backend Auth Storage interface
  */
-namespace Magento\Backend\Model\Auth;
-
 interface StorageInterface
 {
     /**
      * Perform login specific actions
      *
+     * @return $this
      * @abstract
      */
     public function processLogin();
@@ -42,6 +41,7 @@ interface StorageInterface
     /**
      * Perform login specific actions
      *
+     * @return $this
      * @abstract
      */
     public function processLogout();
diff --git a/app/code/Magento/Backend/Model/Cache/Resource/Grid/Collection.php b/app/code/Magento/Backend/Model/Cache/Resource/Grid/Collection.php
index 6f99738f267332a4e7d1327eb72357662fbe5ec2..a8cfcb8769139d015c5f5f7e7daa7f7275adcb3e 100644
--- a/app/code/Magento/Backend/Model/Cache/Resource/Grid/Collection.php
+++ b/app/code/Magento/Backend/Model/Cache/Resource/Grid/Collection.php
@@ -49,7 +49,7 @@ class Collection extends \Magento\Data\Collection
      *
      * @param bool $printQuery
      * @param bool $logQuery
-     * @return \Magento\Backend\Model\Cache\Resource\Grid\Collection
+     * @return $this
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function loadData($printQuery = false, $logQuery = false)
diff --git a/app/code/Magento/Backend/Model/Config.php b/app/code/Magento/Backend/Model/Config.php
index 17fe9e669da788dedefd25837129032e29b16694..efaa5a7577a3d4287d588c600662b6fe48f3c64e 100644
--- a/app/code/Magento/Backend/Model/Config.php
+++ b/app/code/Magento/Backend/Model/Config.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model;
 
 /**
  * Backend config model
@@ -32,9 +33,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Backend\Model;
-
 class Config extends \Magento\Object
 {
     /**
@@ -133,7 +131,7 @@ class Config extends \Magento\Object
      * Require set: section, website, store and groups
      *
      * @throws \Exception
-     * @return \Magento\Backend\Model\Config
+     * @return $this
      */
     public function save()
     {
@@ -193,10 +191,11 @@ class Config extends \Magento\Object
      * @param array $groupData
      * @param array $groups
      * @param string $sectionPath
-     * @param array $extraOldGroups
-     * @param array $oldConfig
+     * @param array &$extraOldGroups
+     * @param array &$oldConfig
      * @param \Magento\Core\Model\Resource\Transaction $saveTransaction
      * @param \Magento\Core\Model\Resource\Transaction $deleteTransaction
+     * @return void
      */
     protected function _processGroup(
         $groupId,
@@ -355,8 +354,9 @@ class Config extends \Magento\Object
     }
 
     /**
-     * Validate isset required parametrs
+     * Validate isset required parameters
      *
+     * @return void
      */
     protected function _validate()
     {
@@ -374,6 +374,7 @@ class Config extends \Magento\Object
     /**
      * Get scope name and scopeId
      *
+     * @return void
      */
     protected function _getScope()
     {
@@ -415,6 +416,7 @@ class Config extends \Magento\Object
      *
      * @param \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig
      * @param \Magento\App\Config\ValueInterface $dataObject
+     * @return void
      */
     protected function _checkSingleStoreMode(
         \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig,
@@ -437,7 +439,7 @@ class Config extends \Magento\Object
      * Get config data value
      *
      * @param string $path
-     * @param null|bool $inherit
+     * @param null|bool &$inherit
      * @param null|array $configData
      * @return \Magento\Simplexml\Element
      */
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php
index d284a612d21627a51c8f9570a9d71b2dded19592..36bc7a2e60f9087f839f89dc1fc192f7a220d09c 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php
@@ -86,7 +86,7 @@ class Custom extends \Magento\Core\Model\Config\Value
     /**
      * Validate value before save
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Custom
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -103,7 +103,7 @@ class Custom extends \Magento\Core\Model\Config\Value
     /**
      * Change secure/unsecure base_url after use_custom_url was modified
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Custom
+     * @return $this
      */
     public function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php
index e8153bafab1faa7a8d474c848744e484376fe130..987ec37faa718a4b49a601b0d38d20216bc754c3 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custompath.php
@@ -38,7 +38,7 @@ class Custompath extends \Magento\Core\Model\Config\Value
     /**
      * Check whether redirect should be set
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Custom
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php
index 19ec9000950bfea7421be0c25a3fe098020c8b70..1eea1145c89bc34a55b7da01678586a7bdd9add0 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Observer.php
@@ -81,6 +81,7 @@ class Observer
     /**
      * Log out user and redirect him to new admin custom url
      *
+     * @return void
      * @SuppressWarnings(PHPMD.ExitExpression)
      */
     public function afterCustomUrlChanged()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php
index 2d2fb9a26776a8d9fbbded120187ccb74b1179f6..be72be0629f9f0545a3ba9e47840b610a809a44e 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php
@@ -39,7 +39,7 @@ class Expirationperiod
     /**
      * Validate expiration period value before saving
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Password\Link\Expirationperiod
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php
index b27630864e9ff328b78922ed643b50200365de35..1549e350d6e820e4655844e3bde890ecdd8dbc59 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php
@@ -90,7 +90,7 @@ class Robots extends \Magento\Core\Model\Config\Value
     /**
      * Load default content from robots.txt if customer does not define own
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Robots
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -104,7 +104,7 @@ class Robots extends \Magento\Core\Model\Config\Value
     /**
      * Check and process robots file
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Robots
+     * @return $this
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php
index 8dedcf8643a40be6e0e20908e7d6d1d27273ca4a..456c090a356359b1f9f250518a5ff021fef15e69 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php
@@ -74,7 +74,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value
     /**
      * Validate custom url
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Usecustom
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeSave()
@@ -95,7 +95,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value
     /**
      * Delete custom admin url from configuration if "Use Custom Admin Url" option disabled
      *
-     * @return \Magento\Backend\Model\Config\Backend\Admin\Usecustom
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -103,14 +103,14 @@ class Usecustom extends \Magento\Core\Model\Config\Value
 
         if (!$value) {
             $this->_configWriter->delete(
-                \Magento\Backend\Model\Config\Backend\Admin\Custom::XML_PATH_SECURE_BASE_URL,
-                \Magento\Backend\Model\Config\Backend\Admin\Custom::CONFIG_SCOPE,
-                \Magento\Backend\Model\Config\Backend\Admin\Custom::CONFIG_SCOPE_ID
+                Custom::XML_PATH_SECURE_BASE_URL,
+                Custom::CONFIG_SCOPE,
+                Custom::CONFIG_SCOPE_ID
             );
             $this->_configWriter->delete(
-                \Magento\Backend\Model\Config\Backend\Admin\Custom::XML_PATH_UNSECURE_BASE_URL,
-                \Magento\Backend\Model\Config\Backend\Admin\Custom::CONFIG_SCOPE,
-                \Magento\Backend\Model\Config\Backend\Admin\Custom::CONFIG_SCOPE_ID
+                Custom::XML_PATH_UNSECURE_BASE_URL,
+                Custom::CONFIG_SCOPE,
+                Custom::CONFIG_SCOPE_ID
             );
         }
 
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php
index c969bc007dcb11582f21119004cc30a35a3e00b5..639ad905e6c5fdb0af069c9981a9955b7907ec07 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php
@@ -60,6 +60,9 @@ class Usesecretkey extends \Magento\Core\Model\Config\Value
         parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return $this
+     */
     protected function _afterSave()
     {
         $this->_backendUrl->renewSecretUrls();
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php b/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php
index a30cf63981ac5ac6053fcbaf732b6c0a289a3226..d57aa466d59609be58deb68c06993f0c97a0dbc3 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php
@@ -65,7 +65,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value
     /**
      * Validate a base URL field value
      *
-     * @return \Magento\Backend\Model\Config\Backend\Baseurl
+     * @return void
      * @throws \Magento\Core\Exception
      */
     protected function _beforeSave()
@@ -145,6 +145,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value
      *
      * @param array $values
      * @param string $value
+     * @return void
      * @throws \Magento\Core\Exception
      */
     private function _assertValuesOrUrl(array $values, $value)
@@ -160,6 +161,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value
      *
      * @param array $values
      * @param string $value
+     * @return void
      * @throws \Magento\Core\Exception
      */
     private function _assertStartsWithValuesOrUrl(array $values, $value)
@@ -176,6 +178,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value
      *
      * @param array $values
      * @param string $value
+     * @return void
      * @throws \Magento\Core\Exception
      */
     private function _assertStartsWithValuesOrUrlOrEmpty(array $values, $value)
@@ -196,6 +199,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value
      * Default validation of a URL
      *
      * @param string $value
+     * @return void
      * @throws \Magento\Core\Exception
      */
     private function _validateFullyQualifiedUrl($value)
@@ -221,6 +225,8 @@ class Baseurl extends \Magento\Core\Model\Config\Value
 
     /**
      * Clean compiled JS/CSS when updating url configuration settings
+     *
+     * @return void
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Cache.php b/app/code/Magento/Backend/Model/Config/Backend/Cache.php
index e4360f0aacd5be2da767b2c26c79af8541c621fe..4f3075ee371c50156a248c12b996547f7138073d 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Cache.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Cache.php
@@ -42,6 +42,7 @@ class Cache extends \Magento\Core\Model\Config\Value
     /**
      * Clean cache, value was changed
      *
+     * @return void
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Cookie.php b/app/code/Magento/Backend/Model/Config/Backend/Cookie.php
index 40dabfddcbc53552915e9f00cd1b176c1417cad1..c607f17ae66fb4e8ae61235cea238e31a3f903dd 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Cookie.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Cookie.php
@@ -35,5 +35,8 @@ namespace Magento\Backend\Model\Config\Backend;
 
 class Cookie extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @var string
+     */
     protected $_eventPrefix = 'adminhtml_system_config_backend_cookie';
 }
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php
index db7ef1f16b673b753aaf1f588bf4d25a28e2f016..0378619ca6c90edea4f57e7b2015c8d4f6f632f5 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php
@@ -97,7 +97,7 @@ abstract class AbstractCurrency extends \Magento\Core\Model\Config\Value
     /**
      * Retrieve Installed Currencies
      *
-     * @return array
+     * @return string[]
      */
     protected function _getInstalledCurrencies()
     {
@@ -122,7 +122,7 @@ abstract class AbstractCurrency extends \Magento\Core\Model\Config\Value
     }
 
     /**
-     * Retrieve Default desplay Currency value for current scope
+     * Retrieve Default display Currency value for current scope
      *
      * @return string
      */
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php
index bea126e62df313a4b14fa78751dd9cae3366ea5c..323ccf82df0cf31e35ff3c1ee718d144aab5e9ea 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php
@@ -30,7 +30,7 @@
  */
 namespace Magento\Backend\Model\Config\Backend\Currency;
 
-class Allow extends \Magento\Backend\Model\Config\Backend\Currency\AbstractCurrency
+class Allow extends AbstractCurrency
 {
     /**
      * @var \Magento\Core\Model\LocaleInterface
@@ -68,7 +68,7 @@ class Allow extends \Magento\Backend\Model\Config\Backend\Currency\AbstractCurre
      * Check is isset default display currency in allowed currencies
      * Check allowed currencies is available in installed currencies
      *
-     * @return \Magento\Backend\Model\Config\Backend\Currency\Allow
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php
index 789668c27946a958f783351814a78c7a11a15125..7a593da5a4452444eb025a3782645738a24604f4 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Base.php
@@ -30,12 +30,12 @@
  */
 namespace Magento\Backend\Model\Config\Backend\Currency;
 
-class Base extends \Magento\Backend\Model\Config\Backend\Currency\AbstractCurrency
+class Base extends AbstractCurrency
 {
     /**
      * Check base currency is available in installed currencies
      *
-     * @return \Magento\Backend\Model\Config\Backend\Currency\Base
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php
index 3e6f042ea97c0f130cfa46fdcaa53c131733e3ed..74e69679fa51c73f3ccc99dbc904ab686030e9c1 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php
@@ -31,7 +31,7 @@ namespace Magento\Backend\Model\Config\Backend\Currency;
 
 class Cron extends \Magento\Core\Model\Config\Value
 {
-    const CRON_STRING_PATH = 'crontab/jobs/currency_rates_update/schedule/cron_expr';
+    const CRON_STRING_PATH = 'crontab/default/jobs/currency_rates_update/schedule/cron_expr';
 
     /**
      * @var \Magento\Core\Model\Config\ValueFactory
@@ -62,6 +62,10 @@ class Cron extends \Magento\Core\Model\Config\Value
         parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return void
+     * @throws \Exception
+     */
     protected function _afterSave()
     {
         $time = $this->getData('groups/import/fields/time/value');
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php
index a5834ee5623570f186d38af122a4016d51262e4b..1822c25933f9ceb7f24276c4f29a9ca8819483ff 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/DefaultCurrency.php
@@ -30,14 +30,13 @@
  */
 namespace Magento\Backend\Model\Config\Backend\Currency;
 
-class DefaultCurrency
-    extends \Magento\Backend\Model\Config\Backend\Currency\AbstractCurrency
+class DefaultCurrency extends AbstractCurrency
 {
     /**
      * Check default currency is available in installed currencies
      * Check default currency is available in allowed currencies
      *
-     * @return \Magento\Backend\Model\Config\Backend\Currency\DefaultCurrency
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Datashare.php b/app/code/Magento/Backend/Model/Config/Backend/Datashare.php
index 3ab1d8f886cb09756a3e69d130befaf86b279e35..840db1f7e83bcb5e1a0e9f9e1ddf5c61b5f504bc 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Datashare.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Datashare.php
@@ -35,6 +35,9 @@ namespace Magento\Backend\Model\Config\Backend;
 
 class Datashare extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @return void
+     */
     protected function _afterSave()
     {
     }
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Design/Exception.php b/app/code/Magento/Backend/Model/Config/Backend/Design/Exception.php
index 8728d80e7561309c5428086be7170ea83ed777d4..9b0ff509aa1fe2a5ef7450bce08d7a6eb082c132 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Design/Exception.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Design/Exception.php
@@ -29,5 +29,8 @@ namespace Magento\Backend\Model\Config\Backend\Design;
 class Exception
     extends \Magento\Backend\Model\Config\Backend\Serialized\ArraySerialized
 {
+    /**
+     * @var string
+     */
     protected $_eventPrefix = 'core_config_backend_design_exception';
 }
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php b/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php
index c713b9f48594a9381d79ceac1f158eebf495035b..e288b41aa8a9ea40a39f11d2429fa5104b1c1e26 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Email/Address.php
@@ -29,13 +29,19 @@
  */
 namespace Magento\Backend\Model\Config\Backend\Email;
 
+use Magento\Core\Exception;
+
 class Address extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @return $this
+     * @throws Exception
+     */
     protected function _beforeSave()
     {
         $value = $this->getValue();
         if (!\Zend_Validate::is($value, 'EmailAddress')) {
-            throw new \Magento\Core\Exception(
+            throw new Exception(
                 __('Please correct the email address: "%1".', $value)
             );
         }
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Email/Logo.php b/app/code/Magento/Backend/Model/Config/Backend/Email/Logo.php
index 1e93d7b3bd323e644a0ea3a1e13d17cb8fe63ae1..d001dde5fc2cdb184ea7c86da38f3851e99aeee2 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Email/Logo.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Email/Logo.php
@@ -72,7 +72,7 @@ class Logo extends \Magento\Backend\Model\Config\Backend\Image
      *
      * Save changes and delete file if "delete" option passed
      *
-     * @return \Magento\Backend\Model\Config\Backend\Email\Logo
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php b/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php
index 36f860a2670fa82a2955a516813cdf43790ee6c1..7c762b7f218646fa74c40e6a3e917edee8935091 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Email/Sender.php
@@ -34,7 +34,7 @@ class Sender extends \Magento\Core\Model\Config\Value
     /**
      * Check sender name validity
      *
-     * @return \Magento\Backend\Model\Config\Backend\Email\Sender
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php
index a0dd946444fdbfa5a923319859d157b29cb843eb..2f052eeef072164c0e3eba17db5beb00e6dd039b 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php
@@ -63,7 +63,7 @@ class Encrypted
     /**
      * Magic method called during class serialization
      *
-     * @return array
+     * @return string[]
      */
     public function __sleep()
     {
@@ -73,6 +73,8 @@ class Encrypted
 
     /**
      * Magic method called during class un-serialization
+     *
+     * @return void
      */
     public function __wakeup()
     {
@@ -84,6 +86,7 @@ class Encrypted
     /**
      * Decrypt value after loading
      *
+     * @return void
      */
     protected function _afterLoad()
     {
@@ -96,6 +99,7 @@ class Encrypted
     /**
      * Encrypt value before saving
      *
+     * @return void
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/File.php b/app/code/Magento/Backend/Model/Config/Backend/File.php
index c5f3d1f61ce304f3dffd67cde8a76d9066d3dd83..78c9a5ef6b25d334e543dca50783604881a17dac 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/File.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/File.php
@@ -94,7 +94,7 @@ class File extends \Magento\Core\Model\Config\Value
     /**
      * Save uploaded file before saving config value
      *
-     * @return \Magento\Backend\Model\Config\Backend\File
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeSave()
@@ -143,6 +143,7 @@ class File extends \Magento\Core\Model\Config\Value
      * Validation callback for checking max file size
      *
      * @param  string $filePath Path to temporary uploaded file
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function validateMaxSize($filePath)
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Filename.php b/app/code/Magento/Backend/Model/Config/Backend/Filename.php
index 76cf5974294d511ad1717e28cb5335189f48d2e8..02e90b75d79c77df03b8db86bc53b3450759c894 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Filename.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Filename.php
@@ -27,6 +27,9 @@ namespace Magento\Backend\Model\Config\Backend;
 
 class Filename extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @return $this
+     */
     protected function _beforeSave()
     {
         $value = $this->getValue();
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image.php b/app/code/Magento/Backend/Model/Config/Backend/Image.php
index 97d805107dd0bdbfb64490db81b5063083fb66dd..0f50695cf083dbca794cdd08097c5833906b026a 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Image.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Image.php
@@ -29,12 +29,12 @@
  */
 namespace Magento\Backend\Model\Config\Backend;
 
-class Image extends \Magento\Backend\Model\Config\Backend\File
+class Image extends File
 {
     /**
      * Getter for allowed extensions of uploaded files
      *
-     * @return array
+     * @return string[]
      */
     protected function _getAllowedExtensions()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php b/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php
index 70df22d778e19bdbe7a7b696f8562b0ad135ecc4..ec2216bebc15bbbd6e85581105641259f5adce91 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php
@@ -76,7 +76,7 @@ class Adapter extends \Magento\Core\Model\Config\Value
     /**
      * Checks if chosen image adapter available
      *
-     * @throws \Magento\Core\Exception if some of adapter dipendencies was not loaded
+     * @throws \Magento\Core\Exception If some of adapter dependencies was not loaded
      * @return \Magento\Backend\Model\Config\Backend\File
      */
     protected function _beforeSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php b/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php
index d2eb248eae7798af52fa7c3dbbd933ea547bcb9f..7ba10cef12b183a7e4390c807497091594d71b9f 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Favicon.php
@@ -61,7 +61,7 @@ class Favicon extends \Magento\Backend\Model\Config\Backend\Image
     /**
      * Getter for allowed extensions of uploaded files.
      *
-     * @return array
+     * @return string[]
      */
     protected function _getAllowedExtensions()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image/Pdf.php b/app/code/Magento/Backend/Model/Config/Backend/Image/Pdf.php
index 26ee7577569f4cc7f7184a5129a2fb45596407a9..069ef5350cd7c25198fd8d64304a462286f19754 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Image/Pdf.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Pdf.php
@@ -36,6 +36,9 @@ namespace Magento\Backend\Model\Config\Backend\Image;
 
 class Pdf extends \Magento\Backend\Model\Config\Backend\Image
 {
+    /**
+     * @return string[]
+     */
     protected function _getAllowedExtensions()
     {
         return array('tif', 'tiff', 'png', 'jpg', 'jpe', 'jpeg');
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Locale.php b/app/code/Magento/Backend/Model/Config/Backend/Locale.php
index 5bf74b97a74479b2c74b9fac654db0386e16bc88..1942420a94a33d78f3ae0e34e3c3f0b4ed2392a7 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Locale.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Locale.php
@@ -87,7 +87,7 @@ class Locale extends \Magento\Core\Model\Config\Value
     }
 
     /**
-     * @return \Magento\Backend\Model\Config\Backend\Locale
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php b/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php
index 2e3a7120b43fcf7462158be2ac19745ea41be44e..d597f97925dd3afd570bd944f3b7cbcfb73ca3c9 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Locale/Timezone.php
@@ -29,12 +29,18 @@
  */
 namespace Magento\Backend\Model\Config\Backend\Locale;
 
+use Magento\Core\Exception;
+
 class Timezone extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @return $this
+     * @throws Exception
+     */
     protected function _beforeSave()
     {
         if (!in_array($this->getValue(), \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC))) {
-            throw new \Magento\Core\Exception(__('Please correct the timezone.'));
+            throw new Exception(__('Please correct the timezone.'));
         }
         return $this;
     }
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php b/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php
index 61897521bc82fe4d25ffe331bce335562041dce3..706b9915b1171fe396566c2596dc3814b7fc3215 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php
@@ -31,8 +31,8 @@ namespace Magento\Backend\Model\Config\Backend\Log;
 
 class Cron extends \Magento\Core\Model\Config\Value
 {
-    const CRON_STRING_PATH  = 'crontab/jobs/log_clean/schedule/cron_expr';
-    const CRON_MODEL_PATH   = 'crontab/jobs/log_clean/run/model';
+    const CRON_STRING_PATH  = 'crontab/default/jobs/log_clean/schedule/cron_expr';
+    const CRON_MODEL_PATH   = 'crontab/default/jobs/log_clean/run/model';
 
     /**
      * @var \Magento\Core\Model\Config\ValueFactory
@@ -74,7 +74,7 @@ class Cron extends \Magento\Core\Model\Config\Value
     /**
      * Cron settings after save
      *
-     * @return \Magento\Backend\Model\Config\Backend\Log\Cron
+     * @return void
      * @throws \Magento\Core\Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Secure.php b/app/code/Magento/Backend/Model/Config/Backend/Secure.php
index c8438f0d7f650383cebca47bbfed4cf84aefa604..9df57bb89290fed4fb6bcf79b92befb0a41da55a 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Secure.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Secure.php
@@ -64,6 +64,8 @@ class Secure extends \Magento\Core\Model\Config\Value
 
     /**
      * Clean compiled JS/CSS when updating configuration settings
+     *
+     * @return void
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Serialized.php b/app/code/Magento/Backend/Model/Config/Backend/Serialized.php
index 18309c976f7526a022d5c91d8f5d1a21b83a307f..f07f2d3207ac539284789fc73f8ccfc648a7b90c 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Serialized.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Serialized.php
@@ -28,6 +28,9 @@ namespace Magento\Backend\Model\Config\Backend;
 
 class Serialized extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @return void
+     */
     protected function _afterLoad()
     {
         if (!is_array($this->getValue())) {
@@ -36,6 +39,9 @@ class Serialized extends \Magento\Core\Model\Config\Value
         }
     }
 
+    /**
+     * @return void
+     */
     protected function _beforeSave()
     {
         if (is_array($this->getValue())) {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Serialized/ArraySerialized.php b/app/code/Magento/Backend/Model/Config/Backend/Serialized/ArraySerialized.php
index 982428235d710fbe35ce1152902b06c9865040ab..b7356bbda9f1ec861cf146bf8ecd0a87160f3ce3 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Serialized/ArraySerialized.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Serialized/ArraySerialized.php
@@ -35,6 +35,7 @@ class ArraySerialized extends \Magento\Backend\Model\Config\Backend\Serialized
     /**
      * Unset array element with '__empty' key
      *
+     * @return void
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php b/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php
index 459d4dd18d9f3f118ddd7fad170bdf468fd4b538..afa74d82e774fd09dde5e1029a28d55da1f803b4 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php
@@ -63,7 +63,7 @@ class Database extends \Magento\Core\Model\Config\Value
     /**
      * Create db structure
      *
-     * @return \Magento\Backend\Model\Config\Backend\Storage\Media\Database
+     * @return $this
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Store.php b/app/code/Magento/Backend/Model/Config/Backend/Store.php
index f7dbf51cd358f6a72c18c38245cf07e7c9199298..4460606164d9ee40c320708349d1216079e7e352 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Store.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Store.php
@@ -31,6 +31,9 @@ namespace Magento\Backend\Model\Config\Backend;
 
 class Store extends \Magento\Core\Model\Config\Value
 {
+    /**
+     * @return void
+     */
     protected function _afterSave()
     {
         $this->_storeManager->getStore()->setConfig(\Magento\Core\Model\Store::XML_PATH_STORE_IN_URL, $this->getValue());
diff --git a/app/code/Magento/Backend/Model/Config/Backend/Translate.php b/app/code/Magento/Backend/Model/Config/Backend/Translate.php
index 52d1217bde88e705c262106f4d881e3a2c7a671c..d4a7279d46077407deeb15afb1696ca4f33648a5 100644
--- a/app/code/Magento/Backend/Model/Config/Backend/Translate.php
+++ b/app/code/Magento/Backend/Model/Config/Backend/Translate.php
@@ -90,7 +90,7 @@ class Translate extends \Magento\Core\Model\Config\Value
     /**
      * Set status 'invalidate' for blocks and other output caches
      *
-     * @return \Magento\Backend\Model\Config\Backend\Translate
+     * @return $this
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Backend/Model/Config/CommentFactory.php b/app/code/Magento/Backend/Model/Config/CommentFactory.php
index 30e1049ccfb6ce8e90fcab6bf36da1b76de7f9f8..48422cc356163b9568721d9af5e6d462c07b6ef2 100644
--- a/app/code/Magento/Backend/Model/Config/CommentFactory.php
+++ b/app/code/Magento/Backend/Model/Config/CommentFactory.php
@@ -48,13 +48,13 @@ class CommentFactory
      * Create new config object
      *
      * @param string $type
-     * @return \Magento\Backend\Model\Config\CommentInterface
+     * @return CommentInterface
      * @throws \InvalidArgumentException
      */
     public function create($type)
     {
         $commentModel = $this->_objectManager->create($type);
-        if (!$commentModel instanceof \Magento\Backend\Model\Config\CommentInterface) {
+        if (!$commentModel instanceof CommentInterface) {
             throw new \InvalidArgumentException('Incorrect comment model provided');
         }
         return $commentModel;
diff --git a/app/code/Magento/Backend/Model/Config/CommentInterface.php b/app/code/Magento/Backend/Model/Config/CommentInterface.php
index 9358fe525a52af928fa4d140251eec24e79a543b..6cf25e9d5174eee2699e84dd2c3e0468bec175f1 100644
--- a/app/code/Magento/Backend/Model/Config/CommentInterface.php
+++ b/app/code/Magento/Backend/Model/Config/CommentInterface.php
@@ -33,7 +33,7 @@ interface CommentInterface
 {
     /**
      * Retrieve element comment by element value
-     * @param mixed $elementValue
+     * @param string $elementValue
      * @return string
      */
     public function getCommentText($elementValue);
diff --git a/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php b/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php
index e312cd705fe458ef7aa39e2cea6a58a1cb3b5c51..b646800c5c45277b1403c0dae7714bf75ef82b8e 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Admin system config sturtup page
+ * Admin system config startup page
  *
  * Magento
  *
@@ -51,6 +51,9 @@ class Page implements \Magento\Core\Model\Option\ArrayInterface
         $this->_iteratorFactory = $iteratorFactory;
     }
 
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         $options = array();
@@ -74,9 +77,10 @@ class Page implements \Magento\Core\Model\Option\ArrayInterface
     /**
      * Create options array
      *
-     * @param array $optionArray
+     * @param array &$optionArray
      * @param \Magento\Backend\Model\Menu $menu
      * @param int $level
+     * @return void
      */
     protected function _createOptions(&$optionArray, \Magento\Backend\Model\Menu $menu, $level = 0)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Source/Date/Short.php b/app/code/Magento/Backend/Model/Config/Source/Date/Short.php
index 21ecb6378d5dc3d8798dcc67747c2c7cbe01683a..7ba4596e0c0cff731254f74d4d29076622047dc9 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Date/Short.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Date/Short.php
@@ -29,6 +29,9 @@ namespace Magento\Backend\Model\Config\Source\Date;
 
 class Short implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         $arr = array();
diff --git a/app/code/Magento/Backend/Model/Config/Source/Design/Robots.php b/app/code/Magento/Backend/Model/Config/Source/Design/Robots.php
index bb1a67a6244382d8475e03628cb04aec5a7c6d65..d879e4fee49c0478df0e156f3d163ba85dab2c80 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Design/Robots.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Design/Robots.php
@@ -29,6 +29,9 @@ namespace Magento\Backend\Model\Config\Source\Design;
 
 class Robots implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Dev/Dbautoup.php b/app/code/Magento/Backend/Model/Config/Source/Dev/Dbautoup.php
index 229e771d27a245cb15ade21f52ad90b40a4bf703..26b2b3bc53399eb4d437bdba52f5f986c33859e3 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Dev/Dbautoup.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Dev/Dbautoup.php
@@ -27,6 +27,9 @@ namespace Magento\Backend\Model\Config\Source\Dev;
 
 class Dbautoup implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Email/Method.php b/app/code/Magento/Backend/Model/Config/Source/Email/Method.php
index 731e611eca15a0664f71eb11f79335febc9302ee..a6c569ecaa57f04bb3adaeaa39bf290e2c1e4209 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Email/Method.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Email/Method.php
@@ -36,6 +36,9 @@ namespace Magento\Backend\Model\Config\Source\Email;
 
 class Method implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         $options    = array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Email/Smtpauth.php b/app/code/Magento/Backend/Model/Config/Source/Email/Smtpauth.php
index 01949f5fbce4333e783a0bb70b571945cc67efc6..5706498c3cb11bf37c56603c98f0c5d0e51733e2 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Email/Smtpauth.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Email/Smtpauth.php
@@ -29,6 +29,9 @@ namespace Magento\Backend\Model\Config\Source\Email;
 
 class Smtpauth implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Enabledisable.php b/app/code/Magento/Backend/Model/Config/Source/Enabledisable.php
index b35d1e9844f9108e2b44a322698e06b42c051625..3e5ec55f7edb01b88c319b05dda81f5391443e84 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Enabledisable.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Enabledisable.php
@@ -29,6 +29,9 @@ namespace Magento\Backend\Model\Config\Source;
 
 class Enabledisable implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Nooptreq.php b/app/code/Magento/Backend/Model/Config/Source/Nooptreq.php
index c90aa2da21e5e265455e5095160623f7ddbdf3c9..14772971f7acedca2dfd746cdb4a1f1e2a95e22f 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Nooptreq.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Nooptreq.php
@@ -27,6 +27,9 @@ namespace Magento\Backend\Model\Config\Source;
 
 class Nooptreq implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Reports/Scope.php b/app/code/Magento/Backend/Model/Config/Source/Reports/Scope.php
index 6e5ccb0b5c279a62fda62eb3981771d84b4bb6ea..c5cb584099ec30fddf953b7e059469dbd6a3875d 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Reports/Scope.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Reports/Scope.php
@@ -37,6 +37,8 @@ class Scope implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
      * Scope filter
+     *
+     * @return array
      */
     public function toOptionArray()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php b/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php
index 415fcfd1a80a06b09e07c20ce34389d29b2aa1cf..3ac0d9dec465420affbafd8fb622247d01811bcb 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php
@@ -29,17 +29,19 @@
  */
 namespace Magento\Backend\Model\Config\Source\Storage\Media;
 
+use Magento\App\Arguments;
+
 class Database implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
-     * @var \Magento\App\Arguments
+     * @var Arguments
      */
     protected $_arguments;
 
     /**
-     * @param \Magento\App\Arguments
+     * @param Arguments $arguments
      */
-    public function __construct(\Magento\App\Arguments $arguments)
+    public function __construct(Arguments $arguments)
     {
         $this->_arguments = $arguments;
     }
diff --git a/app/code/Magento/Backend/Model/Config/Source/Web/Protocol.php b/app/code/Magento/Backend/Model/Config/Source/Web/Protocol.php
index ac3885bbaeaa404315161e00b6d34406fa6e6085..fd24b6b35765ec22ec86b8f0781609ed19c085ea 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Web/Protocol.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Web/Protocol.php
@@ -27,7 +27,9 @@ namespace Magento\Backend\Model\Config\Source\Web;
 
 class Protocol implements \Magento\Core\Model\Option\ArrayInterface
 {
-
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Web/Redirect.php b/app/code/Magento/Backend/Model/Config/Source/Web/Redirect.php
index 5249d6eafbb48966e3a4480e579b99e6ab9cca29..74d9b74af715f8431a78768fc9d8a30817de4bc8 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Web/Redirect.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Web/Redirect.php
@@ -27,7 +27,9 @@ namespace Magento\Backend\Model\Config\Source\Web;
 
 class Redirect implements \Magento\Core\Model\Option\ArrayInterface
 {
-
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Backend/Model/Config/Source/Website/OptionHash.php b/app/code/Magento/Backend/Model/Config/Source/Website/OptionHash.php
index 0f23519fab5947a8aa33e4d4aacf07366ec531cc..6800391e71c48fc3625209082cb77a5728f32be4 100644
--- a/app/code/Magento/Backend/Model/Config/Source/Website/OptionHash.php
+++ b/app/code/Magento/Backend/Model/Config/Source/Website/OptionHash.php
@@ -26,20 +26,22 @@
 
 namespace Magento\Backend\Model\Config\Source\Website;
 
+use Magento\Core\Model\System\Store;
+
 class OptionHash
     implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
      * System Store Model
      *
-     * @var \Magento\Core\Model\System\Store
+     * @var Store
      */
     protected $_systemStore;
 
     /**
-     * @param \Magento\Core\Model\System\Store
+     * @param Store $systemStore
      */
-    public function __construct(\Magento\Core\Model\System\Store $systemStore)
+    public function __construct(Store $systemStore)
     {
         $this->_systemStore = $systemStore;
     }
diff --git a/app/code/Magento/Backend/Model/Config/Structure.php b/app/code/Magento/Backend/Model/Config/Structure.php
index 2973466bd19153a125609f8d152ff03639ff1dca..419d8f8660d58d7576fe1cfe8fb9859f70c0599b 100644
--- a/app/code/Magento/Backend/Model/Config/Structure.php
+++ b/app/code/Magento/Backend/Model/Config/Structure.php
@@ -60,7 +60,7 @@ class Structure implements \Magento\Backend\Model\Config\Structure\SearchInterfa
     /**
      * Provider of current config scope
      *
-     * @var \Magento\Backend\Model\Config\ScopeDefiner
+     * @var ScopeDefiner
      */
     protected $_scopeDefiner;
 
@@ -75,13 +75,13 @@ class Structure implements \Magento\Backend\Model\Config\Structure\SearchInterfa
      * @param \Magento\Backend\Model\Config\Structure\Data $structureData
      * @param \Magento\Backend\Model\Config\Structure\Element\Iterator\Tab $tabIterator
      * @param \Magento\Backend\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory
-     * @param \Magento\Backend\Model\Config\ScopeDefiner $scopeDefiner
+     * @param ScopeDefiner $scopeDefiner
      */
     public function __construct(
         \Magento\Backend\Model\Config\Structure\Data $structureData,
         \Magento\Backend\Model\Config\Structure\Element\Iterator\Tab $tabIterator,
         \Magento\Backend\Model\Config\Structure\Element\FlyweightFactory $flyweightFactory,
-        \Magento\Backend\Model\Config\ScopeDefiner $scopeDefiner
+        ScopeDefiner $scopeDefiner
     ) {
         $this->_data = $structureData->get();
         $this->_tabIterator = $tabIterator;
@@ -136,7 +136,7 @@ class Structure implements \Magento\Backend\Model\Config\Structure\SearchInterfa
     /**
      * Find element by path parts
      *
-     * @param array $pathParts
+     * @param string[] $pathParts
      * @return \Magento\Backend\Model\Config\Structure\ElementInterface|null
      */
     public function getElementByPathParts(array $pathParts)
@@ -164,7 +164,7 @@ class Structure implements \Magento\Backend\Model\Config\Structure\SearchInterfa
     /**
      * Create empty element data
      *
-     * @param array $pathParts
+     * @param string[] $pathParts
      * @return array
      */
     protected function _createEmptyElement(array $pathParts)
diff --git a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php
index 578732088e1c97934942237cdae239a15839fb70..3ae346c0a6b4cf8775b12497ec5417ea786c8c9e 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php
@@ -26,8 +26,9 @@
 
 namespace Magento\Backend\Model\Config\Structure;
 
-abstract class AbstractElement
-    implements \Magento\Backend\Model\Config\Structure\ElementInterface
+use Magento\Core\Model\StoreManagerInterface;
+
+abstract class AbstractElement implements ElementInterface
 {
     /**
      * Element data
@@ -46,14 +47,14 @@ abstract class AbstractElement
     /**
      * Store manager
      *
-     * @var \Magento\Core\Model\StoreManagerInterface
+     * @var StoreManagerInterface
      */
     protected $_storeManager;
 
     /**
-     * @param \Magento\Core\Model\StoreManagerInterface
+     * @param StoreManagerInterface $storeManager
      */
-    public function __construct(\Magento\Core\Model\StoreManagerInterface $storeManager)
+    public function __construct(StoreManagerInterface $storeManager)
     {
         $this->_storeManager = $storeManager;
     }
@@ -77,6 +78,7 @@ abstract class AbstractElement
      *
      * @param array $data
      * @param string $scope
+     * @return void
      */
     public function setData(array $data, $scope)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/AbstractMapper.php b/app/code/Magento/Backend/Model/Config/Structure/AbstractMapper.php
index 2e9d205ff8b9dea33704ccc48a56513ca94747a0..e45f0d283d60904302f042e785b6edb96bbfc231 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/AbstractMapper.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/AbstractMapper.php
@@ -29,8 +29,7 @@
  */
 namespace Magento\Backend\Model\Config\Structure;
 
-abstract class AbstractMapper
-    implements \Magento\Backend\Model\Config\Structure\MapperInterface
+abstract class AbstractMapper implements MapperInterface
 {
     /**
      * Check value existence
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Converter.php b/app/code/Magento/Backend/Model/Config/Structure/Converter.php
index 6f96bfea18cbb2b1cdfcdb646c22bd93e2f60e29..5858c2545cda8054ac296a519a683c6d2dabae09 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Converter.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Converter.php
@@ -36,7 +36,7 @@ class Converter implements \Magento\Config\ConverterInterface
     /**
      * Mapper type list
      *
-     * @var array
+     * @var string[]
      */
     protected $_mapperList = array(
         \Magento\Backend\Model\Config\Structure\Mapper\Factory::MAPPER_EXTENDS,
@@ -72,7 +72,7 @@ class Converter implements \Magento\Config\ConverterInterface
     /**
      * Convert dom document
      *
-     * @param mixed $source
+     * @param \DOMNode $source
      * @return array
      */
     public function convert($source)
@@ -80,7 +80,7 @@ class Converter implements \Magento\Config\ConverterInterface
         $result = $this->_convertDOMDocument($source);
 
         foreach ($this->_mapperList as $type) {
-            /** @var $mapper \Magento\Backend\Model\Config\Structure\MapperInterface */
+            /** @var $mapper MapperInterface */
             $mapper = $this->_mapperFactory->create($type);
             $result = $mapper->map($result);
         }
@@ -92,7 +92,7 @@ class Converter implements \Magento\Config\ConverterInterface
      * Retrieve \DOMDocument as array
      *
      * @param \DOMNode $root
-     * @return mixed
+     * @return array|null
      */
     protected function _convertDOMDocument(\DOMNode $root)
     {
@@ -166,8 +166,7 @@ class Converter implements \Magento\Config\ConverterInterface
      * @param array $convertedChild
      * @param array $result
      * @param string $childName
-     *
-     * @return mixed
+     * @return array
      */
     protected function _addProcessedNode($convertedChild, $result, $childName)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Data.php b/app/code/Magento/Backend/Model/Config/Structure/Data.php
index 8901da28eef745719aef8220fe4ec7cb1b2d17df..25d5b027f031107a18261fcf866262ca304bbcba 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Data.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Data.php
@@ -26,13 +26,13 @@ namespace Magento\Backend\Model\Config\Structure;
 class Data extends \Magento\Config\Data\Scoped
 {
     /**
-     * @param \Magento\Backend\Model\Config\Structure\Reader $reader
+     * @param Reader $reader
      * @param \Magento\Config\ScopeInterface $configScope
      * @param \Magento\Config\CacheInterface $cache
-     * @param $cacheId
+     * @param string $cacheId
      */
     public function __construct(
-        \Magento\Backend\Model\Config\Structure\Reader $reader,
+        Reader $reader,
         \Magento\Config\ScopeInterface $configScope,
         \Magento\Config\CacheInterface $cache,
         $cacheId
@@ -44,6 +44,7 @@ class Data extends \Magento\Config\Data\Scoped
      * Merge additional config
      *
      * @param array $config
+     * @return void
      */
     public function merge(array $config)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php
index 09b1a7397d17078d1b319a00bf7abddc4f6eef8f..0cf8cff5d436becb24e5013d9d881ba75f4ae94f 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php
@@ -32,17 +32,17 @@ abstract class AbstractComposite
     /**
      * Child elements iterator
      *
-     * @var \Magento\Backend\Model\Config\Structure\Element\Iterator
+     * @var Iterator
      */
     protected $_childrenIterator;
 
     /**
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator
+     * @param Iterator $childrenIterator
      */
     public function __construct(
         \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator
+        Iterator $childrenIterator
     ) {
         parent::__construct($storeManager);
         $this->_childrenIterator = $childrenIterator;
@@ -53,6 +53,7 @@ abstract class AbstractComposite
      *
      * @param array $data
      * @param string $scope
+     * @return void
      */
     public function setData(array $data, $scope)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Field.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Field.php
index 46174a8a0729fff2847aa256f7bb28d843d6b7e4..d72c9cf5ed36d90be8680bdf082027ac6868ccbe 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Field.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Field.php
@@ -31,7 +31,7 @@ class Field
     /**
      * Values for dependence
      *
-     * @var array
+     * @var string[]
      */
     protected $_values;
 
@@ -91,7 +91,7 @@ class Field
     /**
      * Get values for dependence
      *
-     * @return array
+     * @return string[]
      */
     public function getValues()
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/FieldFactory.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/FieldFactory.php
index 5285a2a51ff1717adf197c83ae3256944bf6d516..e17200aa541b33cb89057b3f1cf53df606ebff13 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/FieldFactory.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/FieldFactory.php
@@ -45,7 +45,7 @@ class FieldFactory
      * Create dependency field model instance.
      *
      * @param array $arguments
-     * @return \Magento\Backend\Model\Config\Structure\Element\Dependency\Field
+     * @return Field
      */
     public function create(array $arguments = array())
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php
index 75db42e38bf6fba5b0d7c2804712ff81694dcc43..3d70101ee66d76d81ca515906d9cef29b8d68287 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php
@@ -38,7 +38,7 @@ class Mapper
     /**
      * Dependency Field model
      *
-     * @var \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory
+     * @var FieldFactory
      */
     protected $_fieldFactory;
 
@@ -52,12 +52,12 @@ class Mapper
     /**
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Backend\Model\Config\Structure\SearchInterface $fieldLocator
-     * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory
+     * @param FieldFactory $fieldFactory
      */
     public function __construct(
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Backend\Model\Config\Structure\SearchInterface $fieldLocator,
-        \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory
+        FieldFactory $fieldFactory
     ) {
 
         $this->_fieldLocator = $fieldLocator;
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php
index 12cb2e6f6ac883cdbe96ec93c126e6a7533e3031..055a8725b3b6a8de93de67bd2461a2d2b8382ab4 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php
@@ -171,7 +171,7 @@ class Field
      *
      * @param string $fieldPrefix
      * @param string $elementType
-     * @return array
+     * @return string[]
      */
     protected function _getRequiredElements($fieldPrefix = '', $elementType = 'group')
     {
@@ -192,7 +192,7 @@ class Field
      * Get required groups paths for the field
      *
      * @param string $fieldPrefix
-     * @return array
+     * @return string[]
      */
     public function getRequiredGroups($fieldPrefix = '')
     {
@@ -204,7 +204,7 @@ class Field
      * Get required fields paths for the field
      *
      * @param string $fieldPrefix
-     * @return array
+     * @return string[]
      */
     public function getRequiredFields($fieldPrefix = '')
     {
@@ -306,6 +306,7 @@ class Field
      * Populate form element with field data
      *
      * @param \Magento\Data\Form\Element\AbstractElement $formField
+     * @return void
      */
     public function populateInput($formField)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php
index 5921eb20c1f66290d27842e1cdbd5194aa712d71..23dd72a540ef1a53394792dfa88192e02fc16b5b 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php
@@ -26,8 +26,7 @@
 
 namespace Magento\Backend\Model\Config\Structure\Element;
 
-class Group
-    extends \Magento\Backend\Model\Config\Structure\Element\AbstractComposite
+class Group extends AbstractComposite
 {
     /**
      * Group clone model factory
@@ -87,6 +86,7 @@ class Group
      * Populate form fieldset with group data
      *
      * @param \Magento\Data\Form\Element\Fieldset $fieldset
+     * @return void
      */
     public function populateFieldset(\Magento\Data\Form\Element\Fieldset $fieldset)
     {
@@ -122,7 +122,7 @@ class Group
     /**
      * Retrieve field dependencies
      *
-     * @param $storeCode
+     * @param string $storeCode
      * @return array
      */
     public function getDependencies($storeCode)
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php
index 278afe6247ce597ffb8b70cd8a27cf1c01ab926f..fb8abd5aad87bb457fddf01e8edfe447f52b0153 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group/Proxy.php
@@ -66,6 +66,7 @@ class Proxy
      *
      * @param array $data
      * @param string $scope
+     * @return void
      */
     public function setData(array $data, $scope)
     {
@@ -136,6 +137,8 @@ class Proxy
     /**
      * Check whether element should be displayed
      *
+     * @param string $websiteCode
+     * @param string $storeCode
      * @return bool
      */
     public function isVisible($websiteCode = '', $storeCode = '')
@@ -198,6 +201,7 @@ class Proxy
      * Populate form fieldset with group data
      *
      * @param \Magento\Data\Form\Element\Fieldset $fieldset
+     * @return void
      */
     public function populateFieldset(\Magento\Data\Form\Element\Fieldset $fieldset)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator.php
index f7c6c3b8e4d14af61a64ecad978cca030ae64e63..081c4b36795bb489ae2dd8a3ad8b0e721584e9d0 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator.php
@@ -69,6 +69,7 @@ class Iterator implements \Iterator
      *
      * @param array $elements
      * @param string $scope
+     * @return void
      */
     public function setElements(array $elements, $scope)
     {
@@ -110,6 +111,7 @@ class Iterator implements \Iterator
      * Initialize current flyweight
      *
      * @param array $element
+     * @return void
      */
     protected function _initFlyweight(array $element)
     {
@@ -119,7 +121,7 @@ class Iterator implements \Iterator
     /**
      * Return the key of the current element
      *
-     * @return mixed scalar on success, or null on failure.
+     * @return void
      */
     public function key()
     {
@@ -129,7 +131,7 @@ class Iterator implements \Iterator
     /**
      * Checks if current position is valid
      *
-     * @return boolean The return value will be casted to boolean and then evaluated.
+     * @return bool The return value will be casted to boolean and then evaluated.
      * Returns true on success or false on failure.
      */
     public function valid()
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator/Field.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator/Field.php
index e51f58937c162320cca7d0be9f296ab77e51d684..b456f8b6e8674d465736b1284ac9eb871a91df70 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator/Field.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Iterator/Field.php
@@ -59,6 +59,7 @@ class Field
      * Init current element
      *
      * @param array $element
+     * @return void
      * @throws \LogicException
      */
     protected function _initFlyweight(array $element)
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php
index ba1a3a3584834953e77b09886477d676dac87058..a0642481bcf4da7e6d478ad078c4a02a35195c92 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php
@@ -26,8 +26,7 @@
 
 namespace Magento\Backend\Model\Config\Structure\Element;
 
-class Section
-    extends \Magento\Backend\Model\Config\Structure\Element\AbstractComposite
+class Section extends AbstractComposite
 {
     /**
      * Authorization service
@@ -38,12 +37,12 @@ class Section
 
     /**
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator
+     * @param Iterator $childrenIterator
      * @param \Magento\AuthorizationInterface $authorization
      */
     public function __construct(
         \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator,
+        Iterator $childrenIterator,
         \Magento\AuthorizationInterface $authorization
     ) {
         parent::__construct($storeManager, $childrenIterator);
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Tab.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Tab.php
index 736ea09d365bc3312efede55999897137f86c4af..399a75925ad6919a0491f6676212206c0cfdd335 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Element/Tab.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Tab.php
@@ -26,8 +26,7 @@
 
 namespace Magento\Backend\Model\Config\Structure\Element;
 
-class Tab
-    extends \Magento\Backend\Model\Config\Structure\Element\AbstractComposite
+class Tab extends AbstractComposite
 {
 
     /**
diff --git a/app/code/Magento/Backend/Model/Config/Structure/ElementInterface.php b/app/code/Magento/Backend/Model/Config/Structure/ElementInterface.php
index ea5b095dae43c6827edd325ed2d60bcd439bd8e5..751e471fb3cc8f7297c6f4f9aa836d4a7cb08a29 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/ElementInterface.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/ElementInterface.php
@@ -33,6 +33,7 @@ interface ElementInterface
      *
      * @param array $data
      * @param string $scope
+     * @return void
      */
     public function setData(array $data, $scope);
 
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Mapper/Dependencies.php b/app/code/Magento/Backend/Model/Config/Structure/Mapper/Dependencies.php
index 79d3f7f32899b58071a6abddaf27c2f14b0de99b..9c07402fb7d47487609d9017658ab7741ed4327f 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Mapper/Dependencies.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Mapper/Dependencies.php
@@ -105,7 +105,7 @@ class Dependencies
      *
      * @param array $field
      * @param array $config
-     * @return array
+     * @return string[]
      * @throws \InvalidArgumentException
      */
     protected function _getDependPath($field, $config)
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Mapper/ExtendsMapper.php b/app/code/Magento/Backend/Model/Config/Structure/Mapper/ExtendsMapper.php
index 983d5781aa7bcd1a776c9cc91134570da29113fe..d0fc42c4f79f58a543dcb5f086124b289325d996 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Mapper/ExtendsMapper.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Mapper/ExtendsMapper.php
@@ -42,7 +42,7 @@ class ExtendsMapper
     /**
      * List of already extended notes (used to break circular extends)
      *
-     * @var array
+     * @var string[]
      */
     protected $_extendedNodesList = array();
 
@@ -87,6 +87,7 @@ class ExtendsMapper
      * Recursively traverse through configuration and apply extends
      *
      * @param string $path
+     * @return void
      */
     protected function _traverseAndExtend($path)
     {
@@ -190,6 +191,7 @@ class ExtendsMapper
      *
      * @param string $path
      * @param array $newData
+     * @return void
      */
     protected function _replaceData($path, $newData)
     {
@@ -210,7 +212,7 @@ class ExtendsMapper
      * Transform path to list of keys
      *
      * @param string $path
-     * @return array
+     * @return string[]
      */
     protected function _transformPathToKeysList($path)
     {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Mapper/Factory.php b/app/code/Magento/Backend/Model/Config/Structure/Mapper/Factory.php
index 217f475678b96e2eccc347f8385ae25c4a7d91c8..bc9ff9aaf3ff40f78c246ca394674f778b7fa5e5 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Mapper/Factory.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Mapper/Factory.php
@@ -55,6 +55,9 @@ class Factory
         self::MAPPER_EXTENDS => 'Magento\Backend\Model\Config\Structure\Mapper\ExtendsMapper',
     );
 
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     */
     public function __construct(\Magento\ObjectManager $objectManager)
     {
         $this->_objectManager = $objectManager;
@@ -64,7 +67,6 @@ class Factory
      * Get mapper instance
      *
      * @param string $type
-     * @param array $arguments
      * @return \Magento\Backend\Model\Config\Structure\MapperInterface
      * @throws \Exception
      */
@@ -87,7 +89,7 @@ class Factory
      * Get mapper class name by type
      *
      * @param string $type
-     * @return string mixed
+     * @return string
      * @throws \InvalidArgumentException
      */
     protected function _getMapperClassNameByType($type)
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Mapper/Sorting.php b/app/code/Magento/Backend/Model/Config/Structure/Mapper/Sorting.php
index 6b83f0e29ca4729089d8af0612ed64abd082a779..63646bda41746c6577debe6d3aca4c91553266bd 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Mapper/Sorting.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Mapper/Sorting.php
@@ -46,6 +46,10 @@ class Sorting
         return $data;
     }
 
+    /**
+     * @param array $data
+     * @return array
+     */
     protected function _processConfig($data)
     {
         foreach ($data as &$item) {
diff --git a/app/code/Magento/Backend/Model/Config/Structure/Reader.php b/app/code/Magento/Backend/Model/Config/Structure/Reader.php
index c70db6d1c9f2cc92083a0779402ebc5c9a34d799..69a1b77f06e0bfab7927f03d916d19ee4a40857a 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/Reader.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/Reader.php
@@ -44,7 +44,7 @@ class Reader extends \Magento\Config\Reader\Filesystem
 
     /**
      * @param \Magento\Config\FileResolverInterface $fileResolver
-     * @param \Magento\Backend\Model\Config\Structure\Converter $converter
+     * @param Converter $converter
      * @param \Magento\Backend\Model\Config\SchemaLocator $schemaLocator
      * @param \Magento\Config\ValidationStateInterface $validationState
      * @param string $fileName
@@ -54,7 +54,7 @@ class Reader extends \Magento\Config\Reader\Filesystem
      */
     public function __construct(
         \Magento\Config\FileResolverInterface $fileResolver,
-        \Magento\Backend\Model\Config\Structure\Converter $converter,
+        Converter $converter,
         \Magento\Backend\Model\Config\SchemaLocator $schemaLocator,
         \Magento\Config\ValidationStateInterface $validationState,
         $fileName = 'system.xml',
diff --git a/app/code/Magento/Backend/Model/Config/Structure/SearchInterface.php b/app/code/Magento/Backend/Model/Config/Structure/SearchInterface.php
index 61ec51643ec42d938673a143b4751d3390b57264..4e0b2c80ce9cd95c2a3f6fa2592b0dae600f847b 100644
--- a/app/code/Magento/Backend/Model/Config/Structure/SearchInterface.php
+++ b/app/code/Magento/Backend/Model/Config/Structure/SearchInterface.php
@@ -31,7 +31,7 @@ interface SearchInterface
      * Find element by path
      *
      * @param string $path
-     * @return \Magento\Backend\Model\Config\Structure\ElementInterface|null
+     * @return ElementInterface|null
      */
     public function getElement($path);
 }
diff --git a/app/code/Magento/Backend/Model/Locale.php b/app/code/Magento/Backend/Model/Locale.php
index 121ead615c9b53bd2805b519725bdab26d947b21..6104023ecb5a9fdc4e4820f90cf95a6af6b431e4 100644
--- a/app/code/Magento/Backend/Model/Locale.php
+++ b/app/code/Magento/Backend/Model/Locale.php
@@ -23,14 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model;
 
 /**
  * Backend locale model
  *
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model;
-
 class Locale extends \Magento\Core\Model\Locale
 {
     /**
@@ -109,7 +108,7 @@ class Locale extends \Magento\Core\Model\Locale
      * Set locale
      *
      * @param   string $locale
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  $this
      */
     public function setLocale($locale = null)
     {
diff --git a/app/code/Magento/Backend/Model/Locale/Manager.php b/app/code/Magento/Backend/Model/Locale/Manager.php
index 1351119ee63dd79b9e912f8a090cc6ca74874892..a4c42d6432489c006820f383c0035880692a90bb 100644
--- a/app/code/Magento/Backend/Model/Locale/Manager.php
+++ b/app/code/Magento/Backend/Model/Locale/Manager.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Locale;
 
 /**
  * Locale manager model
@@ -31,8 +32,6 @@
  * @package    Magento_Backend
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Locale;
-
 class Manager
 {
     /**
@@ -71,7 +70,7 @@ class Manager
      * Switch backend locale according to locale code
      *
      * @param string $localeCode
-     * @return \Magento\Backend\Model\Locale\Manager
+     * @return $this
      */
     public function switchBackendInterfaceLocale($localeCode)
     {
diff --git a/app/code/Magento/Backend/Model/Menu.php b/app/code/Magento/Backend/Model/Menu.php
index a6589fc18ebd62e229ecc179f66a9b97e5064ec6..160eea5b90c39d4e4c9a976091a9093dd2e2c0bc 100644
--- a/app/code/Magento/Backend/Model/Menu.php
+++ b/app/code/Magento/Backend/Model/Menu.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model;
 
 /**
  * Backend menu model
  */
-namespace Magento\Backend\Model;
-
 class Menu extends \ArrayObject
 {
     /**
@@ -67,6 +66,7 @@ class Menu extends \ArrayObject
      * @param \Magento\Backend\Model\Menu\Item $item
      * @param string $parentId
      * @param int $index
+     * @return void
      * @throws \InvalidArgumentException
      */
     public function add(\Magento\Backend\Model\Menu\Item $item, $parentId = null, $index = null)
@@ -120,6 +120,7 @@ class Menu extends \ArrayObject
      * @param string $itemId
      * @param string $toItemId
      * @param int $sortIndex
+     * @return void
      * @throws \InvalidArgumentException
      */
     public function move($itemId, $toItemId, $sortIndex = null)
@@ -238,7 +239,7 @@ class Menu extends \ArrayObject
      *
      * @param \Magento\Backend\Model\Menu $menu
      * @param string $itemId
-     * @param array $parents
+     * @param array &$parents
      * @return bool
      */
     protected function _findParentItems($menu, $itemId, &$parents)
diff --git a/app/code/Magento/Backend/Model/Menu/AbstractDirector.php b/app/code/Magento/Backend/Model/Menu/AbstractDirector.php
index 549265bc3ecb5df372c7d4e3c5b48f602a8a4199..a1b3e2222eb7af4a15fc88c90021b908195afca6 100644
--- a/app/code/Magento/Backend/Model/Menu/AbstractDirector.php
+++ b/app/code/Magento/Backend/Model/Menu/AbstractDirector.php
@@ -47,6 +47,7 @@ abstract class AbstractDirector
      * @param array $config
      * @param \Magento\Backend\Model\Menu\Builder $builder
      * @param \Magento\Logger $logger
+     * @return void
      */
     abstract public function direct(
         array $config, \Magento\Backend\Model\Menu\Builder $builder, \Magento\Logger $logger
diff --git a/app/code/Magento/Backend/Model/Menu/Builder.php b/app/code/Magento/Backend/Model/Menu/Builder.php
index b305f4565da497d5a460ad6b7e6887bd70acd2e3..0c4c3444ab6e66288a94d76c580ca08d769d7e82 100644
--- a/app/code/Magento/Backend/Model/Menu/Builder.php
+++ b/app/code/Magento/Backend/Model/Menu/Builder.php
@@ -23,13 +23,12 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu;
 
 /**
  * Menu builder object. Retrieves commands (\Magento\Backend\Model\Menu\Builder\AbstractCommand)
  * to build menu (\Magento\Backend\Model\Menu)
  */
-namespace Magento\Backend\Model\Menu;
-
 class Builder
 {
     /**
@@ -55,7 +54,7 @@ class Builder
      * Process provided command object
      *
      * @param \Magento\Backend\Model\Menu\Builder\AbstractCommand $command
-     * @return \Magento\Backend\Model\Menu\Builder
+     * @return $this
      */
     public function processCommand(\Magento\Backend\Model\Menu\Builder\AbstractCommand $command)
     {
diff --git a/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php b/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php
index d7554c4cb5cdfe955b1a48950fa80a46fe7cad5b..9b521780ecba2fab350dc08df7ff2b67b10ac5dd 100644
--- a/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php
+++ b/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php
@@ -23,18 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Builder;
 
 /**
  * Menu builder command
  */
-namespace Magento\Backend\Model\Menu\Builder;
-
 abstract class AbstractCommand
 {
     /**
      * List of required params
      *
-     * @var array
+     * @var string[]
      */
     protected $_requiredParams = array("id");
 
@@ -80,7 +79,7 @@ abstract class AbstractCommand
      * Add command as last in the list of callbacks
      *
      * @param \Magento\Backend\Model\Menu\Builder\AbstractCommand $command
-     * @return \Magento\Backend\Model\Menu\Builder\AbstractCommand
+     * @return $this
      * @throws \InvalidArgumentException if invalid chaining command is supplied
      */
     public function chain(\Magento\Backend\Model\Menu\Builder\AbstractCommand $command)
diff --git a/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php b/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php
index a470af1bce15398c9266c922f0fc2e382a72012a..3e3255a3a974d2f099274f07f1d63117f8633ccb 100644
--- a/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php
+++ b/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php
@@ -23,18 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Builder\Command;
 
 /**
  * Builder command to add menu items
  */
-namespace Magento\Backend\Model\Menu\Builder\Command;
-
 class Add extends \Magento\Backend\Model\Menu\Builder\AbstractCommand
 {
     /**
      * List of params that command requires for execution
      *
-     * @var array
+     * @var string[]
      */
     protected $_requiredParams = array(
         "id",
@@ -47,7 +46,7 @@ class Add extends \Magento\Backend\Model\Menu\Builder\AbstractCommand
      * Add command as last in the list of callbacks
      *
      * @param \Magento\Backend\Model\Menu\Builder\AbstractCommand $command
-     * @return \Magento\Backend\Model\Menu\Builder\AbstractCommand
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function chain(\Magento\Backend\Model\Menu\Builder\AbstractCommand $command)
diff --git a/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php b/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php
index 032a1bf5db155e1146a7cf062267aad03f67708e..0468fdb1e55ba256c678663b483ea530623d197c 100644
--- a/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php
+++ b/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Builder\Command;
 
 /**
  * Command to remove menu item
  */
-namespace Magento\Backend\Model\Menu\Builder\Command;
-
 class Remove extends \Magento\Backend\Model\Menu\Builder\AbstractCommand
 {
     /**
diff --git a/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php b/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php
index acb52c23ade2660aab03092196cbf728b13fdccb..2aa613ad8ad5d410581e3ec530cd56a3ddc521d5 100644
--- a/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php
+++ b/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Builder\Command;
 
 /**
  * Command to update menu item data
  */
-namespace Magento\Backend\Model\Menu\Builder\Command;
-
 class Update extends \Magento\Backend\Model\Menu\Builder\AbstractCommand
 {
     /**
diff --git a/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php b/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php
index 2dc8e2797583c63b3cd47c2923d976729ee6346f..68e5bcbd4d82fbd5f6b2bc96c6094eac28b0cf28 100644
--- a/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php
+++ b/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php
@@ -21,12 +21,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Builder;
 
 /**
  * Menu builder command factory
  */
-namespace Magento\Backend\Model\Menu\Builder;
-
 class CommandFactory
 {
     /**
diff --git a/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php b/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php
index 07a7117b3948c91ae5ab18fa7c4768c094a9bc73..ba8b3b6427342ff92cbdf16ba3a5dfa82cb11400 100644
--- a/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php
+++ b/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php
@@ -23,21 +23,19 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Config\Menu;
 
 /**
  * Menu configuration files handler
  */
-namespace Magento\Backend\Model\Menu\Config\Menu;
-
 class Dom extends \Magento\Config\Dom
 {
-
     /**
      * Getter for node by path
      *
      * @param string $nodePath
+     * @return \DOMElement|null
      * @throws \Magento\Exception an exception is possible if original document contains multiple fixed nodes
-     * @return \DOMElement | null
      */
     protected function _getMatchedNode($nodePath)
     {
diff --git a/app/code/Magento/Backend/Model/Menu/Director/Director.php b/app/code/Magento/Backend/Model/Menu/Director/Director.php
index bbfb153f8b054fec5717f92d4daa7d2bd52f3fa8..6edd8cc533f06717cc458be0e44ddbf34b466ad4 100644
--- a/app/code/Magento/Backend/Model/Menu/Director/Director.php
+++ b/app/code/Magento/Backend/Model/Menu/Director/Director.php
@@ -59,6 +59,7 @@ class Director extends \Magento\Backend\Model\Menu\AbstractDirector
      * @param array $config
      * @param \Magento\Backend\Model\Menu\Builder $builder
      * @param \Magento\Logger $logger
+     * @return void
      */
     public function direct(
         array $config,
diff --git a/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php b/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php
index 9ecafedc164350b13e4bcd7b66f8fc7f93abb5bb..06893120c06a489b13f2b7909f1209737c23761d 100644
--- a/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php
+++ b/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu\Filter;
 
 /**
  * Menu filter iterator
  */
-namespace Magento\Backend\Model\Menu\Filter;
-
 class Iterator extends \FilterIterator
 {
     /**
diff --git a/app/code/Magento/Backend/Model/Menu/Item.php b/app/code/Magento/Backend/Model/Menu/Item.php
index d7782fc3abd487bbc502af370a4c281920243236..9d44a404c23b974299fbdf17eb2f9f7886e56702 100644
--- a/app/code/Magento/Backend/Model/Menu/Item.php
+++ b/app/code/Magento/Backend/Model/Menu/Item.php
@@ -207,7 +207,7 @@ class Item
      * Retrieve argument element, or default value
      *
      * @param array $array
-     * @param mixed $key
+     * @param string $key
      * @param mixed $defaultValue
      * @return mixed
      */
@@ -276,7 +276,7 @@ class Item
      * Set Item action
      *
      * @param string $action
-     * @return \Magento\Backend\Model\Menu\Item
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function setAction($action)
@@ -323,7 +323,7 @@ class Item
      * Set Item title
      *
      * @param string $title
-     * @return \Magento\Backend\Model\Menu\Item
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function setTitle($title)
@@ -357,7 +357,7 @@ class Item
      * Set Item tooltip
      *
      * @param string $tooltip
-     * @return \Magento\Backend\Model\Menu\Item
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function setTooltip($tooltip)
@@ -371,7 +371,7 @@ class Item
      * Set Item module
      *
      * @param string $module
-     * @return \Magento\Backend\Model\Menu\Item
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function setModule($module)
@@ -385,7 +385,7 @@ class Item
      * Set Item module dependency
      *
      * @param string $moduleName
-     * @return \Magento\Backend\Model\Menu\Item
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function setModuleDependency($moduleName)
@@ -399,7 +399,7 @@ class Item
      * Set Item config dependency
      *
      * @param string $configPath
-     * @return \Magento\Backend\Model\Menu\Item
+     * @return $this
      * @throws \InvalidArgumentException
      */
     public function setConfigDependency($configPath)
@@ -462,6 +462,9 @@ class Item
         }
     }
 
+    /**
+     * @return string[]
+     */
     public function __sleep()
     {
         if ($this->_submenu) {
@@ -483,6 +486,9 @@ class Item
         );
     }
 
+    /**
+     * @return void
+     */
     public function __wakeup()
     {
         $objectManager = \Magento\App\ObjectManager::getInstance();
diff --git a/app/code/Magento/Backend/Model/Menu/Item/Validator.php b/app/code/Magento/Backend/Model/Menu/Item/Validator.php
index 05735f38fc647c66a53fbe2fbc517c7072d76d7d..d4d1a39ea0bf866b0dd333c934a03af1b4325c39 100644
--- a/app/code/Magento/Backend/Model/Menu/Item/Validator.php
+++ b/app/code/Magento/Backend/Model/Menu/Item/Validator.php
@@ -30,7 +30,7 @@ class Validator
     /**
      * The list of required params
      *
-     * @var array
+     * @var string[]
      */
     protected $_required = array(
         'id', 'title', 'resource'
@@ -79,10 +79,12 @@ class Validator
         $this->_validators['dependsOnConfig'] = $configDepValidator;
         $this->_validators['toolTip'] = $tooltipValidator;
     }
+
     /**
      * Validate menu item params
      *
      * @param $data
+     * @return void
      * @throws \InvalidArgumentException
      * @throws \BadMethodCallException
      */
@@ -117,6 +119,7 @@ class Validator
      *
      * @param string $param
      * @param mixed $value
+     * @return void
      * @throws \InvalidArgumentException
      */
     public function validateParam($param, $value)
diff --git a/app/code/Magento/Backend/Model/Menu/Iterator.php b/app/code/Magento/Backend/Model/Menu/Iterator.php
index e17dc45cd1dd86e3c46b9d67cd0a9426c90b7b92..60fe8561f0f48089f179b04f5ec18378afa6c5ae 100644
--- a/app/code/Magento/Backend/Model/Menu/Iterator.php
+++ b/app/code/Magento/Backend/Model/Menu/Iterator.php
@@ -23,16 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Menu;
 
 /**
  * Menu iterator
  */
-namespace Magento\Backend\Model\Menu;
-
 class Iterator extends \ArrayIterator
 {
     /**
      * Rewind to first element
+     *
+     * @return void
      */
     public function rewind()
     {
diff --git a/app/code/Magento/Backend/Model/Observer.php b/app/code/Magento/Backend/Model/Observer.php
index f336e59f8e1c686dd654be4d9c413f4dc751304f..65c34dcf3551c932b3bf13ac316c38aaaf7ab3d6 100644
--- a/app/code/Magento/Backend/Model/Observer.php
+++ b/app/code/Magento/Backend/Model/Observer.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model;
 
 /**
  * Backend event observer
  */
-namespace Magento\Backend\Model;
-
 class Observer
 {
     /**
@@ -65,7 +64,7 @@ class Observer
      * Bind locale
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Backend\Model\Observer
+     * @return $this
      */
     public function bindLocale($observer)
     {
@@ -82,7 +81,7 @@ class Observer
     /**
      * Clear result of configuration files access level verification in system cache
      *
-     * @return \Magento\Backend\Model\Observer
+     * @return $this
      */
     public function clearCacheConfigurationFilesAccessLevelVerification()
     {
@@ -92,7 +91,7 @@ class Observer
     /**
      * Backend will always use base class for translation.
      *
-     * @return \Magento\Backend\Model\Observer
+     * @return $this
      */
     public function initializeTranslation()
     {
@@ -103,7 +102,7 @@ class Observer
      * Set url class name for store 'admin'
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Backend\Model\Observer
+     * @return $this
      */
     public function setUrlClassName(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Backend/Model/Resource/Translate.php b/app/code/Magento/Backend/Model/Resource/Translate.php
index a6274735dc22ac30d88c54752864a4cc72cecf60..1defebb13dad3286bb3b33028b0f96bcb8da1d99 100644
--- a/app/code/Magento/Backend/Model/Resource/Translate.php
+++ b/app/code/Magento/Backend/Model/Resource/Translate.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Resource;
 
 /**
diff --git a/app/code/Magento/Backend/Model/Resource/Translate/String.php b/app/code/Magento/Backend/Model/Resource/Translate/String.php
index 6ac23a26649d280e174ce82a79404799bc422bd6..44129bdf32438ec0ed119944777122ff9458007d 100644
--- a/app/code/Magento/Backend/Model/Resource/Translate/String.php
+++ b/app/code/Magento/Backend/Model/Resource/Translate/String.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Resource\Translate;
 
 /**
diff --git a/app/code/Magento/Backend/Model/Search/Catalog.php b/app/code/Magento/Backend/Model/Search/Catalog.php
index 8a3929d74fd36d94116c830ebd502ccf7126e70b..3573bf665daf90e66ebd77630054f2304f49aecd 100644
--- a/app/code/Magento/Backend/Model/Search/Catalog.php
+++ b/app/code/Magento/Backend/Model/Search/Catalog.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Search;
 
 /**
@@ -70,7 +69,7 @@ class Catalog extends \Magento\Object
     /**
      * Load search results
      *
-     * @return \Magento\Backend\Model\Search\Catalog
+     * @return $this
      */
     public function load()
     {
diff --git a/app/code/Magento/Backend/Model/Search/Customer.php b/app/code/Magento/Backend/Model/Search/Customer.php
index cf4bd2d1607e23a77ef51f9d2b83fc68064143b2..6c89ea80d5bf738c6e402c08be34a65e89d33c70 100644
--- a/app/code/Magento/Backend/Model/Search/Customer.php
+++ b/app/code/Magento/Backend/Model/Search/Customer.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Search;
 
 /**
  * Search Customer Model
@@ -31,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Search;
-
 class Customer extends \Magento\Object
 {
     /**
@@ -62,7 +61,7 @@ class Customer extends \Magento\Object
     /**
      * Load search results
      *
-     * @return \Magento\Backend\Model\Search\Customer
+     * @return $this
      */
     public function load()
     {
diff --git a/app/code/Magento/Backend/Model/Search/Order.php b/app/code/Magento/Backend/Model/Search/Order.php
index 5ca041f9f8ed979e84d217835d4f9c15b18db723..2c9f2c7fbf0ab59f0d5d473d2e2124bb564b6ca9 100644
--- a/app/code/Magento/Backend/Model/Search/Order.php
+++ b/app/code/Magento/Backend/Model/Search/Order.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Search;
 
 /**
  * Search Order Model
@@ -31,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Search;
-
 class Order extends \Magento\Object
 {
     /**
@@ -62,7 +61,7 @@ class Order extends \Magento\Object
     /**
      * Load search results
      *
-     * @return \Magento\Backend\Model\Search\Order
+     * @return $this
      */
     public function load()
     {
diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php
index 87ac7dd0c9ac1e720bd35a303f4c4912f6006363..7ec28a444022b5cb530d76bebc2f040c45664f69 100644
--- a/app/code/Magento/Backend/Model/Session/Quote.php
+++ b/app/code/Magento/Backend/Model/Session/Quote.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Session;
 
 /**
@@ -153,8 +152,9 @@ class Quote extends \Magento\Session\SessionManager
     /**
      * Set customer model object
      * To enable quick switch of preconfigured customer
+     *
      * @param \Magento\Customer\Model\Customer $customer
-     * @return \Magento\Backend\Model\Session\Quote
+     * @return $this
      */
     public function setCustomer(\Magento\Customer\Model\Customer $customer)
     {
@@ -164,6 +164,7 @@ class Quote extends \Magento\Session\SessionManager
 
     /**
      * Retrieve customer model object
+     *
      * @param bool $forceReload
      * @param bool $useSetStore
      * @return \Magento\Customer\Model\Customer
diff --git a/app/code/Magento/Backend/Model/Translate.php b/app/code/Magento/Backend/Model/Translate.php
index f7fb517bf5fc43637107f33c83d4c458d16e9a18..0e953115385e9eaef5895076b3344dce674ff514 100644
--- a/app/code/Magento/Backend/Model/Translate.php
+++ b/app/code/Magento/Backend/Model/Translate.php
@@ -28,7 +28,7 @@ namespace Magento\Backend\Model;
 class Translate extends \Magento\Translate implements \Magento\TranslateInterface
 {
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function init($area = null, $initParams = null, $forceReload = false)
     {
diff --git a/app/code/Magento/Backend/Model/Translate/Inline.php b/app/code/Magento/Backend/Model/Translate/Inline.php
index 38749aeb07294292f57bc814ba492a05a5230ea2..777d94c75f5f6d4e7e4e6a8e5f48dbbaf4a7e089 100644
--- a/app/code/Magento/Backend/Model/Translate/Inline.php
+++ b/app/code/Magento/Backend/Model/Translate/Inline.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Translate;
 
 /**
  * Inline Translations PHP part
  */
-namespace Magento\Backend\Model\Translate;
-
 class Inline extends \Magento\Translate\Inline
 {
     /**
@@ -44,7 +43,7 @@ class Inline extends \Magento\Translate\Inline
     /**
      * Replace translation templates with HTML fragments
      *
-     * @param array|string $body
+     * @param array|string &$body
      * @param bool $isJson
      * @return $this
      */
diff --git a/app/code/Magento/Backend/Model/Translate/Inline/Config.php b/app/code/Magento/Backend/Model/Translate/Inline/Config.php
index 2b8f33ccdda462ab9e411641024590d5024c3aaf..710f0262034055592e1f35c12b2a7e2c0f1f6732 100644
--- a/app/code/Magento/Backend/Model/Translate/Inline/Config.php
+++ b/app/code/Magento/Backend/Model/Translate/Inline/Config.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Translate\Inline;
 
 /**
  * Backend Inline Translation config
  */
-namespace Magento\Backend\Model\Translate\Inline;
-
 class Config implements \Magento\Translate\Inline\ConfigInterface
 {
     /**
@@ -54,7 +53,7 @@ class Config implements \Magento\Translate\Inline\ConfigInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function isActive($scope = null)
     {
@@ -62,7 +61,7 @@ class Config implements \Magento\Translate\Inline\ConfigInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function isDevAllowed($scope = null)
     {
diff --git a/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php b/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php
index 0ad93428b490a78d633dfca7ff99ca4a5c05d434..41ea96b99747e0f23e3b41b91e149f324cd2e73b 100644
--- a/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php
+++ b/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Translate\Inline;
 
 /**
  * Backend Inline Translation config factory
  */
-namespace Magento\Backend\Model\Translate\Inline;
-
 class ConfigFactory extends \Magento\Translate\Inline\ConfigFactory
 {
     /**
diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php
index ffa5254b2072378515345ca832a5a23d85e045c1..ff7651cae84516e9ead9f9f74b1de6f6b4fe58aa 100644
--- a/app/code/Magento/Backend/Model/Url.php
+++ b/app/code/Magento/Backend/Model/Url.php
@@ -186,7 +186,7 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface
      *
      * @param array $data
      * @param bool $unsetOldParams
-     * @return \Magento\Backend\Model\UrlInterface
+     * @return $this
      */
     protected function _setRouteParams(array $data, $unsetOldParams = true)
     {
@@ -279,7 +279,7 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface
     /**
      * Return secret key settings flag
      *
-     * @return boolean
+     * @return bool
      */
     public function useSecretKey()
     {
@@ -289,7 +289,7 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface
     /**
      * Enable secret key using
      *
-     * @return \Magento\Backend\Model\UrlInterface
+     * @return $this
      */
     public function turnOnSecretKey()
     {
@@ -300,7 +300,7 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface
     /**
      * Disable secret key using
      *
-     * @return \Magento\Backend\Model\UrlInterface
+     * @return $this
      */
     public function turnOffSecretKey()
     {
@@ -311,7 +311,7 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface
     /**
      * Refresh admin menu cache etc.
      *
-     * @return \Magento\Backend\Model\UrlInterface
+     * @return void
      */
     public function renewSecretUrls()
     {
@@ -372,7 +372,7 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface
      * Set custom auth session
      *
      * @param \Magento\Backend\Model\Auth\Session $session
-     * @return \Magento\Backend\Model\UrlInterface
+     * @return $this
      */
     public function setSession(\Magento\Backend\Model\Auth\Session $session)
     {
diff --git a/app/code/Magento/Backend/Model/Url/ScopeResolver.php b/app/code/Magento/Backend/Model/Url/ScopeResolver.php
index 07f64f5d41ec844f0cf0321b745275df5f612448..24f9aab451a64c1a4dbc1d1f848df212a8947f4f 100644
--- a/app/code/Magento/Backend/Model/Url/ScopeResolver.php
+++ b/app/code/Magento/Backend/Model/Url/ScopeResolver.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Url;
 
 class ScopeResolver extends \Magento\Core\Model\Url\ScopeResolver
diff --git a/app/code/Magento/Backend/Model/UrlInterface.php b/app/code/Magento/Backend/Model/UrlInterface.php
index ab9eba4d410dac72a287a7cb5f8c3840bc01ce4f..8dbbc3a64b855ecbeb674827281b7c08b79d6089 100644
--- a/app/code/Magento/Backend/Model/UrlInterface.php
+++ b/app/code/Magento/Backend/Model/UrlInterface.php
@@ -48,7 +48,7 @@ interface UrlInterface extends \Magento\UrlInterface
     /**
      * Return secret key settings flag
      *
-     * @return boolean
+     * @return bool
      */
     public function useSecretKey();
 
diff --git a/app/code/Magento/Backend/Model/View.php b/app/code/Magento/Backend/Model/View.php
index 8be9b1ad29a893d7679995d3adb90fb6e3225c17..76e3c050f22edc7cbace14d71a117eeedf81cbf6 100644
--- a/app/code/Magento/Backend/Model/View.php
+++ b/app/code/Magento/Backend/Model/View.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model;
 
 class View extends \Magento\App\View
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php b/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php
index e632ac9be66cec50e4cb2bb634d03db0f8194a80..90a44b9df5e83604fd7c3fab0e136725ca5bae1e 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Widget\Grid;
 
 abstract class AbstractTotals
@@ -74,20 +73,20 @@ abstract class AbstractTotals
     /**
      * Count collection column sum based on column index
      *
-     * @abstract
      * @param string $index
      * @param \Magento\Data\Collection $collection
      * @return float|int
+     * @abstract
      */
     abstract protected function _countSum($index, $collection);
 
     /**
      * Count collection column average based on column index
      *
-     * @abstract
      * @param string $index
      * @param \Magento\Data\Collection $collection
      * @return float|int
+     * @abstract
      */
     abstract protected function _countAverage($index, $collection);
 
@@ -148,10 +147,11 @@ abstract class AbstractTotals
     /**
      * Check if operands in not null and set operands values if they are empty
      *
-     * @param float|int $firstOperand
-     * @param float|int $secondOperand
-     * @param float|int $tmpResult
+     * @param float|int &$firstOperand
+     * @param float|int &$secondOperand
+     * @param float|int &$tmpResult
      * @param float|int $result
+     * @return void
      */
     protected function _checkOperandsSet(&$firstOperand, &$secondOperand, &$tmpResult, $result)
     {
@@ -219,7 +219,7 @@ abstract class AbstractTotals
      *
      * @param string $index
      * @param string $totalExpr
-     * @return \Magento\Backend\Model\Widget\Grid\AbstractTotals
+     * @return $this
      */
     public function setColumn($index, $totalExpr)
     {
@@ -267,6 +267,7 @@ abstract class AbstractTotals
      * Reset totals and columns set
      *
      * @param bool $isFullReset
+     * @return void
      */
     public function reset($isFullReset = false)
     {
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Parser.php b/app/code/Magento/Backend/Model/Widget/Grid/Parser.php
index f8cc62969cd709d72380025fd5106d9e4ba386d9..5f3e612dc1690a5a288b5a372bea8279929637af 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/Parser.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/Parser.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Widget\Grid;
 
 class Parser
@@ -31,7 +30,7 @@ class Parser
     /**
      * List of allowed operations
      *
-     * @var array
+     * @var string[]
      */
     protected $_operations = array('-', '+', '/', '*');
 
@@ -63,7 +62,7 @@ class Parser
     /**
      * Check if string is operation
      *
-     * @param $operation
+     * @param string $operation
      * @return bool
      */
     public function isOperation($operation)
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php
index 816372f3eff61486ee42027a97c49dd32741626c..669723ea9883084000a15ba0e7a49ebeeffb0bc8 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Backend\Model\Widget\Grid\Row;
 
 /**
  * Grid row url generator
  */
-namespace Magento\Backend\Model\Widget\Grid\Row;
-
 class UrlGenerator implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorInterface
 {
     /**
@@ -73,6 +72,7 @@ class UrlGenerator implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorIn
 
     /**
      * Create url for passed item using passed url model
+     *
      * @param \Magento\Object $item
      * @return string
      */
@@ -87,8 +87,9 @@ class UrlGenerator implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorIn
 
     /**
      * Convert template params array and merge with preselected params
-     * @param $item
-     * @return mixed
+     *
+     * @param \Magento\Object $item
+     * @return array
      */
     protected function _prepareParameters($item)
     {
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php
index 21ad8d053a4aeecfa08b7dbfed3f5fce6b568b44..e3873c3cd25e14c9d21fae08c6e3bbaa48699620 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Backend\Model\Widget\Grid\Row;
 
 /**
  * Grid row url generator factory
@@ -32,8 +32,6 @@
  * @package     Magento_Backend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Backend\Model\Widget\Grid\Row;
-
 class UrlGeneratorFactory
 {
     /**
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php
index fc564c5c64830d7c51d0f739c2b5fd5e0b21a9f8..0f6a948688b93a1a4bc2fa9599771c279ffe3543 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php
@@ -30,6 +30,7 @@ class UrlGeneratorId
 {
     /**
      * Create url for passed item using passed url model
+     *
      * @param \Magento\Object $item
      * @return string
      */
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php b/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php
index a7246a685252d61dd37f3ba5af9a65cab4c2e6ee..7ee919214353ce25735e888d8c87412a18eb2a07 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Widget\Grid;
 
 class SubTotals extends \Magento\Backend\Model\Widget\Grid\AbstractTotals
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Totals.php b/app/code/Magento/Backend/Model/Widget/Grid/Totals.php
index dde9c4888d337795126a3f3fe8201832ec7159ac..9ed6791ce61ead0c33bdd8a1c56cda7938edfdf9 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/Totals.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/Totals.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Widget\Grid;
 
 class Totals extends \Magento\Backend\Model\Widget\Grid\AbstractTotals
diff --git a/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php b/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php
index b838ecade008a95b2d3094d30cbcd9cb8b3481a1..648d2d09483e96f7c52904f9baaf478f4c52671e 100644
--- a/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php
+++ b/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Backend\Model\Widget\Grid;
 
 interface TotalsInterface
diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml
index c022bc7c8433b8e157451479f33cb9f07e22bb71..3d1389f18cc01b0b8737d3f57e2287116e17859e 100644
--- a/app/code/Magento/Backend/etc/di.xml
+++ b/app/code/Magento/Backend/etc/di.xml
@@ -88,7 +88,7 @@
             <instance type="Magento\Backend\Model\UrlInterface\Proxy" />
         </param>
     </type>
-    <type name="\Magento\Backend\Model\Observer">
+    <type name="Magento\Backend\Model\Observer">
         <param name="backendSession">
             <instance type="Magento\Backend\Model\Session\Proxy" />
         </param>
diff --git a/app/code/Magento/Backend/view/adminhtml/admin/page.phtml b/app/code/Magento/Backend/view/adminhtml/admin/page.phtml
index d3cfbaf4f6b32944d235bb268526ad896a458e2f..58a927f5cd13bdddbcb31b2d281ad93c12225ab7 100644
--- a/app/code/Magento/Backend/view/adminhtml/admin/page.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/admin/page.phtml
@@ -32,7 +32,7 @@
     <?php echo $this->getChildHtml('head') ?>
 </head>
 
-<body id="html-body"<?php echo $this->getBodyClass() ? ' class="' . $this->getBodyClass() . '"' : ''; ?> data-container="body" data-mage-init="{loaderAjax: {}, loader: {}}">
+<body id="html-body"<?php echo $this->getBodyClass() ? ' class="' . $this->getBodyClass() . '"' : ''; ?> data-container="body" data-mage-init='{"loaderAjax":{},"loader":{}}'>
     <div class="wrapper">
         <?php echo $this->getChildHtml('notification_window'); ?>
         <?php echo $this->getChildHtml('global_notices') ?>
diff --git a/app/code/Magento/Backend/view/adminhtml/system/search.phtml b/app/code/Magento/Backend/view/adminhtml/system/search.phtml
index 906504d155a90c15d21a580b78eaa85c06d21985..4135c8939ae89cba4cbeca8db6770b59965af5eb 100644
--- a/app/code/Magento/Backend/view/adminhtml/system/search.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/system/search.phtml
@@ -46,9 +46,9 @@
 <div class="search">
     <form action="#" id="form-search">
         <label for="search-global">
-            <input type="text" id="search-global" name="query" data-mage-init="<?php
+            <input type="text" id="search-global" name="query" data-mage-init='<?php
             echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode($this->getWidgetInitOptions()))
-            ?>">
+            ?>'>
         </label>
         <button type="submit" title="<?php echo __('Search') ?>"><?php echo __('Search') ?></button>
     </form>
diff --git a/app/code/Magento/Backend/view/adminhtml/urlrewrite/categories.phtml b/app/code/Magento/Backend/view/adminhtml/urlrewrite/categories.phtml
index 7fb2ea45f8b118cfd3780c987e2e2976b376461e..bc690fdc810e3af48bbd260f90605c31e07052dd 100644
--- a/app/code/Magento/Backend/view/adminhtml/urlrewrite/categories.phtml
+++ b/app/code/Magento/Backend/view/adminhtml/urlrewrite/categories.phtml
@@ -28,14 +28,14 @@
     <div class="content" style="clear: both;">
         <input type="hidden" name="categories" id="product_categories" value="" />
         <?php if ($this->getRoot()): ?>
-        <div data-mage-init="<?php
+        <div data-mage-init='<?php
             echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode(array(
-                "categoryTree" => array(
-                    "data" => $this->getTreeArray(null),
-                    "url" => $this->getLoadTreeUrl(),
+                'categoryTree' => array(
+                    'data' => $this->getTreeArray(null),
+                    'url' => $this->getLoadTreeUrl(),
                 )
             )));
-        ?>"  class="jstree-default"></div>
+        ?>' class="jstree-default"></div>
         <?php endif; ?>
     </div>
 </fieldset>
diff --git a/app/code/Magento/Backup/Model/Config/Backend/Cron.php b/app/code/Magento/Backup/Model/Config/Backend/Cron.php
index 10efaae7054416c3ab8a65451493d4429951a6ad..a8a625d93e0c94a903038fdf68a405c6ba0ade11 100644
--- a/app/code/Magento/Backup/Model/Config/Backend/Cron.php
+++ b/app/code/Magento/Backup/Model/Config/Backend/Cron.php
@@ -29,8 +29,8 @@ namespace Magento\Backup\Model\Config\Backend;
 
 class Cron extends \Magento\Core\Model\Config\Value
 {
-    const CRON_STRING_PATH  = 'crontab/jobs/system_backup/schedule/cron_expr';
-    const CRON_MODEL_PATH   = 'crontab/jobs/system_backup/run/model';
+    const CRON_STRING_PATH  = 'crontab/default/jobs/system_backup/schedule/cron_expr';
+    const CRON_MODEL_PATH   = 'crontab/default/jobs/system_backup/run/model';
 
     const XML_PATH_BACKUP_ENABLED       = 'groups/backup/fields/enabled/value';
     const XML_PATH_BACKUP_TIME          = 'groups/backup/fields/time/value';
diff --git a/app/code/Magento/Backup/etc/crontab.xml b/app/code/Magento/Backup/etc/crontab.xml
index 2e30a77acf6b6e84f141f65d54908f15a8f9ef02..6757dafaefb87bf5adb030365ee5ec18dc8d6575 100644
--- a/app/code/Magento/Backup/etc/crontab.xml
+++ b/app/code/Magento/Backup/etc/crontab.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="system_backup" instance="Magento\Backup\Model\Observer" method="scheduledBackup" />
+    <group id="default">
+        <job name="system_backup" instance="Magento\Backup\Model\Observer" method="scheduledBackup" />
+    </group>
 </config>
diff --git a/app/code/Magento/Backup/view/adminhtml/backup/dialogs.phtml b/app/code/Magento/Backup/view/adminhtml/backup/dialogs.phtml
index 7af80e070f7d6aee5397027577685496ad63d34f..a1c426fdd224f8929073726dbd6c2aa1e126688c 100644
--- a/app/code/Magento/Backup/view/adminhtml/backup/dialogs.phtml
+++ b/app/code/Magento/Backup/view/adminhtml/backup/dialogs.phtml
@@ -88,7 +88,7 @@
                     </div>
                 </form>
 
-                <button type="button" data-mage-init="{button:{event:'submit', target:'#backup-form'}}"><?php echo __('OK')?></button>
+                <button type="button" data-mage-init='{"button":{"event":"submit","target":"#backup-form"}}'><?php echo __('OK')?></button>
                 <button type="button" onclick="backup.hidePopups()"><?php echo __('Cancel')?></button>
             </div>
         </div>
@@ -141,7 +141,7 @@
                     </div>
                 </form>
 
-                <button type="button" data-mage-init="{button:{event:'submit', target:'#rollback-form'}}"><?php echo __('OK')?></button>
+                <button type="button" data-mage-init='{"button":{"event":"submit","target":"#rollback-form"}}'><?php echo __('OK')?></button>
                 <button type="button" onclick="backup.hidePopups()"><?php echo __('Cancel')?></button>
             </div>
         </div>
diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php
index f0a39119339eae0e5ee61f2736a23e1a0a9ffaf0..89c7abe5343c177f7070ff0aab55e1f9ab82cdd5 100644
--- a/app/code/Magento/Bundle/Model/Product/Type.php
+++ b/app/code/Magento/Bundle/Model/Product/Type.php
@@ -659,7 +659,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
             $optionIds = array_keys($options);
 
             if (empty($optionIds) && $isStrictProcessMode) {
-                return __('Please select options for the product.');
+                return __('Please specify product option(s).');
             }
 
             $product->getTypeInstance()->setStoreFilter($product->getStoreId(), $product);
diff --git a/app/code/Magento/Bundle/view/frontend/catalog/product/view/summary.phtml b/app/code/Magento/Bundle/view/frontend/catalog/product/view/summary.phtml
index df0f704074c6603e02ebb799f9aa1d6343e8abe6..c2f873b2fbf0a4f9c5d4ff50560ff53de8c0e4a4 100644
--- a/app/code/Magento/Bundle/view/frontend/catalog/product/view/summary.phtml
+++ b/app/code/Magento/Bundle/view/frontend/catalog/product/view/summary.phtml
@@ -51,7 +51,7 @@
         <div class="bundle summary">
             <strong class="subtitle"><?php echo __('Summary'); ?></strong>
             <div id="bundle-summary" data-container="product-summary">
-                <ul data-mage-init='{productSummary: []}'></ul>
+                <ul data-mage-init='{"productSummary": []}'></ul>
                 <script data-template="bundle-summary" type="text/x-jQuery-tmpl">
                     <li>
                         <strong class="label">${_label_}:</strong>
diff --git a/app/code/Magento/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml
index a0b5e4dce89d9ba0e1a585192d01bcdf53203080..4c250cd3cf9f42171156d84c5f2b4c5755f0bd37 100644
--- a/app/code/Magento/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml
+++ b/app/code/Magento/Bundle/view/frontend/sales/order/creditmemo/items/renderer.phtml
@@ -289,7 +289,7 @@
                         <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                         <?php if (!$this->getPrintStatus()): ?>
                             <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                                 <?php echo $_formatedOptionValue['value'] ?>
                                 <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                     <div class="truncated_full_value">
diff --git a/app/code/Magento/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml
index 0e2eb321437169cdd5a823fc6c4da1bb4fcab89f..23e98f802b6811db53d3d485137731b33ec0fee2 100644
--- a/app/code/Magento/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml
+++ b/app/code/Magento/Bundle/view/frontend/sales/order/invoice/items/renderer.phtml
@@ -309,7 +309,7 @@
                         <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                         <?php if (!$this->getPrintStatus()): ?>
                             <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                                 <?php echo $_formatedOptionValue['value'] ?>
                                 <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                     <div class="truncated_full_value">
diff --git a/app/code/Magento/Bundle/view/frontend/sales/order/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/sales/order/items/renderer.phtml
index 79970ea7d3267b5eb2c40ccb1d63d09603743516..434dccfdc634d829c44677d805dd97e3890792d9 100644
--- a/app/code/Magento/Bundle/view/frontend/sales/order/items/renderer.phtml
+++ b/app/code/Magento/Bundle/view/frontend/sales/order/items/renderer.phtml
@@ -330,7 +330,7 @@
                     <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                     <?php if (!$this->getPrintStatus()): ?>
                         <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                             <?php echo $_formatedOptionValue['value'] ?>
                             <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                 <div class="truncated_full_value">
diff --git a/app/code/Magento/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml
index ec1fb9e467f7feb03224a0dad1e6d50037cef5ab..06e586f9b6782e4befa5616d88b616eb4dfdf6ca 100644
--- a/app/code/Magento/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml
+++ b/app/code/Magento/Bundle/view/frontend/sales/order/shipment/items/renderer.phtml
@@ -81,7 +81,7 @@
                         <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                         <?php if (!$this->getPrintStatus()): ?>
                             <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                                 <?php echo $_formatedOptionValue['value'] ?>
                                 <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                     <div class="truncated_full_value">
diff --git a/app/code/Magento/Captcha/etc/crontab.xml b/app/code/Magento/Captcha/etc/crontab.xml
index c2e638376408870d76e85a0b6a365a76780c1564..96cc6f5619413bba96d0b014e06a25c36f077927 100644
--- a/app/code/Magento/Captcha/etc/crontab.xml
+++ b/app/code/Magento/Captcha/etc/crontab.xml
@@ -24,10 +24,12 @@
  */
 -->
 <config>
-    <job name="captcha_delete_old_attempts" instance="Magento\Captcha\Model\Cron" method="deleteOldAttempts">
-        <schedule>*/30 * * * *</schedule>
-    </job>
-    <job name="captcha_delete_expired_images" instance="Magento\Captcha\Model\Cron" method="deleteExpiredImages">
-        <schedule>*/10 * * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="captcha_delete_old_attempts" instance="Magento\Captcha\Model\Cron" method="deleteOldAttempts">
+            <schedule>*/30 * * * *</schedule>
+        </job>
+        <job name="captcha_delete_expired_images" instance="Magento\Captcha\Model\Cron" method="deleteExpiredImages">
+            <schedule>*/10 * * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/AbstractCategory.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/AbstractCategory.php
index 018bbac7c007911d043da62bda35b63f27e64bb0..e6981da38314390c96793a179b78dffedb090826 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/AbstractCategory.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/AbstractCategory.php
@@ -33,6 +33,9 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Category;
 
+use Magento\Core\Model\Store;
+use Magento\Data\Tree\Node;
+
 class AbstractCategory extends \Magento\Backend\Block\Template
 {
     /**
@@ -67,13 +70,16 @@ class AbstractCategory extends \Magento\Backend\Block\Template
     /**
      * Retrieve current category instance
      *
-     * @return \Magento\Catalog\Model\Category
+     * @return array|null
      */
     public function getCategory()
     {
         return $this->_coreRegistry->registry('category');
     }
 
+    /**
+     * @return int|string|null
+     */
     public function getCategoryId()
     {
         if ($this->getCategory()) {
@@ -82,11 +88,17 @@ class AbstractCategory extends \Magento\Backend\Block\Template
         return \Magento\Catalog\Model\Category::TREE_ROOT_ID;
     }
 
+    /**
+     * @return string
+     */
     public function getCategoryName()
     {
         return $this->getCategory()->getName();
     }
 
+    /**
+     * @return mixed
+     */
     public function getCategoryPath()
     {
         if ($this->getCategory()) {
@@ -95,6 +107,9 @@ class AbstractCategory extends \Magento\Backend\Block\Template
         return \Magento\Catalog\Model\Category::TREE_ROOT_ID;
     }
 
+    /**
+     * @return bool
+     */
     public function hasStoreRootCategory()
     {
         $root = $this->getRoot();
@@ -104,12 +119,20 @@ class AbstractCategory extends \Magento\Backend\Block\Template
         return false;
     }
 
+    /**
+     * @return Store
+     */
     public function getStore()
     {
         $storeId = (int) $this->getRequest()->getParam('store');
         return $this->_storeManager->getStore($storeId);
     }
 
+    /**
+     * @param mixed|null $parentNodeCategory
+     * @param int $recursionLevel
+     * @return Node|array|null
+     */
     public function getRoot($parentNodeCategory=null, $recursionLevel=3)
     {
         if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
@@ -158,6 +181,7 @@ class AbstractCategory extends \Magento\Backend\Block\Template
      * If ids are empty, default tree with depth = 2 will be returned.
      *
      * @param array $ids
+     * @return mixed
      */
     public function getRootByIds($ids)
     {
@@ -179,6 +203,11 @@ class AbstractCategory extends \Magento\Backend\Block\Template
         return $root;
     }
 
+    /**
+     * @param mixed $parentNodeCategory
+     * @param int $recursionLevel
+     * @return Node
+     */
     public function getNode($parentNodeCategory, $recursionLevel=2)
     {
         $nodeId     = $parentNodeCategory->getId();
@@ -198,6 +227,10 @@ class AbstractCategory extends \Magento\Backend\Block\Template
         return $node;
     }
 
+    /**
+     * @param array $args
+     * @return string
+     */
     public function getSaveUrl(array $args = array())
     {
         $params = array('_current'=>true);
@@ -205,6 +238,9 @@ class AbstractCategory extends \Magento\Backend\Block\Template
         return $this->getUrl('catalog/*/save', $params);
     }
 
+    /**
+     * @return string
+     */
     public function getEditUrl()
     {
         return $this->getUrl(
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Checkboxes/Tree.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Checkboxes/Tree.php
index 2ec8c7ff34b5378e4bae02597f0a00a049cdaef1..24e4cc5c2fe87802e9da0d4a406cb31f765e3dc1 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Checkboxes/Tree.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Checkboxes/Tree.php
@@ -31,20 +31,35 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Category\Checkboxes;
 
+use Magento\Data\Tree\Node;
+
 class Tree extends \Magento\Catalog\Block\Adminhtml\Category\Tree
 {
+    /**
+     * @var int[]
+     */
     protected $_selectedIds = array();
 
+    /**
+     * @return void
+     */
     protected function _prepareLayout()
     {
         $this->setTemplate('catalog/category/checkboxes/tree.phtml');
     }
 
+    /**
+     * @return int[]
+     */
     public function getCategoryIds()
     {
         return $this->_selectedIds;
     }
 
+    /**
+     * @param mixed $ids
+     * @return $this
+     */
     public function setCategoryIds($ids)
     {
         if (empty($ids)) {
@@ -57,6 +72,11 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\Tree
         return $this;
     }
 
+    /**
+     * @param array|Node $node
+     * @param int $level
+     * @return array
+     */
     protected function _getNodeJson($node, $level = 1)
     {
         $item = array();
@@ -93,6 +113,11 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\Tree
         return $item;
     }
 
+    /**
+     * @param mixed|null $parentNodeCategory
+     * @param int $recursionLevel
+     * @return Node|array|null
+     */
     public function getRoot($parentNodeCategory=null, $recursionLevel=3)
     {
         return $this->getRootByIds($this->getCategoryIds());
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Edit/Form.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Edit/Form.php
index 5c3152ffdc71706c17ffccc46a773f7e45049e9d..a3ccc9017facd7ca6d5edbc65890f175ed051031 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Edit/Form.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Edit/Form.php
@@ -72,6 +72,9 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         parent::__construct($context, $categoryTree, $registry, $data);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         if ($head = $this->getLayout()->getBlock('head')) {
@@ -121,6 +124,9 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getStoreConfigurationUrl()
     {
         $storeId = (int) $this->getRequest()->getParam('store');
@@ -134,11 +140,17 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $this->getUrl('catalog/system_store', $params);
     }
 
+    /**
+     * @return string
+     */
     public function getDeleteButtonHtml()
     {
         return $this->getChildHtml('delete_button');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveButtonHtml()
     {
         if ($this->hasStoreRootCategory()) {
@@ -147,6 +159,9 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return '';
     }
 
+    /**
+     * @return string
+     */
     public function getResetButtonHtml()
     {
         if ($this->hasStoreRootCategory()) {
@@ -174,7 +189,7 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
      *
      * @param string $alias
      * @param array $config
-     * @return \Magento\Catalog\Block\Adminhtml\Category\Edit\Form
+     * @return $this
      */
     public function addAdditionalButton($alias, $config)
     {
@@ -191,7 +206,7 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
      * Remove additional button
      *
      * @param string $alias
-     * @return \Magento\Catalog\Block\Adminhtml\Category\Edit\Form
+     * @return $this
      */
     public function removeAdditionalButton($alias)
     {
@@ -203,11 +218,17 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getTabsHtml()
     {
         return $this->getChildHtml('tabs');
     }
 
+    /**
+     * @return string
+     */
     public function getHeader()
     {
         if ($this->hasStoreRootCategory()) {
@@ -225,6 +246,10 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return __('Set Root Category for Store');
     }
 
+    /**
+     * @param array $args
+     * @return string
+     */
     public function getDeleteUrl(array $args = array())
     {
         $params = array('_current'=>true);
@@ -245,6 +270,9 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $this->getUrl('catalog/*/refreshPath', $params);
     }
 
+    /**
+     * @return string
+     */
     public function getProductsJson()
     {
         $products = $this->getCategory()->getProductsPosition();
@@ -254,6 +282,9 @@ class Form extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return '{}';
     }
 
+    /**
+     * @return bool
+     */
     public function isAjax()
     {
         return $this->_request->isXmlHttpRequest() || $this->_request->getParam('isAjax');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php
index 22d25b0ee82b743548e9d0b0867010fae7a59c53..40f6fe6ea82004f925b1fccf4eb0d673060df460 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php
@@ -60,6 +60,9 @@ class Image extends \Magento\Data\Form\Element\Image
         parent::__construct($factoryElement, $factoryCollection, $escaper, $urlBuilder, $data);
     }
 
+    /**
+     * @return bool|string
+     */
     protected function _getUrl()
     {
         $url = false;
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Attributes.php
index 8762b49aaa82ed88efd994d1b4d916eba2c8ef93..ad90d0f94929fbe87eb93db102eea072e2f4052e 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Attributes.php
@@ -72,6 +72,7 @@ class Attributes extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Initialize tab
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -81,6 +82,8 @@ class Attributes extends \Magento\Backend\Block\Widget\Form\Generic
 
     /**
      * Load Wysiwyg on demand and Prepare layout
+     *
+     * @return void
      */
     protected function _prepareLayout()
     {
@@ -93,7 +96,7 @@ class Attributes extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form before rendering HTML
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Category\Tab\Attributes
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Design.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Design.php
index dbcbe8b61fe51902ef17aa3c4ff197c177fab593..80d40459126de2855baf9da8bd92b03cdd5b3722 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Design.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Design.php
@@ -27,12 +27,23 @@ namespace Magento\Catalog\Block\Adminhtml\Category\Tab;
 
 class Design extends \Magento\Catalog\Block\Adminhtml\Form
 {
+    /**
+     * @var array|null
+     */
+    protected $_category;
+
+    /**
+     * @return void
+     */
     public function _construct()
     {
         parent::_construct();
         $this->setShowGlobalIcon(true);
     }
 
+    /**
+     * @return array|null
+     */
     public function getCategory()
     {
         if (!$this->_category) {
@@ -41,6 +52,9 @@ class Design extends \Magento\Catalog\Block\Adminhtml\Form
         return $this->_category;
     }
 
+    /**
+     * @return void
+     */
     public function _prepareLayout()
     {
         parent::_prepareLayout();
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/General.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/General.php
index c918962101f541de37e9c0031a00198a49c42230..c33c9c3a2835d24d27fe94fe3ae22496463f8377 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/General.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/General.php
@@ -35,15 +35,23 @@ namespace Magento\Catalog\Block\Adminhtml\Category\Tab;
 
 class General extends \Magento\Catalog\Block\Adminhtml\Form
 {
-
+    /**
+     * @var array|null
+     */
     protected $_category;
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setShowGlobalIcon(true);
     }
 
+    /**
+     * @return array|null
+     */
     public function getCategory()
     {
         if (!$this->_category) {
@@ -52,6 +60,9 @@ class General extends \Magento\Catalog\Block\Adminhtml\Form
         return $this->_category;
     }
 
+    /**
+     * @return void
+     */
     public function _prepareLayout()
     {
         parent::_prepareLayout();
@@ -110,11 +121,19 @@ class General extends \Magento\Catalog\Block\Adminhtml\Form
         $this->setForm($form);
     }
 
+    /**
+     * @return array
+     */
     protected function _getAdditionalElementTypes()
     {
         return array('image' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Image');
     }
 
+    /**
+     * @param array|null $node
+     * @param array &$options
+     * @return array
+     */
     protected function _getParentCategoryOptions($node=null, &$options=array())
     {
         if (is_null($node)) {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php
index 714420ec31ba22afa0ca8d7cf113c71ac6c93ec7..d6454b41f5e5370859f4970e3363368905929d6f 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php
@@ -33,6 +33,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Category\Tab;
 
+use Magento\Backend\Block\Widget\Grid;
+use Magento\Backend\Block\Widget\Grid\Column;
+use Magento\Backend\Block\Widget\Grid\Extended;
+
 class Product extends \Magento\Backend\Block\Widget\Grid\Extended
 {
     /**
@@ -66,6 +70,9 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -74,11 +81,18 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
         $this->setUseAjax(true);
     }
 
+    /**
+     * @return array|null
+     */
     public function getCategory()
     {
         return $this->_coreRegistry->registry('category');
     }
 
+    /**
+     * @param Column $column
+     * @return $this
+     */
     protected function _addColumnFilterToCollection($column)
     {
         // Set custom filter for in category flag
@@ -100,6 +114,9 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
         return $this;
     }
 
+    /**
+     * @return Grid
+     */
     protected function _prepareCollection()
     {
         if ($this->getCategory()->getId()) {
@@ -129,6 +146,9 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareCollection();
     }
 
+    /**
+     * @return Extended
+     */
     protected function _prepareColumns()
     {
         if (!$this->getCategory()->getProductsReadonly()) {
@@ -175,11 +195,17 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareColumns();
     }
 
+    /**
+     * @return string
+     */
     public function getGridUrl()
     {
         return $this->getUrl('catalog/*/grid', array('_current'=>true));
     }
 
+    /**
+     * @return array
+     */
     protected function _getSelectedProducts()
     {
         $products = $this->getRequest()->getPost('selected_products');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tabs.php
index c741c7d43a046d1292d8831c3d2cd3ef067c1dc0..344ce00de9def2cc926a9e76080fff2547c26679 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tabs.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tabs.php
@@ -38,12 +38,15 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
      */
     protected $_attributeTabBlock = 'Magento\Catalog\Block\Adminhtml\Category\Tab\Attributes';
 
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Backend::widget/tabshoriz.phtml';
 
-   /**
+    /**
      * Core registry
      *
-     * @var \Magento\Core\Model\Registry
+     * @var \Magento\Core\Model\Registry|null
      */
     protected $_coreRegistry = null;
 
@@ -85,6 +88,8 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
 
     /**
      * Initialize Tabs
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -96,7 +101,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
     }
 
     /**
-     * Retrieve cattegory object
+     * Retrieve category object
      *
      * @return \Magento\Catalog\Model\Category
      */
@@ -121,7 +126,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
     /**
      * Prepare Layout Content
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Category\Tabs
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php
index 96feef572b8861ad915de2b1213633cf8e00f5ea..df55cd8bb028b402b451b6927538a2bc3fca0a8c 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php
@@ -34,10 +34,19 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Category;
 
+use Magento\Catalog\Model\Resource\Category\Collection;
+use Magento\Data\Tree\Node;
+
 class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
 {
+    /**
+     * @var bool
+     */
     protected $_withProductCount;
 
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/category/tree.phtml';
 
     /**
@@ -87,6 +96,9 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         parent::__construct($context, $categoryTree, $registry, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -94,6 +106,9 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         $this->_withProductCount = true;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $addUrl = $this->getUrl("*/*/add", array(
@@ -127,11 +142,17 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return int
+     */
     protected function _getDefaultStoreId()
     {
         return \Magento\Core\Model\Store::DEFAULT_STORE_ID;
     }
 
+    /**
+     * @return Collection
+     */
     public function getCategoryCollection()
     {
         $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
@@ -139,7 +160,7 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         if (is_null($collection)) {
             $collection = $this->_categoryFactory->create()->getCollection();
 
-            /* @var $collection \Magento\Catalog\Model\Resource\Category\Collection */
+            /* @var $collection Collection */
             $collection->addAttributeToSelect('name')
                 ->addAttributeToSelect('is_active')
                 ->setProductStoreId($storeId)
@@ -161,7 +182,7 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
     {
         $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
 
-        /* @var $collection \Magento\Catalog\Model\Resource\Category\Collection */
+        /* @var $collection Collection */
         $collection = $this->_categoryFactory->create()->getCollection();
 
         $matchingNamesCollection = clone $collection;
@@ -204,31 +225,50 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         );
     }
 
+    /**
+     * @return string
+     */
     public function getAddRootButtonHtml()
     {
         return $this->getChildHtml('add_root_button');
     }
 
+    /**
+     * @return string
+     */
     public function getAddSubButtonHtml()
     {
         return $this->getChildHtml('add_sub_button');
     }
 
+    /**
+     * @return string
+     */
     public function getExpandButtonHtml()
     {
         return $this->getChildHtml('expand_button');
     }
 
+    /**
+     * @return string
+     */
     public function getCollapseButtonHtml()
     {
         return $this->getChildHtml('collapse_button');
     }
 
+    /**
+     * @return string
+     */
     public function getStoreSwitcherHtml()
     {
         return $this->getChildHtml('store_switcher');
     }
 
+    /**
+     * @param bool|null $expanded
+     * @return string
+     */
     public function getLoadTreeUrl($expanded=null)
     {
         $params = array('_current'=>true, 'id'=>null,'store'=>null);
@@ -240,11 +280,17 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $this->getUrl('catalog/*/categoriesJson', $params);
     }
 
+    /**
+     * @return string
+     */
     public function getNodesUrl()
     {
         return $this->getUrl('catalog/category/jsonTree');
     }
 
+    /**
+     * @return string
+     */
     public function getSwitchTreeUrl()
     {
         return $this->getUrl(
@@ -253,16 +299,26 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         );
     }
 
+    /**
+     * @return bool
+     */
     public function getIsWasExpanded()
     {
         return $this->_backendSession->getIsTreeWasExpanded();
     }
 
+    /**
+     * @return string
+     */
     public function getMoveUrl()
     {
         return $this->getUrl('catalog/category/move', array('store'=>$this->getRequest()->getParam('store')));
     }
 
+    /**
+     * @param mixed|null $parenNodeCategory
+     * @return array
+     */
     public function getTree($parenNodeCategory=null)
     {
            $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
@@ -270,6 +326,10 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $tree;
     }
 
+    /**
+     * @param mixed|null $parenNodeCategory
+     * @return string
+     */
     public function getTreeJson($parenNodeCategory=null)
     {
         $rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
@@ -312,7 +372,7 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
     /**
      * Get JSON of a tree node or an associative array
      *
-     * @param \Magento\Data\Tree\Node|array $node
+     * @param Node|array $node
      * @param int $level
      * @return string
      */
@@ -320,7 +380,7 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
     {
         // create a node from data array
         if (is_array($node)) {
-            $node = new \Magento\Data\Tree\Node($node, 'entity_id', new \Magento\Data\Tree);
+            $node = new Node($node, 'entity_id', new \Magento\Data\Tree);
         }
 
         $item = array();
@@ -376,6 +436,10 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $result;
     }
 
+    /**
+     * @param Node|array $node
+     * @return bool
+     */
     protected function _isCategoryMoveable($node)
     {
         $options = new \Magento\Object(array(
@@ -390,6 +454,10 @@ class Tree extends \Magento\Catalog\Block\Adminhtml\Category\AbstractCategory
         return $options->getIsMoveable();
     }
 
+    /**
+     * @param Node|array $node
+     * @return bool
+     */
     protected function _isParentSelectedCategory($node)
     {
         if ($node && $this->getCategory()) {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php
index ed674722be7b2f6f13734bc4f7f67a148d615918..26412c7fb36b89835c5ef4c2ce56e343fe11398f 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Widget/Chooser.php
@@ -35,14 +35,22 @@ namespace Magento\Catalog\Block\Adminhtml\Category\Widget;
 
 class Chooser extends \Magento\Catalog\Block\Adminhtml\Category\Tree
 {
+    /**
+     * @var array
+     */
     protected $_selectedCategories = array();
 
     /**
      * Block construction
      * Defines tree template and init tree params
+     *
+     * @var string
      */
     protected $_template = 'catalog/category/widget/tree.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -54,7 +62,7 @@ class Chooser extends \Magento\Catalog\Block\Adminhtml\Category\Tree
      * Setter
      *
      * @param array $selectedCategories
-     * @return \Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser
+     * @return $this
      */
     public function setSelectedCategories($selectedCategories)
     {
@@ -168,6 +176,7 @@ class Chooser extends \Magento\Catalog\Block\Adminhtml\Category\Tree
     /**
      * Tree JSON source URL
      *
+     * @param bool|null $expanded
      * @return string
      */
     public function getLoadTreeUrl($expanded=null)
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Form.php b/app/code/Magento/Catalog/Block/Adminhtml/Form.php
index b1a8d6f097d175da2bd8bc8aee07a8cfe7ec4a36..05c23fcdd2a541f929e5a2fa6e875f92eff01cfd 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Form.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Form.php
@@ -33,8 +33,14 @@
  */
 namespace Magento\Catalog\Block\Adminhtml;
 
-class Form extends \Magento\Backend\Block\Widget\Form\Generic
+use Magento\Backend\Block\Widget\Form\Generic;
+use Magento\View\Element\AbstractBlock;
+
+class Form extends Generic
 {
+    /**
+     * @return void
+     */
     protected function _prepareLayout()
     {
         \Magento\Data\Form::setElementRenderer(
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Attribute/Urlkey.php b/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Attribute/Urlkey.php
index dd411a0327596e3744978d82d07efc2ee64f315c..416b52c5dd88fd3cbe0df11ba5b6328071dc5db4 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Attribute/Urlkey.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Attribute/Urlkey.php
@@ -67,6 +67,9 @@ class Urlkey
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return string
+     */
     public function getElementHtml()
     {
         /** @var \Magento\Data\Form\Element\AbstractElement $element */
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/DateFieldsOrder.php b/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/DateFieldsOrder.php
index 275cfe2d82b65dfc9181dc1a886bc7d2704f7fcf..f1615b13dc93ff2d9eca4014024a883f7ff5dc11 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/DateFieldsOrder.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/DateFieldsOrder.php
@@ -33,11 +33,16 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Form\Renderer\Config;
 
-class DateFieldsOrder
-    extends \Magento\Backend\Block\System\Config\Form\Field
-{
+use Magento\Backend\Block\System\Config\Form\Field;
+use Magento\Data\Form\Element\AbstractElement;
 
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+class DateFieldsOrder extends Field
+{
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(AbstractElement $element)
     {
         $_options = array(
             'd' => __('Day'),
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/YearRange.php b/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/YearRange.php
index 1b96bfe9e89147e928ae6ef562d04e34b67ee3f0..125a017d6bc9d8557892f1d064d5d4f51ca06939 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/YearRange.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Form/Renderer/Config/YearRange.php
@@ -33,10 +33,16 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Form\Renderer\Config;
 
-class YearRange extends \Magento\Backend\Block\System\Config\Form\Field
-{
+use Magento\Backend\Block\System\Config\Form\Field;
+use Magento\Data\Form\Element\AbstractElement;
 
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+class YearRange extends Field
+{
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(AbstractElement $element)
     {
         $element->setStyle('width:70px;')
             ->setName($element->getName() . '[]');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php
index 11224b3d081fb3cb3e99d747206fa3d4f490dd89..068b7ee1bfaae25be8506efec601bd31203e7654 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php
@@ -134,7 +134,7 @@ HTML;
     /**
      * Check whether wysiwyg enabled or not
      *
-     * @return boolean
+     * @return bool
      */
     public function getIsWysiwygEnabled()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg/Content.php b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg/Content.php
index 97f0842a9621b0ecabd69327e73cbb36ed584daa..55e0c330f41fecca8129c0ededd8a86be4df307d 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg/Content.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg/Content.php
@@ -33,8 +33,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg;
 
-class Content
-    extends \Magento\Backend\Block\Widget\Form\Generic
+use Magento\Backend\Block\Widget\Form;
+use Magento\Backend\Block\Widget\Form\Generic;
+
+class Content extends Generic
 {
     /**
      * @var \Magento\Cms\Model\Wysiwyg\Config
@@ -63,7 +65,7 @@ class Content
      * Prepare form.
      * Adding editor field to render
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg\Content
+     * @return Form
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product.php b/app/code/Magento/Catalog/Block/Adminhtml/Product.php
index a017797a3fde6f55c9c43ad30ea82da9c39e9d20..3d7c2be329916bad844bb74a20cd7f381ac05ec5 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml;
 
 class Product extends \Magento\Backend\Block\Widget\Container
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product.phtml';
 
     /**
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Form.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Form.php
index a80b57e4347022cb2664b846ca3fd6aac91b2c9b..c001a544075a56a3c70d31f3472547bf2ff08d97 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Form.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Form.php
@@ -34,12 +34,17 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit;
 
-class Form extends \Magento\Backend\Block\Widget\Form\Generic
-{
+use Magento\Backend\Block\Widget\Form\Generic;
+use Magento\Data\Form as DataForm;
 
+class Form extends Generic
+{
+    /**
+     * @return $this
+     */
     protected function _prepareForm()
     {
-        /** @var \Magento\Data\Form $form */
+        /** @var DataForm $form */
         $form = $this->_formFactory->create(array(
             'data' => array(
                 'id' => 'edit_form',
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
index 2f521a2e596a0cda85f61f048d771dce7deeb22f..8dfeaa9215cc31974b36b6f26310613e8a26e096 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
@@ -34,18 +34,21 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
 
-class Advanced
-    extends \Magento\Backend\Block\Widget\Form\Generic
+use Magento\Backend\Block\Widget\Form\Generic;
+use Magento\Backend\Model\Config\Source\Yesno;
+use Magento\Eav\Helper\Data;
+
+class Advanced extends Generic
 {
     /**
      * Eav data
      *
-     * @var \Magento\Eav\Helper\Data
+     * @var Data
      */
     protected $_eavData = null;
 
     /**
-     * @var \Magento\Backend\Model\Config\Source\Yesno
+     * @var Yesno
      */
     protected $_yesNo;
 
@@ -53,16 +56,16 @@ class Advanced
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Data\FormFactory $formFactory
-     * @param \Magento\Backend\Model\Config\Source\Yesno $yesNo
-     * @param \Magento\Eav\Helper\Data $eavData
+     * @param Yesno $yesNo
+     * @param Data $eavData
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Data\FormFactory $formFactory,
-        \Magento\Backend\Model\Config\Source\Yesno $yesNo,
-        \Magento\Eav\Helper\Data $eavData,
+        Yesno $yesNo,
+        Data $eavData,
         array $data = array()
     ) {
         $this->_yesNo = $yesNo;
@@ -73,7 +76,7 @@ class Advanced
     /**
      * Adding product form elements for editing attribute
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -227,7 +230,7 @@ class Advanced
     /**
      * Initialize form fileds values
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced
+     * @return $this
      */
     protected function _initFormValues()
     {
@@ -238,7 +241,7 @@ class Advanced
     /**
      * Retrieve attribute object from registry
      *
-     * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
+     * @return mixed
      */
     private function getAttributeObject()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php
index 8d38539b31d09b30402e8dfe80b6dd7f3b5e4874..d7cdee0afb351b99e9c0db1210a77407d5a8c721 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Front.php
@@ -34,10 +34,14 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
 
-class Front extends \Magento\Backend\Block\Widget\Form\Generic
+use Magento\Backend\Block\Widget\Form;
+use Magento\Backend\Block\Widget\Form\Generic;
+use Magento\Backend\Model\Config\Source\Yesno;
+
+class Front extends Generic
 {
     /**
-     * @var \Magento\Backend\Model\Config\Source\Yesno
+     * @var Yesno
      */
     protected $_yesNo;
 
@@ -45,14 +49,14 @@ class Front extends \Magento\Backend\Block\Widget\Form\Generic
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Data\FormFactory $formFactory
-     * @param \Magento\Backend\Model\Config\Source\Yesno $yesNo
+     * @param Yesno $yesNo
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Data\FormFactory $formFactory,
-        \Magento\Backend\Model\Config\Source\Yesno $yesNo,
+        Yesno $yesNo,
         array $data = array()
     ) {
         $this->_yesNo = $yesNo;
@@ -60,7 +64,7 @@ class Front extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      * @return $this
      */
     protected function _prepareForm()
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
index 0c29fb85e1ad9f5e7e03f3ab7ef32fecf6168fbb..1dc0a9084f9d009b958061869a9d3b733545521f 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
@@ -33,12 +33,14 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
 
-class Main extends \Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain
+use Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain;
+
+class Main extends AbstractMain
 {
     /**
      * Adding product form elements for editing attribute
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Main
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/System.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/System.php
index 9afc3666bea90fb2b81c4fbb8fc7b2cb334c7ae2..7d2a793250d6b4c15c767340868b674185253d34 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/System.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/System.php
@@ -34,8 +34,13 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
 
-class System extends \Magento\Backend\Block\Widget\Form\Generic
+use Magento\Backend\Block\Widget\Form\Generic;
+
+class System extends Generic
 {
+    /**
+     * @return $this
+     */
     protected function _prepareForm()
     {
         $model = $this->_coreRegistry->registry('entity_attribute');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tabs.php
index 992a709a76d36c2f8df8834a43b32702ab524de8..2557b20cf3966968acc7f3cb523e7f7df9fd19f1 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tabs.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tabs.php
@@ -35,7 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit;
 
 class Tabs extends \Magento\Backend\Block\Widget\Tabs
 {
-
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -44,6 +46,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
         $this->setTitle(__('Attribute Information'));
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeToHtml()
     {
         $this->addTab(
@@ -74,5 +79,4 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
 
         return parent::_beforeToHtml();
     }
-
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php
index c42694f1f64f312d09a2535e07082196ce3f0517..e2dda7a6aee435580671bfd68095e34ab7a75a52 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php
@@ -33,7 +33,9 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute;
 
-class Grid extends \Magento\Eav\Block\Adminhtml\Attribute\Grid\AbstractGrid
+use Magento\Eav\Block\Adminhtml\Attribute\Grid\AbstractGrid;
+
+class Grid extends AbstractGrid
 {
     /**
      * @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory
@@ -60,7 +62,7 @@ class Grid extends \Magento\Eav\Block\Adminhtml\Attribute\Grid\AbstractGrid
     /**
      * Prepare product attributes grid collection object
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
@@ -74,7 +76,7 @@ class Grid extends \Magento\Eav\Block\Adminhtml\Attribute\Grid\AbstractGrid
     /**
      * Prepare product attributes grid columns
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid
+     * @return $this
      */
     protected function _prepareColumns()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php
index f35809e5ab5450f2cccafbf978595ebcd3de4171..2f7e01615f442ff25ba4412ae36d76968b6201d6 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Attributes.php
@@ -33,8 +33,13 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\NewAttribute\Product;
 
+use Magento\Backend\Block\Widget\Form;
+
 class Attributes extends \Magento\Catalog\Block\Adminhtml\Form
 {
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         /** @var \Magento\Data\Form $form */
@@ -69,6 +74,9 @@ class Attributes extends \Magento\Catalog\Block\Adminhtml\Form
         $this->setForm($form);
     }
 
+    /**
+     * @return array
+     */
     protected function _getAdditionalElementTypes()
     {
         $result = array(
@@ -88,6 +96,9 @@ class Attributes extends \Magento\Catalog\Block\Adminhtml\Form
         return $result;
     }
 
+    /**
+     * @return string
+     */
     protected function _toHtml()
     {
         parent::_toHtml();
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php
index 505f734b8c6b6574e55088edb69614eed445a503..8ee8a2c1b9b7b64e220b1bed54b3aa9611b1905c 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php
@@ -35,7 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\NewAttribute\Product
 
 class Created extends \Magento\Backend\Block\Widget
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/attribute/new/created.phtml';
 
     /**
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php
index 09393049f4551ec67ee614b12c18ee8052feeea8..079aeeeef885f0796eab41808ebb99f571f20c16 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set;
 
 class Main extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/attribute/set/main.phtml';
 
     /**
@@ -111,7 +114,7 @@ class Main extends \Magento\Backend\Block\Template
     /**
      * Prepare Global Layout
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php
index f02d2142adbed3d25801b71f66bb05194c4e56cb..80d6668c20ce755d8c9046cdf282ea627a8508c7 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formattribute.php
@@ -32,8 +32,13 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main;
 
+use Magento\Backend\Block\Widget\Form;
+
 class Formattribute extends \Magento\Backend\Block\Widget\Form\Generic
 {
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         /** @var \Magento\Data\Form $form */
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php
index 72ab2acbc0333896d806cf037c87877c9ee4c3e5..a7514ff85a922dfdb28f9f7a7ff5c1fad4c9c37a 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formgroup.php
@@ -32,6 +32,8 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main;
 
+use Magento\Backend\Block\Widget\Form;
+
 class Formgroup
     extends \Magento\Backend\Block\Widget\Form\Generic
 {
@@ -58,6 +60,9 @@ class Formgroup
         parent::__construct($context, $registry, $formFactory, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         /** @var \Magento\Data\Form $form */
@@ -99,6 +104,9 @@ class Formgroup
         $this->setForm($form);
     }
 
+    /**
+     * @return int
+     */
     protected function _getSetId()
     {
         return ( intval($this->getRequest()->getParam('id')) > 0 )
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formset.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formset.php
index d048e0bf95937ca9ae67b2afe02b92cc7fff429f..165dcd8cf6bef541109c4f1f8b24f9dbe8442364 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formset.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formset.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main;
 
+use Magento\Backend\Block\Widget\Form;
+
 class Formset
     extends \Magento\Backend\Block\Widget\Form\Generic
 {
@@ -55,6 +57,7 @@ class Formset
     /**
      * Prepares attribute set form
      *
+     * @return void
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Attribute.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Attribute.php
index 62ebe20ae2a3f357346f634676525ffd25eaa3d4..cf96b2070d3a5014a3b8aefa66c38178ea0b4d26 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Attribute.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Attribute.php
@@ -34,5 +34,8 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Tree;
 
 class Attribute extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/attribute/set/main/tree/attribute.phtml';
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Group.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Group.php
index c6067dfcc203d31ec09a607570818e444fd91524..91350468c06c820ab9e4286e05936b5b247415bd 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Group.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Tree/Group.php
@@ -34,5 +34,8 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main\Tree;
 
 class Group extends \Magento\Backend\Block\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/attribute/set/main/tree/group.phtml';
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php
index 939743f109afa713fc4f032914f2c62d3984d24e..66e10d0ff08555aa3900c2a70ad07cbe0146d45c 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php
@@ -33,11 +33,18 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Toolbar;
 
+use Magento\View\Element\AbstractBlock;
+
 class Add extends \Magento\Backend\Block\Template
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/attribute/set/toolbar/add.phtml';
 
+    /**
+     * @return AbstractBlock
+     */
     protected function _prepareLayout()
     {
         $this->addChild('save_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -59,21 +66,33 @@ class Add extends \Magento\Backend\Block\Template
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     protected function _getHeader()
     {
         return __('Add New Attribute Set');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveButtonHtml()
     {
         return $this->getChildHtml('save_button');
     }
 
+    /**
+     * @return string
+     */
     public function getBackButtonHtml()
     {
         return $this->getChildHtml('back_button');
     }
 
+    /**
+     * @return string
+     */
     public function getFormHtml()
     {
         return $this->getChildHtml('setForm');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php
index 65741a0fa754539dc798b73849647c4387c9cef1..eb94e33e4c30c6594de38e952a3e3b91abf1726d 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main.php
@@ -41,6 +41,9 @@ class Main extends \Magento\Backend\Block\Template
      */
     protected $_template = 'catalog/product/attribute/set/toolbar/main.phtml';
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->addChild('addButton', 'Magento\Backend\Block\Widget\Button', array(
@@ -51,16 +54,25 @@ class Main extends \Magento\Backend\Block\Template
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getNewButtonHtml()
     {
         return $this->getChildHtml('addButton');
     }
 
+    /**
+     * @return string
+     */
     protected function _getHeader()
     {
         return __('Product Templates');
     }
 
+    /**
+     * @return string
+     */
     protected function _toHtml()
     {
         $this->_eventManager->dispatch('adminhtml_catalog_product_attribute_set_toolbar_main_html_before', array(
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main/Filter.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main/Filter.php
index 19d09de80397e29489a3551e361f1f354ba41258..5d4abf2645f1eee7f9f235ae7ae530fe7ba699bd 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main/Filter.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Main/Filter.php
@@ -32,6 +32,8 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Toolbar\Main;
 
+use Magento\Backend\Block\Widget\Form;
+
 class Filter
     extends \Magento\Backend\Block\Widget\Form\Generic
 {
@@ -58,6 +60,9 @@ class Filter
         parent::__construct($context, $registry, $formFactory, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         /** @var \Magento\Data\Form $form */
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Configure.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Configure.php
index ab86716a4d07d11c607063954e682072d6963df8..56584b595420517d7e52186f6ac606111fd2a780 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Configure.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Configure.php
@@ -40,6 +40,9 @@ class Configure extends \Magento\Backend\Block\Widget
      */
     protected $_product;
 
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/composite/configure.phtml';
 
     /**
@@ -92,7 +95,7 @@ class Configure extends \Magento\Backend\Block\Widget
      * Set product object
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Composite\Configure
+     * @return $this
      */
     public function setProduct(\Magento\Catalog\Model\Product $product = null)
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Created.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Created.php
index 3823e0a17db5f3449b102a5fc5577647114137dc..d619c590abc68810f82c4fa8a115462b7349b198 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Created.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Created.php
@@ -35,7 +35,14 @@ namespace Magento\Catalog\Block\Adminhtml\Product;
 
 class Created extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var \Magento\Catalog\Model\Product
+     */
     protected $_configurableProduct;
+
+    /**
+     * @var \Magento\Catalog\Model\Product
+     */
     protected $_product;
 
     /**
@@ -70,6 +77,9 @@ class Created extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _prepareLayout()
     {
         $this->addChild('close_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -78,12 +88,17 @@ class Created extends \Magento\Backend\Block\Widget
         ));
     }
 
-
+    /**
+     * @return string
+     */
     public function getCloseButtonHtml()
     {
         return $this->getChildHtml('close_button');
     }
 
+    /**
+     * @return int
+     */
     public function getProductId()
     {
         return (int) $this->getRequest()->getParam('id');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php
index 3502ccac77d440576af1cf6348863c2cf893efca..9b81ec717d7ff3c4a97ad121e17e00d79e3c62db 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product;
 
 class Edit extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit.phtml';
 
     /**
@@ -82,6 +85,9 @@ class Edit extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -102,7 +108,7 @@ class Edit extends \Magento\Backend\Block\Widget
     /**
      * Add elements in layout
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -142,31 +148,49 @@ class Edit extends \Magento\Backend\Block\Widget
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getBackButtonHtml()
     {
         return $this->getChildHtml('back_button');
     }
 
+    /**
+     * @return string
+     */
     public function getCancelButtonHtml()
     {
         return $this->getChildHtml('reset_button');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveButtonHtml()
     {
         return $this->getChildHtml('save_button');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveAndEditButtonHtml()
     {
         return $this->getChildHtml('save_and_edit_button');
     }
 
+    /**
+     * @return string
+     */
     public function getDeleteButtonHtml()
     {
         return $this->getChildHtml('delete_button');
     }
 
+    /**
+     * @return string
+     */
     public function getDuplicateButtonHtml()
     {
         return $this->getChildHtml('duplicate_button');
@@ -182,16 +206,25 @@ class Edit extends \Magento\Backend\Block\Widget
         return $this->getChildHtml('save-split-button');
     }
 
+    /**
+     * @return string
+     */
     public function getValidationUrl()
     {
         return $this->getUrl('catalog/*/validate', array('_current'=>true));
     }
 
+    /**
+     * @return string
+     */
     public function getSaveUrl()
     {
         return $this->getUrl('catalog/*/save', array('_current'=>true, 'back'=>null));
     }
 
+    /**
+     * @return string
+     */
     public function getSaveAndContinueUrl()
     {
         return $this->getUrl('catalog/*/save', array(
@@ -202,11 +235,17 @@ class Edit extends \Magento\Backend\Block\Widget
         ));
     }
 
+    /**
+     * @return mixed
+     */
     public function getProductId()
     {
         return $this->getProduct()->getId();
     }
 
+    /**
+     * @return mixed
+     */
     public function getProductSetId()
     {
         $setId = false;
@@ -216,11 +255,17 @@ class Edit extends \Magento\Backend\Block\Widget
         return $setId;
     }
 
+    /**
+     * @return string
+     */
     public function getDuplicateUrl()
     {
         return $this->getUrl('catalog/*/duplicate', array('_current'=>true));
     }
 
+    /**
+     * @return string
+     */
     public function getHeader()
     {
         if ($this->getProduct()->getId()) {
@@ -231,6 +276,9 @@ class Edit extends \Magento\Backend\Block\Widget
         return $header;
     }
 
+    /**
+     * @return string
+     */
     public function getAttributeSetName()
     {
         if ($setId = $this->getProduct()->getAttributeSetId()) {
@@ -240,6 +288,9 @@ class Edit extends \Magento\Backend\Block\Widget
         return '';
     }
 
+    /**
+     * @return bool
+     */
     public function getIsConfigured()
     {
         $result = true;
@@ -253,6 +304,9 @@ class Edit extends \Magento\Backend\Block\Widget
         return $result;
     }
 
+    /**
+     * @return string
+     */
     public function getSelectedTabId()
     {
         return addslashes(htmlspecialchars($this->getRequest()->getParam('tab')));
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php
index 626d6bd800cec208903d67c9af0d2b84236818b5..6a0f6c6291ab6460fde1cde90eed9a5b1f2a8bbc 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute.php
@@ -34,30 +34,36 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action;
 
+use Magento\Catalog\Helper\Product\Edit\Action\Attribute as ActionAttribute;
+use Magento\Catalog\Model\Resource\Product\Collection;
+
 class Attribute extends \Magento\Backend\Block\Widget
 {
 
     /**
      * Adminhtml catalog product edit action attribute
      *
-     * @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute
+     * @var ActionAttribute
      */
     protected $_helperActionAttribute = null;
 
     /**
      * @param \Magento\Backend\Block\Template\Context $context
-     * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $helperActionAttribute
+     * @param ActionAttribute $helperActionAttribute
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
-        \Magento\Catalog\Helper\Product\Edit\Action\Attribute $helperActionAttribute,
+        ActionAttribute $helperActionAttribute,
         array $data = array()
     ) {
         $this->_helperActionAttribute = $helperActionAttribute;
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _prepareLayout()
     {
         $this->addChild('back_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -85,7 +91,7 @@ class Attribute extends \Magento\Backend\Block\Widget
     /**
      * Retrieve selected products for update
      *
-     * @return unknown
+     * @return Collection
      */
     public function getProducts()
     {
@@ -95,7 +101,7 @@ class Attribute extends \Magento\Backend\Block\Widget
     /**
      * Retrieve block attributes update helper
      *
-     * @return \Magento\Catalog\Helper\Product\Edit\Action\Attribute
+     * @return ActionAttribute|null
      */
     protected function _getHelper()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
index 78f9d02c5a4c42d1ec1e7904b71595cb4b7dbf5a..8b17998f3e4dd9665fe108aa085179f162473e67 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Attributes.php
@@ -34,6 +34,8 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
 
+use Magento\Data\Form\Element\AbstractElement;
+
 class Attributes
     extends \Magento\Catalog\Block\Adminhtml\Form
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
@@ -69,12 +71,18 @@ class Attributes
         parent::__construct($context, $registry, $formFactory, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->setShowGlobalIcon(true);
     }
 
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         $this->setFormExcludedFieldList(array(
@@ -110,7 +118,7 @@ class Attributes
     /**
      * Retrieve attributes for product mass update
      *
-     * @return array
+     * @return \Magento\Object[]
      */
     public function getAttributes()
     {
@@ -136,7 +144,7 @@ class Attributes
     /**
      * Custom additional element html
      *
-     * @param \Magento\Data\Form\Element\AbstractElement $element
+     * @param AbstractElement $element
      * @return string
      */
     protected function _getAdditionalElementHtml($element)
@@ -164,21 +172,33 @@ HTML;
         return $html;
     }
 
+    /**
+     * @return string
+     */
     public function getTabLabel()
     {
         return __('Attributes');
     }
 
+    /**
+     * @return string
+     */
     public function getTabTitle()
     {
         return __('Attributes');
     }
 
+    /**
+     * @return bool
+     */
     public function canShowTab()
     {
         return true;
     }
 
+    /**
+     * @return bool
+     */
     public function isHidden()
     {
         return false;
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php
index 58b67b478593926f2773469723b39fc559d58e22..6c6334b144caf7a7841f0fb556247613bb567261 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php
@@ -33,6 +33,8 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
 
+use Magento\CatalogInventory\Model\Stock\Item;
+
 class Inventory
     extends \Magento\Backend\Block\Widget
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
@@ -91,31 +93,42 @@ class Inventory
      * Get default config value
      *
      * @param string $field
-     * @return mixed
+     * @return string|null
      */
     public function getDefaultConfigValue($field)
     {
-        return $this->_storeConfig->getConfig(\Magento\CatalogInventory\Model\Stock\Item::XML_PATH_ITEM . $field, $this->getStoreId());
+        return $this->_storeConfig->getConfig(Item::XML_PATH_ITEM . $field, $this->getStoreId());
     }
 
     /**
-     * ######################## TAB settings #################################
+     * Tab settings
+     *
+     * @return string
      */
     public function getTabLabel()
     {
         return __('Advanced Inventory');
     }
 
+    /**
+     * @return string
+     */
     public function getTabTitle()
     {
         return __('Advanced Inventory');
     }
 
+    /**
+     * @return bool
+     */
     public function canShowTab()
     {
         return true;
     }
 
+    /**
+     * @return bool
+     */
     public function isHidden()
     {
         return false;
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Websites.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Websites.php
index ee105107e23c5179e00be3c0502e536314fd77a4..2577b008da46158b2fedba6a8aa6499e3bd12d30 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Websites.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Websites.php
@@ -33,43 +33,68 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
 
+use Magento\Core\Model\Store\Group;
+use Magento\Core\Model\Website;
+
 class Websites
     extends \Magento\Backend\Block\Widget
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
+    /**
+     * @return Website[]
+     */
     public function getWebsiteCollection()
     {
         return $this->_storeManager->getWebsites();
     }
 
-    public function getGroupCollection(\Magento\Core\Model\Website $website)
+    /**
+     * @param Website $website
+     * @return Group[]
+     */
+    public function getGroupCollection(Website $website)
     {
         return $website->getGroups();
     }
 
-    public function getStoreCollection(\Magento\Core\Model\Store\Group $group)
+    /**
+     * @param Group $group
+     * @return array
+     */
+    public function getStoreCollection(Group $group)
     {
         return $group->getStores();
     }
 
     /**
-     * ######################## TAB settings #################################
+     * Tab settings
+     *
+     * @return string
      */
     public function getTabLabel()
     {
         return __('Websites');
     }
 
+    /**
+     * @return string
+     */
     public function getTabTitle()
     {
         return __('Websites');
     }
 
+    /**
+     * @return bool
+     */
     public function canShowTab()
     {
         return true;
     }
 
+    /**
+     * @return bool
+     */
     public function isHidden()
     {
         return false;
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/NewCategory.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/NewCategory.php
index 8abe4f5ad9661ea14f082206f78cd0bcb267771e..298d2066a0cc6f339fee8bc32a14751c838fa18b 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/NewCategory.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/NewCategory.php
@@ -72,6 +72,8 @@ class NewCategory extends \Magento\Backend\Block\Widget\Form\Generic
 
     /**
      * Form preparation
+     *
+     * @return void
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Ajax/Serializer.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Ajax/Serializer.php
index 37c7d9dfc8859f106fb20b3e6170c210f8fd0fb3..bfa70fab826ffff2ed4cb9d4154288282950ed15 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Ajax/Serializer.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Ajax/Serializer.php
@@ -27,6 +27,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Ajax;
 
 class Serializer extends \Magento\View\Element\Template
 {
+    /**
+     * @return $this
+     */
     public function _construct()
     {
         parent::_construct();
@@ -34,6 +37,9 @@ class Serializer extends \Magento\View\Element\Template
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getProductsJSON()
     {
         $result = array();
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php
index 8d89f26d3f3ce164a8f2450b238eda54afecc0fd..002497a5d2d77dd9e33d1870e47b605d6dad25d6 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts.php
@@ -37,8 +37,14 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
 class Alerts extends \Magento\Backend\Block\Widget\Tab
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/tab/alert.phtml';
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $accordion = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Accordion')
@@ -71,6 +77,9 @@ class Alerts extends \Magento\Backend\Block\Widget\Tab
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getAccordionHtml()
     {
         return $this->getChildHtml('accordion');
@@ -79,7 +88,7 @@ class Alerts extends \Magento\Backend\Block\Widget\Tab
     /**
      * Tab is hidden
      *
-     * @return boolean
+     * @return bool
      */
     public function canShowTab()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php
index 7f78cb96fb7044ec28c1d46cb8decff97c2dd9d0..0b5c58052993c3f23f596bac67a9f16952282b55 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php
@@ -34,7 +34,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts;
 
-class Price extends \Magento\Backend\Block\Widget\Grid\Extended
+use Magento\Backend\Block\Widget\Grid;
+use \Magento\Backend\Block\Widget\Grid\Extended;
+
+class Price extends Extended
 {
     /**
      * Catalog data
@@ -67,6 +70,9 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -79,6 +85,9 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended
         $this->setEmptyText(__('There are no customers for this alert.'));
     }
 
+    /**
+     * @return Grid
+     */
     protected function _prepareCollection()
     {
         $productId = $this->getRequest()->getParam('id');
@@ -94,6 +103,9 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareCollection();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('firstname', array(
@@ -139,6 +151,9 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareColumns();
     }
 
+    /**
+     * @return string
+     */
     public function getGridUrl()
     {
         $productId = $this->getRequest()->getParam('id');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php
index 3abdd6e4b3b6a2e5f222863fae6b783bca49e57a..88da5c017d368eca118c07fba1623dc780dd2097 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php
@@ -34,7 +34,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts;
 
-class Stock extends \Magento\Backend\Block\Widget\Grid\Extended
+use Magento\Backend\Block\Widget\Grid;
+use \Magento\Backend\Block\Widget\Grid\Extended;
+
+class Stock extends Extended
 {
     /**
      * Catalog data
@@ -67,6 +70,9 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -79,6 +85,9 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended
         $this->setEmptyText(__('There are no customers for this alert.'));
     }
 
+    /**
+     * @return Grid
+     */
     protected function _prepareCollection()
     {
         $productId = $this->getRequest()->getParam('id');
@@ -95,6 +104,9 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareCollection();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('firstname', array(
@@ -132,6 +144,9 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareColumns();
     }
 
+    /**
+     * @return string
+     */
     public function getGridUrl()
     {
         $productId = $this->getRequest()->getParam('id');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php
index f722228288b1d65423bf8e13a9d1bb2cb776b019..109be40b628badce0a7607ea1721f2bda60f807c 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes.php
@@ -70,6 +70,8 @@ class Attributes extends \Magento\Catalog\Block\Adminhtml\Form
 
     /**
      * Load Wysiwyg on demand and prepare layout
+     *
+     * @return void
      */
     protected function _prepareLayout()
     {
@@ -84,7 +86,7 @@ class Attributes extends \Magento\Catalog\Block\Adminhtml\Form
     /**
      * Prepare attributes form
      *
-     * @return null
+     * @return void
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Create.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Create.php
index 90369dc44c4c3ffb1348b261a56f48da1730fa5e..d862f375c04bb14a0bb17f9e9e6a62e12149c6c6 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Create.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Create.php
@@ -33,7 +33,9 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes;
 
-class Create extends \Magento\Backend\Block\Widget\Button
+use Magento\Backend\Block\Widget\Button;
+
+class Create extends Button
 {
     /**
      * Config of create new attribute
@@ -56,6 +58,9 @@ class Create extends \Magento\Backend\Block\Widget\Button
         return $this->_config;
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeToHtml()
     {
         $this->setId('create_attribute_' . $this->getConfig()->getGroupId())
@@ -94,6 +99,9 @@ class Create extends \Magento\Backend\Block\Widget\Button
         return parent::_beforeToHtml();
     }
 
+    /**
+     * @return string
+     */
     protected function _toHtml()
     {
         $this->setCanShow(true);
@@ -107,8 +115,11 @@ class Create extends \Magento\Backend\Block\Widget\Button
         return parent::_toHtml();
     }
 
+    /**
+     * @return string
+     */
     public function getJsObjectName()
     {
         return $this->getId() . 'JsObject';
     }
-} // Class \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes\Create End
+}
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php
index 36366ac4253aabab24c6aabfb432f64c7693a757..199be8aa211f50f2e33a70fb4f0b026d78c16416 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php
@@ -74,6 +74,8 @@ class Search extends \Magento\Backend\Block\Widget
 
     /**
      * Define block template
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php
index af1959479e24da2c1891dff39a798d6d4b9c898e..ed612c80dd0b17801ae444ab833cfd9bd9f8a0b2 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php
@@ -33,7 +33,11 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
-class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
+use Magento\Backend\Block\Widget\Grid\Column;
+use Magento\Backend\Block\Widget\Grid\Extended;
+use Magento\Catalog\Model\Product;
+
+class Crosssell extends Extended
 {
     /**
      * Core registry
@@ -111,6 +115,7 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Set grid params
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -127,9 +132,9 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * Retirve currently edited product model
+     * Retrieve currently edited product model
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -139,8 +144,8 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add filter
      *
-     * @param object $column
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Crosssell
+     * @param Column $column
+     * @return $this
      */
     protected function _addColumnFilterToCollection($column)
     {
@@ -166,7 +171,7 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare collection
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return Extended
      */
     protected function _prepareCollection()
     {
@@ -193,7 +198,7 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Checks when this block is readonly
      *
-     * @return boolean
+     * @return bool
      */
     public function isReadonly()
     {
@@ -203,7 +208,7 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add columns to grid
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return $this
      */
     protected function _prepareColumns()
     {
@@ -308,7 +313,7 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * Rerieve grid URL
+     * Retrieve grid URL
      *
      * @return string
      */
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php
index 0a39be93b2e7996438184ebbf9633b9ff9659c58..8b8b68f9c85e8dcdeaacf574ffc41a3188daac37 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php
@@ -33,6 +33,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
 class Inventory extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/tab/inventory.phtml';
 
     /**
@@ -82,6 +85,9 @@ class Inventory extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return array
+     */
     public function getBackordersOption()
     {
         if ($this->_catalogData->isModuleEnabled('Magento_CatalogInventory')) {
@@ -125,11 +131,18 @@ class Inventory extends \Magento\Backend\Block\Widget
         return $this->getProduct()->getStockItem();
     }
 
+    /**
+     * @return bool
+     */
     public function isConfigurable()
     {
         return $this->getProduct()->isConfigurable();
     }
 
+    /**
+     * @param string $field
+     * @return string|null
+     */
     public function getFieldValue($field)
     {
         if ($this->getStockItem()) {
@@ -139,6 +152,10 @@ class Inventory extends \Magento\Backend\Block\Widget
         return $this->_storeConfig->getConfig(\Magento\CatalogInventory\Model\Stock\Item::XML_PATH_ITEM . $field);
     }
 
+    /**
+     * @param string $field
+     * @return string|null
+     */
     public function getConfigFieldValue($field)
     {
         if ($this->getStockItem()) {
@@ -150,6 +167,10 @@ class Inventory extends \Magento\Backend\Block\Widget
         return $this->_storeConfig->getConfig(\Magento\CatalogInventory\Model\Stock\Item::XML_PATH_ITEM . $field);
     }
 
+    /**
+     * @param string $field
+     * @return string|null
+     */
     public function getDefaultConfigValue($field)
     {
         return $this->_storeConfig->getConfig(\Magento\CatalogInventory\Model\Stock\Item::XML_PATH_ITEM . $field);
@@ -158,13 +179,16 @@ class Inventory extends \Magento\Backend\Block\Widget
     /**
      * Is readonly stock
      *
-     * @return boolean
+     * @return bool
      */
     public function isReadonly()
     {
         return $this->getProduct()->getInventoryReadonly();
     }
 
+    /**
+     * @return bool
+     */
     public function isNew()
     {
         if ($this->getProduct()->getId()) {
@@ -173,6 +197,9 @@ class Inventory extends \Magento\Backend\Block\Widget
         return true;
     }
 
+    /**
+     * @return string
+     */
     public function getFieldSuffix()
     {
         return 'product';
@@ -191,7 +218,7 @@ class Inventory extends \Magento\Backend\Block\Widget
     /**
      * Check if product type is virtual
      *
-     * @return boolean
+     * @return bool
      */
     public function isVirtual()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php
index a1b67ef76f23454c77af2a07da353c0a28d9095b..fa193e6a7d363f96585e6e3b0f6da6ea21a17442 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options.php
@@ -34,10 +34,18 @@
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
-class Options extends \Magento\Backend\Block\Widget
+use Magento\Backend\Block\Widget;
+
+class Options extends Widget
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/options.phtml';
 
+    /**
+     * @return Widget
+     */
     protected function _prepareLayout()
     {
         $this->addChild('add_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -57,11 +65,17 @@ class Options extends \Magento\Backend\Block\Widget
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getAddButtonHtml()
     {
         return $this->getChildHtml('add_button');
     }
 
+    /**
+     * @return string
+     */
     public function getOptionsBoxHtml()
     {
         return $this->getChildHtml('options_box');
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php
index 961102e241d957941f43f06cec69846d7d418316..5f949d9712d3657be21f25de1304893c5f701332 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php
@@ -29,14 +29,29 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options;
 
-class Option extends \Magento\Backend\Block\Widget
+use Magento\Backend\Block\Widget;
+use Magento\Catalog\Model\Product;
+
+class Option extends Widget
 {
+    /**
+     * @var Product
+     */
     protected $_productInstance;
 
+    /**
+     * @var \Magento\Object[]
+     */
     protected $_values;
 
+    /**
+     * @var int
+     */
     protected $_itemCount = 1;
 
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/options/option.phtml';
 
     /**
@@ -52,7 +67,7 @@ class Option extends \Magento\Backend\Block\Widget
     protected $_productOptionConfig;
 
     /**
-     * @var \Magento\Catalog\Model\Product
+     * @var Product
      */
     protected $_product;
 
@@ -70,7 +85,7 @@ class Option extends \Magento\Backend\Block\Widget
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Backend\Model\Config\Source\Yesno $configYesNo
      * @param \Magento\Catalog\Model\Config\Source\Product\Options\Type $optionType
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Catalog\Model\ProductOptions\ConfigInterface $productOptionConfig
      * @param array $data
@@ -79,7 +94,7 @@ class Option extends \Magento\Backend\Block\Widget
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Backend\Model\Config\Source\Yesno $configYesNo,
         \Magento\Catalog\Model\Config\Source\Product\Options\Type $optionType,
-        \Magento\Catalog\Model\Product $product,
+        Product $product,
         \Magento\Core\Model\Registry $registry,
         \Magento\Catalog\Model\ProductOptions\ConfigInterface $productOptionConfig,
         array $data = array()
@@ -94,6 +109,8 @@ class Option extends \Magento\Backend\Block\Widget
 
     /**
      * Class constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -103,11 +120,18 @@ class Option extends \Magento\Backend\Block\Widget
         $this->setCanEditPrice(true);
     }
 
+    /**
+     * @return int
+     */
     public function getItemCount()
     {
         return $this->_itemCount;
     }
 
+    /**
+     * @param int $itemCount
+     * @return $this
+     */
     public function setItemCount($itemCount)
     {
         $this->_itemCount = max($this->_itemCount, $itemCount);
@@ -117,7 +141,7 @@ class Option extends \Magento\Backend\Block\Widget
     /**
      * Get Product
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -133,6 +157,10 @@ class Option extends \Magento\Backend\Block\Widget
         return $this->_productInstance;
     }
 
+    /**
+     * @param Product $product
+     * @return $this
+     */
     public function setProduct($product)
     {
         $this->_productInstance = $product;
@@ -162,13 +190,16 @@ class Option extends \Magento\Backend\Block\Widget
     /**
      * Check block is readonly
      *
-     * @return boolean
+     * @return bool
      */
     public function isReadonly()
     {
         return $this->getProduct()->getOptionsReadonly();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         foreach ($this->_productOptionConfig->getAll() as $option) {
@@ -178,6 +209,9 @@ class Option extends \Magento\Backend\Block\Widget
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return mixed
+     */
     public function getAddButtonId()
     {
         $buttonId = $this->getLayout()
@@ -186,6 +220,9 @@ class Option extends \Magento\Backend\Block\Widget
         return $buttonId;
     }
 
+    /**
+     * @return mixed
+     */
     public function getTypeSelectHtml()
     {
         $select = $this->getLayout()->createBlock('Magento\View\Element\Html\Select')
@@ -199,6 +236,9 @@ class Option extends \Magento\Backend\Block\Widget
         return $select->getHtml();
     }
 
+    /**
+     * @return mixed
+     */
     public function getRequireSelectHtml()
     {
         $select = $this->getLayout()->createBlock('Magento\View\Element\Html\Select')
@@ -245,6 +285,9 @@ class Option extends \Magento\Backend\Block\Widget
         return $templates;
     }
 
+    /**
+     * @return \Magento\Object[]
+     */
     public function getOptionValues()
     {
         $optionsArr = $this->getProduct()->getOptions();
@@ -365,6 +408,11 @@ class Option extends \Magento\Backend\Block\Widget
         return $useDefault;
     }
 
+    /**
+     * @param float $value
+     * @param string $type
+     * @return string
+     */
     public function getPriceValue($value, $type)
     {
         if ($type == 'percent') {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Popup/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Popup/Grid.php
index ec3dc2c4bd0dd6502263eff3dcb456d37809fc65..21a87cb6cb764d1bfa90d8c7b92c57b3ddc47d67 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Popup/Grid.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Popup/Grid.php
@@ -33,13 +33,15 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Popup;
 
+use Magento\Catalog\Model\Product;
+
 class Grid
     extends \Magento\Catalog\Block\Adminhtml\Product\Grid
 {
     /**
      * Return empty row url for disabling JS click events
      *
-     * @param \Magento\Catalog\Model\Product|\Magento\Object
+     * @param Product|\Magento\Object $row
      * @return string|null
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
@@ -50,6 +52,8 @@ class Grid
 
     /**
      * Remove some grid columns for product grid in popup
+     *
+     * @return void
      */
     public function _prepareColumns()
     {
@@ -63,7 +67,7 @@ class Grid
     /**
      * Add import action to massaction block
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Popup\Grid
+     * @return $this
      */
     public function _prepareMassaction()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php
index 506a991ba3e65cc7541e0ef2bf753b38aa01500b..03b8d29b0a9a2581ea1be3bbd5579b3683d1aa46 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/AbstractType.php
@@ -36,6 +36,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type;
 
 class AbstractType extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var string
+     */
     protected $_name = 'abstract';
 
     /**
@@ -57,6 +60,9 @@ class AbstractType extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->setChild('option_price_type',
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Date.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Date.php
index 8023493caca302873ae0f6cd31fad1cffe488e1e..ee4599404a3fe63021d9dd2c94b2b97d6a5bf167 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Date.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Date.php
@@ -37,5 +37,8 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type;
 class Date extends
     \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type\AbstractType
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/options/type/date.phtml';
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/File.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/File.php
index 15ac9ffc648d0c61829fb041f48137762e621f3d..4364a486bd82350b3757c0d416f5b9e5028a66f1 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/File.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/File.php
@@ -37,5 +37,8 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type;
 class File extends
     \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type\AbstractType
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/options/type/file.phtml';
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php
index 04989355ac5db4d58b7247e179ba80046c244c01..12cc40f7096537235dab1aff245b0c8f1f231d2a 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php
@@ -37,11 +37,15 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type;
 class Select extends
     \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type\AbstractType
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/options/type/select.phtml';
 
     /**
      * Class constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -51,6 +55,9 @@ class Select extends
         $this->setCanReadPrice(true);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->addChild('add_select_row_button', 'Magento\Backend\Block\Widget\Button', array(
@@ -68,16 +75,25 @@ class Select extends
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getAddButtonHtml()
     {
         return $this->getChildHtml('add_select_row_button');
     }
 
+    /**
+     * @return string
+     */
     public function getDeleteButtonHtml()
     {
         return $this->getChildHtml('delete_select_row_button');
     }
 
+    /**
+     * @return string
+     */
     public function getPriceTypeSelectHtml()
     {
         $this->getChildBlock('option_price_type')
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Text.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Text.php
index e31eafa057ee8c4d07feb68075da9fd0f3424150..b1bb15811afa1e075159578bcd88d53de0555207 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Text.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Text.php
@@ -37,5 +37,8 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type;
 class Text extends
     \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Options\Type\AbstractType
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/options/type/text.phtml';
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php
index ace2a33b8c9fc2bcd5f98959f72e47ff5be30e0f..e5097d346a8aa781b7ad540cb80f83c060c6be3d 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price.php
@@ -31,6 +31,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
 class Price extends \Magento\Backend\Block\Widget\Form\Generic
 {
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         $product = $this->_coreRegistry->registry('product');
@@ -59,4 +62,4 @@ class Price extends \Magento\Backend\Block\Widget\Form\Generic
 
         $this->setForm($form);
     }
-}// Class \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price END
+}
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php
index 84ad57950b55492e115d96da0277203a00e139da..3fcea471592efd64e9d05f5aa6f39527f0016e00 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group.php
@@ -37,6 +37,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price;
 class Group
     extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group\AbstractGroup
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/price/group.phtml';
 
     /**
@@ -74,7 +77,7 @@ class Group
      *
      * Add "Add Group Price" button to layout
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php
index b3aba882d006a0663c44cf6811d6b836c80a17c1..aee9d7bd2f79fa09ae62e770750ab667bb95a36b 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Tier.php
@@ -36,7 +36,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price;
 class Tier
     extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Group\AbstractGroup
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/price/tier.phtml';
 
     /**
@@ -87,7 +89,7 @@ class Tier
      * Prepare global layout
      * Add "Add tier" button to layout
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Tier
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php
index ecbc97934debce0ff89270399347b359271dfcc1..adb8d53dc40af5aa7aab8a72f3c7056a44432529 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php
@@ -33,7 +33,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
-class Related extends \Magento\Backend\Block\Widget\Grid\Extended
+use Magento\Backend\Block\Widget\Grid\Column;
+use Magento\Backend\Block\Widget\Grid\Extended;
+
+class Related extends Extended
 {
     /**
      * Core registry
@@ -111,6 +114,7 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Set grid params
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -127,9 +131,9 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * Retirve currently edited product model
+     * Retrieve currently edited product model
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return array|null
      */
     public function getProduct()
     {
@@ -139,8 +143,8 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add filter
      *
-     * @param object $column
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Related
+     * @param Column $column
+     * @return $this
      */
     protected function _addColumnFilterToCollection($column)
     {
@@ -166,7 +170,7 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare collection
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return Extended
      */
     protected function _prepareCollection()
     {
@@ -190,7 +194,7 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Checks when this block is readonly
      *
-     * @return boolean
+     * @return bool
      */
     public function isReadonly()
     {
@@ -200,7 +204,7 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add columns to grid
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return $this
      */
     protected function _prepareColumns()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config.php
index b0cd6d8970c9326be3e94cbc734215950c0e30b8..d99e4682f1b97f775d858a7007cbb3a681e5f37f 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config.php
@@ -33,6 +33,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super;
 
+use Magento\Catalog\Model\Product;
+use Magento\Core\Model\App;
+use Magento\Core\Model\LocaleInterface;
+
 class Config
     extends \Magento\Backend\Block\Widget
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
@@ -88,6 +92,7 @@ class Config
     /**
      * Initialize block
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -112,7 +117,7 @@ class Config
     /**
      * Check block is readonly
      *
-     * @return boolean
+     * @return bool
      */
     public function isReadonly()
     {
@@ -122,7 +127,7 @@ class Config
     /**
      * Check whether attributes of configurable products can be editable
      *
-     * @return boolean
+     * @return bool
      */
     public function isAttributesConfigurationReadonly()
     {
@@ -132,7 +137,7 @@ class Config
     /**
      * Check whether prices of configurable products can be editable
      *
-     * @return boolean
+     * @return bool
      */
     public function isAttributesPricesReadonly()
     {
@@ -143,7 +148,7 @@ class Config
     /**
      * Prepare Layout data
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -224,7 +229,7 @@ class Config
     /**
      * Retrieve currently edited product object
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -294,10 +299,11 @@ class Config
     /**
      * Retrieve configurable settings
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return array
      */
-    public function getConfigurableSettings($product) {
+    public function getConfigurableSettings($product)
+    {
         $data = array();
         $attributes = $this->_configurableType
             ->getUsedProductAttributes($this->getProduct());
@@ -460,7 +466,7 @@ class Config
     }
 
     /**
-     * @return \Magento\Core\Model\App
+     * @return App
      */
     public function getApp()
     {
@@ -468,7 +474,7 @@ class Config
     }
 
     /**
-     * @return \Magento\Core\Model\LocaleInterface
+     * @return LocaleInterface
      */
     public function getLocale()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php
index ab214a0f01d2bc85e2c28514f4cfc3fc182bdcc6..adcbea35c7cfe5f1df3a6c32a36bd08eb63814af 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Filter/Inventory.php
@@ -34,9 +34,14 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Filter;
 
-class Inventory extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
+use Magento\Backend\Block\Widget\Grid\Column\Filter\Select;
+
+class Inventory extends Select
 {
 
+    /**
+     * @return array
+     */
     protected function _getOptions()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php
index c83a35a99fd2f591e5fa1d9bff58baabc83ea9ba..5096329da0efb54e2fe15ccb9b764fb8aeff3f5c 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Grid/Renderer/Checkbox.php
@@ -60,8 +60,8 @@ class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkb
     /**
      * Renders grid column
      *
-     * @param   \Magento\Object $row
-     * @return  string
+     * @param \Magento\Object $row
+     * @return string
      */
     public function render(\Magento\Object $row)
     {
@@ -69,6 +69,10 @@ class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkb
         return $result.'<input type="hidden" class="value-json" value="'.htmlspecialchars($this->getAttributesJson($row)).'" />';
     }
 
+    /**
+     * @param \Magento\Object $row
+     * @return string
+     */
     public function getAttributesJson(\Magento\Object $row)
     {
         if(!$this->getColumn()->getAttributes()) {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php
index 8f98e63ef44ad1f0d94264ed0d2fb2a96abc47d8..d806c35012707d5ec2b18201e423485c6bff9c41 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php
@@ -33,6 +33,8 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config;
 
+use Magento\Catalog\Model\Product;
+
 class Matrix
     extends \Magento\Backend\Block\Template
 {
@@ -95,7 +97,7 @@ class Matrix
     /**
      * Retrieve currently edited product object
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -166,8 +168,7 @@ class Matrix
     /**
      * Get url for product edit
      *
-     * @param $id
-     *
+     * @param string $id
      * @return string
      */
     public function getEditProductUrl($id)
@@ -175,7 +176,6 @@ class Matrix
         return $this->getUrl('catalog/*/edit', array('id' => $id));
     }
 
-
     /**
      * Retrieve attributes data
      *
@@ -217,7 +217,7 @@ class Matrix
     /**
      * Retrieve actual list of associated products, array key is obtained from varying attributes values
      *
-     * @return array
+     * @return Product[]
      */
     public function getAssociatedProducts()
     {
@@ -237,7 +237,7 @@ class Matrix
      * Retrieve actual list of associated products (i.e. if product contains variations matrix form data
      * - previously saved in database relations are not considered)
      *
-     * @return array
+     * @return Product[]
      */
     protected function _getAssociatedProducts()
     {
@@ -248,7 +248,7 @@ class Matrix
         }
         $products = array();
         foreach ($ids as $productId) {
-            /** @var $product \Magento\Catalog\Model\Product */
+            /** @var $product Product */
             $product = $this->_productFactory->create()->load($productId);
             if ($product->getId()) {
                 $products[] = $product;
@@ -266,7 +266,7 @@ class Matrix
     public function getAttributeFrontendClass($code)
     {
         /** @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */
-        $attribute = $this->_config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $code);
+        $attribute = $this->_config->getAttribute(Product::ENTITY, $code);
         return $attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
             ? $attribute->getFrontend()->getClass()
             : '';
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Simple.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Simple.php
index 547d75b6941ac60942bdca5a52473e3516c7481b..8bfb0e04e32c813945911ece0d0884cebee15a83 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Simple.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Config/Simple.php
@@ -33,18 +33,21 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Config;
 
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ProductFactory;
+
 class Simple
     extends \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes
 {
     /**
      * Link to currently editing product
      *
-     * @var \Magento\Catalog\Model\Product
+     * @var Product
      */
     protected $_product = null;
 
     /**
-     * @var \Magento\Catalog\Model\ProductFactory
+     * @var ProductFactory
      */
     protected $_productFactory;
 
@@ -54,7 +57,7 @@ class Simple
      * @param \Magento\Data\FormFactory $formFactory
      * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
      * @param \Magento\Catalog\Helper\Data $catalogData
-     * @param \Magento\Catalog\Model\ProductFactory $productFactory
+     * @param ProductFactory $productFactory
      * @param array $data
      */
     public function __construct(
@@ -63,13 +66,16 @@ class Simple
         \Magento\Data\FormFactory $formFactory,
         \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
         \Magento\Catalog\Helper\Data $catalogData,
-        \Magento\Catalog\Model\ProductFactory $productFactory,
+        ProductFactory $productFactory,
         array $data = array()
     ) {
         $this->_productFactory = $productFactory;
         parent::__construct($context, $registry, $formFactory, $wysiwygConfig, $catalogData, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _prepareForm()
     {
         /** @var \Magento\Data\Form $form */
@@ -207,7 +213,7 @@ class Simple
     /**
      * Retrieve currently edited product object
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Settings.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Settings.php
index 153905e86ed9b7e74571e13e9bf665eb9e2253d6..0460219e0f803367a589705c5458946d99f93986 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Settings.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Super/Settings.php
@@ -33,7 +33,9 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super;
 
-class Settings extends \Magento\Backend\Block\Widget\Form\Generic
+use Magento\Backend\Block\Widget\Form\Generic;
+
+class Settings extends Generic
 {
     /**
      * @var \Magento\Catalog\Model\Product\Type\Configurable
@@ -69,6 +71,7 @@ class Settings extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare block children and data
      *
+     * @return void
      */
     protected function _prepareLayout()
     {
@@ -86,7 +89,7 @@ class Settings extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Retrieve currently edited product object
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return array|null
      */
     public function getProduct()
     {
@@ -96,7 +99,7 @@ class Settings extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form before rendering HTML
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Super\Settings
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php
index a34c27ab753e5e886ff565661f61e278d6c45cc7..91a4c1eee0c905fd50884f23392141cc0ca51eb7 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php
@@ -111,6 +111,7 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Set grid params
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -140,7 +141,7 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended
      * Add filter
      *
      * @param object $column
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Upsell
+     * @return $this
      */
     protected function _addColumnFilterToCollection($column)
     {
@@ -200,7 +201,7 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add columns to grid
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return $this
      */
     protected function _prepareColumns()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Websites.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Websites.php
index 2de3dca6a19e0d0f84f12b7706bc9af485e82474..f5472863ae22a0b66b22fa38fef29b190786e335 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Websites.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Websites.php
@@ -35,8 +35,14 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
 class Websites extends \Magento\Backend\Block\Store\Switcher
 {
+    /**
+     * @var string
+     */
     protected $_storeFromHtml;
 
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/edit/websites.phtml';
 
     /**
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php
index b1b42b2a6cf115da315bfbb7c8c8e8a322d7c9c3..8ad4947ffcf3bb11659f5fc667988bfcce5116bb 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php
@@ -31,13 +31,18 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Edit;
 
 class Tabs extends \Magento\Backend\Block\Widget\Tabs
 {
+
     const BASIC_TAB_GROUP_CODE = 'basic';
     const ADVANCED_TAB_GROUP_CODE = 'advanced';
 
-    /** @var string */
+    /**
+     * @var string
+     */
     protected $_attributeTabBlock = 'Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes';
 
-    /** @var string */
+    /**
+     * @var string
+     */
     protected $_template = 'Magento_Catalog::product/edit/tabs.phtml';
 
     /**
@@ -109,6 +114,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
         parent::__construct($context, $jsonEncoder, $authSession, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -116,6 +124,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
         $this->setDestElementId('product-edit-form-tabs');
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $product = $this->getProduct();
@@ -298,6 +309,10 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
         return $this->_helperCatalog->getAttributeTabBlock();
     }
 
+    /**
+     * @param string $attributeTabBlock
+     * @return $this
+     */
     public function setAttributeTabBlock($attributeTabBlock)
     {
         $this->_attributeTabBlock = $attributeTabBlock;
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Frontend/Product/Watermark.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Frontend/Product/Watermark.php
index a6c8046948cd8a1d2bf906b18200c63a8906d356..1528e3bfc1272416090f6bc235670be76106d77b 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Frontend/Product/Watermark.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Frontend/Product/Watermark.php
@@ -33,6 +33,8 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Frontend\Product;
 
+use Magento\Data\Form\Element\AbstractElement;
+
 class Watermark
     extends \Magento\Backend\Block\AbstractBlock
     implements \Magento\Data\Form\Element\Renderer\RendererInterface
@@ -80,7 +82,11 @@ class Watermark
         parent::__construct($context, $data);
     }
 
-    public function render(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    public function render(AbstractElement $element)
     {
         $html = $this->_getHeaderHtml($element);
         foreach ($this->_imageTypes as $key => $attribute) {
@@ -124,6 +130,10 @@ class Watermark
         return $html;
     }
 
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
     protected function _getHeaderHtml($element)
     {
         $id = $element->getHtmlId();
@@ -143,6 +153,10 @@ class Watermark
         return $html;
     }
 
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
     protected function _getFooterHtml($element)
     {
         $html = '</tbody></table></fieldset>';
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php
index 3598be070252146fa40e333c9f35161c4a799192..4018a54c3460bfb63e22fe77796fcfc475014630 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php
@@ -108,6 +108,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -120,12 +123,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 
     }
 
+    /**
+     * @return \Magento\Core\Model\Store
+     */
     protected function _getStore()
     {
         $storeId = (int) $this->getRequest()->getParam('store', 0);
         return $this->_storeManager->getStore($storeId);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareCollection()
     {
         $store = $this->_getStore();
@@ -155,7 +164,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
                 'entity_id',
                 null,
                 'inner',
-                \Magento\Core\Model\Store::DEFAULT_STORE_ID
+                Store::DEFAULT_STORE_ID
             );
             $collection->joinAttribute(
                 'custom_name',
@@ -202,6 +211,10 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         return $this;
     }
 
+    /**
+     * @param \Magento\Backend\Block\Widget\Grid\Column $column
+     * @return $this
+     */
     protected function _addColumnFilterToCollection($column)
     {
         if ($this->getCollection()) {
@@ -219,6 +232,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_addColumnFilterToCollection($column);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
         $this->addColumn(
@@ -399,6 +415,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareColumns();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareMassaction()
     {
         $this->setMassactionIdField('entity_id');
@@ -439,11 +458,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getGridUrl()
     {
         return $this->getUrl('catalog/*/grid', array('_current'=>true));
     }
 
+    /**
+     * @param \Magento\Catalog\Model\Product|\Magento\Object $row
+     * @return string
+     */
     public function getRowUrl($row)
     {
         return $this->getUrl(
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Apply.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Apply.php
index 8a9f87ccc70b72581962f0ca440376a1c6a4e103..31f046f1d802524cce57c4e7d3adec009c59e8ba 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Apply.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Apply.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form;
 
 class Apply extends \Magento\Data\Form\Element\Multiselect
 {
+    /**
+     * @return string
+     */
     public function getElementHtml()
     {
         $elementAttributeHtml = '';
@@ -61,7 +64,7 @@ class Apply extends \Magento\Data\Form\Element\Multiselect
      *
      * @param bool $readonly
      * @param bool $useDisabled
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply
+     * @return $this
      */
     public function setReadonly($readonly, $useDisabled = false)
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php
index cbf7773c3390ae02a2f9e71633ce488682fc85bd..0c40224e102ad4c8e6380968b4cb1e29c8982877 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php
@@ -119,7 +119,7 @@ class BaseImage extends \Magento\Data\Form\Element\AbstractElement
         /** @var $product \Magento\Catalog\Model\Product */
         $html = <<<HTML
 <div id="{$htmlId}-container" class="images"
-    data-mage-init="{baseImage:{}}"
+    data-mage-init='{"baseImage":{}}'
     data-max-file-size="{$this->_getFileMaxSize()}"
     >
     <div class="image image-placeholder">
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php
index 9723c5e870fedb6fd05c7c427beca148f8475328..f504e09a531f2d33f5faa99b370a9ffb8bcd0021 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php
@@ -25,6 +25,7 @@
  */
 
 namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form;
+use Magento\Catalog\Model\Resource\Category\Collection;
 
 /**
  * Product form category field helper
@@ -82,6 +83,7 @@ class Category extends \Magento\Data\Form\Element\Multiselect
 
     /**
      * Get values for select
+     *
      * @return array
      */
     public function getValues()
@@ -107,7 +109,8 @@ class Category extends \Magento\Data\Form\Element\Multiselect
 
     /**
      * Get categories collection
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     *
+     * @return Collection
      */
     protected function _getCategoriesCollection()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php
index 7cd53e3b4f61adc0831d1a157b7482d807dc96a3..dfe860a53ca698ba84a2942db98efce99d8dacf4 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php
@@ -34,7 +34,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form;
 
-class Gallery extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Data\Form\Element\AbstractElement;
+use Magento\Eav\Model\Entity\Attribute;
+
+class Gallery extends AbstractElement
 {
     /**
      * @var \Magento\Core\Model\StoreManagerInterface
@@ -67,6 +70,9 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
         parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
     }
 
+    /**
+     * @return string
+     */
     public function getElementHtml()
     {
         $html = $this->getContentHtml();
@@ -89,6 +95,9 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
         return $content->toHtml();
     }
 
+    /**
+     * @return string
+     */
     public function getLabel()
     {
         return '';
@@ -97,7 +106,7 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
     /**
      * Check "Use default" checkbox display availability
      *
-     * @param \Magento\Eav\Model\Entity\Attribute $attribute
+     * @param Attribute $attribute
      * @return bool
      */
     public function canDisplayUseDefault($attribute)
@@ -112,7 +121,7 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
     /**
      * Check default value usage fact
      *
-     * @param \Magento\Eav\Model\Entity\Attribute $attribute
+     * @param Attribute $attribute
      * @return bool
      */
     public function usedDefault($attribute)
@@ -137,7 +146,7 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
      *
      * GLOBAL | WEBSITE | STORE
      *
-     * @param \Magento\Eav\Model\Entity\Attribute $attribute
+     * @param Attribute $attribute
      * @return string
      */
     public function getScopeLabel($attribute)
@@ -160,7 +169,7 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
     /**
      * Retrieve data object related with form
      *
-     * @return \Magento\Catalog\Model\Product || \Magento\Catalog\Model\Category
+     *@return mixed
      */
     public function getDataObject()
     {
@@ -171,7 +180,7 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
      * Retrieve attribute field name
      *
      *
-     * @param \Magento\Eav\Model\Entity\Attribute $attribute
+     * @param Attribute $attribute
      * @return string
      */
     public function getAttributeFieldName($attribute)
@@ -186,7 +195,7 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
     /**
      * Check readonly attribute
      *
-     * @param \Magento\Eav\Model\Entity\Attribute|string $attribute
+     * @param Attribute|string $attribute
      * @return boolean
      */
     public function getAttributeReadonly($attribute)
@@ -202,6 +211,9 @@ class Gallery extends \Magento\Data\Form\Element\AbstractElement
         return false;
     }
 
+    /**
+     * @return string
+     */
     public function toHtml()
     {
         return '<tr><td class="value" colspan="3">' . $this->getElementHtml() . '</td></tr>';
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php
index 06b0b8f3d3b95ed1c85e530f12838104e352c822..911a5a10cf3ca3c5a1244f32109c3d88a3f4d302 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php
@@ -36,8 +36,14 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery;
 
+use Magento\Backend\Block\Media\Uploader;
+use Magento\View\Element\AbstractBlock;
+
 class Content extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/helper/gallery.phtml';
 
     /**
@@ -67,6 +73,9 @@ class Content extends \Magento\Backend\Block\Widget
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return AbstractBlock
+     */
     protected function _prepareLayout()
     {
         $this->addChild('uploader', 'Magento\Backend\Block\Media\Uploader');
@@ -93,7 +102,7 @@ class Content extends \Magento\Backend\Block\Widget
     /**
      * Retrieve uploader block
      *
-     * @return \Magento\Backend\Block\Media\Uploader
+     * @return Uploader
      */
     public function getUploader()
     {
@@ -110,11 +119,17 @@ class Content extends \Magento\Backend\Block\Widget
         return $this->getChildHtml('uploader');
     }
 
+    /**
+     * @return string
+     */
     public function getJsObjectName()
     {
         return $this->getHtmlId() . 'JsObject';
     }
 
+    /**
+     * @return string
+     */
     public function getAddImagesButton()
     {
         return $this->getButtonHtml(
@@ -125,6 +140,9 @@ class Content extends \Magento\Backend\Block\Widget
         );
     }
 
+    /**
+     * @return string
+     */
     public function getImagesJson()
     {
         if (is_array($this->getElement()->getValue())) {
@@ -139,6 +157,9 @@ class Content extends \Magento\Backend\Block\Widget
         return '[]';
     }
 
+    /**
+     * @return string
+     */
     public function getImagesValuesJson()
     {
         $values = array();
@@ -172,6 +193,9 @@ class Content extends \Magento\Backend\Block\Widget
         return $imageTypes;
     }
 
+    /**
+     * @return bool
+     */
     public function hasUseDefault()
     {
         foreach ($this->getMediaAttributes() as $attribute) {
@@ -193,6 +217,9 @@ class Content extends \Magento\Backend\Block\Widget
         return $this->getElement()->getDataObject()->getMediaAttributes();
     }
 
+    /**
+     * @return string
+     */
     public function getImageTypesJson()
     {
         return $this->_jsonEncoder->encode($this->getImageTypes());
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php
index eeaadb8c5b25113f1e7f97309b74fd28f54631cc..6001df81e70e99490bd70f9b987d1dd0ed952b3a 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form;
 
 class Image extends \Magento\Data\Form\Element\Image
 {
+    /**
+     * @return bool|string
+     */
     protected function _getUrl()
     {
         $url = false;
@@ -44,7 +47,10 @@ class Image extends \Magento\Data\Form\Element\Image
         }
         return $url;
     }
-    
+
+    /**
+     * @return string
+     */
     protected function _getDeleteCheckbox()
     {
         $html = '';
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php
index c5e410fe695c41d695c19f365c8678e8a7a04cd3..6d309bb01803eb64eb07a452c10828f6ef44e075 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php
@@ -76,12 +76,18 @@ class Price extends \Magento\Data\Form\Element\Text
         parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->addClass('validate-zero-or-greater');
     }
 
+    /**
+     * @return mixed
+     */
     public function getAfterElementHtml()
     {
         $html = parent::getAfterElementHtml();
@@ -110,6 +116,10 @@ class Price extends \Magento\Data\Form\Element\Text
         return $html;
     }
 
+    /**
+     * @param mixed $attribute
+     * @return string
+     */
     protected function _getTaxObservingCode($attribute)
     {
         $spanId = "dynamic-tax-{$attribute->getAttributeCode()}";
@@ -118,6 +128,10 @@ class Price extends \Magento\Data\Form\Element\Text
         return $html;
     }
 
+    /**
+     * @param null|int|string $index
+     * @return null|string
+     */
     public function getEscapedValue($index=null)
     {
         $value = $this->getValue();
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php
index 07a5f4e7bc5114b69a4b59269d3c7f70dc46f6a6..4c0ff2ae1df7bf9eb16f04a5ad5a86c7f532ff89 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php
@@ -33,6 +33,8 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form;
 
+use Magento\Data\Form;
+
 class Weight extends \Magento\Data\Form\Element\Text
 {
     const VIRTUAL_FIELD_HTML_ID = 'weight_and_type_switcher';
@@ -100,8 +102,8 @@ class Weight extends \Magento\Data\Form\Element\Text
     /**
      * Set form for both fields
      *
-     * @param \Magento\Data\Form $form
-     * @return \Magento\Data\Form
+     * @param Form $form
+     * @return $this
      */
     public function setForm($form)
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php
index 41d5c69761014698fe26875f04a9af3073ed67fc..61dd6c364729570caeb8bf70389fd7ceaf2a0ebf 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php
@@ -33,8 +33,16 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Widget;
 
-class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
+use Magento\Backend\Block\Widget\Grid;
+use Magento\Backend\Block\Widget\Grid\Column;
+use Magento\Backend\Block\Widget\Grid\Extended;
+use Magento\Data\Form\Element\AbstractElement;
+
+class Chooser extends Extended
 {
+    /**
+     * @var array
+     */
     protected $_selectedProducts = array();
 
     /**
@@ -84,6 +92,8 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
 
     /**
      * Block construction, prepare grid params
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -95,10 +105,10 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare chooser element HTML
      *
-     * @param \Magento\Data\Form\Element\AbstractElement $element Form Element
-     * @return \Magento\Data\Form\Element\AbstractElement
+     * @param AbstractElement $element Form Element
+     * @return AbstractElement
      */
-    public function prepareElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+    public function prepareElementHtml(AbstractElement $element)
     {
         $uniqId = $this->mathRandom->getUniqueHash($element->getId());
         $sourceUrl = $this->getUrl('catalog/product_widget/chooser', array(
@@ -206,8 +216,8 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Filter checked/unchecked rows in grid
      *
-     * @param \Magento\Backend\Block\Widget\Grid\Column $column
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser
+     * @param Column $column
+     * @return $this
      */
     protected function _addColumnFilterToCollection($column)
     {
@@ -227,7 +237,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare products collection, defined collection filters (category, product type)
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return Extended
      */
     protected function _prepareCollection()
     {
@@ -260,7 +270,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare columns for products grid
      *
-     * @return \Magento\Backend\Block\Widget\Grid\Extended
+     * @return Extended
      */
     protected function _prepareColumns()
     {
@@ -323,7 +333,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
      * Setter
      *
      * @param array $selectedProducts
-     * @return \Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser
+     * @return $this
      */
     public function setSelectedProducts($selectedProducts)
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser/Container.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser/Container.php
index d7082d2907d65bea192b66eb776b834588d9785d..0fd475e42796288297a8a4633bc70db8e7c4e7bc 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser/Container.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser/Container.php
@@ -33,7 +33,12 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser;
 
-class Container extends \Magento\Backend\Block\Template
+use Magento\Backend\Block\Template;
+
+class Container extends Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'catalog/product/widget/chooser/container.phtml';
 }
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php b/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php
index ac370e5d6f3be0759629d594f92fa83e8092fcb4..55aa5238473893986f3ab635a7b7e1733c788f0a 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php
@@ -52,6 +52,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_objectId = 'id';
@@ -64,6 +67,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         $this->_updateButton('delete', 'label', __('Delete Search'));
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderText()
     {
         if ($this->coreRegistry->registry('current_catalog_search')->getId()) {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit/Form.php b/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit/Form.php
index e84c4d26c546f7a63eee34ec5ca369b2ef7753a8..e0d7a6c78ccc00489d4a93f2875e3e6ebae8f16e 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit/Form.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit/Form.php
@@ -62,6 +62,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Init Form properties
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -73,7 +74,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form fields
      *
-     * @return \Magento\Catalog\Block\Adminhtml\Search\Edit\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatcatalog.php b/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatcatalog.php
deleted file mode 100644
index dc6a665d8dd473ad7bc6887c63c8dddd18512846..0000000000000000000000000000000000000000
--- a/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatcatalog.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Catalog
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-
-/**
- * System configuration shipping methods allow all countries selec
- *
- * @category   Magento
- * @package    Magento_Catalog
- * @author     Magento Core Team <core@magentocommerce.com>
- */
-namespace Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select;
-
-class Flatcatalog
-    extends \Magento\Backend\Block\System\Config\Form\Field
-{
-    /**
-     * @var \Magento\Catalog\Helper\Category\Flat
-     */
-    protected $_flatCategory;
-
-    /**
-     * @param \Magento\Backend\Block\Template\Context $context
-     * @param \Magento\Catalog\Helper\Category\Flat $flatCategory
-     * @param array $data
-     */
-    public function __construct(
-        \Magento\Backend\Block\Template\Context $context,
-        \Magento\Catalog\Helper\Category\Flat $flatCategory,
-        array $data = array()
-    ) {
-        $this->_flatCategory = $flatCategory;
-        parent::__construct($context, $data);
-    }
-
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
-    {
-        if (!$this->_flatCategory->isBuilt()) {
-            $element->setDisabled(true)
-                ->setValue(0);
-        }
-        return parent::_getElementHtml($element);
-    }
-
-}
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatproduct.php b/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatproduct.php
index 473e0dbe152ee2379ee45f6e57e573276c2b6c01..5ad34a477ec1acc99160ef911be9967beb3a2287 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatproduct.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/System/Config/Form/Field/Select/Flatproduct.php
@@ -34,8 +34,10 @@
  */
 namespace Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select;
 
-class Flatproduct
-    extends \Magento\Backend\Block\System\Config\Form\Field
+use Magento\Backend\Block\System\Config\Form\Field;
+use Magento\Data\Form\Element\AbstractElement;
+
+class Flatproduct extends Field
 {
     /**
      * @var \Magento\Catalog\Helper\Product\Flat
@@ -59,10 +61,10 @@ class Flatproduct
     /**
      * Retrieve Element HTML
      *
-     * @param \Magento\Data\Form\Element\AbstractElement $element
+     * @param AbstractElement $element
      * @return string
      */
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element) {
+    protected function _getElementHtml(AbstractElement $element) {
         if (!$this->_flatProduct->isBuilt()) {
             $element->setDisabled(true)
                 ->setValue(0);
diff --git a/app/code/Magento/Catalog/Block/Breadcrumbs.php b/app/code/Magento/Catalog/Block/Breadcrumbs.php
index 90c8a441fddc64d40834aedd6c7e6c0d7c1cfc3b..898794d9e84b02a4cf8d2ad5d396ec90288223f5 100644
--- a/app/code/Magento/Catalog/Block/Breadcrumbs.php
+++ b/app/code/Magento/Catalog/Block/Breadcrumbs.php
@@ -33,23 +33,27 @@
  */
 namespace Magento\Catalog\Block;
 
+use Magento\Catalog\Helper\Data;
+use Magento\Core\Model\Store;
+use Magento\View\Element\Template\Context;
+
 class Breadcrumbs extends \Magento\View\Element\Template
 {
     /**
      * Catalog data
      *
-     * @var \Magento\Catalog\Helper\Data
+     * @var Data
      */
     protected $_catalogData = null;
 
     /**
-     * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Catalog\Helper\Data $catalogData
+     * @param Context $context
+     * @param Data $catalogData
      * @param array $data
      */
     public function __construct(
-        \Magento\View\Element\Template\Context $context,
-        \Magento\Catalog\Helper\Data $catalogData,
+        Context $context,
+        Data $catalogData,
         array $data = array()
     ) {
         $this->_catalogData = $catalogData;
@@ -59,7 +63,7 @@ class Breadcrumbs extends \Magento\View\Element\Template
     /**
      * Retrieve HTML title value separator (with space)
      *
-     * @param mixed $store
+     * @param null|string|bool|int|Store $store
      * @return string
      */
     public function getTitleSeparator($store = null)
diff --git a/app/code/Magento/Catalog/Block/Category/View.php b/app/code/Magento/Catalog/Block/Category/View.php
index 93f21a08ce410dbbb749098db969b4e30816b340..ba666afb9bd224dbc068f8f38d0635d9588f00f8 100644
--- a/app/code/Magento/Catalog/Block/Category/View.php
+++ b/app/code/Magento/Catalog/Block/Category/View.php
@@ -74,6 +74,9 @@ class View extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         parent::_prepareLayout();
@@ -124,16 +127,25 @@ class View extends \Magento\View\Element\Template
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function isRssCatalogEnable()
     {
         return $this->_storeConfig->getConfig('rss/catalog/category');
     }
 
+    /**
+     * @return bool
+     */
     public function isTopCategory()
     {
         return $this->getCurrentCategory()->getLevel()==2;
     }
 
+    /**
+     * @return string
+     */
     public function getRssLink()
     {
         return $this->_urlBuilder->getUrl('rss/catalog/category', array(
@@ -142,6 +154,9 @@ class View extends \Magento\View\Element\Template
         );
     }
 
+    /**
+     * @return string
+     */
     public function getProductListHtml()
     {
         return $this->getChildHtml('product_list');
@@ -160,6 +175,9 @@ class View extends \Magento\View\Element\Template
         return $this->getData('current_category');
     }
 
+    /**
+     * @return mixed
+     */
     public function getCmsBlockHtml()
     {
         if (!$this->getData('cms_block_html')) {
diff --git a/app/code/Magento/Catalog/Block/Layer/Filter/AbstractFilter.php b/app/code/Magento/Catalog/Block/Layer/Filter/AbstractFilter.php
index a4fd728dcdcd6eed21340630695547fd6381235c..1c995eb6ab5065e9c8ad11a55f5f3038455d7bb7 100644
--- a/app/code/Magento/Catalog/Block/Layer/Filter/AbstractFilter.php
+++ b/app/code/Magento/Catalog/Block/Layer/Filter/AbstractFilter.php
@@ -58,8 +58,8 @@ abstract class AbstractFilter extends \Magento\View\Element\Template
     /**
      * Initialize filter template
      *
+     * @var string
      */
-
     protected $_template = 'Magento_Catalog::layer/filter.phtml';
 
     /**
diff --git a/app/code/Magento/Catalog/Block/Layer/Filter/Attribute.php b/app/code/Magento/Catalog/Block/Layer/Filter/Attribute.php
index a1dbda77d03a2dbac4bcc7e5c462207b11e28b7e..a8d582e355dffc19c4f7fe8bb7c86d89b4b4498c 100644
--- a/app/code/Magento/Catalog/Block/Layer/Filter/Attribute.php
+++ b/app/code/Magento/Catalog/Block/Layer/Filter/Attribute.php
@@ -35,12 +35,18 @@ namespace Magento\Catalog\Block\Layer\Filter;
 
 class Attribute extends \Magento\Catalog\Block\Layer\Filter\AbstractFilter
 {
+    /**
+     *
+     */
     protected function _construct()
     {
         parent::_construct();
         $this->_filterModelName = 'Magento\Catalog\Model\Layer\Filter\Attribute';
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareFilter()
     {
         $this->_filter->setAttributeModel($this->getAttributeModel());
diff --git a/app/code/Magento/Catalog/Block/Layer/Filter/Category.php b/app/code/Magento/Catalog/Block/Layer/Filter/Category.php
index 698452f294cc511659b2793e6029c3399b8a023e..b3f31b7b647d53bdfc0eda1af0dcfc5c5f52e716 100644
--- a/app/code/Magento/Catalog/Block/Layer/Filter/Category.php
+++ b/app/code/Magento/Catalog/Block/Layer/Filter/Category.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Layer\Filter;
 
 class Category extends \Magento\Catalog\Block\Layer\Filter\AbstractFilter
 {
+    /**
+     *
+     */
     protected function _construct()
     {
         parent::_construct();
diff --git a/app/code/Magento/Catalog/Block/Layer/Filter/Price.php b/app/code/Magento/Catalog/Block/Layer/Filter/Price.php
index b311406b81b8486eb511a271a8322328e856f043..ce254fa3a4f8650eefc1a3f9b9604c70165b19cd 100644
--- a/app/code/Magento/Catalog/Block/Layer/Filter/Price.php
+++ b/app/code/Magento/Catalog/Block/Layer/Filter/Price.php
@@ -37,7 +37,6 @@ class Price extends \Magento\Catalog\Block\Layer\Filter\AbstractFilter
 {
     /**
      * Initialize Price filter module
-     *
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Catalog/Block/Layer/State.php b/app/code/Magento/Catalog/Block/Layer/State.php
index b57e2ca0af0824b48d271512777c253736046406..b9ba719a808347f64e0e5709b7754797bb1a485b 100644
--- a/app/code/Magento/Catalog/Block/Layer/State.php
+++ b/app/code/Magento/Catalog/Block/Layer/State.php
@@ -35,6 +35,9 @@ namespace Magento\Catalog\Block\Layer;
 
 class State extends \Magento\View\Element\Template
 {
+    /**
+     * @var string
+     */
     protected $_template = 'layer/state.phtml';
 
     /**
diff --git a/app/code/Magento/Catalog/Block/Layer/View.php b/app/code/Magento/Catalog/Block/Layer/View.php
index 0b0bd892b194ad97110c73bf84b041432d526865..751505515d3f8391356772463388ccb509a4567b 100644
--- a/app/code/Magento/Catalog/Block/Layer/View.php
+++ b/app/code/Magento/Catalog/Block/Layer/View.php
@@ -103,6 +103,8 @@ class View extends \Magento\View\Element\Template
 
     /**
      * Initialize blocks names
+     *
+     * @return void
      */
     protected function _initBlocks()
     {
@@ -165,7 +167,7 @@ class View extends \Magento\View\Element\Template
     /**
      * Get all fiterable attributes of current category
      *
-     * @return array
+     * @return mixed
      */
     protected function _getFilterableAttributes()
     {
diff --git a/app/code/Magento/Catalog/Block/Navigation.php b/app/code/Magento/Catalog/Block/Navigation.php
index 5a5e88638f642027f6ac551df960fef455049cca..64b44f44740b169197aa5c28fce2754f6c4399f2 100644
--- a/app/code/Magento/Catalog/Block/Navigation.php
+++ b/app/code/Magento/Catalog/Block/Navigation.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Block;
 
+use Magento\Catalog\Model\Category;
+
 /**
  * Catalog navigation
  *
@@ -33,7 +34,10 @@ namespace Magento\Catalog\Block;
  */
 class Navigation extends \Magento\View\Element\Template
 {
-    protected $_categoryInstance = null;
+    /**
+     * @var Category
+     */
+    protected $_categoryInstance;
 
     /**
      * Current category key
@@ -54,14 +58,7 @@ class Navigation extends \Magento\View\Element\Template
      *
      * @var \Magento\Catalog\Helper\Category
      */
-    protected $_catalogCategory = null;
-
-    /**
-     * Catalog category flat
-     *
-     * @var \Magento\Catalog\Helper\Category\Flat
-     */
-    protected $_catalogCategoryFlat = null;
+    protected $_catalogCategory;
 
     /**
      * @var \Magento\Core\Model\Registry
@@ -89,15 +86,20 @@ class Navigation extends \Magento\View\Element\Template
      */
     protected $_productCollectionFactory;
 
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\State
+     */
+    protected $flatState;
+
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
      * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory
      * @param \Magento\Catalog\Model\Layer $catalogLayer
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat
      * @param \Magento\Catalog\Helper\Category $catalogCategory
      * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\Catalog\Model\Indexer\Category\Flat\State $flatState
      * @param array $data
      */
     public function __construct(
@@ -106,17 +108,17 @@ class Navigation extends \Magento\View\Element\Template
         \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory,
         \Magento\Catalog\Model\Layer $catalogLayer,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat,
         \Magento\Catalog\Helper\Category $catalogCategory,
         \Magento\Core\Model\Registry $registry,
+        \Magento\Catalog\Model\Indexer\Category\Flat\State $flatState,
         array $data = array()
     ) {
         $this->_productCollectionFactory = $productCollectionFactory;
         $this->_catalogLayer = $catalogLayer;
         $this->_customerSession = $customerSession;
-        $this->_catalogCategoryFlat = $catalogCategoryFlat;
         $this->_catalogCategory = $catalogCategory;
         $this->_registry = $registry;
+        $this->flatState = $flatState;
         $this->_categoryInstance = $categoryFactory->create();
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
@@ -127,7 +129,7 @@ class Navigation extends \Magento\View\Element\Template
         $this->addData(array(
             'cache_lifetime'    => false,
             'cache_tags'        => array(
-                \Magento\Catalog\Model\Category::CACHE_TAG,
+                Category::CACHE_TAG,
                 \Magento\Core\Model\Store\Group::CACHE_TAG
             ),
         ));
@@ -136,7 +138,7 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Get current category
      *
-     * @return \Magento\Catalog\Model\Category
+     * @return Category
      */
     public function getCategory()
     {
@@ -174,7 +176,7 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Get current category key
      *
-     * @return mixed
+     * @return string
      */
     public function getCurrenCategoryKey()
     {
@@ -197,8 +199,7 @@ class Navigation extends \Magento\View\Element\Template
      */
     public function getStoreCategories()
     {
-        $helper = $this->_catalogCategory;
-        return $helper->getStoreCategories();
+        return $this->_catalogCategory->getStoreCategories();
     }
 
     /**
@@ -233,12 +234,12 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Get url for category data
      *
-     * @param \Magento\Catalog\Model\Category $category
+     * @param Category $category
      * @return string
      */
     public function getCategoryUrl($category)
     {
-        if ($category instanceof \Magento\Catalog\Model\Category) {
+        if ($category instanceof Category) {
             $url = $category->getUrl();
         } else {
             $url = $this->_categoryInstance
@@ -268,7 +269,7 @@ class Navigation extends \Magento\View\Element\Template
         }
 
         $position = array();
-        for($i = 0; $i <= $level; $i++) {
+        for ($i = 0; $i <= $level; $i++) {
             if (isset($this->_itemLevelPositions[$i])) {
                 $position[] = $this->_itemLevelPositions[$i];
             }
@@ -279,33 +280,29 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Render category to html
      *
-     * @param \Magento\Catalog\Model\Category $category
-     * @param int Nesting level number
-     * @param boolean Whether ot not this item is last, affects list item class
-     * @param boolean Whether ot not this item is first, affects list item class
-     * @param boolean Whether ot not this item is outermost, affects list item class
-     * @param string Extra class of outermost list items
-     * @param string If specified wraps children list in div with this class
-     * @param boolean Whether ot not to add on* attributes to list item
+     * @param Category $category
+     * @param int $level Nesting level number
+     * @param boolean $isLast Whether ot not this item is last, affects list item class
+     * @param boolean $isFirst Whether ot not this item is first, affects list item class
+     * @param boolean $isOutermost Whether ot not this item is outermost, affects list item class
+     * @param string $outermostItemClass Extra class of outermost list items
+     * @param string $childrenWrapClass If specified wraps children list in div with this class
+     * @param boolean $noEventAttributes Whether ot not to add on* attributes to list item
      * @return string
      */
     protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
-        $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
-    {
+        $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false
+    ) {
         if (!$category->getIsActive()) {
             return '';
         }
-        $html = array();
 
         // get all children
-        if ($this->_catalogCategoryFlat->isAvailable()) {
+        if ($this->flatState->isAvailable()) {
             $children = (array)$category->getChildrenNodes();
-            $childrenCount = count($children);
         } else {
             $children = $category->getChildren();
-            $childrenCount = $children->count();
         }
-        $hasChildren = ($children && $childrenCount);
 
         // select active children
         $activeChildren = array();
@@ -314,6 +311,7 @@ class Navigation extends \Magento\View\Element\Template
                 $activeChildren[] = $child;
             }
         }
+
         $activeChildrenCount = count($activeChildren);
         $hasActiveChildren = ($activeChildrenCount > 0);
 
@@ -324,6 +322,7 @@ class Navigation extends \Magento\View\Element\Template
         if ($this->isCategoryActive($category)) {
             $classes[] = 'active';
         }
+
         $linkClass = '';
         if ($isOutermost && $outermostItemClass) {
             $classes[] = $outermostItemClass;
@@ -355,6 +354,8 @@ class Navigation extends \Magento\View\Element\Template
             $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . '"';
         }
         $htmlLi .= '>';
+
+        $html = array();
         $html[] = $htmlLi;
 
         $html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
@@ -398,7 +399,7 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Enter description here...
      *
-     * @return \Magento\Catalog\Model\Category
+     * @return Category
      */
     public function getCurrentCategory()
     {
@@ -421,10 +422,11 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Enter description here...
      *
-     * @param \Magento\Catalog\Model\Category $category
+     * @param Category $category
      * @return string
      */
-    public function drawOpenCategoryItem($category) {
+    public function drawOpenCategoryItem($category)
+    {
         $html = '';
         if (!$category->getIsActive()) {
             return $html;
@@ -463,9 +465,9 @@ class Navigation extends \Magento\View\Element\Template
     /**
      * Render categories menu in HTML
      *
-     * @param int Level number for list item class to start from
-     * @param string Extra class of outermost list items
-     * @param string If specified wraps children list in div with this class
+     * @param int $level Level number for list item class to start from
+     * @param string $outermostItemClass Extra class of outermost list items
+     * @param string $childrenWrapClass If specified wraps children list in div with this class
      * @return string
      */
     public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')
@@ -501,5 +503,4 @@ class Navigation extends \Magento\View\Element\Template
 
         return $html;
     }
-
 }
diff --git a/app/code/Magento/Catalog/Block/Product.php b/app/code/Magento/Catalog/Block/Product.php
index e22b1be54444b2ac459634cb8beb5a320d5bdb11..b0191b53d83ed0f9579acf7080858e4b12fac157 100644
--- a/app/code/Magento/Catalog/Block/Product.php
+++ b/app/code/Magento/Catalog/Block/Product.php
@@ -26,8 +26,13 @@
 
 namespace Magento\Catalog\Block;
 
+use Magento\Catalog\Model\Product as ModelProduct;
+
 class Product extends \Magento\View\Element\Template
 {
+    /**
+     * @var array
+     */
     protected $_finalPrice = array();
 
     /**
@@ -51,9 +56,12 @@ class Product extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return ModelProduct
+     */
     public function getProduct()
     {
-        if (!$this->getData('product') instanceof \Magento\Catalog\Model\Product) {
+        if (!$this->getData('product') instanceof ModelProduct) {
             if ($this->getData('product')->getProductId()) {
                 $productId = $this->getData('product')->getProductId();
             }
@@ -67,11 +75,17 @@ class Product extends \Magento\View\Element\Template
         return $this->getData('product');
     }
 
+    /**
+     * @return float
+     */
     public function getPrice()
     {
         return $this->getProduct()->getPrice();
     }
 
+    /**
+     * @return float
+     */
     public function getFinalPrice()
     {
         if (!isset($this->_finalPrice[$this->getProduct()->getId()])) {
@@ -80,6 +94,10 @@ class Product extends \Magento\View\Element\Template
         return $this->_finalPrice[$this->getProduct()->getId()];
     }
 
+    /**
+     * @param ModelProduct $product
+     * @return string
+     */
     public function getPriceHtml($product)
     {
         $this->setTemplate('product/price.phtml');
diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php
index 89e1ea3bd992cba40b744b4f4da3a964c50c790d..3936cc70dc602d3c8b0dd3596db50b34f506f2fd 100644
--- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php
+++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php
@@ -34,8 +34,14 @@
  */
 namespace Magento\Catalog\Block\Product;
 
+use Magento\View\Element\BlockInterface;
+use Magento\View\Element\Template\Helper;
+
 abstract class AbstractProduct extends \Magento\View\Element\Template
 {
+    /**
+     * @var array
+     */
     protected $_priceBlock = array();
 
     /**
@@ -45,10 +51,19 @@ abstract class AbstractProduct extends \Magento\View\Element\Template
      */
     protected $_block = 'Magento\Catalog\Block\Product\Price';
 
+    /**
+     * @var string
+     */
     protected $_priceBlockDefaultTemplate = 'product/price.phtml';
 
+    /**
+     * @var string
+     */
     protected $_tierPriceDefaultTemplate  = 'product/view/tierprices.phtml';
 
+    /**
+     * @var array
+     */
     protected $_priceBlockTypes = array();
 
     /**
@@ -58,6 +73,9 @@ abstract class AbstractProduct extends \Magento\View\Element\Template
      */
     protected $_useLinkForAsLowAs = true;
 
+    /**
+     * @var Helper
+     */
     protected $_reviewsHelperBlock;
 
     /**
@@ -268,6 +286,10 @@ abstract class AbstractProduct extends \Magento\View\Element\Template
         return null;
     }
 
+    /**
+     * @param string $productTypeId
+     * @return BlockInterface
+     */
     protected function _getPriceBlock($productTypeId)
     {
         if (!isset($this->_priceBlock[$productTypeId])) {
@@ -282,6 +304,10 @@ abstract class AbstractProduct extends \Magento\View\Element\Template
         return $this->_priceBlock[$productTypeId];
     }
 
+    /**
+     * @param string $productTypeId
+     * @return string
+     */
     protected function _getPriceBlockTemplate($productTypeId)
     {
         if (isset($this->_priceBlockTypes[$productTypeId])) {
@@ -341,6 +367,7 @@ abstract class AbstractProduct extends \Magento\View\Element\Template
      * @param string $type
      * @param string $block
      * @param string $template
+     * @return void
      */
     public function addPriceBlockType($type, $block = '', $template = '')
     {
diff --git a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php
index 468469635ec126888588dc711639afd431ba6514..78277a259f10d562dd0a49b6d0ace88bab9125b0 100644
--- a/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php
+++ b/app/code/Magento/Catalog/Block/Product/Compare/ListCompare.php
@@ -34,6 +34,9 @@
  */
 namespace Magento\Catalog\Block\Product\Compare;
 
+use Magento\App\Action\Action;
+use Magento\Catalog\Model\Product;
+
 class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare
 {
     /**
@@ -178,13 +181,13 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare
     /**
      * Get add to wishlist params
      *
-     * @param \Magento\Catalog\Model\Product $product
-     * @return array
+     * @param Product $product
+     * @return string
      */
     public function getAddToWishlistParams($product)
     {
         $continueUrl    = $this->_coreData->urlEncode($this->getUrl('customer/account'));
-        $urlParamName   = \Magento\App\Action\Action::PARAM_NAME_URL_ENCODED;
+        $urlParamName   = Action::PARAM_NAME_URL_ENCODED;
 
         $continueUrlParams = array($urlParamName => $continueUrl);
 
@@ -255,7 +258,7 @@ class ListCompare extends \Magento\Catalog\Block\Product\Compare\AbstractCompare
     /**
      * Retrieve Product Attribute Value
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
      * @return string
      */
diff --git a/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php b/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php
index 96bfb6bb2b1e6e074a3d1659f341176d05738f7f..2bb946859c5fbd142a760164fcb1b177cca8d556 100644
--- a/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php
+++ b/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php
@@ -45,7 +45,6 @@ class Sidebar extends \Magento\Catalog\Block\Product\Compare\AbstractCompare
 
     /**
      * Initialize block
-     *
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Catalog/Block/Product/Gallery.php b/app/code/Magento/Catalog/Block/Product/Gallery.php
index 70657a25cbda802af8549f1cce77eee6bcf305c4..e06f81011452880ae9dd28b91a143b0032351ecd 100644
--- a/app/code/Magento/Catalog/Block/Product/Gallery.php
+++ b/app/code/Magento/Catalog/Block/Product/Gallery.php
@@ -33,6 +33,10 @@
  */
 namespace Magento\Catalog\Block\Product;
 
+use Magento\Catalog\Model\Product;
+use Magento\Data\Collection;
+use Magento\View\Element\AbstractBlock;
+
 class Gallery extends \Magento\View\Element\Template
 {
     /**
@@ -56,6 +60,9 @@ class Gallery extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $headBlock = $this->getLayout()->getBlock('head');
@@ -65,16 +72,25 @@ class Gallery extends \Magento\View\Element\Template
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return Product
+     */
     public function getProduct()
     {
         return $this->_coreRegistry->registry('product');
     }
 
+    /**
+     * @return Collection
+     */
     public function getGalleryCollection()
     {
         return $this->getProduct()->getMediaGalleryImages();
     }
 
+    /**
+     * @return Image|null
+     */
     public function getCurrentImage()
     {
         $imageId = $this->getRequest()->getParam('image');
@@ -89,11 +105,17 @@ class Gallery extends \Magento\View\Element\Template
         return $image;
     }
 
+    /**
+     * @return string
+     */
     public function getImageUrl()
     {
         return $this->getCurrentImage()->getUrl();
     }
 
+    /**
+     * @return mixed
+     */
     public function getImageFile()
     {
         return $this->getCurrentImage()->getFile();
@@ -122,6 +144,9 @@ class Gallery extends \Magento\View\Element\Template
         return false;
     }
 
+    /**
+     * @return Image|false
+     */
     public function getPreviousImage()
     {
         $current = $this->getCurrentImage();
@@ -138,6 +163,9 @@ class Gallery extends \Magento\View\Element\Template
         return $previous;
     }
 
+    /**
+     * @return Image|false
+     */
     public function getNextImage()
     {
         $current = $this->getCurrentImage();
@@ -158,6 +186,9 @@ class Gallery extends \Magento\View\Element\Template
         return $next;
     }
 
+    /**
+     * @return false|string
+     */
     public function getPreviousImageUrl()
     {
         $image = $this->getPreviousImage();
@@ -167,6 +198,9 @@ class Gallery extends \Magento\View\Element\Template
         return false;
     }
 
+    /**
+     * @return false|string
+     */
     public function getNextImageUrl()
     {
         $image = $this->getNextImage();
diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php
index 2d14fe67088a0ca53598651eb536e8b8143c78d7..b0ba12e2030581a712038da96dd7abfc36204086 100644
--- a/app/code/Magento/Catalog/Block/Product/ListProduct.php
+++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php
@@ -34,6 +34,9 @@
  */
 namespace Magento\Catalog\Block\Product;
 
+use Magento\Eav\Model\Entity\Collection\AbstractCollection;
+use Magento\View\Element\AbstractBlock;
+
 class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct
 {
     /**
@@ -46,7 +49,7 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct
     /**
      * Product Collection
      *
-     * @var \Magento\Eav\Model\Entity\Collection\AbstractCollection
+     * @var AbstractCollection
      */
     protected $_productCollection;
 
@@ -122,7 +125,7 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct
     /**
      * Retrieve loaded category collection
      *
-     * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
+     * @return AbstractCollection
      */
     protected function _getProductCollection()
     {
@@ -184,7 +187,7 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct
     /**
      * Retrieve loaded category collection
      *
-     * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
+     * @return AbstractCollection
      */
     public function getLoadedProductCollection()
     {
@@ -204,6 +207,7 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct
     /**
      * Need use as _prepareLayout - but problem in declaring collection from
      * another block (was problem with search result)
+     * @return $this
      */
     protected function _beforeToHtml()
     {
@@ -281,18 +285,29 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this->getChildHtml('toolbar');
     }
 
+    /**
+     * @param AbstractCollection $collection
+     * @return $this
+     */
     public function setCollection($collection)
     {
         $this->_productCollection = $collection;
         return $this;
     }
 
+    /**
+     * @param array|string|integer|\Magento\Core\Model\Config\Element $code
+     * @return $this
+     */
     public function addAttribute($code)
     {
         $this->_getProductCollection()->addAttributeToSelect($code);
         return $this;
     }
 
+    /**
+     * @return mixed
+     */
     public function getPriceBlockTemplate()
     {
         return $this->_getData('price_block_template');
diff --git a/app/code/Magento/Catalog/Block/Product/NewProduct.php b/app/code/Magento/Catalog/Block/Product/NewProduct.php
index 298044570e2a06e5e612bbfe15d50ef5b8eefd4e..bece75cfdeefe85526947adcad7225447828c95e 100644
--- a/app/code/Magento/Catalog/Block/Product/NewProduct.php
+++ b/app/code/Magento/Catalog/Block/Product/NewProduct.php
@@ -41,7 +41,7 @@ class NewProduct extends \Magento\Catalog\Block\Product\AbstractProduct
     /**
      * Products count
      *
-     * @var null
+     * @var int
      */
     protected $_productsCount;
 
@@ -219,8 +219,8 @@ class NewProduct extends \Magento\Catalog\Block\Product\AbstractProduct
     /**
      * Set how much product should be displayed at once.
      *
-     * @param $count
-     * @return \Magento\Catalog\Block\Product\NewProduct
+     * @param int $count
+     * @return $this
      */
     public function setProductsCount($count)
     {
diff --git a/app/code/Magento/Catalog/Block/Product/Price.php b/app/code/Magento/Catalog/Block/Product/Price.php
index ef07e2357cd23d51fdc317f31b4728f8a2ac5c7c..9bb09395db79a1831ba75fb5cc8db1186082db1a 100644
--- a/app/code/Magento/Catalog/Block/Product/Price.php
+++ b/app/code/Magento/Catalog/Block/Product/Price.php
@@ -35,7 +35,14 @@ namespace Magento\Catalog\Block\Product;
 
 class Price extends \Magento\View\Element\Template
 {
+    /**
+     * @var null
+     */
     protected $_priceDisplayType = null;
+
+    /**
+     * @var string
+     */
     protected $_idSuffix = '';
 
     /**
@@ -125,17 +132,27 @@ class Price extends \Magento\View\Element\Template
         return $product;
     }
 
+    /**
+     * @return mixed
+     */
     public function getDisplayMinimalPrice()
     {
         return $this->_getData('display_minimal_price');
     }
 
+    /**
+     * @param string $idSuffix
+     * @return $this
+     */
     public function setIdSuffix($idSuffix)
     {
         $this->_idSuffix = $idSuffix;
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getIdSuffix()
     {
         return $this->_idSuffix;
diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php b/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php
index efb01480736bf0b78d1eb1abf85a33a42725e89e..11ab978e106ce5b90726814aa8d3e5ae4228ea57 100644
--- a/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php
+++ b/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php
@@ -25,12 +25,15 @@
  */
 namespace Magento\Catalog\Block\Product\ProductList;
 
+use Magento\Catalog\Model\Resource\Product\Collection;
+use Magento\Catalog\Model\Resource\Product\CollectionFactory;
+
 class Promotion extends \Magento\Catalog\Block\Product\ListProduct
 {
     /**
      * Product collection factory
      *
-     * @var \Magento\Catalog\Model\Resource\Product\CollectionFactory
+     * @var CollectionFactory
      */
     protected $_productCollectionFactory;
 
@@ -56,7 +59,7 @@ class Promotion extends \Magento\Catalog\Block\Product\ListProduct
      * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
      * @param \Magento\Catalog\Model\Layer $catalogLayer
      * @param \Magento\Catalog\Model\LayerFactory $layerFactory
-     * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory
+     * @param CollectionFactory $productCollectionFactory
      * @param array $data
      * @param array $priceBlockTypes
      * 
@@ -77,7 +80,7 @@ class Promotion extends \Magento\Catalog\Block\Product\ListProduct
         \Magento\Catalog\Model\CategoryFactory $categoryFactory,
         \Magento\Catalog\Model\Layer $catalogLayer,
         \Magento\Catalog\Model\LayerFactory $layerFactory,
-        \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory,
+        CollectionFactory $productCollectionFactory,
         array $data = array(),
         array $priceBlockTypes = array()
     ) {
@@ -102,10 +105,13 @@ class Promotion extends \Magento\Catalog\Block\Product\ListProduct
         );
     }
 
+    /**
+     * @return Collection
+     */
     protected function _getProductCollection()
     {
         if (is_null($this->_productCollection)) {
-            /** @var \Magento\Catalog\Model\Resource\Product\Collection $collection */
+            /** @var Collection $collection */
             $collection = $this->_productCollectionFactory->create();
             $this->_layerFactory->create()->prepareProductCollection($collection);
 
diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Random.php b/app/code/Magento/Catalog/Block/Product/ProductList/Random.php
index af628b100907f9582dc3c902b525d2aaf9a7b64c..7a6e1db50f19447d606114b9d9a382e60a7e0fd4 100644
--- a/app/code/Magento/Catalog/Block/Product/ProductList/Random.php
+++ b/app/code/Magento/Catalog/Block/Product/ProductList/Random.php
@@ -108,6 +108,9 @@ class Random extends \Magento\Catalog\Block\Product\ListProduct
         );
     }
 
+    /**
+     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     */
     protected function _getProductCollection()
     {
         if (is_null($this->_productCollection)) {
diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php
index da7bc90343e8946cd7ea1d578a87f8a376da40cc..9987f309131ceb756d4aea9eeef46f6ab4529f6a 100644
--- a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php
+++ b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php
@@ -23,9 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Block\Product\ProductList;
 
+use Magento\Catalog\Model\Resource\Product\Collection;
+use Magento\View\Element\AbstractBlock;
+
 /**
  * Catalog product related items block
  *
@@ -40,6 +42,9 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct
      */
     protected $_mapRenderer = 'msrp_noform';
 
+    /**
+     * @var Collection
+     */
     protected $_itemCollection;
 
     /**
@@ -122,6 +127,9 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct
         $this->_isScopePrivate = true;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareData()
     {
         $product = $this->_coreRegistry->registry('product');
@@ -152,12 +160,18 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeToHtml()
     {
         $this->_prepareData();
         return parent::_beforeToHtml();
     }
 
+    /**
+     * @return Collection
+     */
     public function getItems()
     {
         return $this->_itemCollection;
diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
index f6b4b4c47ce916f8bdcbebded2d0cf8ee84b2a5a..cf467375b9e073f10d512c757ed238c2f9fa9796 100644
--- a/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
+++ b/app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
@@ -88,7 +88,7 @@ class Toolbar extends \Magento\View\Element\Template
     /**
      * List of available view types
      *
-     * @var string
+     * @var array
      */
     protected $_availableMode       = array();
 
@@ -140,6 +140,9 @@ class Toolbar extends \Magento\View\Element\Template
     protected $_paramsMemorizeAllowed = true;
 
 
+    /**
+     * @var string
+     */
     protected $_template = 'product/list/toolbar.phtml';
 
 
@@ -187,7 +190,6 @@ class Toolbar extends \Magento\View\Element\Template
 
     /**
      * Init Toolbar
-     *
      */
     protected function _construct()
     {
@@ -220,6 +222,8 @@ class Toolbar extends \Magento\View\Element\Template
 
     /**
      * Disable list state params memorizing
+     *
+     * @return $this
      */
     public function disableParamsMemorizing()
     {
@@ -232,7 +236,7 @@ class Toolbar extends \Magento\View\Element\Template
      *
      * @param string $param parameter name
      * @param mixed $value parameter value
-     * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     protected function _memorizeParam($param, $value)
     {
@@ -246,7 +250,7 @@ class Toolbar extends \Magento\View\Element\Template
      * Set collection to pager
      *
      * @param \Magento\Data\Collection $collection
-     * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     public function setCollection($collection)
     {
@@ -411,7 +415,7 @@ class Toolbar extends \Magento\View\Element\Template
      * Set default Order field
      *
      * @param string $field
-     * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     public function setDefaultOrder($field)
     {
@@ -425,7 +429,7 @@ class Toolbar extends \Magento\View\Element\Template
      * Set default sort direction
      *
      * @param string $dir
-     * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     public function setDefaultDirection($dir)
     {
@@ -449,7 +453,7 @@ class Toolbar extends \Magento\View\Element\Template
      * Set Available order fields list
      *
      * @param array $orders
-     * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     public function setAvailableOrders($orders)
     {
@@ -473,7 +477,7 @@ class Toolbar extends \Magento\View\Element\Template
      * Remove order from available orders if exists
      *
      * @param string $order
-     * @param \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     public function removeOrderFromAvailableOrders($order)
     {
@@ -572,7 +576,7 @@ class Toolbar extends \Magento\View\Element\Template
     }
 
     /**
-     * Retrieve availables view modes
+     * Retrieve available view modes
      *
      * @return array
      */
@@ -585,7 +589,7 @@ class Toolbar extends \Magento\View\Element\Template
      * Set available view modes list
      *
      * @param array $modes
-     * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
+     * @return $this
      */
     public function setModes($modes)
     {
@@ -777,33 +781,52 @@ class Toolbar extends \Magento\View\Element\Template
         ));
     }
 
+    /**
+     * @param int $limit
+     * @return bool
+     */
     public function isLimitCurrent($limit)
     {
         return $limit == $this->getLimit();
     }
 
+    /**
+     * @return int
+     */
     public function getFirstNum()
     {
         $collection = $this->getCollection();
         return $collection->getPageSize()*($collection->getCurPage()-1)+1;
     }
 
+    /**
+     * @return int
+     */
     public function getLastNum()
     {
         $collection = $this->getCollection();
         return $collection->getPageSize()*($collection->getCurPage()-1)+$collection->count();
     }
 
+    /**
+     * @return int
+     */
     public function getTotalNum()
     {
         return $this->getCollection()->getSize();
     }
 
+    /**
+     * @return bool
+     */
     public function isFirstPage()
     {
         return $this->getCollection()->getCurPage() == 1;
     }
 
+    /**
+     * @return int
+     */
     public function getLastPageNum()
     {
         return $this->getCollection()->getLastPageNumber();
diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
index f62188a8e1fe0e3e627f29002a886947d73a319a..97d15a168a148212a7ff6e99db2a9ca6da3e38b6 100644
--- a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
+++ b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
@@ -26,6 +26,9 @@
 
 namespace Magento\Catalog\Block\Product\ProductList;
 
+use Magento\Catalog\Model\Resource\Product\Collection;
+use Magento\View\Element\AbstractBlock;
+
 /**
  * Catalog product related items block
  *
@@ -40,12 +43,24 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct
      */
     protected $_mapRenderer = 'msrp_noform';
 
+    /**
+     * @var int
+     */
     protected $_columnCount = 4;
 
+    /**
+     * @var  \Magento\Object[]
+     */
     protected $_items;
 
+    /**
+     * @var Collection
+     */
     protected $_itemCollection;
 
+    /**
+     * @var array
+     */
     protected $_itemLimits = array();
 
     /**
@@ -128,6 +143,9 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct
         $this->_isScopePrivate = true;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareData()
     {
         $product = $this->_coreRegistry->registry('product');
@@ -169,17 +187,26 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeToHtml()
     {
         $this->_prepareData();
         return parent::_beforeToHtml();
     }
 
+    /**
+     * @return Collection
+     */
     public function getItemCollection()
     {
         return $this->_itemCollection;
     }
 
+    /**
+     * @return \Magento\Object[]
+     */
     public function getItems()
     {
         if (is_null($this->_items)) {
@@ -188,11 +215,18 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this->_items;
     }
 
+    /**
+     * @return float
+     */
     public function getRowCount()
     {
         return ceil(count($this->getItemCollection()->getItems())/$this->getColumnCount());
     }
 
+    /**
+     * @param string $columns
+     * @return $this
+     */
     public function setColumnCount($columns)
     {
         if (intval($columns) > 0) {
@@ -201,17 +235,26 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this;
     }
 
+    /**
+     * @return int
+     */
     public function getColumnCount()
     {
         return $this->_columnCount;
     }
 
+    /**
+     * @return void
+     */
     public function resetItemsIterator()
     {
         $this->getItems();
         reset($this->_items);
     }
 
+    /**
+     * @return mixed
+     */
     public function getIterableItem()
     {
         $item = current($this->_items);
@@ -235,6 +278,10 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this;
     }
 
+    /**
+     * @param string $type
+     * @return array|int
+     */
     public function getItemLimit($type = '')
     {
         if ($type == '') {
diff --git a/app/code/Magento/Catalog/Block/Product/Send.php b/app/code/Magento/Catalog/Block/Product/Send.php
index 6b9c1a6197d8b3f0b18c60757b69e7e2dbd3ac2f..43a34fc0c56dd7069742ce9cc49fec98daf7a456 100644
--- a/app/code/Magento/Catalog/Block/Product/Send.php
+++ b/app/code/Magento/Catalog/Block/Product/Send.php
@@ -106,16 +106,25 @@ class Send extends \Magento\Catalog\Block\Product\AbstractProduct
         return $this->_customerSession->getCustomer()->getName();
     }
 
+    /**
+     * @return string
+     */
     public function getEmail()
     {
         return (string)$this->_customerSession->getCustomer()->getEmail();
     }
 
+    /**
+     * @return mixed
+     */
     public function getProductId()
     {
         return $this->getRequest()->getParam('id');
     }
 
+    /**
+     * @return int
+     */
     public function getMaxRecipients()
     {
         $sendToFriendModel = $this->_coreRegistry->registry('send_to_friend_model');
diff --git a/app/code/Magento/Catalog/Block/Product/View/AbstractView.php b/app/code/Magento/Catalog/Block/Product/View/AbstractView.php
index e56062c6f642788a1381cd6d83aaa0ae9e9563c6..bdc3759abfededed45b6154ddd91d4b81cb12bcc 100644
--- a/app/code/Magento/Catalog/Block/Product/View/AbstractView.php
+++ b/app/code/Magento/Catalog/Block/Product/View/AbstractView.php
@@ -109,10 +109,10 @@ abstract class AbstractView extends \Magento\Catalog\Block\Product\AbstractProdu
     /**
      * Decorate a plain array of arrays or objects
      *
-     * @param mixed $array
+     * @param array $array
      * @param string $prefix
      * @param bool $forceSetAll
-     * @return mixed
+     * @return array
      */
     public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false)
     {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Additional.php b/app/code/Magento/Catalog/Block/Product/View/Additional.php
index c43b66b702314285b85f18e86a5371126c955549..72c4e8d0a543e7cca219d68d648e074e1e3cbaa2 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Additional.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Additional.php
@@ -36,12 +36,20 @@ namespace Magento\Catalog\Block\Product\View;
 
 class Additional extends \Magento\View\Element\Template
 {
-
+    /**
+     * @var array
+     */
     protected $_list;
 
+    /**
+     * @var string
+     */
     protected $_template = 'product/view/additional.phtml';
 
 
+    /**
+     * @return array
+     */
     public function getChildHtmlList()
     {
         if (is_null($this->_list)) {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Attributes.php b/app/code/Magento/Catalog/Block/Product/View/Attributes.php
index 109fcf67e644ac695cd4a7a266642eb423eae37d..5e48b6ef585701bb1ed3dbc9c921e8ec03c2546f 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Attributes.php
@@ -34,8 +34,13 @@
  */
 namespace Magento\Catalog\Block\Product\View;
 
+use Magento\Catalog\Model\Product;
+
 class Attributes extends \Magento\View\Element\Template
 {
+    /**
+     * @var Product
+     */
     protected $_product = null;
 
     /**
@@ -59,6 +64,9 @@ class Attributes extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return Product
+     */
     function getProduct()
     {
         if (!$this->_product) {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Description.php b/app/code/Magento/Catalog/Block/Product/View/Description.php
index 34ebe2afb079ce3b597d4abbd0b75f9379f66dab..a0bf623ba8d6c70295ff4bd253ac3737acc03929 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Description.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Description.php
@@ -34,8 +34,13 @@
  */
 namespace Magento\Catalog\Block\Product\View;
 
+use Magento\Catalog\Model\Product;
+
 class Description extends \Magento\View\Element\Template
 {
+    /**
+     * @var Product
+     */
     protected $_product = null;
 
     /**
@@ -59,6 +64,9 @@ class Description extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return Product
+     */
     public function getProduct()
     {
         if (!$this->_product) {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Gallery.php b/app/code/Magento/Catalog/Block/Product/View/Gallery.php
index a086b8f442f2452264638b6e0435434c19236b89..8d323f87a12b2fe105400f5b57721197f0632a3d 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Gallery.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Gallery.php
@@ -33,12 +33,14 @@
  */
 namespace Magento\Catalog\Block\Product\View;
 
+use Magento\Data\Collection;
+
 class Gallery extends \Magento\Catalog\Block\Product\View\AbstractView
 {
     /**
      * Retrieve list of gallery images
      *
-     * @return array|\Magento\Data\Collection
+     * @return array|Collection
      */
     public function getGalleryImages()
     {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Options.php b/app/code/Magento/Catalog/Block/Product/View/Options.php
index ef07dce2c07924ccb39e0d043e1b0aa335c0a99a..83928d268d0e1c3e250d45b5620285c338e31cc4 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Options.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Options.php
@@ -34,8 +34,13 @@
  */
 namespace Magento\Catalog\Block\Product\View;
 
+use Magento\Catalog\Model\Product;
+
 class Options extends \Magento\View\Element\Template
 {
+    /**
+     * @var Product
+     */
     protected $_product;
 
     /**
@@ -62,7 +67,7 @@ class Options extends \Magento\View\Element\Template
     /**
      * Catalog product
      *
-     * @var \Magento\Catalog\Model\Product
+     * @var Product
      */
     protected $_catalogProduct;
 
@@ -80,7 +85,7 @@ class Options extends \Magento\View\Element\Template
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Core\Helper\Data $coreData
      * @param \Magento\Json\EncoderInterface $jsonEncoder
-     * @param \Magento\Catalog\Model\Product $catalogProduct
+     * @param Product $catalogProduct
      * @param \Magento\Tax\Helper\Data $taxData
      * @param \Magento\Catalog\Model\Product\Option $option
      * @param \Magento\Core\Model\Registry $registry
@@ -91,7 +96,7 @@ class Options extends \Magento\View\Element\Template
         \Magento\View\Element\Template\Context $context,
         \Magento\Core\Helper\Data $coreData,
         \Magento\Json\EncoderInterface $jsonEncoder,
-        \Magento\Catalog\Model\Product $catalogProduct,
+        Product $catalogProduct,
         \Magento\Tax\Helper\Data $taxData,
         \Magento\Catalog\Model\Product\Option $option,
         \Magento\Core\Model\Registry $registry,
@@ -111,7 +116,7 @@ class Options extends \Magento\View\Element\Template
     /**
      * Retrieve product object
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -128,15 +133,19 @@ class Options extends \Magento\View\Element\Template
     /**
      * Set product object
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return \Magento\Catalog\Block\Product\View\Options
      */
-    public function setProduct(\Magento\Catalog\Model\Product $product = null)
+    public function setProduct(Product $product = null)
     {
         $this->_product = $product;
         return $this;
     }
 
+    /**
+     * @param string $type
+     * @return string
+     */
     public function getGroupOfOption($type)
     {
         $group = $this->_option->getGroupByType($type);
@@ -154,6 +163,9 @@ class Options extends \Magento\View\Element\Template
         return $this->getProduct()->getOptions();
     }
 
+    /**
+     * @return bool
+     */
     public function hasOptions()
     {
         if ($this->getOptions()) {
@@ -228,10 +240,10 @@ class Options extends \Magento\View\Element\Template
     /**
      * Decorate a plain array of arrays or objects
      *
-     * @param mixed $array
+     * @param array $array
      * @param string $prefix
      * @param bool $forceSetAll
-     * @return mixed
+     * @return array
      */
     public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false)
     {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php
index db94ad6445a77c2c1bd825e81ef1164ede824fe7..f85cfe12756fea0444ecf0cc030bea61a7f87114 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php
@@ -123,6 +123,9 @@ abstract class AbstractOptions extends \Magento\View\Element\Template
         return $this->_option;
     }
 
+    /**
+     * @return string
+     */
     public function getFormatedPrice()
     {
         if ($option = $this->getOption()) {
@@ -138,6 +141,7 @@ abstract class AbstractOptions extends \Magento\View\Element\Template
      * Return formated price
      *
      * @param array $value
+     * @param bool $flag
      * @return string
      */
     protected function _formatPrice($value, $flag=true)
@@ -179,9 +183,9 @@ abstract class AbstractOptions extends \Magento\View\Element\Template
     /**
      * Get price with including/excluding tax
      *
-     * @param decimal $price
+     * @param float $price
      * @param bool $includingTax
-     * @return decimal
+     * @return float
      */
     public function getPrice($price, $includingTax = null)
     {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php
index 206a232e541ab84a6a51d777d9c80c5c95f59b8b..23a6164067318584d22ed1c0eb03b5583bd450e3 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Catalog\Block\Product\View\Options\Type;
 
+use Magento\View\Element\AbstractBlock;
+
 /**
  * Product options text type block
  *
@@ -66,6 +68,9 @@ class Date extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions
         parent::__construct($context, $taxData, $coreHelper, $data);
     }
 
+    /**
+     * @return AbstractBlock
+     */
     protected function _prepareLayout()
     {
         if ($head = $this->getLayout()->getBlock('head')) {
@@ -183,7 +188,7 @@ class Date extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions
      * @param string $name Id/name of html select element
      * @param int $from  Start position
      * @param int $to    End position
-     * @param int $value Value selected
+     * @param int|null $value Value selected
      * @return string Formatted Html
      */
     protected function _getSelectFromToHtml($name, $from, $to, $value = null)
@@ -203,7 +208,8 @@ class Date extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions
      * HTML select element
      *
      * @param string $name Id/name of html select element
-     * @return \Magento\View\Element\Html\Select
+     * @param int|null $value
+     * @return mixed
      */
     protected function _getHtmlSelect($name, $value = null)
     {
@@ -238,8 +244,8 @@ class Date extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions
     /**
      * Add Leading Zeros to number less than 10
      *
-     * @param int
-     * @return string
+     * @param int $value
+     * @return string|int
      */
     protected function _getValueWithLeadingZeros($value)
     {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Price.php b/app/code/Magento/Catalog/Block/Product/View/Price.php
index 4cea83d5b7a2474fabfb872f9e1149f1debb404b..9508584f370a7baaa0e2cd4c798638f339063a1e 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Price.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Price.php
@@ -52,6 +52,9 @@ class Price extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return  array|float
+     */
     public function getPrice()
     {
         $product = $this->_coreRegistry->registry('product');
diff --git a/app/code/Magento/Catalog/Block/Product/View/Tabs.php b/app/code/Magento/Catalog/Block/Product/View/Tabs.php
index 7d87944243cb4b525d63147b029395f72053752b..c4c2d9597ed9d7eae00541f4f3db9bd1a567a9c2 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Tabs.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Tabs.php
@@ -46,6 +46,7 @@ class Tabs extends \Magento\View\Element\Template
      * @param string $block
      * @param string $template
      * @param string $header
+     * @return void
      */
     public function addTab($alias, $title, $block, $template, $header = null)
     {
diff --git a/app/code/Magento/Catalog/Block/Product/View/Type/Configurable.php b/app/code/Magento/Catalog/Block/Product/View/Type/Configurable.php
index 01ddde2fefe5728036359b88f317452f6fc6ce4b..34bff6598a1dd4fbb2e4aa6d13c657350bde1d4a 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Type/Configurable.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Type/Configurable.php
@@ -188,7 +188,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
     }
 
     /**
-     * retrieve current store
+     * Retrieve current store
      *
      * @return \Magento\Core\Model\Store
      */
@@ -364,7 +364,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
      * @param int $attributeId
      * @param array $value
      * @param array $options
-     * @return boolean
+     * @return bool
      */
     protected function _validateAttributeValue($attributeId, &$value, &$options)
     {
@@ -379,7 +379,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
      * Validation of super product option
      *
      * @param array $info
-     * @return boolean
+     * @return bool
      */
     protected function _validateAttributeInfo(&$info)
     {
@@ -394,7 +394,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
      *
      * @param float $price
      * @param bool $isPercent
-     * @return mixed
+     * @return string
      */
     protected function _preparePrice($price, $isPercent = false)
     {
@@ -410,7 +410,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
      *
      * @param float $price
      * @param bool $isPercent
-     * @return mixed
+     * @return string
      */
     protected function _prepareOldPrice($price, $isPercent = false)
     {
@@ -436,7 +436,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
      * Convert price from default currency to current currency
      *
      * @param float $price
-     * @param boolean $round
+     * @param bool $round
      * @return float
      */
     protected function _convertPrice($price, $round = false)
diff --git a/app/code/Magento/Catalog/Block/ShortcutButtons.php b/app/code/Magento/Catalog/Block/ShortcutButtons.php
new file mode 100644
index 0000000000000000000000000000000000000000..65de988d68339c52346d2060f47ee2a0a39a4b07
--- /dev/null
+++ b/app/code/Magento/Catalog/Block/ShortcutButtons.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Block;
+
+use Magento\View\Element\Template;
+
+class ShortcutButtons extends Template
+{
+    /**#@+
+     * Position of "OR" label against shortcut
+     */
+    const POSITION_BEFORE = 'before';
+    const POSITION_AFTER = 'after';
+    /**#@-*/
+
+    /**
+     * @var array
+     */
+    protected $_shortcuts = array();
+
+    /**
+     * @var bool
+     */
+    protected $_isCatalogProduct;
+
+    /**
+     * @var null|string
+     */
+    protected $_orPosition;
+
+    /**
+     * @param Template\Context $context
+     * @param bool $isCatalogProduct
+     * @param null|string $orPosition
+     * @param array $data
+     */
+    public function __construct(
+        Template\Context $context,
+        $isCatalogProduct = false,
+        $orPosition = null,
+        array $data = array()
+    ) {
+        parent::__construct($context, $data);
+        $this->_isCatalogProduct = $isCatalogProduct;
+        $this->_orPosition = $orPosition ?: ($isCatalogProduct ? self::POSITION_BEFORE : self::POSITION_AFTER);
+    }
+
+    /**
+     * Add shortcut button
+     *
+     * @param Template $block
+     */
+    public function addShortcut(Template $block)
+    {
+        if ($block instanceof ShortcutInterface) {
+            $this->_shortcuts[] = $block;
+        }
+    }
+
+    /**
+     * Dispatch shortcuts container event
+     * @return $this
+     */
+    protected function _beforeToHtml()
+    {
+        $this->_eventManager->dispatch(
+            'shortcut_buttons_container',
+            array(
+                'container' => $this,
+                'is_catalog_product' => $this->_isCatalogProduct,
+                'or_position' => $this->_orPosition
+            )
+        );
+        return $this;
+    }
+
+    /**
+     * Render all shortcuts
+     *
+     * @return string
+     */
+    protected function _toHtml()
+    {
+        /** @var ShortcutInterface $shortcut */
+        foreach ($this->_shortcuts as $shortcut) {
+            $this->setChild($shortcut->getAlias(), $shortcut);
+        }
+        return $this->getChildHtml();
+    }
+}
diff --git a/app/code/Magento/Catalog/Block/ShortcutInterface.php b/app/code/Magento/Catalog/Block/ShortcutInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..46d27d8ca5dccba2daaa5c175520f8e657846c70
--- /dev/null
+++ b/app/code/Magento/Catalog/Block/ShortcutInterface.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Block;
+
+interface ShortcutInterface
+{
+    /**
+     * Get shortcut alias
+     *
+     * @return string
+     */
+    public function getAlias();
+}
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
index 839971c48ed20cc26c0f8929156ee3d72652e1eb..0904deea705aae34632f8ecd964f6c558e206ded 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller\Adminhtml;
 
 /**
  * Catalog category controller
  */
-namespace Magento\Catalog\Controller\Adminhtml;
-
 class Category extends \Magento\Backend\App\Action
 {
     /**
@@ -73,8 +72,11 @@ class Category extends \Magento\Backend\App\Action
         $this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config')->setStoreId($this->getRequest()->getParam('store'));
         return $category;
     }
+
     /**
      * Catalog categories index action
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -83,6 +85,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Add new category form
+     *
+     * @return void
      */
     public function addAction()
     {
@@ -92,6 +96,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Edit category page
+     *
+     * @return void
      */
     public function editAction()
     {
@@ -208,6 +214,7 @@ class Category extends \Magento\Backend\App\Action
     /**
      * WYSIWYG editor action for ajax request
      *
+     * @return void
      */
     public function wysiwygAction()
     {
@@ -233,6 +240,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Get tree node (Ajax version)
+     *
+     * @return void
      */
     public function categoriesJsonAction()
     {
@@ -257,6 +266,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Category save
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -400,6 +411,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Move category action
+     *
+     * @return void
      */
     public function moveAction()
     {
@@ -426,11 +439,12 @@ class Category extends \Magento\Backend\App\Action
             $this->getResponse()->setBody(__('There was a category move error %1', $e));
             $this->_objectManager->get('Magento\Logger')->logException($e);
         }
-
     }
 
     /**
      * Delete category action
+     *
+     * @return void
      */
     public function deleteAction()
     {
@@ -462,6 +476,8 @@ class Category extends \Magento\Backend\App\Action
     /**
      * Grid Action
      * Display list of products related to current category
+     *
+     * @return void
      */
     public function gridAction()
     {
@@ -477,6 +493,8 @@ class Category extends \Magento\Backend\App\Action
     /**
      * Tree Action
      * Retrieve category tree
+     *
+     * @return void
      */
     public function treeAction()
     {
@@ -511,6 +529,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Build response for refresh input element 'path' in form
+     *
+     * @return void
      */
     public function refreshPathAction()
     {
@@ -528,6 +548,8 @@ class Category extends \Magento\Backend\App\Action
 
     /**
      * Category list suggestion based on already entered symbols
+     *
+     * @return void
      */
     public function suggestCategoriesAction()
     {
@@ -538,7 +560,7 @@ class Category extends \Magento\Backend\App\Action
     /**
      * Check if admin has permissions to visit related pages
      *
-     * @return boolean
+     * @return bool
      */
     protected function _isAllowed()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php
index b1a96c943cf2f1788038834536efdc239605b610..73b3f1415062d858a6fb28787b68f393b6411554 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller\Adminhtml\Category;
+
+use Magento\View\Element\BlockInterface;
 
 /**
  * Catalog category widgets controller for CMS WYSIWYG
@@ -31,8 +34,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Controller\Adminhtml\Category;
-
 class Widget extends \Magento\Backend\App\Action
 {
     /**
@@ -56,6 +57,8 @@ class Widget extends \Magento\Backend\App\Action
 
     /**
      * Chooser Source action
+     *
+     * @return void
      */
     public function chooserAction()
     {
@@ -66,6 +69,8 @@ class Widget extends \Magento\Backend\App\Action
 
     /**
      * Categories tree node (Ajax version)
+     *
+     * @return void
      */
     public function categoriesJsonAction()
     {
@@ -83,6 +88,9 @@ class Widget extends \Magento\Backend\App\Action
         }
     }
 
+    /**
+     * @return BlockInterface
+     */
     protected function _getCategoryTreeBlock()
     {
         return $this->_view->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Widget\Chooser', '', array(
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php
index 347e2c1ac0e29598f6ce28688cebd79c6c7993dc..8dc823c223d02eae819a2ec750117ad6dd9e8b08 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php
@@ -209,6 +209,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Output specified blocks as a text list
+     *
+     * @return void
      */
     protected function _outputBlocks()
     {
@@ -222,6 +224,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Product list page
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -233,6 +237,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Create new product page
+     *
+     * @return void
      */
     public function newAction()
     {
@@ -283,6 +289,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Product edit form
+     *
+     * @return void
      */
     public function editAction()
     {
@@ -344,6 +352,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * WYSIWYG editor action for ajax request
      *
+     * @return void
      */
     public function wysiwygAction()
     {
@@ -368,6 +377,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Product grid for AJAX request
+     *
+     * @return void
      */
     public function gridAction()
     {
@@ -377,6 +388,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get specified tab grid
+     *
+     * @return void
      */
     public function gridOnlyAction()
     {
@@ -395,6 +408,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Generate product variations matrix
+     *
+     * @return void
      */
     public function generateVariationsAction()
     {
@@ -411,6 +426,8 @@ class Product extends \Magento\Backend\App\Action
      *   when full set of operations for attribute options during
      *   product creation will be implemented: edit labels, remove, reorder.
      * Currently only addition of options to end and removal of just added option is supported.
+     *
+     * @return void
      */
     protected function _saveAttributeOptions()
     {
@@ -456,6 +473,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Get categories fieldset block
      *
+     * @return void
      */
     public function categoriesAction()
     {
@@ -467,6 +485,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Get options fieldset block
      *
+     * @return void
      */
     public function optionsAction()
     {
@@ -477,6 +496,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get related products grid and serializer block
+     *
+     * @return void
      */
     public function relatedAction()
     {
@@ -489,6 +510,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get upsell products grid and serializer block
+     *
+     * @return void
      */
     public function upsellAction()
     {
@@ -501,6 +524,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get crosssell products grid and serializer block
+     *
+     * @return void
      */
     public function crosssellAction()
     {
@@ -513,6 +538,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get related products grid
+     *
+     * @return void
      */
     public function relatedGridAction()
     {
@@ -525,6 +552,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get upsell products grid
+     *
+     * @return void
      */
     public function upsellGridAction()
     {
@@ -537,6 +566,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get crosssell products grid
+     *
+     * @return void
      */
     public function crosssellGridAction()
     {
@@ -550,6 +581,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Get product reviews grid
      *
+     * @return void
      */
     public function reviewsAction()
     {
@@ -564,6 +596,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Get super config grid
      *
+     * @return void
      */
     public function superConfigAction()
     {
@@ -575,6 +608,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Validate product
      *
+     * @return void
      */
     public function validateAction()
     {
@@ -661,7 +695,6 @@ class Product extends \Magento\Backend\App\Action
      *
      * @param \Magento\Catalog\Model\Product $parentProduct
      * @param array $products
-     *
      * @return array
      */
     protected function _validateProductVariations($parentProduct, array $products)
@@ -703,6 +736,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Save product action
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -804,6 +839,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Create product duplicate
+     *
+     * @return void
      */
     public function duplicateAction()
     {
@@ -821,6 +858,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get alerts price grid
+     *
+     * @return void
      */
     public function alertsPriceGridAction()
     {
@@ -830,6 +869,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Get alerts stock grid
+     *
+     * @return void
      */
     public function alertsStockGridAction()
     {
@@ -837,6 +878,9 @@ class Product extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function addAttributeAction()
     {
         $this->_view->loadLayout('popup');
@@ -847,6 +891,9 @@ class Product extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function createdAction()
     {
         $this->_view->loadLayout('popup');
@@ -856,6 +903,9 @@ class Product extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function massDeleteAction()
     {
         $productIds = $this->getRequest()->getParam('product');
@@ -882,6 +932,7 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Update product(s) status action
      *
+     * @return void
      */
     public function massStatusAction()
     {
@@ -912,10 +963,10 @@ class Product extends \Magento\Backend\App\Action
     /**
      * Validate batch of products before theirs status will be set
      *
-     * @throws \Magento\Core\Exception
-     * @param  array $productIds
-     * @param  int $status
+     * @param array $productIds
+     * @param int $status
      * @return void
+     * @throws \Magento\Core\Exception
      */
     public function _validateMassStatus(array $productIds, $status)
     {
@@ -942,6 +993,7 @@ class Product extends \Magento\Backend\App\Action
      * Show item update result from updateAction
      * in Wishlist and Cart controllers.
      *
+     * @return bool
      */
     public function showUpdateResultAction()
     {
@@ -959,6 +1011,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Show product grid for custom options import popup
+     *
+     * @return void
      */
     public function optionsImportGridAction()
     {
@@ -968,6 +1022,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Show custom options in JSON format for specified products
+     *
+     * @return void
      */
     public function customOptionsAction()
     {
@@ -978,6 +1034,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Action for product template selector
+     *
+     * @return void
      */
     public function suggestProductTemplatesAction()
     {
@@ -990,6 +1048,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Search for attributes by part of attribute's label in admin store
+     *
+     * @return void
      */
     public function suggestAttributesAction()
     {
@@ -1001,6 +1061,8 @@ class Product extends \Magento\Backend\App\Action
 
     /**
      * Add attribute to product template
+     *
+     * @return void
      */
     public function addAttributeToTemplateAction()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php
index 3d44c6908e1159e96a1ada38af73a1f603ded92f..dec4a3b2242a4eef6bc920e04cb14a26e0f2716e 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller\Adminhtml\Product\Action;
 
+use Magento\Backend\App\Action;
 
 /**
  * Adminhtml catalog product action attribute update controller
@@ -32,11 +34,7 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Controller\Adminhtml\Product\Action;
-
-use Magento\Backend\App\Action;
-
-class Attribute extends \Magento\Backend\App\Action
+class Attribute extends Action
 {
     /**
      * @param Action\Context $context
@@ -50,6 +48,9 @@ class Attribute extends \Magento\Backend\App\Action
         $this->_helper = $helper;
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         if (!$this->_validateProducts()) {
@@ -62,6 +63,8 @@ class Attribute extends \Magento\Backend\App\Action
 
     /**
      * Update product attributes
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -219,6 +222,9 @@ class Attribute extends \Magento\Backend\App\Action
         return !$error;
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Catalog::update_attributes');
@@ -227,6 +233,7 @@ class Attribute extends \Magento\Backend\App\Action
     /**
      * Attributes validation action
      *
+     * @return void
      */
     public function validateAction()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php
index 9c2dae069398e7f634d2124ac830125c4f1858dc..cf5da02a11f6325870b4974e04476785bd7820cb 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php
@@ -77,6 +77,9 @@ class Attribute extends \Magento\Backend\App\Action
         return parent::dispatch($request);
     }
 
+    /**
+     * @return $this
+     */
     protected function _initAction()
     {
         $this->_title->add(__('Product Attributes'));
@@ -109,6 +112,9 @@ class Attribute extends \Magento\Backend\App\Action
         return $this;
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_initAction()
@@ -118,11 +124,17 @@ class Attribute extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function newAction()
     {
         $this->_forward('edit');
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $id = $this->getRequest()->getParam('attribute_id');
@@ -171,9 +183,11 @@ class Attribute extends \Magento\Backend\App\Action
             ->setIsPopup((bool)$this->getRequest()->getParam('popup'));
 
         $this->_view->renderLayout();
-
     }
 
+    /**
+     * @return void
+     */
     public function validateAction()
     {
         $response = new \Magento\Object();
@@ -241,6 +255,9 @@ class Attribute extends \Magento\Backend\App\Action
         return $code;
     }
 
+    /**
+     * @return void
+     */
     public function saveAction()
     {
         $data = $this->getRequest()->getPost();
@@ -252,7 +269,7 @@ class Attribute extends \Magento\Backend\App\Action
             if (!empty($data['new_attribute_set_name'])) {
                 /** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
                 $attributeSet = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Set');
-                $name = $this->_objectManager->get('Magento\Backend\Helper\Data')
+                $name = $this->_objectManager->get('Magento\Filter\FilterManager')
                     ->stripTags($data['new_attribute_set_name']);
                 $name = trim($name);
                 $attributeSet->setEntityTypeId($this->_entityTypeId)
@@ -423,6 +440,9 @@ class Attribute extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/');
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $id = $this->getRequest()->getParam('attribute_id');
@@ -457,6 +477,8 @@ class Attribute extends \Magento\Backend\App\Action
 
     /**
      * Search for attributes by part of attribute's label in admin store
+     *
+     * @return void
      */
     public function suggestConfigurableAttributesAction()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Datafeeds.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Datafeeds.php
index 8332dadee42848ddb44b319ccdaf497b74bc623f..ebf85c4a14b6e65850bfc965763daea28a5a440a 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Datafeeds.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Datafeeds.php
@@ -23,15 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Catalog\Controller\Adminhtml\Product;
 
 class Datafeeds extends \Magento\Backend\App\Action
 {
-
+    /**
+     * @return void
+     */
     public function indexAction()
     {
-        
     }
 }
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery.php
index aabc2d330b948c55c8a1defbf7e5e55802b7bbb9..09ba072516bec70dc807b4c7b754401c382977b6 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller\Adminhtml\Product;
 
 /**
  * Catalog product gallery controller
@@ -31,10 +32,11 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Controller\Adminhtml\Product;
-
 class Gallery extends \Magento\Backend\App\Action
 {
+    /**
+     * @return void
+     */
     public function uploadAction()
     {
         try {
@@ -72,6 +74,9 @@ class Gallery extends \Magento\Backend\App\Action
         $this->getResponse()->setBody($this->_objectManager->get('Magento\Core\Helper\Data')->jsonEncode($result));
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Catalog::products');
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group.php
index ce35eada30f6e587ec4d682130e7951927abd9ca..08d8566d9d877ef99f6987a666efba75f14ffee0 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Group.php
@@ -23,11 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Controller\Adminhtml\Product;
 
 class Group extends \Magento\Backend\App\Action
 {
+    /**
+     * @return void
+     */
     public function saveAction()
     {
         $model = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Group');
@@ -46,6 +48,9 @@ class Group extends \Magento\Backend\App\Action
         }
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Catalog::products');
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php
index 0e6e3cdca01ec92614b49e0e204031a2ce6bdf85..e5b2602b2b1c5cde863309062803e9ff5df1785d 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Review.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller\Adminhtml\Product;
 
 /**
  * Reviews admin controller
  */
-namespace Magento\Catalog\Controller\Adminhtml\Product;
-
 class Review extends \Magento\Backend\App\Action
 {
     /**
@@ -57,6 +56,9 @@ class Review extends \Magento\Backend\App\Action
         parent::__construct($context);
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Customer Reviews'));
@@ -75,6 +77,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function pendingAction()
     {
         $this->_title->add(__('Customer Reviews'));
@@ -94,6 +99,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $this->_title->add(__('Customer Reviews'));
@@ -108,6 +116,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function newAction()
     {
         $this->_title->add(__('Customer Reviews'));
@@ -125,6 +136,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return mixed
+     */
     public function saveAction()
     {
         if (($data = $this->getRequest()->getPost()) && ($reviewId = $this->getRequest()->getParam('id'))) {
@@ -176,6 +190,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/');
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $reviewId   = $this->getRequest()->getParam('id', false);
@@ -200,6 +217,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/edit/',array('id'=>$reviewId));
     }
 
+    /**
+     * @return void
+     */
     public function massDeleteAction()
     {
         $reviewsIds = $this->getRequest()->getParam('reviews');
@@ -225,6 +245,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/' . $this->getRequest()->getParam('ret', 'index'));
     }
 
+    /**
+     * @return void
+     */
     public function massUpdateStatusAction()
     {
         $reviewsIds = $this->getRequest()->getParam('reviews');
@@ -252,6 +275,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/' . $this->getRequest()->getParam('ret', 'index'));
     }
 
+    /**
+     * @return void
+     */
     public function massVisibleInAction()
     {
         $reviewsIds = $this->getRequest()->getParam('reviews');
@@ -279,6 +305,9 @@ class Review extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/pending');
     }
 
+    /**
+     * @return void
+     */
     public function productGridAction()
     {
         $this->getResponse()->setBody(
@@ -286,6 +315,9 @@ class Review extends \Magento\Backend\App\Action
         );
     }
 
+    /**
+     * @return void
+     */
     public function reviewGridAction()
     {
         $this->getResponse()->setBody(
@@ -293,6 +325,9 @@ class Review extends \Magento\Backend\App\Action
         );
     }
 
+    /**
+     * @return void
+     */
     public function jsonProductInfoAction()
     {
         $response = new \Magento\Object();
@@ -311,6 +346,9 @@ class Review extends \Magento\Backend\App\Action
         $this->getResponse()->setBody($response->toJSON());
     }
 
+    /**
+     * @return void
+     */
     public function postAction()
     {
         $productId  = $this->getRequest()->getParam('product_id', false);
@@ -365,6 +403,9 @@ class Review extends \Magento\Backend\App\Action
         return;
     }
 
+    /**
+     * @return void
+     */
     public function ratingItemsAction()
     {
         $this->getResponse()->setBody(
@@ -375,6 +416,9 @@ class Review extends \Magento\Backend\App\Action
         );
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         switch ($this->getRequest()->getActionName()) {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php
index bbc01bffa47642b941871346a21e618aa6a7c76a..f082eca4f0b9b1db51ee6fa765cab53e250b1804 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller\Adminhtml\Product;
 
 /**
  * Adminhtml entity sets controller
@@ -31,9 +32,6 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Catalog\Controller\Adminhtml\Product;
-
 class Set extends \Magento\Backend\App\Action
 {
     /**
@@ -55,6 +53,9 @@ class Set extends \Magento\Backend\App\Action
         parent::__construct($context);
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Product Templates'));
@@ -72,6 +73,9 @@ class Set extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $this->_title->add(__('Product Templates'));
@@ -105,6 +109,9 @@ class Set extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function setGridAction()
     {
         $this->_setTypeId();
@@ -118,6 +125,7 @@ class Set extends \Magento\Backend\App\Action
      * [POST] Create attribute set from another set and redirect to edit page
      * [AJAX] Save attribute set data
      *
+     * @return void
      */
     public function saveAction()
     {
@@ -203,6 +211,9 @@ class Set extends \Magento\Backend\App\Action
         }
     }
 
+    /**
+     * @return void
+     */
     public function addAction()
     {
         $this->_title->add(__('New Product Template'));
@@ -220,6 +231,9 @@ class Set extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $setId = $this->getRequest()->getParam('id');
@@ -239,6 +253,7 @@ class Set extends \Magento\Backend\App\Action
     /**
      * Define in register catalog_product entity type code as entityType
      *
+     * @return void
      */
     protected function _setTypeId()
     {
@@ -246,6 +261,9 @@ class Set extends \Magento\Backend\App\Action
             $this->_objectManager->create('Magento\Catalog\Model\Product')->getResource()->getTypeId());
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Catalog::sets');
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget.php
index 0f2070d35f324cb69d4c0ea69ad0a003afd385ce..8e9cf2eaf29c45838adeb8818b0d3150234ddcad 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Widget.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Controller\Adminhtml\Product;
 
 /**
  * Catalog Product widgets controller for CMS WYSIWYG
@@ -32,12 +32,12 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Controller\Adminhtml\Product;
-
 class Widget extends \Magento\Backend\App\Action
 {
     /**
      * Chooser Source action
+     *
+     * @return void
      */
     public function chooserAction()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Search.php b/app/code/Magento/Catalog/Controller/Adminhtml/Search.php
index f785a07742f231a5783acd42fbe891b7fcde6b51..377ecdf552bf59885a8f1604a9ce73e8bd3c9737 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Search.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Search.php
@@ -49,15 +49,20 @@ class Search extends \Magento\Backend\App\Action
         parent::__construct($context);
     }
 
+    /**
+     * @return $this
+     */
     protected function _initAction()
     {
         $this->_view->loadLayout();
         $this->_setActiveMenu('Magento_CatalogSearch::catalog_search')
-            ->_addBreadcrumb(__('Search'), __('Search'))
-        ;
+            ->_addBreadcrumb(__('Search'), __('Search'));
         return $this;
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Search Terms'));
@@ -67,11 +72,17 @@ class Search extends \Magento\Backend\App\Action
             $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function newAction()
     {
         $this->_forward('edit');
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $this->_title->add(__('Search Terms'));
@@ -113,6 +124,7 @@ class Search extends \Magento\Backend\App\Action
     /**
      * Save search query
      *
+     * @return void
      */
     public function saveAction()
     {
@@ -166,6 +178,9 @@ class Search extends \Magento\Backend\App\Action
         }
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $id = $this->getRequest()->getParam('id');
@@ -187,6 +202,9 @@ class Search extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/');
     }
 
+    /**
+     * @return void
+     */
     public function massDeleteAction()
     {
         $searchIds = $this->getRequest()->getParam('search');
@@ -206,6 +224,9 @@ class Search extends \Magento\Backend\App\Action
         $this->_redirect('catalog/*/index');
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_CatalogSearch::search');
diff --git a/app/code/Magento/Catalog/Controller/Category.php b/app/code/Magento/Catalog/Controller/Category.php
index f275d54e5fcd1a3649e0b7ba91393367fd13f8fa..f7867fa51ce57286980b4b2d7a492ff7ffb05248 100644
--- a/app/code/Magento/Catalog/Controller/Category.php
+++ b/app/code/Magento/Catalog/Controller/Category.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Controller;
 
 /**
  * Category controller
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Controller;
-
 class Category extends \Magento\App\Action\Action
 {
     /**
@@ -132,6 +131,8 @@ class Category extends \Magento\App\Action\Action
 
     /**
      * Category view action
+     *
+     * @return void
      */
     public function viewAction()
     {
diff --git a/app/code/Magento/Catalog/Controller/Index.php b/app/code/Magento/Catalog/Controller/Index.php
index d6ec80f5759f86d181af1f039b1b0a478f35bd00..11eb9d5fe60a031d2b1c147b12d0698c6c40b0c9 100644
--- a/app/code/Magento/Catalog/Controller/Index.php
+++ b/app/code/Magento/Catalog/Controller/Index.php
@@ -23,17 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Controller;
 
 class Index extends \Magento\App\Action\Action
 {
     /**
      * Index action
+     *
+     * @return void
      */
     public function indexAction()
     {
         $this->_redirect('/');
     }
-
 }
diff --git a/app/code/Magento/Catalog/Controller/Product.php b/app/code/Magento/Catalog/Controller/Product.php
index f3b986dc59b153248ba2bb058456fb453eb2f04c..953d5a7c73c3b7819beb4425d5681a525175ca85 100644
--- a/app/code/Magento/Catalog/Controller/Product.php
+++ b/app/code/Magento/Catalog/Controller/Product.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Catalog\Controller;
 
+use Magento\Catalog\Model\Product as ModelProduct;
+
 class Product
     extends \Magento\App\Action\Action
     implements \Magento\Catalog\Controller\Product\View\ViewInterface
@@ -33,7 +35,7 @@ class Product
     /**
      * Initialize requested product object
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return ModelProduct
      */
     protected function _initProduct()
     {
@@ -49,8 +51,8 @@ class Product
     /**
      * Initialize product view layout
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  \Magento\Catalog\Controller\Product
+     * @param ModelProduct $product
+     * @return $this
      */
     protected function _initProductLayout($product)
     {
@@ -60,6 +62,8 @@ class Product
 
     /**
      * Product view action
+     *
+     * @return void
      */
     public function viewAction()
     {
@@ -95,6 +99,8 @@ class Product
 
     /**
      * View product gallery action
+     *
+     * @return void
      */
     public function galleryAction()
     {
diff --git a/app/code/Magento/Catalog/Controller/Product/Compare.php b/app/code/Magento/Catalog/Controller/Product/Compare.php
index e16d237fe06518c7e73f9aee4fbe4beda3a12661..c3a926627d132af4356d8d101ba8661be53e041a 100644
--- a/app/code/Magento/Catalog/Controller/Product/Compare.php
+++ b/app/code/Magento/Catalog/Controller/Product/Compare.php
@@ -23,11 +23,12 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Controller\Product;
 
+use Magento\Core\App\Action\FormKeyValidator;
+
 /**
- * Catalog comapare controller
+ * Catalog compare controller
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  */
@@ -102,7 +103,7 @@ class Compare extends \Magento\App\Action\Action
     protected $_storeManager;
 
     /**
-     * @var \Magento\Core\App\Action\FormKeyValidator
+     * @var FormKeyValidator
      */
     protected $_formKeyValidator;
 
@@ -117,6 +118,7 @@ class Compare extends \Magento\App\Action\Action
      * @param \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList
      * @param \Magento\Catalog\Model\Session $catalogSession
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param FormKeyValidator $formKeyValidator
      */
     public function __construct(
         \Magento\App\Action\Context $context,
@@ -129,7 +131,7 @@ class Compare extends \Magento\App\Action\Action
         \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList,
         \Magento\Catalog\Model\Session $catalogSession,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Core\App\Action\FormKeyValidator $formKeyValidator
+        FormKeyValidator $formKeyValidator
     ) {
         $this->_storeManager = $storeManager;
         $this->_customerFactory = $customerFactory;
@@ -146,6 +148,8 @@ class Compare extends \Magento\App\Action\Action
 
     /**
      * Compare index action
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -172,6 +176,8 @@ class Compare extends \Magento\App\Action\Action
 
     /**
      * Add item to compare list
+     *
+     * @return void
      */
     public function addAction()
     {
@@ -206,6 +212,8 @@ class Compare extends \Magento\App\Action\Action
 
     /**
      * Remove item from compare list
+     *
+     * @return void
      */
     public function removeAction()
     {
@@ -251,6 +259,8 @@ class Compare extends \Magento\App\Action\Action
 
     /**
      * Remove all items from comparison list
+     *
+     * @return void
      */
     public function clearAction()
     {
@@ -282,7 +292,7 @@ class Compare extends \Magento\App\Action\Action
      * Setter for customer id
      *
      * @param int $customerId
-     * @return \Magento\Catalog\Controller\Product\Compare
+     * @return $this
      */
     public function setCustomerId($customerId)
     {
diff --git a/app/code/Magento/Catalog/Helper/Catalog.php b/app/code/Magento/Catalog/Helper/Catalog.php
index 8110197e210632bad5f1ef091bb3eaa250356761..4eb113877ebb435e309e07c261e92e4c6f00dfe1 100644
--- a/app/code/Magento/Catalog/Helper/Catalog.php
+++ b/app/code/Magento/Catalog/Helper/Catalog.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Helper;
 
 /**
  * Adminhtml Catalog helper
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Helper;
-
 class Catalog extends \Magento\App\Helper\AbstractHelper
 {
     /**
@@ -94,7 +93,7 @@ class Catalog extends \Magento\App\Helper\AbstractHelper
      * Set Custom Attribute Tab Block Name for Product Edit
      *
      * @param string $attributeTabBlock
-     * @return \Magento\Catalog\Helper\Catalog
+     * @return $this
      */
     public function setAttributeTabBlock($attributeTabBlock)
     {
@@ -116,7 +115,7 @@ class Catalog extends \Magento\App\Helper\AbstractHelper
      * Set Custom Attribute Tab Block Name for Category Edit
      *
      * @param string $attributeTabBlock
-     * @return \Magento\Catalog\Helper\Catalog
+     * @return $this
      */
     public function setCategoryAttributeTabBlock($attributeTabBlock)
     {
diff --git a/app/code/Magento/Catalog/Helper/Category.php b/app/code/Magento/Catalog/Helper/Category.php
index dceb2ef9456c829c92a45a4aa70daf80f194ddea..91c9f5037bf7d12c06fad0ebd7e37bb30c716055 100644
--- a/app/code/Magento/Catalog/Helper/Category.php
+++ b/app/code/Magento/Catalog/Helper/Category.php
@@ -23,15 +23,18 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Helper;
 
+use Magento\App\Helper\AbstractHelper;
+use Magento\Catalog\Model\Category as ModelCategory;
+use Magento\Core\Model\Store;
+
 /**
  * Catalog category helper
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  */
-class Category extends \Magento\App\Helper\AbstractHelper
+class Category extends AbstractHelper
 {
     const XML_PATH_CATEGORY_URL_SUFFIX          = 'catalog/seo/category_url_suffix';
     const XML_PATH_USE_CATEGORY_CANONICAL_TAG   = 'catalog/seo/category_canonical_tag';
@@ -103,9 +106,10 @@ class Category extends \Magento\App\Helper\AbstractHelper
     /**
      * Retrieve current store categories
      *
-     * @param   boolean|string $sorted
-     * @param   boolean $asCollection
-     * @return  \Magento\Data\Tree\Node\Collection|\Magento\Catalog\Model\Resource\Category\Collection|array
+     * @param bool|string $sorted
+     * @param bool $asCollection
+     * @param bool $toLoad
+     * @return \Magento\Data\Tree\Node\Collection|\Magento\Catalog\Model\Resource\Category\Collection|array
      */
     public function getStoreCategories($sorted=false, $asCollection=false, $toLoad=true)
     {
@@ -119,7 +123,7 @@ class Category extends \Magento\App\Helper\AbstractHelper
          * Check if parent node of the store still exists
          */
         $category = $this->_categoryFactory->create();
-        /* @var $category \Magento\Catalog\Model\Category */
+        /* @var $category ModelCategory */
         if (!$category->checkId($parent)) {
             if ($asCollection) {
                 return $this->_dataCollectionFactory->create();
@@ -137,12 +141,12 @@ class Category extends \Magento\App\Helper\AbstractHelper
     /**
      * Retrieve category url
      *
-     * @param   \Magento\Catalog\Model\Category $category
-     * @return  string
+     * @param ModelCategory $category
+     * @return string
      */
     public function getCategoryUrl($category)
     {
-        if ($category instanceof \Magento\Catalog\Model\Category) {
+        if ($category instanceof ModelCategory) {
             return $category->getUrl();
         }
         return $this->_categoryFactory->create()
@@ -153,8 +157,8 @@ class Category extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if a category can be shown
      *
-     * @param  \Magento\Catalog\Model\Category|int $category
-     * @return boolean
+     * @param ModelCategory|int $category
+     * @return bool
      */
     public function canShow($category)
     {
@@ -176,8 +180,8 @@ class Category extends \Magento\App\Helper\AbstractHelper
         return true;
     }
 
-/**
-     * Retrieve category rewrite sufix for store
+    /**
+     * Retrieve category rewrite suffix for store
      *
      * @param int $storeId
      * @return string
@@ -197,12 +201,11 @@ class Category extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
-     * Retrieve clear url for category as parrent
+     * Retrieve clear url for category as parent
      *
-     * @param string $url
+     * @param string $urlPath
      * @param bool $slash
      * @param int $storeId
-     *
      * @return string
      */
     public function getCategoryUrlPath($urlPath, $slash = false, $storeId = null)
@@ -226,7 +229,7 @@ class Category extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if <link rel="canonical"> can be used for category
      *
-     * @param $store
+     * @param null|string|bool|int|Store $store
      * @return bool
      */
     public function canUseCanonicalTag($store = null)
diff --git a/app/code/Magento/Catalog/Helper/Category/Flat.php b/app/code/Magento/Catalog/Helper/Category/Flat.php
deleted file mode 100644
index 74aff94c0bbd5e78812133b27572d4e9aaf78e6e..0000000000000000000000000000000000000000
--- a/app/code/Magento/Catalog/Helper/Category/Flat.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Catalog
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-/**
- * Catalog flat helper
- *
- * @category   Magento
- * @package    Magento_Catalog
- * @author     Magento Core Team <core@magentocommerce.com>
- */
-namespace Magento\Catalog\Helper\Category;
-
-class Flat extends \Magento\Catalog\Helper\Flat\AbstractFlat
-{
-    /**
-     * Catalog Category Flat Is Enabled Config
-     */
-    const XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY = 'catalog/frontend/flat_catalog_category';
-
-    /**
-     * Catalog Flat Category index process code
-     */
-    const CATALOG_CATEGORY_FLAT_PROCESS_CODE = 'catalog_category_flat';
-
-    /**
-     * Catalog Category Flat index process code
-     *
-     * @var string
-     */
-    protected $_indexerCode = self::CATALOG_CATEGORY_FLAT_PROCESS_CODE;
-
-    /**
-     * Store catalog Category Flat index process instance
-     *
-     * @var \Magento\Index\Model\Process|null
-     */
-    protected $_process = null;
-
-    /**
-     * Core store config
-     *
-     * @var \Magento\Core\Model\Store\Config
-     */
-    protected $_coreStoreConfig;
-
-    /**
-     * Catalog category flat
-     *
-     * @var \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected $_catalogCategoryFlat;
-
-    /**
-     * @param \Magento\App\Helper\Context $context
-     * @param \Magento\Index\Model\ProcessFactory $processFactory
-     * @param \Magento\Catalog\Model\Resource\Category\Flat $catalogCategoryFlat
-     * @param \Magento\Core\Model\Store\Config $coreStoreConfig
-     * @param bool $isAvailable
-     */
-    public function __construct(
-        \Magento\App\Helper\Context $context,
-        \Magento\Index\Model\ProcessFactory $processFactory,
-        \Magento\Catalog\Model\Resource\Category\Flat $catalogCategoryFlat,
-        \Magento\Core\Model\Store\Config $coreStoreConfig,
-        $isAvailable = true
-    ) {
-        $this->_catalogCategoryFlat = $catalogCategoryFlat;
-        $this->_coreStoreConfig = $coreStoreConfig;
-        parent::__construct($context, $processFactory, $isAvailable);
-    }
-
-    /**
-     * Check if Catalog Category Flat Data is enabled
-     *
-     * @param bool $skipAdminCheck this parameter is deprecated and no longer in use
-     *
-     * @return bool
-     */
-    public function isEnabled($skipAdminCheck = false)
-    {
-        return $this->_coreStoreConfig->getConfigFlag(self::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY);
-    }
-
-    /**
-     * Check if Catalog Category Flat Data has been initialized
-     *
-     * @return bool
-     */
-    public function isBuilt()
-    {
-        return $this->_catalogCategoryFlat->isBuilt();
-    }
-
-    /**
-     * Check if Catalog Category Flat Data has been initialized
-     *
-     * @deprecated after 1.7.0.0 use \Magento\Catalog\Helper\Category\Flat::isBuilt() instead
-     *
-     * @return bool
-     */
-    public function isRebuilt()
-    {
-        return $this->isBuilt();
-    }
-}
diff --git a/app/code/Magento/Catalog/Helper/Data.php b/app/code/Magento/Catalog/Helper/Data.php
index 8bf63ef90843f83d02941dba7be5b16b604e8a85..1bde0389d6d16ec27d975faa3e80ed061abcea56 100644
--- a/app/code/Magento/Catalog/Helper/Data.php
+++ b/app/code/Magento/Catalog/Helper/Data.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Helper;
 
 /**
@@ -80,14 +79,14 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Catalog product
      *
-     * @var \Magento\Catalog\Helper\Product
+     * @var Product
      */
     protected $_catalogProduct;
 
     /**
      * Catalog category
      *
-     * @var \Magento\Catalog\Helper\Category
+     * @var Category
      */
     protected $_catalogCategory;
 
@@ -156,8 +155,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Catalog\Model\Session $catalogSession
      * @param \Magento\Stdlib\String $string
-     * @param \Magento\Catalog\Helper\Category $catalogCategory
-     * @param \Magento\Catalog\Helper\Product $catalogProduct
+     * @param Category $catalogCategory
+     * @param Product $catalogProduct
      * @param \Magento\Core\Model\Registry $coreRegistry
      * @param \Magento\Core\Model\Store\Config $coreStoreConfig
      * @param \Magento\Catalog\Model\Template\Filter\Factory $templateFilterFactory
@@ -172,8 +171,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Catalog\Model\Session $catalogSession,
         \Magento\Stdlib\String $string,
-        \Magento\Catalog\Helper\Category $catalogCategory,
-        \Magento\Catalog\Helper\Product $catalogProduct,
+        Category $catalogCategory,
+        Product $catalogProduct,
         \Magento\Core\Model\Registry $coreRegistry,
         \Magento\Core\Model\Store\Config $coreStoreConfig,
         \Magento\Catalog\Model\Template\Filter\Factory $templateFilterFactory,
@@ -200,7 +199,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * Set a specified store ID value
      *
      * @param int $store
-     * @return \Magento\Catalog\Helper\Data
+     * @return $this
      */
     public function setStoreId($store)
     {
@@ -312,11 +311,11 @@ class Data extends \Magento\App\Helper\AbstractHelper
 
     /**
      * Split SKU of an item by dashes and spaces
-     * Words will not be broken, unless thir length is greater than $length
+     * Words will not be broken, unless this length is greater than $length
      *
      * @param string $sku
      * @param int $length
-     * @return array
+     * @return string[]
      */
     public function splitSku($sku, $length = 30)
     {
diff --git a/app/code/Magento/Catalog/Helper/Image.php b/app/code/Magento/Catalog/Helper/Image.php
index 25d19644887697d18a6e5156ed1b2d92290130a4..221195de6b24821312453e16293448dafb67a0de 100644
--- a/app/code/Magento/Catalog/Helper/Image.php
+++ b/app/code/Magento/Catalog/Helper/Image.php
@@ -23,15 +23,16 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Helper;
+
+use Magento\App\Helper\AbstractHelper;
 
 /**
  * Catalog image helper
  *
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Helper;
-
-class Image extends \Magento\App\Helper\AbstractHelper
+class Image extends AbstractHelper
 {
     /**
      * Current model
@@ -150,7 +151,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
     /**
      * Reset all previous data
      *
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function _reset()
     {
@@ -172,8 +173,8 @@ class Image extends \Magento\App\Helper\AbstractHelper
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param string $attributeName
-     * @param mixed $imageFile
-     * @return \Magento\Catalog\Helper\Image
+     * @param string|null $imageFile
+     * @return $this
      */
     public function init(\Magento\Catalog\Model\Product $product, $attributeName, $imageFile=null)
     {
@@ -211,7 +212,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * @see \Magento\Catalog\Model\Product\Image
      * @param int $width
      * @param int $height
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function resize($width, $height = null)
     {
@@ -224,7 +225,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set image quality, values in percentage from 0 to 100
      *
      * @param int $quality
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function setQuality($quality)
     {
@@ -239,7 +240,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      *
      * @see \Magento\Catalog\Model\Product\Image
      * @param bool $flag
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function keepAspectRatio($flag)
     {
@@ -256,8 +257,8 @@ class Image extends \Magento\App\Helper\AbstractHelper
      *
      * @see \Magento\Catalog\Model\Product\Image
      * @param bool $flag
-     * @param array $position
-     * @return \Magento\Catalog\Helper\Image
+     * @param string[] $position
+     * @return $this
      */
     public function keepFrame($flag, $position = array('center', 'middle'))
     {
@@ -275,7 +276,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * @see \Magento\Catalog\Model\Product\Image
      * @param bool $flag
      * @param int $alphaOpacity
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function keepTransparency($flag, $alphaOpacity = null)
     {
@@ -289,7 +290,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * It is false by default
      *
      * @param bool $flag
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function constrainOnly($flag)
     {
@@ -305,7 +306,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      *
      * @see \Magento\Catalog\Model\Product\Image
      * @param array $colorRGB
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function backgroundColor($colorRGB)
     {
@@ -321,7 +322,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Rotate image into specified angle
      *
      * @param int $angle
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function rotate($angle)
     {
@@ -339,7 +340,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * @param string $position
      * @param string $size
      * @param int $imageOpacity
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function watermark($fileName, $position, $size=null, $imageOpacity=null)
     {
@@ -418,7 +419,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set current Image model
      *
      * @param \Magento\Catalog\Model\Product\Image $model
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function _setModel($model)
     {
@@ -440,7 +441,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set Rotation Angle
      *
      * @param int $angle
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function setAngle($angle)
     {
@@ -462,7 +463,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set watermark file name
      *
      * @param string $watermark
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function setWatermark($watermark)
     {
@@ -485,7 +486,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set watermark position
      *
      * @param string $position
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function setWatermarkPosition($position)
     {
@@ -509,7 +510,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * param size in format 100x200
      *
      * @param string $size
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function setWatermarkSize($size)
     {
@@ -532,7 +533,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set watermark image opacity
      *
      * @param int $imageOpacity
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     public function setWatermarkImageOpacity($imageOpacity)
     {
@@ -559,7 +560,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set current Product
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function setProduct($product)
     {
@@ -581,7 +582,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Set Image file
      *
      * @param string $file
-     * @return \Magento\Catalog\Helper\Image
+     * @return $this
      */
     protected function setImageFile($file)
     {
@@ -641,7 +642,7 @@ class Image extends \Magento\App\Helper\AbstractHelper
      * Retrieve Original image size as array
      * 0 - width, 1 - height
      *
-     * @return array
+     * @return int[]
      */
     public function getOriginalSizeArray()
     {
diff --git a/app/code/Magento/Catalog/Helper/Output.php b/app/code/Magento/Catalog/Helper/Output.php
index 8bad2f16ee24446d524371974cd30e389a18a5eb..c1d5a8d32cf1c4a3484eae5c6647f3efbe1389be 100644
--- a/app/code/Magento/Catalog/Helper/Output.php
+++ b/app/code/Magento/Catalog/Helper/Output.php
@@ -26,6 +26,10 @@
 
 namespace Magento\Catalog\Helper;
 
+use Magento\Catalog\Model\Category as ModelCategory;
+use Magento\Catalog\Model\Product as ModelProduct;
+use Magento\Filter\Template;
+
 class Output extends \Magento\App\Helper\AbstractHelper
 {
     /**
@@ -38,14 +42,14 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * Template processor instance
      *
-     * @var \Magento\Filter\Template
+     * @var Template
      */
     protected $_templateProcessor = null;
 
     /**
      * Catalog data
      *
-     * @var \Magento\Catalog\Helper\Data
+     * @var Data
      */
     protected $_catalogData = null;
 
@@ -64,13 +68,13 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * @param \Magento\App\Helper\Context $context
      * @param \Magento\Eav\Model\Config $eavConfig
-     * @param \Magento\Catalog\Helper\Data $catalogData
+     * @param Data $catalogData
      * @param \Magento\Escaper $escaper
      */
     public function __construct(
         \Magento\App\Helper\Context $context,
         \Magento\Eav\Model\Config $eavConfig,
-        \Magento\Catalog\Helper\Data $catalogData,
+        Data $catalogData,
         \Magento\Escaper $escaper
     ) {
         $this->_eavConfig = $eavConfig;
@@ -79,6 +83,9 @@ class Output extends \Magento\App\Helper\AbstractHelper
         parent::__construct($context);
     }
 
+    /**
+     * @return Template
+     */
     protected function _getTemplateProcessor()
     {
         if (null === $this->_templateProcessor) {
@@ -91,9 +98,9 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * Adding method handler
      *
-     * @param   string $method
-     * @param   object $handler
-     * @return  \Magento\Catalog\Helper\Output
+     * @param string $method
+     * @param object $handler
+     * @return $this
      */
     public function addHandler($method, $handler)
     {
@@ -113,8 +120,8 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * Get all handlers for some method
      *
-     * @param   string $method
-     * @return  array
+     * @param string $method
+     * @return array
      */
     public function getHandlers($method)
     {
@@ -125,10 +132,10 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * Process all method handlers
      *
-     * @param   string $method
-     * @param   mixed $result
-     * @param   array $params
-     * @return unknown
+     * @param string $method
+     * @param mixed $result
+     * @param array $params
+     * @return mixed
      */
     public function process($method, $result, $params)
     {
@@ -143,14 +150,14 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * Prepare product attribute html output
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @param   string $attributeHtml
-     * @param   string $attributeName
-     * @return  string
+     * @param ModelProduct $product
+     * @param string $attributeHtml
+     * @param string $attributeName
+     * @return string
      */
     public function productAttribute($product, $attributeHtml, $attributeName)
     {
-        $attribute = $this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeName);
+        $attribute = $this->_eavConfig->getAttribute(ModelProduct::ENTITY, $attributeName);
         if ($attribute && $attribute->getId() && ($attribute->getFrontendInput() != 'media_image')
             && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled())) {
                 if ($attribute->getFrontendInput() != 'price') {
@@ -177,14 +184,14 @@ class Output extends \Magento\App\Helper\AbstractHelper
     /**
      * Prepare category attribute html output
      *
-     * @param   \Magento\Catalog\Model\Category $category
-     * @param   string $attributeHtml
-     * @param   string $attributeName
-     * @return  string
+     * @param ModelCategory $category
+     * @param string $attributeHtml
+     * @param string $attributeName
+     * @return string
      */
     public function categoryAttribute($category, $attributeHtml, $attributeName)
     {
-        $attribute = $this->_eavConfig->getAttribute(\Magento\Catalog\Model\Category::ENTITY, $attributeName);
+        $attribute = $this->_eavConfig->getAttribute(ModelCategory::ENTITY, $attributeName);
 
         if ($attribute && ($attribute->getFrontendInput() != 'image')
             && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled())) {
diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php
index e6180db8cffe40860a4dd845b018690e5cb65a89..b5c746b4822cb77f0613d5958ca6c969a69d0cf6 100644
--- a/app/code/Magento/Catalog/Helper/Product.php
+++ b/app/code/Magento/Catalog/Helper/Product.php
@@ -23,9 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Helper;
 
+use Magento\Catalog\Model\Product as ModelProduct;
+use Magento\Core\Model\Store;
+
 /**
  * Catalog category helper
  *
@@ -57,6 +59,9 @@ class Product extends \Magento\Core\Helper\Url
      */
     protected $_statuses;
 
+    /**
+     * @var mixed
+     */
     protected $_priceBlock;
 
     /**
@@ -163,12 +168,12 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Retrieve product view page url
      *
-     * @param   mixed $product
-     * @return  string
+     * @param int|ModelProduct $product
+     * @return string|false
      */
     public function getProductUrl($product)
     {
-        if ($product instanceof \Magento\Catalog\Model\Product) {
+        if ($product instanceof ModelProduct) {
             return $product->getProductUrl();
         } elseif (is_numeric($product)) {
             return $this->_productFactory->create()->load($product)->getProductUrl();
@@ -179,8 +184,8 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Retrieve product price
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  float
+     * @param ModelProduct $product
+     * @return float
      */
     public function getPrice($product)
     {
@@ -190,8 +195,8 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Retrieve product final price
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  float
+     * @param ModelProduct $product
+     * @return float
      */
     public function getFinalPrice($product)
     {
@@ -201,7 +206,7 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Retrieve base image url
      *
-     * @param \Magento\Catalog\Model\Product|\Magento\Object $product
+     * @param ModelProduct|\Magento\Object $product
      * @return string|bool
      */
     public function getImageUrl($product)
@@ -219,7 +224,7 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Retrieve small image url
      *
-     * @param \Magento\Catalog\Model\Product|\Magento\Object $product
+     * @param ModelProduct|\Magento\Object $product
      * @return string|bool
      */
     public function getSmallImageUrl($product)
@@ -237,7 +242,7 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Retrieve thumbnail image url
      *
-     * @param \Magento\Catalog\Model\Product|\Magento\Object $product
+     * @param ModelProduct|\Magento\Object $product
      * @return string
      */
     public function getThumbnailUrl($product)
@@ -246,7 +251,7 @@ class Product extends \Magento\Core\Helper\Url
     }
 
     /**
-     * @param \Magento\Catalog\Model\Product $product
+     * @param ModelProduct $product
      * @return string
      */
     public function getEmailToFriendUrl($product)
@@ -277,7 +282,7 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Check if a product can be shown
      *
-     * @param \Magento\Catalog\Model\Product|int $product
+     * @param ModelProduct|int $product
      * @param string $where
      * @return boolean
      */
@@ -287,7 +292,7 @@ class Product extends \Magento\Core\Helper\Url
             $product = $this->_productFactory->create()->load($product);
         }
 
-        /* @var $product \Magento\Catalog\Model\Product */
+        /* @var $product ModelProduct */
 
         if (!$product->getId()) {
             return false;
@@ -319,7 +324,7 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Check if <link rel="canonical"> can be used for product
      *
-     * @param $store
+     * @param null|string|bool|int|Store $store
      * @return bool
      */
     public function canUseCanonicalTag($store = null)
@@ -397,7 +402,7 @@ class Product extends \Magento\Core\Helper\Url
      * @param \Magento\App\Action\Action $controller
      * @param \Magento\Object $params
      *
-     * @return false|\Magento\Catalog\Model\Product
+     * @return false|ModelProduct
      */
     public function initProduct($productId, $controller, $params = null)
     {
@@ -465,9 +470,9 @@ class Product extends \Magento\Core\Helper\Url
      * Prepares product options by buyRequest: retrieves values and assigns them as default.
      * Also parses and adds product management related values - e.g. qty
      *
-     * @param  \Magento\Catalog\Model\Product $product
-     * @param  \Magento\Object $buyRequest
-     * @return \Magento\Catalog\Helper\Product
+     * @param ModelProduct $product
+     * @param \Magento\Object $buyRequest
+     * @return Product
      */
     public function prepareProductOptions($product, $buyRequest)
     {
@@ -501,7 +506,6 @@ class Product extends \Magento\Core\Helper\Url
             $params = new \Magento\Object($params);
         }
 
-
         // Ensure that currentConfig goes as \Magento\Object - for easier work with it later
         $currentConfig = $params->getCurrentConfig();
         if ($currentConfig) {
@@ -529,14 +533,14 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Return loaded product instance
      *
-     * @param  int|string $productId (SKU or ID)
-     * @param  int $store
-     * @param  string $identifierType
-     * @return \Magento\Catalog\Model\Product
+     * @param int|string $productId (SKU or ID)
+     * @param int $store
+     * @param string $identifierType
+     * @return ModelProduct
      */
     public function getProduct($productId, $store, $identifierType = null)
     {
-        /** @var $product \Magento\Catalog\Model\Product */
+        /** @var $product ModelProduct */
         $product = $this->_productFactory->create()->setStoreId($this->_storeManager->getStore($store)->getId());
 
         $expectedIdType = false;
@@ -569,7 +573,7 @@ class Product extends \Magento\Core\Helper\Url
      * For instance, during order creation in the backend admin has ability to add any products to order
      *
      * @param bool $skipSaleableCheck
-     * @return \Magento\Catalog\Helper\Product
+     * @return Product
      */
     public function setSkipSaleableCheck($skipSaleableCheck = false)
     {
@@ -590,12 +594,12 @@ class Product extends \Magento\Core\Helper\Url
     /**
      * Get masks for auto generation of fields
      *
-     * @return array
+     * @return mixed
      */
     public function getFieldsAutogenerationMasks()
     {
         return $this->_coreConfig
-            ->getValue(\Magento\Catalog\Helper\Product::XML_PATH_AUTO_GENERATE_MASK, 'default');
+            ->getValue(Product::XML_PATH_AUTO_GENERATE_MASK, 'default');
     }
 
     /**
diff --git a/app/code/Magento/Catalog/Helper/Product/Compare.php b/app/code/Magento/Catalog/Helper/Product/Compare.php
index b2f6b968aae9a4372d8d2e51463cd839846083d5..857d6006f81b31ce14a228c3bf79ce6e681e7ba3 100644
--- a/app/code/Magento/Catalog/Helper/Product/Compare.php
+++ b/app/code/Magento/Catalog/Helper/Product/Compare.php
@@ -23,9 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Helper\Product;
 
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Resource\Product\Compare\Item\Collection;
+
 /**
  * Catalog Product Compare Helper
  *
@@ -36,7 +38,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Product Compare Items Collection
      *
-     * @var \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @var Collection
      */
     protected $_itemCollection;
 
@@ -169,8 +171,8 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Get parameters used for build add product to compare list urls
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  string
+     * @param Product $product
+     * @return string
      */
     public function getPostDataParams($product)
     {
@@ -180,7 +182,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Retrieve url for adding product to compare list
      *
-     * @return  string
+     * @return string
      */
     public function getAddUrl()
     {
@@ -190,7 +192,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Retrieve add to wishlist params
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return string
      */
     public function getAddToWishlistParams($product)
@@ -207,7 +209,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Retrieve add to cart url
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return string
      */
     public function getAddToCartUrl($product)
@@ -224,7 +226,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Retrieve remove item from compare list url
      *
-     * @return  string
+     * @return string
      */
     public function getRemoveUrl()
     {
@@ -234,7 +236,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Get parameters to remove products from compare list
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return string
      */
     public function getPostDataRemove($product)
@@ -258,7 +260,7 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Retrieve compare list items collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return Collection
      */
     public function getItemCollection()
     {
@@ -298,8 +300,8 @@ class Compare extends \Magento\Core\Helper\Url
     /**
      * Calculate cache product compare collection
      *
-     * @param  bool $logout
-     * @return \Magento\Catalog\Helper\Product\Compare
+     * @param bool $logout
+     * @return $this
      */
     public function calculate($logout = false)
     {
@@ -307,7 +309,7 @@ class Compare extends \Magento\Core\Helper\Url
         if (!$this->_catalogSession->hasCatalogCompareItemsCount() && !$this->_customerId) {
             $count = 0;
         } else {
-            /** @var $collection \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection */
+            /** @var $collection Collection */
             $collection = $this->_itemCollectionFactory->create()
                 ->useProductItem(true);
             if (!$logout && $this->_customerSession->isLoggedIn()) {
@@ -358,7 +360,7 @@ class Compare extends \Magento\Core\Helper\Url
      * Set is allow used flat (for collection)
      *
      * @param bool $flag
-     * @return \Magento\Catalog\Helper\Product\Compare
+     * @return $this
      */
     public function setAllowUsedFlat($flag)
     {
@@ -380,7 +382,7 @@ class Compare extends \Magento\Core\Helper\Url
      * Setter for customer id
      *
      * @param int $id
-     * @return \Magento\Catalog\Helper\Product\Compare
+     * @return $this
      */
     public function setCustomerId($id)
     {
diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php
index abea265160e7767bebb207df4461fffe5e9a95b0..f87d519dccf7f83ae38bfafa30a8eaef757bc1c1 100644
--- a/app/code/Magento/Catalog/Helper/Product/Composite.php
+++ b/app/code/Magento/Catalog/Helper/Product/Composite.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Helper\Product;
 
 /**
  * Adminhtml catalog product composite helper
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Helper\Product;
-
 class Composite extends \Magento\App\Helper\AbstractHelper
 {
     /**
@@ -99,7 +98,7 @@ class Composite extends \Magento\App\Helper\AbstractHelper
     /**
      * Init layout of product configuration update result
      *
-     * @return \Magento\Catalog\Helper\Product\Composite
+     * @return $this
      */
     protected function _initUpdateResultLayout()
     {
@@ -115,7 +114,7 @@ class Composite extends \Magento\App\Helper\AbstractHelper
      * when single configuration submitted
      *
      * @param \Magento\Object $updateResult
-     * @return \Magento\Catalog\Helper\Product\Composite
+     * @return void
      */
     public function renderUpdateResult(\Magento\Object $updateResult)
     {
@@ -125,16 +124,16 @@ class Composite extends \Magento\App\Helper\AbstractHelper
         $this->_view->renderLayout();
     }
 
-     /**
-      * Init composite product configuration layout
-      *
-      * $isOk - true or false, whether action was completed nicely or with some error
-      * If $isOk is FALSE (some error during configuration), so $productType must be null
-      *
-      * @param bool $isOk
-      * @param string $productType
-      * @return \Magento\Catalog\Helper\Product\Composite
-      */
+    /**
+     * Init composite product configuration layout
+     *
+     * $isOk - true or false, whether action was completed nicely or with some error
+     * If $isOk is FALSE (some error during configuration), so $productType must be null
+     *
+     * @param bool $isOk
+     * @param string $productType
+     * @return $this
+     */
     protected function _initConfigureResultLayout($isOk, $productType)
     {
         $update = $this->_view->getLayout()->getUpdate();
@@ -158,7 +157,7 @@ class Composite extends \Magento\App\Helper\AbstractHelper
      *  - 'error' = true, and 'message' to show
      *
      * @param \Magento\Object $configureResult
-     * @return \Magento\Catalog\Helper\Product\Composite
+     * @return void
      */
     public function renderConfigureResult(\Magento\Object $configureResult)
     {
diff --git a/app/code/Magento/Catalog/Helper/Product/Configuration.php b/app/code/Magento/Catalog/Helper/Product/Configuration.php
index e5f7b9e9628380c5f23ce51dd4cb8acb9ac52fe9..8083343d4c8116fde7e97ee5ae1a6b581bf1e256 100644
--- a/app/code/Magento/Catalog/Helper/Product/Configuration.php
+++ b/app/code/Magento/Catalog/Helper/Product/Configuration.php
@@ -175,7 +175,7 @@ class Configuration extends \Magento\App\Helper\AbstractHelper
     /**
      * Accept option value and return its formatted view
      *
-     * @param mixed $optionValue
+     * @param string|array $optionValue
      * Method works well with these $optionValue format:
      *      1. String
      *      2. Indexed array e.g. array(val1, val2, ...)
diff --git a/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php b/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php
index d589e7de04a936dbf772b654706d2944f6cab35a..6f3a8fc4659ad293efcb20bb29e38adf518c16b5 100644
--- a/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php
+++ b/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php
@@ -48,7 +48,7 @@ class Attribute extends \Magento\Backend\Helper\Data
     /**
      * Excluded from batch update attribute codes
      *
-     * @var array
+     * @var string[]
      */
     protected $_excludedAttributes = array('url_key');
 
diff --git a/app/code/Magento/Catalog/Helper/Product/Flat.php b/app/code/Magento/Catalog/Helper/Product/Flat.php
index b6ff3f139693e0d244420c9042e6af6bbadbfead..331b260528f3904f487b2afd4b4e2d7662f930db 100644
--- a/app/code/Magento/Catalog/Helper/Product/Flat.php
+++ b/app/code/Magento/Catalog/Helper/Product/Flat.php
@@ -97,9 +97,9 @@ class Flat extends \Magento\Catalog\Helper\Flat\AbstractFlat
      * @param \Magento\Index\Model\ProcessFactory $processFactory
      * @param \Magento\Core\Model\Store\Config $coreStoreConfig
      * @param \Magento\Catalog\Model\Product\Flat\Flag $flatFlag
-     * @param $addFilterableAttrs
-     * @param $addChildData
-     * @param $isAvailable
+     * @param mixed $addFilterableAttrs
+     * @param mixed $addChildData
+     * @param bool $isAvailable
      */
     public function __construct(
         \Magento\App\Helper\Context $context,
diff --git a/app/code/Magento/Catalog/Helper/Product/Options.php b/app/code/Magento/Catalog/Helper/Product/Options.php
index 522ee1a0d46b080c30f4ea82513300b9b1da4640..0a5547de86b0d583cb76972676687e2cea94c60d 100644
--- a/app/code/Magento/Catalog/Helper/Product/Options.php
+++ b/app/code/Magento/Catalog/Helper/Product/Options.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Helper\Product;
 
 /**
  * Catalog Product Custom Options helper
@@ -32,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Helper\Product;
-
 class Options extends \Magento\App\Helper\AbstractHelper
 {
     /**
diff --git a/app/code/Magento/Catalog/Helper/Product/Price.php b/app/code/Magento/Catalog/Helper/Product/Price.php
index 3cbedaa549f7a6b774e633fe58726958c58cbfe6..c317ad6a000e648514bb67b85a9c5527a76942c3 100644
--- a/app/code/Magento/Catalog/Helper/Product/Price.php
+++ b/app/code/Magento/Catalog/Helper/Product/Price.php
@@ -21,7 +21,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Helper\Product;
 
+use Magento\Catalog\Model\Product;
+use Magento\Customer\Model\Customer;
 
 /**
  * Collection of tax module calls
@@ -30,8 +33,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Helper\Product;
-
 class Price extends \Magento\App\Helper\AbstractHelper
 {
     /**
@@ -59,9 +60,9 @@ class Price extends \Magento\App\Helper\AbstractHelper
     /**
      * Get product price with all tax settings processing
      *
-     * @param $_product
-     * @param $_minimalPriceValue
-     * @param null $includingTax
+     * @param Product $_product
+     * @param float $_minimalPriceValue inputed product price
+     * @param bool $includingTax return price include tax flag
      * @return float
      */
     public function getPrice($_product, $_minimalPriceValue, $includingTax = null)
@@ -102,7 +103,7 @@ class Price extends \Magento\App\Helper\AbstractHelper
     /**
      * Get customer object
      *
-     * @return bool|\Magento\Customer\Model\Customer
+     * @return bool|Customer
      */
     public function getCustomer()
     {
@@ -112,10 +113,10 @@ class Price extends \Magento\App\Helper\AbstractHelper
     /**
      * Specify customer object which can be used for rate calculation
      *
-     * @param   \Magento\Customer\Model\Customer $customer
+     * @param Customer $customer
      * @return $this
      */
-    public function setCustomer(\Magento\Customer\Model\Customer $customer)
+    public function setCustomer(Customer $customer)
     {
         $this->taxCalculation->setCustomer($customer);
         return $this;
@@ -124,11 +125,11 @@ class Price extends \Magento\App\Helper\AbstractHelper
     /**
      * Get request object with information necessary for getting tax rate
      *
-     * @param   null|bool|\Magento\Object $shippingAddress
-     * @param   null|bool||\Magento\Object $billingAddress
-     * @param   null|int $customerTaxClass
-     * @param   null|int $store
-     * @return  \Magento\Object
+     * @param null|bool|\Magento\Object $shippingAddress
+     * @param null|bool||\Magento\Object $billingAddress
+     * @param null|int $customerTaxClass
+     * @param null|int $store
+     * @return \Magento\Object
      */
     public function getRateRequest(
         $shippingAddress = null,
@@ -142,8 +143,8 @@ class Price extends \Magento\App\Helper\AbstractHelper
     /**
      * Get calculation tax rate by specific request
      *
-     * @param   \Magento\Object $request
-     * @return  float
+     * @param \Magento\Object $request
+     * @return float
      */
     public function getRate($request)
     {
diff --git a/app/code/Magento/Catalog/Model/AbstractModel.php b/app/code/Magento/Catalog/Model/AbstractModel.php
index 47b83a33aae872baf712597cc8b981e885adb9b7..7d559d8220a973ceb825b4f4e543042a7bb60842 100644
--- a/app/code/Magento/Catalog/Model/AbstractModel.php
+++ b/app/code/Magento/Catalog/Model/AbstractModel.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model;
 
 /**
  * Abstract model for catalog entities
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model;
-
 abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -105,7 +104,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      * Lock attribute
      *
      * @param string $attributeCode
-     * @return \Magento\Catalog\Model\AbstractModel
+     * @return $this
      */
     public function lockAttribute($attributeCode)
     {
@@ -117,7 +116,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      * Unlock attribute
      *
      * @param string $attributeCode
-     * @return \Magento\Catalog\Model\AbstractModel
+     * @return $this
      */
     public function unlockAttribute($attributeCode)
     {
@@ -131,7 +130,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
     /**
      * Unlock all attributes
      *
-     * @return \Magento\Catalog\Model\AbstractModel
+     * @return $this
      */
     public function unlockAttributes()
     {
@@ -162,6 +161,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve locked attributes
      *
+     * @param mixed $attributeCode
      * @return boolean
      */
     public function isLockedAttribute($attributeCode)
@@ -172,7 +172,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
     /**
      * Overwrite data in the object.
      *
-     * $key can be string or array.
+     * The $key can be string or array.
      * If $key is string, the attribute value will be overwritten by $value
      *
      * If $key is an array, it will overwrite all the data in the object.
@@ -181,7 +181,6 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      *
      * @param string|array $key
      * @param mixed $value
-     * @param boolean $isChanged
      * @return \Magento\Object
      */
     public function setData($key, $value = null)
@@ -206,13 +205,12 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
     /**
      * Unset data from the object.
      *
-     * $key can be a string only. Array will be ignored.
+     * The $key can be a string only. Array will be ignored.
      *
      * $isChanged will specify if the object needs to be saved after an update.
      *
      * @param string $key
-     * @param boolean $isChanged
-     * @return \Magento\Catalog\Model\AbstractModel
+     * @return $this
      */
     public function unsetData($key = null)
     {
@@ -283,8 +281,8 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      * Default value existing is flag for using store value in data
      *
      * @param   string $attributeCode
-     * @value   mixed  $value
-     * @return  \Magento\Catalog\Model\AbstractModel
+     * @param   mixed  $value
+     * @return  $this
      */
     public function setAttributeDefaultValue($attributeCode, $value)
     {
@@ -308,7 +306,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      * value of default store as value
      *
      * @param   string $attributeCode
-     * @return  \Magento\Catalog\Model\AbstractModel
+     * @return  $this
      */
     public function setExistsStoreValueFlag($attributeCode)
     {
@@ -352,7 +350,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      * Set is deletable flag
      *
      * @param boolean $value
-     * @return \Magento\Catalog\Model\AbstractModel
+     * @return $this
      */
     public function setIsDeleteable($value)
     {
@@ -374,7 +372,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel
      * Set is deletable flag
      *
      * @param boolean $value
-     * @return \Magento\Catalog\Model\AbstractModel
+     * @return $this
      */
     public function setIsReadonly($value)
     {
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index 90849465d84552ee26b3fcd51bc8b4fb54a27492..3707116c2cce6c41f4bec434765fc2798f3f2f8d 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -23,9 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Attribute\Backend;
 
+use Magento\Core\Model\Layout\Update\ValidatorFactory;
+use Magento\Eav\Model\Entity\Attribute\Exception;
+
 /**
  * Product url key attribute backend
  *
@@ -37,22 +39,31 @@ class Customlayoutupdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Abs
     /**
      * Layout update validator factory
      *
-     * @var \Magento\Core\Model\Layout\Update\ValidatorFactory
+     * @var ValidatorFactory
      */
     protected $_layoutUpdateValidatorFactory;
 
     /**
+     * Construct the custom layout update class
+     *
      * @param \Magento\Logger $logger
-     * @param \Magento\Core\Model\Layout\Update\ValidatorFactory $layoutUpdateValidatorFactory
+     * @param ValidatorFactory $layoutUpdateValidatorFactory
      */
     public function __construct(
         \Magento\Logger $logger,
-        \Magento\Core\Model\Layout\Update\ValidatorFactory $layoutUpdateValidatorFactory
+        ValidatorFactory $layoutUpdateValidatorFactory
     ) {
         $this->_layoutUpdateValidatorFactory = $layoutUpdateValidatorFactory;
         parent::__construct($logger);
     }
 
+    /**
+     * Validate the custom layout update
+     *
+     * @param \Magento\Object $object
+     * @return bool
+     * @throws Exception
+     */
     public function validate($object)
     {
         $attributeName = $this->getAttribute()->getName();
@@ -68,7 +79,7 @@ class Customlayoutupdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Abs
             $messages = $validator->getMessages();
             //Add first message to exception
             $massage = array_shift($messages);
-            $eavExc = new \Magento\Eav\Model\Entity\Attribute\Exception($massage);
+            $eavExc = new Exception($massage);
             $eavExc->setAttributeCode($attributeName);
             throw $eavExc;
         }
diff --git a/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php b/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php
index 416bf63da39c4d78793be45bb6d84514957bf156..d8563c658e6254c29176d2df3bc7c4bdd57194e6 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Config/Reader.php
@@ -1,7 +1,5 @@
 <?php
 /**
- * Loads catalog attributes configuration from multiple XML files by merging them together
- *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -25,6 +23,9 @@
  */
 namespace Magento\Catalog\Model\Attribute\Config;
 
+/**
+ * Loads catalog attributes configuration from multiple XML files by merging them together
+ */
 class Reader extends \Magento\Config\Reader\Filesystem
 {
     /**
@@ -38,6 +39,8 @@ class Reader extends \Magento\Config\Reader\Filesystem
     );
 
     /**
+     * Construct the FileSystem Reader Class
+     *
      * @param \Magento\Config\FileResolverInterface $fileResolver
      * @param Converter $converter
      * @param SchemaLocator $schemaLocator
@@ -49,8 +52,8 @@ class Reader extends \Magento\Config\Reader\Filesystem
      */
     public function __construct(
         \Magento\Config\FileResolverInterface $fileResolver,
-        \Magento\Catalog\Model\Attribute\Config\Converter $converter,
-        \Magento\Catalog\Model\Attribute\Config\SchemaLocator $schemaLocator,
+        Converter $converter,
+        SchemaLocator $schemaLocator,
         \Magento\Config\ValidationStateInterface $validationState,
         $fileName = 'catalog_attributes.xml',
         $idAttributes = array(),
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 0ff486480c73cfea615ebbbd05a7d188dca056e9..bb59cd08d7282ad7ce05c47115ccdd0b4a650469 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -18,18 +18,20 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Catalog
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model;
 
 /**
  * Catalog category
  *
+ * @method setAffectedProductIds(array $productIds)
  * @method array getAffectedProductIds()
+ * @method setMovedCategoryId(array $productIds)
+ * @method int metMovedCategoryId()
+ * @method setAffectedCategoryIds(array $categoryIds)
+ * @method array getAffectedCategoryIds()
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  */
@@ -66,6 +68,8 @@ class Category extends \Magento\Catalog\Model\AbstractModel
 
     /**
      * Model cache tag for clear cache in after save and after delete
+     *
+     * @var string
      */
     protected $_cacheTag        = self::CACHE_TAG;
 
@@ -93,7 +97,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel
     /**
      * Category design attributes
      *
-     * @var array
+     * @var string[]
      */
     protected $_designAttributes  = array(
         'custom_design',
@@ -111,13 +115,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel
      */
     protected $_treeModel = null;
 
-    /**
-     * Catalog category flat
-     *
-     * @var \Magento\Catalog\Helper\Category\Flat
-     */
-    protected $_catalogCategoryFlat = null;
-
     /**
      * Core data
      *
@@ -125,13 +122,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel
      */
     protected $filter;
 
-    /**
-     * Index indexer
-     *
-     * @var \Magento\Index\Model\Indexer
-     */
-    protected $_indexIndexer;
-
     /**
      * Catalog config
      *
@@ -174,6 +164,21 @@ class Category extends \Magento\Catalog\Model\AbstractModel
      */
     protected $_categoryTreeFactory;
 
+    /**
+     * @var Indexer\Category\Flat\State
+     */
+    protected $flatState;
+
+    /**
+     * @var \Magento\Indexer\Model\IndexerInterface
+     */
+    protected $flatIndexer;
+
+    /**
+     * @var \Magento\Index\Model\Indexer
+     */
+    protected $indexIndexer;
+
     /**
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
@@ -187,9 +192,9 @@ class Category extends \Magento\Catalog\Model\AbstractModel
      * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory
      * @param \Magento\Catalog\Model\Config $catalogConfig
      * @param \Magento\Index\Model\Indexer $indexIndexer
-     * @param \Magento\Core\Helper\Data $coreData
-     * @param \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat
      * @param \Magento\Filter\FilterManager $filter
+     * @param Indexer\Category\Flat\State $flatState
+     * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
@@ -207,13 +212,14 @@ class Category extends \Magento\Catalog\Model\AbstractModel
         \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory,
         \Magento\Catalog\Model\Config $catalogConfig,
         \Magento\Index\Model\Indexer $indexIndexer,
-        \Magento\Core\Helper\Data $coreData,
-        \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat,
         \Magento\Filter\FilterManager $filter,
+        Indexer\Category\Flat\State $flatState,
+        \Magento\Indexer\Model\IndexerInterface $flatIndexer,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
         array $data = array()
     ) {
+        $this->_treeModel = $categoryTreeResource;
         $this->_categoryTreeFactory = $categoryTreeFactory;
         $this->_categoryFactory = $categoryFactory;
         $this->_urlRewriteFactory = $urlRewriteFactory;
@@ -221,10 +227,10 @@ class Category extends \Magento\Catalog\Model\AbstractModel
         $this->_url = $url;
         $this->_productCollectionFactory = $productCollectionFactory;
         $this->_catalogConfig = $catalogConfig;
-        $this->_indexIndexer = $indexIndexer;
+        $this->indexIndexer = $indexIndexer;
         $this->filter = $filter;
-        $this->_catalogCategoryFlat = $catalogCategoryFlat;
-        $this->_treeModel = $categoryTreeResource;
+        $this->flatState = $flatState;
+        $this->flatIndexer = $flatIndexer;
         parent::__construct($context, $registry, $storeManager, $resource, $resourceCollection, $data);
     }
 
@@ -235,8 +241,8 @@ class Category extends \Magento\Catalog\Model\AbstractModel
      */
     protected function _construct()
     {
-        // If Flat Data enabled then use it but only on frontend
-        if ($this->_catalogCategoryFlat->isAvailable()) {
+        // If Flat Index enabled then use it but only on frontend
+        if ($this->flatState->isAvailable()) {
             $this->_init('Magento\Catalog\Model\Resource\Category\Flat');
             $this->_useFlatResource = true;
         } else {
@@ -244,6 +250,19 @@ class Category extends \Magento\Catalog\Model\AbstractModel
         }
     }
 
+    /**
+     * Return own indexer object
+     *
+     * @return \Magento\Indexer\Model\IndexerInterface
+     */
+    protected function getFlatIndexer()
+    {
+        if (!$this->flatIndexer->getId()) {
+            $this->flatIndexer->load(Indexer\Category\Flat\State::INDEXER_ID);
+        }
+        return $this->flatIndexer;
+    }
+
     /**
      * Retrieve URL instance
      *
@@ -290,9 +309,9 @@ class Category extends \Magento\Catalog\Model\AbstractModel
     /**
      * Move category
      *
-     * @param   int $parentId new parent category id
-     * @param   null|int $afterCategoryId category id after which we have put current category
-     * @return  \Magento\Catalog\Model\Category
+     * @param  int $parentId new parent category id
+     * @param  null|int $afterCategoryId category id after which we have put current category
+     * @return $this
      * @throws \Magento\Core\Exception|\Exception
      */
     public function move($parentId, $afterCategoryId)
@@ -325,15 +344,15 @@ class Category extends \Magento\Catalog\Model\AbstractModel
          * Setting affected category ids for third party engine index refresh
         */
         $this->setMovedCategoryId($this->getId());
+        $oldParentId = $this->getParentId();
 
         $eventParams = array(
             $this->_eventObject => $this,
             'parent'        => $parent,
             'category_id'   => $this->getId(),
-            'prev_parent_id'=> $this->getParentId(),
+            'prev_parent_id'=> $oldParentId,
             'parent_id'     => $parentId
         );
-        $moveComplete = false;
 
         $this->_getResource()->beginTransaction();
         try {
@@ -343,20 +362,19 @@ class Category extends \Magento\Catalog\Model\AbstractModel
             $this->_getResource()->commit();
 
             // Set data for indexer
-            $this->setAffectedCategoryIds(array($this->getId(), $this->getParentId(), $parentId));
-
-            $moveComplete = true;
+            $this->setAffectedCategoryIds(array($this->getId(), $oldParentId, $parentId));
         } catch (\Exception $e) {
             $this->_getResource()->rollBack();
             throw $e;
         }
-        if ($moveComplete) {
-            $this->_eventManager->dispatch('category_move', $eventParams);
-            $this->_indexIndexer->processEntityAction(
-                $this, self::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE
-            );
-            $this->_cacheManager->clean(array(self::CACHE_TAG));
+        $this->_eventManager->dispatch('category_move', $eventParams);
+        $this->indexIndexer->processEntityAction(
+            $this, self::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE
+        );
+        if ($this->flatState->isFlatEnabled() && !$this->getFlatIndexer()->isScheduled()) {
+            $this->getFlatIndexer()->reindexList(array($this->getId(), $oldParentId, $parentId));
         }
+        $this->_cacheManager->clean(array(self::CACHE_TAG));
 
         return $this;
     }
@@ -387,9 +405,9 @@ class Category extends \Magento\Catalog\Model\AbstractModel
     /**
      * Retrieve all customer attributes
      *
-     * @todo Use with Flat Resource
      * @param bool $noDesignAttributes
      * @return array
+     * @todo Use with Flat Resource
      */
     public function getAttributes($noDesignAttributes = false)
     {
@@ -397,8 +415,8 @@ class Category extends \Magento\Catalog\Model\AbstractModel
             ->loadAllAttributes($this)
             ->getSortedAttributes();
 
-        if ($noDesignAttributes){
-            foreach ($result as $k => $a){
+        if ($noDesignAttributes) {
+            foreach ($result as $k => $a) {
                 if (in_array($k, $this->_designAttributes)) {
                     unset($result[$k]);
                 }
@@ -411,6 +429,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel
     /**
      * Retrieve array of product id's for category
      *
+     * The array returned has the following format:
      * array($productId => $position)
      *
      * @return array
@@ -491,7 +510,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel
      * Set store id
      *
      * @param int|string $storeId
-     * @return \Magento\Catalog\Model\Category
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -605,7 +624,8 @@ class Category extends \Magento\Catalog\Model\AbstractModel
 
         if ($this->getParentId()) {
             $parentPath = $this->_categoryFactory->create()
-                ->load($this->getParentId())->getCategoryPath();
+                ->load($this->getParentId())
+                ->getCategoryPath();
             $path = $parentPath . '/' . $path;
         }
 
@@ -822,7 +842,8 @@ class Category extends \Magento\Catalog\Model\AbstractModel
     /**
      * Before delete process
      *
-     * @return \Magento\Catalog\Model\Category
+     * @throws \Magento\Core\Exception
+     * @return $this
      */
     protected function _beforeDelete()
     {
@@ -1010,16 +1031,40 @@ class Category extends \Magento\Catalog\Model\AbstractModel
     }
 
     /**
-     * Init indexing process after category save
+     * Add reindexCallback
      *
      * @return \Magento\Catalog\Model\Category
      */
     protected function _afterSave()
     {
         $result = parent::_afterSave();
-        $this->_indexIndexer->processEntityAction(
+        $this->indexIndexer->processEntityAction(
             $this, self::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE
         );
+        $this->_getResource()->addCommitCallback(array($this, 'reindex'));
         return $result;
     }
+
+    /**
+     * Init indexing process after category save
+     *
+     * @return void
+     */
+    public function reindex()
+    {
+        if ($this->flatState->isFlatEnabled() && !$this->getFlatIndexer()->isScheduled()) {
+            $this->getFlatIndexer()->reindexRow($this->getId());
+        }
+    }
+
+    /**
+     * Init indexing process after category delete
+     *
+     * @return \Magento\Core\Model\AbstractModel
+     */
+    protected function _afterDeleteCommit()
+    {
+        $this->reindex();
+        return parent::_afterDeleteCommit();
+    }
 }
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php
index 7ae16edbe6ce5e58a2ef3e4d24671701e45d2993..a762e31cc4860fc9c9ad8c4c2ef93393cf6dfb9e 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Category\Attribute\Backend;
 
 /**
  * Catalog Category Attribute Default and Available Sort By Backend Model
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Category\Attribute\Backend;
-
 class Sortby
     extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
@@ -122,7 +121,7 @@ class Sortby
      * Before Attribute Save Process
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Category\Attribute\Backend\Sortby
+     * @return $this
      */
     public function beforeSave($object)
     {
@@ -140,6 +139,12 @@ class Sortby
         return $this;
     }
 
+    /**
+     * After Load Attribute Process
+     *
+     * @param \Magento\Object $object
+     * @return $this
+     */
     public function afterLoad($object)
     {
         $attributeCode = $this->getAttribute()->getName();
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Urlkey.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Urlkey.php
index 482d07fb8ab3012bed9e36a519577845a0570f29..a68f5c2bf3f73b4515ad893677850e08b4ed6d3d 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Urlkey.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Urlkey.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Category\Attribute\Backend;
 
 /**
  * Category url key attribute backend
@@ -32,16 +32,14 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Category\Attribute\Backend;
-
 class Urlkey extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
 
     /**
-     * Enter description here...
+     * TODO: Enter description here...
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Category\Attribute\Backend\Urlkey
+     * @return $this
      */
     public function beforeSave($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Layout.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Layout.php
index 15562b83fa4b0699aacb12ba9e11121ad638e759..323d0e11bb33e245f0d2e9fc232e9e0f260c1a9f 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Layout.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Layout.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Category\Attribute\Source;
 
 /**
  * Catalog category landing page attribute source
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Category\Attribute\Source;
-
 class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
     /**
@@ -53,6 +52,9 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
         $this->_pageSourceLayout = $pageSourceLayout;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getAllOptions()
     {
         if (!$this->_options) {
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Mode.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Mode.php
index 60037771909fc979bab7d68d9d1158d1b648a7b8..3bceb12f3a06b71526e7b5674cc36776a0dd3f18 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Mode.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Mode.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Category\Attribute\Source;
 
 /**
  * Catalog category landing page attribute source
@@ -31,10 +32,11 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Category\Attribute\Source;
-
 class Mode extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
+    /**
+     * {@inheritdoc}
+     */
     public function getAllOptions()
     {
         if (!$this->_options) {
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Page.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Page.php
index 2cd1d006f57c6d58329f664c3902d54ac1682a66..438a93128f0710d965f61470c1e7b034dac81e84 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Page.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Page.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Category\Attribute\Source;
 
+use Magento\Cms\Model\Resource\Block\CollectionFactory;
+
 /**
  * Catalog category landing page attribute source
  *
@@ -36,22 +37,22 @@ class Page extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
     /**
      * Block collection factory
      *
-     * @var \Magento\Cms\Model\Resource\Block\CollectionFactory
+     * @var CollectionFactory
      */
     protected $_blockCollectionFactory;
 
     /**
      * Construct
      *
-     * @param \Magento\Cms\Model\Resource\Block\CollectionFactory
-     * $blockCollectionFactory
+     * @param CollectionFactory $blockCollectionFactory
      */
-    public function __construct(
-        \Magento\Cms\Model\Resource\Block\CollectionFactory $blockCollectionFactory
-    ) {
+    public function __construct(CollectionFactory $blockCollectionFactory) {
         $this->_blockCollectionFactory = $blockCollectionFactory;
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function getAllOptions()
     {
         if (!$this->_options) {
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php
index 5c23c40c1d08a86f50ad680dea4ff1695d0023d1..237527ea26d98ca9a8639e6e81322c97ce4fb68e 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Category\Attribute\Source;
 
 /**
  * Catalog Category *_sort_by Attributes Source Model
@@ -32,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Category\Attribute\Source;
-
 class Sortby
     extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
@@ -60,14 +58,13 @@ class Sortby
      *
      * @return \Magento\Catalog\Model\Config
      */
-    protected function _getCatalogConfig() {
+    protected function _getCatalogConfig()
+    {
         return $this->_catalogConfig;
     }
 
     /**
-     * Retrieve All options
-     *
-     * @return array
+     * {@inheritdoc}
      */
     public function getAllOptions()
     {
diff --git a/app/code/Magento/Catalog/Model/Category/Indexer/Flat.php b/app/code/Magento/Catalog/Model/Category/Indexer/Flat.php
deleted file mode 100644
index b37c59e34c4e7d766b245c48c664557a15db143b..0000000000000000000000000000000000000000
--- a/app/code/Magento/Catalog/Model/Category/Indexer/Flat.php
+++ /dev/null
@@ -1,298 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Catalog
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-
-/**
- * Catalog Category Flat Indexer Model
- *
- * @category    Magento
- * @package     Magento_Catalog
- * @author      Magento Core Team <core@magentocommerce.com>
- */
-namespace Magento\Catalog\Model\Category\Indexer;
-
-class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
-{
-    /**
-     * Data key for matching result to be saved in
-     */
-    const EVENT_MATCH_RESULT_KEY = 'catalog_category_flat_match_result';
-
-    /**
-     * Matched entity events
-     *
-     * @var array
-     */
-    protected $_matchedEntities = array(
-        \Magento\Catalog\Model\Category::ENTITY => array(
-            \Magento\Index\Model\Event::TYPE_SAVE
-        ),
-        \Magento\Core\Model\Store::ENTITY => array(
-            \Magento\Index\Model\Event::TYPE_SAVE,
-            \Magento\Index\Model\Event::TYPE_DELETE
-        ),
-        \Magento\Core\Model\Store\Group::ENTITY => array(
-            \Magento\Index\Model\Event::TYPE_SAVE
-        ),
-    );
-
-    /**
-     * Whether the indexer should be displayed on process/list page
-     *
-     * @return bool
-     */
-    /**
-     * Catalog category flat
-     *
-     * @var \Magento\Catalog\Helper\Category\Flat
-     */
-    protected $_catalogCategoryFlat = null;
-
-    /**
-     * Catalog resource category flat
-     *
-     * @var \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected $_resourceCategoryFlat;
-
-    /**
-     * @param \Magento\Core\Model\Context $context
-     * @param \Magento\Core\Model\Registry $registry
-     * @param \Magento\Catalog\Model\Resource\Category\Flat $resourceCategoryFlat
-     * @param \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat
-     * @param \Magento\Core\Model\Resource\AbstractResource $resource
-     * @param \Magento\Data\Collection\Db $resourceCollection
-     * @param array $data
-     */
-    public function __construct(
-        \Magento\Core\Model\Context $context,
-        \Magento\Core\Model\Registry $registry,
-        \Magento\Catalog\Model\Resource\Category\Flat $resourceCategoryFlat,
-        \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat,
-        \Magento\Core\Model\Resource\AbstractResource $resource = null,
-        \Magento\Data\Collection\Db $resourceCollection = null,
-        array $data = array()
-    ) {
-        $this->_resourceCategoryFlat = $resourceCategoryFlat;
-        $this->_catalogCategoryFlat = $catalogCategoryFlat;
-        parent::__construct($context, $registry, $resource, $resourceCollection, $data);
-    }
-
-    public function isVisible()
-    {
-        return $this->_catalogCategoryFlat->isEnabled() || !$this->_catalogCategoryFlat->isBuilt();
-    }
-
-    /**
-     * Retrieve Indexer name
-     *
-     * @return string
-     */
-    public function getName()
-    {
-        return __('Category Flat Data');
-    }
-
-    /**
-     * Retrieve Indexer description
-     *
-     * @return string
-     */
-    public function getDescription()
-    {
-        return __('Reorganize EAV category structure to flat structure');
-    }
-
-    /**
-     * Retrieve Catalog Category Flat Indexer model
-     *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected function _getIndexer()
-    {
-        return $this->_resourceCategoryFlat;
-    }
-
-    /**
-     * Check if event can be matched by process
-     * Overwrote for check is flat catalog category is enabled and specific save
-     * category, store, store_group
-     *
-     * @param \Magento\Index\Model\Event $event
-     * @return bool
-     */
-    public function matchEvent(\Magento\Index\Model\Event $event)
-    {
-        if (!$this->_catalogCategoryFlat->isAvailable() || !$this->_catalogCategoryFlat->isBuilt()) {
-            return false;
-        }
-
-        $data = $event->getNewData();
-        if (isset($data[self::EVENT_MATCH_RESULT_KEY])) {
-            return $data[self::EVENT_MATCH_RESULT_KEY];
-        }
-
-        $entity = $event->getEntity();
-        if ($entity == \Magento\Core\Model\Store::ENTITY) {
-            if ($event->getType() == \Magento\Index\Model\Event::TYPE_DELETE) {
-                $result = true;
-            } elseif ($event->getType() == \Magento\Index\Model\Event::TYPE_SAVE) {
-                /** @var $store \Magento\Core\Model\Store */
-                $store = $event->getDataObject();
-                if ($store && ($store->isObjectNew()
-                    || $store->dataHasChangedFor('group_id')
-                    || $store->dataHasChangedFor('root_category_id')
-                )) {
-                    $result = true;
-                } else {
-                    $result = false;
-                }
-            } else {
-                $result = false;
-            }
-        } elseif ($entity == \Magento\Core\Model\Store\Group::ENTITY) {
-            /** @var $storeGroup \Magento\Core\Model\Store\Group */
-            $storeGroup = $event->getDataObject();
-            if ($storeGroup
-                && ($storeGroup->dataHasChangedFor('website_id') || $storeGroup->dataHasChangedFor('root_category_id'))
-            ) {
-                $result = true;
-            } else {
-                $result = false;
-            }
-        } else {
-            $result = parent::matchEvent($event);
-        }
-
-        $event->addNewData(self::EVENT_MATCH_RESULT_KEY, $result);
-
-        return $result;
-    }
-
-    /**
-     * Register data required by process in event object
-     *
-     * @param \Magento\Index\Model\Event $event
-     */
-    protected function _registerEvent(\Magento\Index\Model\Event $event)
-    {
-        $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true);
-        switch ($event->getEntity()) {
-            case \Magento\Catalog\Model\Category::ENTITY:
-                $this->_registerCatalogCategoryEvent($event);
-                break;
-
-            case \Magento\Core\Model\Store::ENTITY:
-                if ($event->getType() == \Magento\Index\Model\Event::TYPE_DELETE) {
-                    $this->_registerCoreStoreEvent($event);
-                    break;
-                }
-            // fall-through intentional
-            case \Magento\Core\Model\Store\Group::ENTITY:
-                $event->addNewData('catalog_category_flat_skip_call_event_handler', true);
-                $process = $event->getProcess();
-                $process->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX);
-                break;
-        }
-    }
-
-    /**
-     * Register data required by catalog category process in event object
-     *
-     * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Category\Indexer\Flat
-     */
-    protected function _registerCatalogCategoryEvent(\Magento\Index\Model\Event $event)
-    {
-        switch ($event->getType()) {
-            case \Magento\Index\Model\Event::TYPE_SAVE:
-                /* @var $category \Magento\Catalog\Model\Category */
-                $category = $event->getDataObject();
-
-                /**
-                 * Check if category has another affected category ids (category move result)
-                 */
-                $affectedCategoryIds = $category->getAffectedCategoryIds();
-                if ($affectedCategoryIds) {
-                    $event->addNewData('catalog_category_flat_affected_category_ids', $affectedCategoryIds);
-                } else {
-                    $event->addNewData('catalog_category_flat_category_id', $category->getId());
-                }
-
-                break;
-        }
-        return $this;
-    }
-
-    /**
-     * Register core store delete process
-     *
-     * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Category\Indexer\Flat
-     */
-    protected function _registerCoreStoreEvent(\Magento\Index\Model\Event $event)
-    {
-        if ($event->getType() == \Magento\Index\Model\Event::TYPE_DELETE) {
-            /* @var $store \Magento\Core\Model\Store */
-            $store = $event->getDataObject();
-            $event->addNewData('catalog_category_flat_delete_store_id', $store->getId());
-        }
-        return $this;
-    }
-
-    /**
-     * Process event
-     *
-     * @param \Magento\Index\Model\Event $event
-     */
-    protected function _processEvent(\Magento\Index\Model\Event $event)
-    {
-        $data = $event->getNewData();
-
-        if (!empty($data['catalog_category_flat_reindex_all'])) {
-            $this->reindexAll();
-        } else if (!empty($data['catalog_category_flat_category_id'])) {
-            // catalog_product save
-            $categoryId = $data['catalog_category_flat_category_id'];
-            $this->_getIndexer()->synchronize($categoryId);
-        } else if (!empty($data['catalog_category_flat_affected_category_ids'])) {
-            $categoryIds = $data['catalog_category_flat_affected_category_ids'];
-            $this->_getIndexer()->move($categoryIds);
-        } else if (!empty($data['catalog_category_flat_delete_store_id'])) {
-            $storeId = $data['catalog_category_flat_delete_store_id'];
-            $this->_getIndexer()->deleteStores($storeId);
-        }
-    }
-
-    /**
-     * Rebuild all index data
-     *
-     */
-    public function reindexAll()
-    {
-        $this->_getIndexer()->reindexAll();
-    }
-}
diff --git a/app/code/Magento/Catalog/Model/Category/Indexer/Product.php b/app/code/Magento/Catalog/Model/Category/Indexer/Product.php
index 569900072b584f41498d9b908570f48db1b3aedb..5fe93afd0f1e53d713718d4ebb9240535ac9dac6 100644
--- a/app/code/Magento/Catalog/Model/Category/Indexer/Product.php
+++ b/app/code/Magento/Catalog/Model/Category/Indexer/Product.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Category\Indexer;
 
 /**
  * Category products indexer model.
@@ -51,8 +52,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Category\Indexer;
-
 class Product extends \Magento\Index\Model\Indexer\AbstractIndexer
 {
     /**
@@ -81,6 +80,8 @@ class Product extends \Magento\Index\Model\Indexer\AbstractIndexer
 
     /**
      * Initialize resource
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -153,6 +154,7 @@ class Product extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Check if category ids was changed
      *
      * @param \Magento\Index\Model\Event $event
+     * @return $this
      */
     protected function _registerEvent(\Magento\Index\Model\Event $event)
     {
@@ -180,6 +182,7 @@ class Product extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register event data during product save process
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerProductEvent(\Magento\Index\Model\Event $event)
     {
@@ -226,6 +229,7 @@ class Product extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register event data during category save process
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerCategoryEvent(\Magento\Index\Model\Event $event)
     {
@@ -248,6 +252,7 @@ class Product extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Process event data and save to index
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _processEvent(\Magento\Index\Model\Event $event)
     {
diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php
index 79696d255fad95649adb06cd4bc1ddec667f3997..9e1581ebe8b187089b1b3e8993b736f294c99fe2 100644
--- a/app/code/Magento/Catalog/Model/Config.php
+++ b/app/code/Magento/Catalog/Model/Config.php
@@ -1,7 +1,4 @@
 <?php
-
-namespace Magento\Catalog\Model;
-
 /**
  * Magento
  *
@@ -23,19 +20,39 @@ namespace Magento\Catalog\Model;
  *
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- *
+ */
+namespace Magento\Catalog\Model;
+
+/**
  * @SuppressWarnings(PHPMD.LongVariable)
  */
 class Config extends \Magento\Eav\Model\Config
 {
     const XML_PATH_LIST_DEFAULT_SORT_BY     = 'catalog/frontend/default_sort_by';
 
+    /**
+     * @var mixed
+     */
     protected $_attributeSetsById;
+
+    /**
+     * @var mixed
+     */
     protected $_attributeSetsByName;
 
+    /**
+     * @var mixed
+     */
     protected $_attributeGroupsById;
+
+    /**
+     * @var mixed
+     */
     protected $_attributeGroupsByName;
 
+    /**
+     * @var mixed
+     */
     protected $_productTypesById;
 
     /**
@@ -59,6 +76,9 @@ class Config extends \Magento\Eav\Model\Config
      */
     protected $_usedForSortBy;
 
+    /**
+     * @var int|float|string|null
+     */
     protected $_storeId = null;
 
     /**
@@ -69,10 +89,6 @@ class Config extends \Magento\Eav\Model\Config
     protected $_coreStoreConfig;
 
     /**
-     * @param \Magento\Core\Model\App $app
-     * @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory
-     * @param \Magento\App\Cache\StateInterface $cacheState
-     * @param \Magento\Validator\UniversalFactory $universalFactory
      * Eav config
      *
      * @var \Magento\Eav\Model\Config
@@ -158,6 +174,7 @@ class Config extends \Magento\Eav\Model\Config
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -189,6 +206,9 @@ class Config extends \Magento\Eav\Model\Config
         return $this->_storeId;
     }
 
+    /**
+     * @return $this
+     */
     public function loadAttributeSets()
     {
         if ($this->_attributeSetsById) {
@@ -209,6 +229,11 @@ class Config extends \Magento\Eav\Model\Config
         return $this;
     }
 
+    /**
+     * @param string|int|float $entityTypeId
+     * @param float|int $id
+     * @return false|string
+     */
     public function getAttributeSetName($entityTypeId, $id)
     {
         if (!is_numeric($id)) {
@@ -222,6 +247,11 @@ class Config extends \Magento\Eav\Model\Config
         return isset($this->_attributeSetsById[$entityTypeId][$id]) ? $this->_attributeSetsById[$entityTypeId][$id] : false;
     }
 
+    /**
+     * @param string|int|float $entityTypeId
+     * @param string|null $name
+     * @return false|string|int
+     */
     public function getAttributeSetId($entityTypeId, $name = null)
     {
         if (is_numeric($name)) {
@@ -236,6 +266,9 @@ class Config extends \Magento\Eav\Model\Config
         return isset($this->_attributeSetsByName[$entityTypeId][$name]) ? $this->_attributeSetsByName[$entityTypeId][$name] : false;
     }
 
+    /**
+     * @return $this
+     */
     public function loadAttributeGroups()
     {
         if ($this->_attributeGroupsById) {
@@ -256,6 +289,11 @@ class Config extends \Magento\Eav\Model\Config
         return $this;
     }
 
+    /**
+     * @param float|int|string $attributeSetId
+     * @param float|int|string $id
+     * @return bool|string
+     */
     public function getAttributeGroupName($attributeSetId, $id)
     {
         if (!is_numeric($id)) {
@@ -270,6 +308,11 @@ class Config extends \Magento\Eav\Model\Config
         return isset($this->_attributeGroupsById[$attributeSetId][$id]) ? $this->_attributeGroupsById[$attributeSetId][$id] : false;
     }
 
+    /**
+     * @param float|int|string $attributeSetId
+     * @param string $name
+     * @return bool|string|int|float
+     */
     public function getAttributeGroupId($attributeSetId, $name)
     {
         if (is_numeric($name)) {
@@ -285,6 +328,9 @@ class Config extends \Magento\Eav\Model\Config
         return isset($this->_attributeGroupsByName[$attributeSetId][$name]) ? $this->_attributeGroupsByName[$attributeSetId][$name] : false;
     }
 
+    /**
+     * @return $this
+     */
     public function loadProductTypes()
     {
         if ($this->_productTypesById) {
@@ -304,6 +350,10 @@ class Config extends \Magento\Eav\Model\Config
         return $this;
     }
 
+    /**
+     * @param string $name
+     * @return false|string
+     */
     public function getProductTypeId($name)
     {
         if (is_numeric($name)) {
@@ -316,6 +366,10 @@ class Config extends \Magento\Eav\Model\Config
         return isset($this->_productTypesByName[$name]) ? $this->_productTypesByName[$name] : false;
     }
 
+    /**
+     * @param float|int|string $id
+     * @return false|string
+     */
     public function getProductTypeName($id)
     {
         if (!is_numeric($id)) {
@@ -327,6 +381,11 @@ class Config extends \Magento\Eav\Model\Config
         return isset($this->_productTypesById[$id]) ? $this->_productTypesById[$id] : false;
     }
 
+    /**
+     * @param /Magento/Object $source
+     * @param string $value
+     * @return null|mixed
+     */
     public function getSourceOptionId($source, $value)
     {
         foreach ($source->getAllOptions() as $option) {
@@ -365,7 +424,8 @@ class Config extends \Magento\Eav\Model\Config
      *
      * @return array
      */
-    public function getAttributesUsedInProductListing() {
+    public function getAttributesUsedInProductListing()
+    {
         if (is_null($this->_usedInProductListing)) {
             $this->_usedInProductListing = array();
             $entityType = \Magento\Catalog\Model\Product::ENTITY;
@@ -387,7 +447,8 @@ class Config extends \Magento\Eav\Model\Config
      *
      * @return array
      */
-    public function getAttributesUsedForSortBy() {
+    public function getAttributesUsedForSortBy()
+    {
         if (is_null($this->_usedForSortBy)) {
             $this->_usedForSortBy = array();
             $entityType     = \Magento\Catalog\Model\Product::ENTITY;
@@ -428,7 +489,8 @@ class Config extends \Magento\Eav\Model\Config
      * @param mixed $store
      * @return string
      */
-    public function getProductListDefaultSortBy($store = null) {
+    public function getProductListDefaultSortBy($store = null)
+    {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_LIST_DEFAULT_SORT_BY, $store);
     }
 }
diff --git a/app/code/Magento/Catalog/Model/Config/Backend/Category.php b/app/code/Magento/Catalog/Model/Config/Backend/Category.php
index 9bb344fbd7e7da3c3c7222d70722687140baed41..18aad4f97ea3d9737024a4d4a850b1be5f91c7c0 100644
--- a/app/code/Magento/Catalog/Model/Config/Backend/Category.php
+++ b/app/code/Magento/Catalog/Model/Config/Backend/Category.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Config\Backend;
 
 /**
  * Config category field backend
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Config\Backend;
-
 class Category extends \Magento\Core\Model\Config\Value
 {
     /**
@@ -43,6 +42,8 @@ class Category extends \Magento\Core\Model\Config\Value
     protected $_catalogCategory;
 
     /**
+     * Constructor
+     *
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
@@ -66,6 +67,9 @@ class Category extends \Magento\Core\Model\Config\Value
         parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * {@inheritdoc}
+     */
     protected function _afterSave()
     {
         if ($this->getScope() == 'stores') {
diff --git a/app/code/Magento/Catalog/Model/Config/Backend/Seo/Product.php b/app/code/Magento/Catalog/Model/Config/Backend/Seo/Product.php
index 806f2535266de2929d756bd9accab83684444d0a..539e03691f36406b2b11cc17365bbdff713a5828 100644
--- a/app/code/Magento/Catalog/Model/Config/Backend/Seo/Product.php
+++ b/app/code/Magento/Catalog/Model/Config/Backend/Seo/Product.php
@@ -23,16 +23,16 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Catalog\Model\Config\Backend\Seo;
 
-class Product extends \Magento\Core\Model\Config\Value
+use Magento\Core\Model\Config\Value;
+
+class Product extends Value
 {
     /**
      * Refresh category url rewrites if configuration was changed
      *
-     * @return \Magento\Catalog\Model\Config\Backend\Seo\Product
+     * @return $this
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Catalog/Model/Config/Source/Category.php b/app/code/Magento/Catalog/Model/Config/Source/Category.php
index 3726161372109b1ef7fbe9ab3231deb73e49c832..8e667a3a4a621784c3fecafacf98ed3fd80c0c86 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/Category.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/Category.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Config\Source;
 
 /**
@@ -51,6 +50,12 @@ class Category implements \Magento\Core\Model\Option\ArrayInterface
         $this->_categoryCollectionFactory = $categoryCollectionFactory;
     }
 
+    /**
+     * Return option array
+     *
+     * @param bool $addEmpty
+     * @return array
+     */
     public function toOptionArray($addEmpty = true)
     {
         /** @var \Magento\Catalog\Model\Resource\Category\Collection $collection */
diff --git a/app/code/Magento/Catalog/Model/Config/Source/GridPerPage.php b/app/code/Magento/Catalog/Model/Config/Source/GridPerPage.php
index d53fc0bf82f8aa3081109263ef66771225a2fb0d..9036ec752aa0665958952f0620ed30fccac92f25 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/GridPerPage.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/GridPerPage.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Config\Source;
 
 /**
  * Catalog products per page on Grid mode source
@@ -32,16 +32,18 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Config\Source;
-
 class GridPerPage implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
+     * Options
+     *
      * @var array
      */
     protected $_options;
 
     /**
+     * Constructor
+     *
      * @param string $perPageValues
      */
     public function __construct($perPageValues)
@@ -49,6 +51,9 @@ class GridPerPage implements \Magento\Core\Model\Option\ArrayInterface
         $this->_options = explode(',', $perPageValues);
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         $result = array();
diff --git a/app/code/Magento/Catalog/Model/Config/Source/ListMode.php b/app/code/Magento/Catalog/Model/Config/Source/ListMode.php
index a78ef3fbe5cf83d845ea49493ef2a3ce02d7de35..84c8b62aa46a2ad206f0b828db2d4db00c667bd5 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/ListMode.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/ListMode.php
@@ -23,12 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Catalog\Model\Config\Source;
 
-class ListMode implements \Magento\Core\Model\Option\ArrayInterface
+use Magento\Core\Model\Option\ArrayInterface;
+
+class ListMode implements ArrayInterface
 {
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Model/Config/Source/ListPerPage.php b/app/code/Magento/Catalog/Model/Config/Source/ListPerPage.php
index 56661ab0aa6057935d7a2f9b3c652707cfab4297..350336fa9bf0e2456bbe50c925309b828021458e 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/ListPerPage.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/ListPerPage.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Config\Source;
 
 /**
  * Catalog products per page on List mode source
@@ -32,16 +32,18 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Config\Source;
-
 class ListPerPage implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
+     * Pager Options
+     *
      * @var array
      */
     protected $_pagerOptions;
 
     /**
+     * Constructor
+     *
      * @param string $options
      */
     public function __construct($options)
@@ -49,6 +51,9 @@ class ListPerPage implements \Magento\Core\Model\Option\ArrayInterface
         $this->_pagerOptions = explode(',', $options);
     }
 
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         $output = array();
diff --git a/app/code/Magento/Catalog/Model/Config/Source/Price/Scope.php b/app/code/Magento/Catalog/Model/Config/Source/Price/Scope.php
index d688f3d20a7b6e491a8691aff66c6c37ef509327..db248883d3cae04630050981399a934bb02a6c90 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/Price/Scope.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/Price/Scope.php
@@ -23,12 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Catalog\Model\Config\Source\Price;
 
-class Scope implements \Magento\Core\Model\Option\ArrayInterface
+use Magento\Core\Model\Option\ArrayInterface;
+
+class Scope implements ArrayInterface
 {
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Model/Config/Source/Price/Step.php b/app/code/Magento/Catalog/Model/Config/Source/Price/Step.php
index 80216d53b07b994970a8562f3db24c8ee795693c..488b46818486024017b6398f21f7b2e1ba49dd49 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/Price/Step.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/Price/Step.php
@@ -23,11 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Config\Source\Price;
 
-class Step implements \Magento\Core\Model\Option\ArrayInterface
+use Magento\Core\Model\Option\ArrayInterface;
+
+class Step implements ArrayInterface
 {
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Price.php b/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Price.php
index af3acb76e9687c85854ba3356d51c8fa8e8765ca..62fc3de539c576f12c191e51f302932eccd6c224 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Price.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Price.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Config\Source\Product\Options;
 
 /**
  * Price types mode source
@@ -31,10 +32,11 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Config\Source\Product\Options;
-
 class Price implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Type.php b/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Type.php
index c0a8427a6cd6a67c2d98675b55216c2370acd5bd..7f4d9a33f5114f5f20c5c0890b7a6af20f42fa8b 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Type.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/Product/Options/Type.php
@@ -1,7 +1,5 @@
 <?php
 /**
- * Product option types mode source
- *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -25,14 +23,21 @@
  */
 namespace Magento\Catalog\Model\Config\Source\Product\Options;
 
+/**
+ * Product option types mode source
+ */
 class Type implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
+     * Product Option Config
+     *
      * @var \Magento\Catalog\Model\ProductOptions\ConfigInterface
      */
     protected $_productOptionConfig;
 
     /**
+     * Constructor
+     *
      * @param \Magento\Catalog\Model\ProductOptions\ConfigInterface $productOptionConfig
      */
     public function __construct(\Magento\Catalog\Model\ProductOptions\ConfigInterface $productOptionConfig)
@@ -40,7 +45,9 @@ class Type implements \Magento\Core\Model\Option\ArrayInterface
         $this->_productOptionConfig = $productOptionConfig;
     }
 
-
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         $groups = array(
diff --git a/app/code/Magento/Catalog/Model/Config/Source/Product/Thumbnail.php b/app/code/Magento/Catalog/Model/Config/Source/Product/Thumbnail.php
index 1913ea80f50089120e40344fef4d80831ae4de81..2fd17f82e1bc7f38ac70138645310f1823f9a84f 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/Product/Thumbnail.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/Product/Thumbnail.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Config\Source\Product;
 
 /**
  * Catalog products per page on Grid mode source
@@ -31,13 +31,14 @@
  * @category   Magento
  * @package    Magento_Catalog
  */
-namespace Magento\Catalog\Model\Config\Source\Product;
-
 class Thumbnail implements \Magento\Core\Model\Option\ArrayInterface
 {
     const OPTION_USE_PARENT_IMAGE = 'parent';
     const OPTION_USE_OWN_IMAGE = 'itself';
 
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Model/Config/Source/TimeFormat.php b/app/code/Magento/Catalog/Model/Config/Source/TimeFormat.php
index 475b24ef641a536fb2a28f5d5aca89207aa82a20..03795dfba8a95344aba1a63632571026be073557 100644
--- a/app/code/Magento/Catalog/Model/Config/Source/TimeFormat.php
+++ b/app/code/Magento/Catalog/Model/Config/Source/TimeFormat.php
@@ -23,11 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Config\Source;
 
 class TimeFormat implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * {@inheritdoc}
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Catalog/Model/Design.php b/app/code/Magento/Catalog/Model/Design.php
index 654ae0f1e485f7a060bca87fd1ed726d769f94ed..6da61ad22bbafd7b5ecb9bffffa0d79af0ca100a 100644
--- a/app/code/Magento/Catalog/Model/Design.php
+++ b/app/code/Magento/Catalog/Model/Design.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model;
 
 /**
  * Catalog Custom Category design Model
@@ -32,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model;
-
 class Design extends \Magento\Core\Model\AbstractModel
 {
     const APPLY_FOR_PRODUCT     = 1;
@@ -81,7 +79,6 @@ class Design extends \Magento\Core\Model\AbstractModel
      *
      * @param string $design
      * @return $this
-     * @return \Magento\Catalog\Model\Design
      */
     public function applyCustomDesign($design)
     {
diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php
index 762c86bb1a565081ace851d11ceddcfcb4c22757..4cc598547f3d44e8fc9ad3085dc73a320716911b 100644
--- a/app/code/Magento/Catalog/Model/Entity/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Entity;
 
 /**
  * Product attribute extension with event dispatching
@@ -70,12 +71,22 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Entity;
-
 class Attribute extends \Magento\Eav\Model\Entity\Attribute
 {
+    /**
+     * Event Prefix
+     *
+     * @var string
+     */
     protected $_eventPrefix = 'catalog_entity_attribute';
+
+    /**
+     * Event Object
+     *
+     * @var string
+     */
     protected $_eventObject = 'attribute';
+
     const MODULE_NAME = 'Magento_Catalog';
 
     /**
diff --git a/app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php b/app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php
index b9637dd1f9fe58713a867dcff15e583ab820249c..0e18d6e1410697c922b82c60c2226e3130c781d0 100644
--- a/app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php
+++ b/app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Entity\Product\Attribute\Design\Options;
 
 /**
  * Entity/Attribute/Model - select product design options container from config
@@ -31,16 +32,13 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Entity\Product\Attribute\Design\Options;
-
-class Container
-    extends \Magento\Eav\Model\Entity\Attribute\Source\Config
+class Container extends \Magento\Eav\Model\Entity\Attribute\Source\Config
 {
     /**
      * Get a text for option value
      *
      * @param string|integer $value
-     * @return string
+     * @return string|false
      */
     public function getOptionText($value)
     {
diff --git a/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php b/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php
new file mode 100644
index 0000000000000000000000000000000000000000..ebd4d2d2cb4c30011dffb0a9b328e4fb2c927abf
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/AbstractFlatState.php
@@ -0,0 +1,101 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer;
+
+abstract class AbstractFlatState
+{
+    /**
+     * Indexer ID in configuration
+     */
+    const INDEXER_ID = '';
+
+    /**
+     * Flat Is Enabled Config XML Path
+     */
+    const INDEXER_ENABLED_XML_PATH = '';
+
+    /**
+     * @var \Magento\Core\Model\Store\ConfigInterface
+     */
+    protected $storeConfig;
+
+    /**
+     * @var bool
+     */
+    protected $isAvailable;
+
+    /**
+     * @var \Magento\Indexer\Model\IndexerInterface
+     */
+    protected $flatIndexer;
+
+    /**
+     * @param \Magento\Core\Model\Store\ConfigInterface $storeConfig
+     * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer
+     * @param bool $isAvailable
+     */
+    public function __construct(
+        \Magento\Core\Model\Store\ConfigInterface $storeConfig,
+        \Magento\Indexer\Model\IndexerInterface $flatIndexer,
+        $isAvailable = false
+    ) {
+        $this->storeConfig = $storeConfig;
+        $this->flatIndexer = $flatIndexer;
+        $this->isAvailable = $isAvailable;
+    }
+
+    /**
+     * Check if Flat Index is enabled
+     *
+     * @return bool
+     */
+    public function isFlatEnabled()
+    {
+        return $this->storeConfig->getConfigFlag(static::INDEXER_ENABLED_XML_PATH);
+    }
+
+    /**
+     * Check if Flat Index is available for use
+     *
+     * @return bool
+     */
+    public function isAvailable()
+    {
+        return $this->isAvailable && $this->isFlatEnabled() && $this->getFlatIndexer()->isValid();
+    }
+
+    /**
+     * Return indexer object
+     *
+     * @return \Magento\Indexer\Model\IndexerInterface
+     */
+    protected function getFlatIndexer()
+    {
+        if (!$this->flatIndexer->getId()) {
+            $this->flatIndexer->load(static::INDEXER_ID);
+        }
+        return $this->flatIndexer;
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php
new file mode 100644
index 0000000000000000000000000000000000000000..bda9a36fdee09fcd9f22aa4eb0180bf191c538a1
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat.php
@@ -0,0 +1,106 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer\Category;
+
+class Flat implements \Magento\Indexer\Model\ActionInterface, \Magento\Mview\ActionInterface
+{
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory
+     */
+    protected $fullActionFactory;
+
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory
+     */
+    protected $rowsActionFactory;
+
+    /**
+     * @var \Magento\Indexer\Model\IndexerInterface
+     */
+    protected $indexer;
+
+    /**
+     * @param Flat\Action\FullFactory $fullActionFactory
+     * @param Flat\Action\RowsFactory $rowsActionFactory
+     * @param \Magento\Indexer\Model\IndexerInterface $indexer
+     */
+    public function __construct(
+        Flat\Action\FullFactory $fullActionFactory,
+        Flat\Action\RowsFactory $rowsActionFactory,
+        \Magento\Indexer\Model\IndexerInterface $indexer
+    ) {
+        $this->fullActionFactory = $fullActionFactory;
+        $this->rowsActionFactory = $rowsActionFactory;
+        $this->indexer = $indexer;
+    }
+
+    /**
+     * Execute materialization on ids entities
+     *
+     * @param int[] $ids
+     */
+    public function execute($ids)
+    {
+        $this->indexer->load(Flat\State::INDEXER_ID);
+        if ($this->indexer->isInvalid()) {
+            return;
+        }
+
+        /** @var Flat\Action\Rows $action */
+        $action = $this->rowsActionFactory->create();
+        if ($this->indexer->isWorking()) {
+            $action->reindex($ids, true);
+        }
+        $action->reindex($ids);
+    }
+
+    /**
+     * Execute full indexation
+     */
+    public function executeFull()
+    {
+        $this->fullActionFactory->create()->reindexAll();
+    }
+
+    /**
+     * Execute partial indexation by ID list
+     *
+     * @param int[] $ids
+     */
+    public function executeList($ids)
+    {
+        $this->execute($ids);
+    }
+
+    /**
+     * Execute partial indexation by ID
+     *
+     * @param int $id
+     */
+    public function executeRow($id)
+    {
+        $this->execute(array($id));
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php
new file mode 100644
index 0000000000000000000000000000000000000000..30342ae107ca2c64c5bd7cb2f1ed76a1f8dfe225
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/AbstractAction.php
@@ -0,0 +1,484 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat;
+
+class AbstractAction
+{
+    /**
+     * Suffix for table to show it is temporary
+     */
+    const TEMPORARY_TABLE_SUFFIX = '_tmp';
+
+    /**
+     * Attribute codes
+     *
+     * @var array
+     */
+    protected $attributeCodes;
+
+    /**
+     * @var \Magento\App\Resource
+     */
+    protected $resource;
+
+    /**
+     * @var \Magento\Core\Model\StoreManagerInterface
+     */
+    protected $storeManager;
+
+    /**
+     * Catalog resource helper
+     *
+     * @var \Magento\Catalog\Model\Resource\Helper
+     */
+    protected $resourceHelper;
+
+    /**
+     * Flat columns
+     *
+     * @var array
+     */
+    protected $columns = array();
+
+    /**
+     * @param \Magento\App\Resource $resource
+     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
+     */
+    public function __construct(
+        \Magento\App\Resource $resource,
+        \Magento\Core\Model\StoreManagerInterface $storeManager,
+        \Magento\Catalog\Model\Resource\Helper $resourceHelper
+    ) {
+        $this->resource = $resource;
+        $this->storeManager = $storeManager;
+        $this->resourceHelper = $resourceHelper;
+        $this->columns = array_merge($this->getStaticColumns(), $this->getEavColumns());
+    }
+
+    /**
+     * Add suffix to table name to show it is temporary
+     *
+     * @param string $tableName
+     * @return string
+     */
+    protected function addTemporaryTableSuffix($tableName)
+    {
+        return $tableName . self::TEMPORARY_TABLE_SUFFIX;
+    }
+
+    /**
+     * Retrieve list of columns for flat structure
+     *
+     * @return array
+     */
+    public function getColumns()
+    {
+        return $this->columns;
+    }
+    /**
+     * Return name of table for given $storeId.
+     *
+     * @param integer $storeId
+     * @return string
+     */
+    public function getMainStoreTable($storeId = \Magento\Core\Model\Store::DEFAULT_STORE_ID)
+    {
+        if (is_string($storeId)) {
+            $storeId = intval($storeId);
+        }
+
+        $suffix = sprintf('store_%d', $storeId);
+        $table = $this->getWriteAdapter()->getTableName($this->getTableName('catalog_category_flat_' . $suffix));
+
+        return $table;
+    }
+
+    /**
+     * Retrieve connection for read data
+     *
+     * @return \Magento\DB\Adapter\AdapterInterface
+     */
+    protected function getReadAdapter()
+    {
+        $writeAdapter = $this->getWriteAdapter();
+        if ($writeAdapter && $writeAdapter->getTransactionLevel() > 0) {
+            // if transaction is started we should use write connection for reading
+            return $writeAdapter;
+        }
+        return $this->resource->getConnection('read');
+    }
+
+    /**
+     * Retrieve connection for write data
+     *
+     * @return \Magento\DB\Adapter\AdapterInterface
+     */
+    protected function getWriteAdapter()
+    {
+        return $this->resource->getConnection('write');
+    }
+
+    /**
+     * Return structure for flat catalog table
+     *
+     * @param $tableName
+     * @return \Magento\DB\Ddl\Table
+     */
+    protected function getFlatTableStructure($tableName)
+    {
+        $table = $this->getWriteAdapter()
+            ->newTable($tableName)
+            ->setComment(sprintf("Catalog Category Flat", $tableName));
+
+        //Adding columns
+        foreach ($this->getColumns() as $fieldName => $fieldProp) {
+            $default = $fieldProp['default'];
+            if ($fieldProp['type'][0] == \Magento\DB\Ddl\Table::TYPE_TIMESTAMP
+                && $default == 'CURRENT_TIMESTAMP') {
+                $default = \Magento\DB\Ddl\Table::TIMESTAMP_INIT;
+            }
+            $table->addColumn(
+                $fieldName,
+                $fieldProp['type'][0],
+                $fieldProp['type'][1],
+                array(
+                    'nullable' => $fieldProp['nullable'],
+                    'unsigned' => $fieldProp['unsigned'],
+                    'default'  => $default,
+                    'primary'  => isset($fieldProp['primary']) ? $fieldProp['primary'] : false,
+                ),
+                ($fieldProp['comment'] != '') ? $fieldProp['comment'] : ucwords(str_replace('_', ' ', $fieldName))
+            );
+        }
+
+        // Adding indexes
+        $table->addIndex(
+            $this->getWriteAdapter()->getIndexName($tableName, array('entity_id')),
+            array('entity_id'),
+            array('type' => 'primary')
+        );
+        $table->addIndex(
+            $this->getWriteAdapter()->getIndexName(
+                $tableName,
+                array('store_id')
+            ),
+            array('store_id'),
+            array('type' => 'index')
+        );
+        $table->addIndex(
+            $this->getWriteAdapter()->getIndexName(
+                $tableName,
+                array('path')
+            ),
+            array('path'),
+            array('type' => 'index')
+        );
+        $table->addIndex(
+            $this->getWriteAdapter()->getIndexName(
+                $tableName,
+                array('level')
+            ),
+            array('level'),
+            array('type' => 'index')
+        );
+
+        return $table;
+    }
+
+    /**
+     * Return array of static columns
+     *
+     * @return array
+     */
+    protected function getStaticColumns()
+    {
+        $columns = array();
+        $columnsToSkip = array('entity_type_id', 'attribute_set_id');
+        $describe = $this->getReadAdapter()->describeTable(
+            $this->getReadAdapter()->getTableName($this->getTableName('catalog_category_entity'))
+        );
+
+        foreach ($describe as $column) {
+            if (in_array($column['COLUMN_NAME'], $columnsToSkip)) {
+                continue;
+            }
+            $isUnsigned = '';
+            $options = null;
+            $ddlType = $this->resourceHelper->getDdlTypeByColumnType($column['DATA_TYPE']);
+            $column['DEFAULT'] = trim($column['DEFAULT'], "' ");
+            switch ($ddlType) {
+                case \Magento\DB\Ddl\Table::TYPE_SMALLINT:
+                case \Magento\DB\Ddl\Table::TYPE_INTEGER:
+                case \Magento\DB\Ddl\Table::TYPE_BIGINT:
+                    $isUnsigned = (bool)$column['UNSIGNED'];
+                    if ($column['DEFAULT'] === '') {
+                        $column['DEFAULT'] = null;
+                    }
+
+                    $options = null;
+                    if ($column['SCALE'] > 0) {
+                        $ddlType = \Magento\DB\Ddl\Table::TYPE_DECIMAL;
+                    } else {
+                        break;
+                    }
+                // fall-through intentional
+                case \Magento\DB\Ddl\Table::TYPE_DECIMAL:
+                    $options = $column['PRECISION'] . ',' . $column['SCALE'];
+                    $isUnsigned = null;
+                    if ($column['DEFAULT'] === '') {
+                        $column['DEFAULT'] = null;
+                    }
+                    break;
+                case \Magento\DB\Ddl\Table::TYPE_TEXT:
+                    $options = $column['LENGTH'];
+                    $isUnsigned = null;
+                    break;
+                case \Magento\DB\Ddl\Table::TYPE_TIMESTAMP:
+                    $options = null;
+                    $isUnsigned = null;
+                    break;
+                case \Magento\DB\Ddl\Table::TYPE_DATETIME:
+                    $isUnsigned = null;
+                    break;
+
+            }
+            $columns[$column['COLUMN_NAME']] = array(
+                'type' => array($ddlType, $options),
+                'unsigned' => $isUnsigned,
+                'nullable' => $column['NULLABLE'],
+                'default' => ($column['DEFAULT'] === null ? false : $column['DEFAULT']),
+                'comment' => $column['COLUMN_NAME']
+            );
+        }
+        $columns['store_id'] = array(
+            'type' => array(\Magento\DB\Ddl\Table::TYPE_SMALLINT, 5),
+            'unsigned' => true,
+            'nullable' => false,
+            'default' => '0',
+            'comment' => 'Store Id'
+        );
+
+        return $columns;
+    }
+
+    /**
+     * Return array of eav columns, skip attribute with static type
+     *
+     * @return array
+     */
+    protected function getEavColumns()
+    {
+        $columns = array();
+        foreach ($this->getAttributes() as $attribute) {
+            if ($attribute['backend_type'] == 'static') {
+                continue;
+            }
+            $columns[$attribute['attribute_code']] = array();
+            switch ($attribute['backend_type']) {
+                case 'varchar':
+                    $columns[$attribute['attribute_code']] = array(
+                        'type' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, 255),
+                        'unsigned' => null,
+                        'nullable' => true,
+                        'default' => null,
+                        'comment' => (string)$attribute['frontend_label']
+                    );
+                    break;
+                case 'int':
+                    $columns[$attribute['attribute_code']] = array(
+                        'type' => array(\Magento\DB\Ddl\Table::TYPE_INTEGER, null),
+                        'unsigned' => null,
+                        'nullable' => true,
+                        'default' => null,
+                        'comment' => (string)$attribute['frontend_label']
+                    );
+                    break;
+                case 'text':
+                    $columns[$attribute['attribute_code']] = array(
+                        'type' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, '64k'),
+                        'unsigned' => null,
+                        'nullable' => true,
+                        'default' => null,
+                        'comment' => (string)$attribute['frontend_label']
+                    );
+                    break;
+                case 'datetime':
+                    $columns[$attribute['attribute_code']] = array(
+                        'type' => array(\Magento\DB\Ddl\Table::TYPE_DATETIME, null),
+                        'unsigned' => null,
+                        'nullable' => true,
+                        'default' => null,
+                        'comment' => (string)$attribute['frontend_label']
+                    );
+                    break;
+                case 'decimal':
+                    $columns[$attribute['attribute_code']] = array(
+                        'type' => array(\Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4'),
+                        'unsigned' => null,
+                        'nullable' => true,
+                        'default' => null,
+                        'comment' => (string)$attribute['frontend_label']
+                    );
+                    break;
+            }
+        }
+
+        return $columns;
+    }
+
+    /**
+     * Return array of attribute codes for entity type 'catalog_category'
+     *
+     * @return array
+     */
+    protected function getAttributes()
+    {
+        if ($this->attributeCodes === null) {
+            $select = $this->getReadAdapter()->select()
+                ->from($this->getReadAdapter()->getTableName($this->getTableName('eav_entity_type')), array())
+                ->join(
+                    $this->getReadAdapter()->getTableName($this->getTableName('eav_attribute')),
+                    $this->getReadAdapter()->getTableName($this->getTableName('eav_attribute'))
+                        . '.entity_type_id = '
+                        . $this->getReadAdapter()->getTableName($this->getTableName('eav_entity_type'))
+                        . '.entity_type_id',
+                    $this->getReadAdapter()->getTableName($this->getTableName('eav_attribute')).'.*'
+                )
+                ->where(
+                    $this->getReadAdapter()
+                        ->getTableName($this->getTableName('eav_entity_type')) . '.entity_type_code = ?',
+                    \Magento\Catalog\Model\Category::ENTITY
+                );
+            $this->attributeCodes = array();
+            foreach ($this->getReadAdapter()->fetchAll($select) as $attribute) {
+                $this->attributeCodes[$attribute['attribute_id']] = $attribute;
+            }
+        }
+
+        return $this->attributeCodes;
+    }
+
+    /**
+     * Return attribute values for given entities and store
+     *
+     * @param array $entityIds
+     * @param integer $storeId
+     * @return array
+     */
+    protected function getAttributeValues($entityIds, $storeId)
+    {
+        if (!is_array($entityIds)) {
+            $entityIds = array($entityIds);
+        }
+        $values = array();
+
+        foreach ($entityIds as $entityId) {
+            $values[$entityId] = array();
+        }
+        $attributes = $this->getAttributes();
+        $attributesType = array(
+            'varchar',
+            'int',
+            'decimal',
+            'text',
+            'datetime'
+        );
+        foreach ($attributesType as $type) {
+            foreach ($this->getAttributeTypeValues($type, $entityIds, $storeId) as $row) {
+                if (isset($row['entity_id']) && isset($row['attribute_id'])) {
+                    $attributeId   = $row['attribute_id'];
+                    if (isset($attributes[$attributeId])) {
+                        $attributeCode = $attributes[$attributeId]['attribute_code'];
+                        $values[$row['entity_id']][$attributeCode] = $row['value'];
+                    }
+                }
+            }
+        }
+        return $values;
+    }
+
+    /**
+     * Return attribute values for given entities and store of specific attribute type
+     *
+     * @param string $type
+     * @param array $entityIds
+     * @param integer $storeId
+     * @return array
+     */
+    protected function getAttributeTypeValues($type, $entityIds, $storeId)
+    {
+        $select = $this->getReadAdapter()->select()
+            ->from(
+                array('def' => $this->getReadAdapter()
+                        ->getTableName($this->getTableName('catalog_category_entity_' . $type))),
+                array('entity_id', 'attribute_id')
+            )
+            ->joinLeft(
+                array('store' => $this->getReadAdapter()
+                        ->getTableName($this->getTableName('catalog_category_entity_' . $type))),
+                'store.entity_id = def.entity_id AND store.attribute_id = def.attribute_id '
+                . 'AND store.store_id = ' . $storeId,
+                array('value' => $this->getReadAdapter()->getCheckSql(
+                    'store.value_id > 0',
+                    $this->getReadAdapter()->quoteIdentifier('store.value'),
+                    $this->getReadAdapter()->quoteIdentifier('def.value')
+                ))
+            )
+            ->where('def.entity_id IN (?)', $entityIds)
+            ->where('def.store_id IN (?)', array(\Magento\Core\Model\Store::DEFAULT_STORE_ID, $storeId));
+
+        return $this->getReadAdapter()->fetchAll($select);
+    }
+
+    /**
+     * Prepare array of column and columnValue pairs
+     *
+     * @param array $data
+     * @return array
+     */
+    protected function prepareValuesToInsert($data)
+    {
+        $values = array();
+        foreach (array_keys($this->getColumns()) as $column) {
+            if (isset($data[$column])) {
+                $values[$column] = $data[$column];
+            } else {
+                $values[$column] = null;
+            }
+        }
+        return $values;
+    }
+
+    /**
+     * Get table name
+     *
+     * @param string $name
+     * @return string
+     */
+    protected function getTableName($name)
+    {
+        return $this->resource->getTableName($name);
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Full.php
new file mode 100644
index 0000000000000000000000000000000000000000..89e265e5d98d837bc53c9009e99a1ae322484ab6
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Full.php
@@ -0,0 +1,203 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Action;
+
+class Full extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction
+{
+    /**
+     * Suffix for table to show it is old
+     */
+    const OLD_TABLE_SUFFIX = '_old';
+
+    /**
+     * Whether table changes are allowed
+     *
+     * @var bool
+     */
+    protected $allowTableChanges = true;
+
+    /**
+     * Add suffix to table name to show it is old
+     *
+     * @param string $tableName
+     * @return string
+     */
+    protected function addOldTableSuffix($tableName)
+    {
+        return $tableName . self::OLD_TABLE_SUFFIX;
+    }
+
+    /**
+     * Populate category flat tables with data
+     *
+     * @param \Magento\Core\Model\Store[] $stores
+     * @return Full
+     */
+    protected function populateFlatTables(array $stores)
+    {
+        $rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
+        $categories = array();
+        $categoriesIds = array();
+        /* @var $store \Magento\Core\Model\Store */
+        foreach ($stores as $store) {
+            if (!isset($categories[$store->getRootCategoryId()])) {
+                $select = $this->getWriteAdapter()->select()
+                    ->from($this->getWriteAdapter()->getTableName($this->getTableName('catalog_category_entity')))
+                    ->where('path = ?', (string)$rootId)
+                    ->orWhere('path = ?', "{$rootId}/{$store->getRootCategoryId()}")
+                    ->orWhere('path LIKE ?', "{$rootId}/{$store->getRootCategoryId()}/%");
+                $categories[$store->getRootCategoryId()] = $this->getWriteAdapter()->fetchAll($select);
+                $categoriesIds[$store->getRootCategoryId()] = array();
+                foreach ($categories[$store->getRootCategoryId()] as $category) {
+                    $categoriesIds[$store->getRootCategoryId()][] = $category['entity_id'];
+                }
+            }
+            /** @TODO Do something with chunks */
+            $categoriesIdsChunks = array_chunk($categoriesIds[$store->getRootCategoryId()], 500);
+            foreach ($categoriesIdsChunks as $categoriesIdsChunk) {
+                $attributesData = $this->getAttributeValues($categoriesIdsChunk, $store->getId());
+                $data = array();
+                foreach ($categories[$store->getRootCategoryId()] as $category) {
+                    if (!isset($attributesData[$category['entity_id']])) {
+                        continue;
+                    }
+                    $category['store_id'] = $store->getId();
+                    $data[] = $this->prepareValuesToInsert(
+                        array_merge($category, $attributesData[$category['entity_id']])
+                    );
+                }
+                $this->getWriteAdapter()->insertMultiple(
+                    $this->addTemporaryTableSuffix($this->getMainStoreTable($store->getId())),
+                    $data
+                );
+            }
+        }
+
+        return $this;
+    }
+
+    /**
+     * Create table and add attributes as fields for specified store.
+     * This routine assumes that DDL operations are allowed
+     *
+     * @param int $store
+     * @return Full
+     */
+    protected function createTable($store)
+    {
+        $temporaryTable = $this->addTemporaryTableSuffix($this->getMainStoreTable($store));
+        $table  = $this->getFlatTableStructure($temporaryTable);
+        $this->getWriteAdapter()->dropTable($temporaryTable);
+        $this->getWriteAdapter()->createTable($table);
+
+        return $this;
+    }
+
+    /**
+     * Create category flat tables and add attributes as fields.
+     * Tables are created only if DDL operations are allowed
+     *
+     * @param \Magento\Core\Model\Store[] $stores if empty, create tables for all stores of the application
+     * @return Full
+     */
+    protected function createTables(array $stores = array())
+    {
+        if ($this->getWriteAdapter()->getTransactionLevel() > 0) {
+            return $this;
+        }
+        if (empty($stores)) {
+            $stores = $this->storeManager->getStores();
+        }
+        /* @var $store \Magento\Core\Model\Store */
+        foreach ($stores as $store) {
+            $this->createTable($store->getId());
+        }
+
+        return $this;
+    }
+
+    /**
+     * Switch table (temporary becomes active, old active will be dropped)
+     *
+     * @param \Magento\Core\Model\Store[] $stores
+     * @return Full
+     */
+    protected function switchTables(array $stores = array())
+    {
+        /** @var $store \Magento\Core\Model\Store */
+        foreach ($stores as $store) {
+            $activeTableName = $this->getMainStoreTable($store->getId());
+            $temporaryTableName = $this->addTemporaryTableSuffix($this->getMainStoreTable($store->getId()));
+            $oldTableName = $this->addOldTableSuffix($this->getMainStoreTable($store->getId()));
+
+            //switch tables
+            $tablesToRename = array();
+            if ($this->getWriteAdapter()->isTableExists($activeTableName)) {
+                $tablesToRename[] = array(
+                    'oldName' => $activeTableName,
+                    'newName' => $oldTableName
+                );
+            }
+
+            $tablesToRename[] = array(
+                'oldName' => $temporaryTableName,
+                'newName' => $activeTableName
+            );
+
+            foreach ($tablesToRename as $tableToRename) {
+                $this->getWriteAdapter()->renameTable($tableToRename['oldName'], $tableToRename['newName']);
+            }
+
+            //delete inactive table
+            $tableToDelete = $oldTableName;
+
+            if ($this->getWriteAdapter()->isTableExists($tableToDelete)) {
+                $this->getWriteAdapter()->dropTable($tableToDelete);
+            }
+        }
+
+        return $this;
+    }
+
+    /**
+     * Transactional rebuild flat data from eav
+     *
+     * @return Full
+     */
+    public function reindexAll()
+    {
+        $this->createTables();
+
+        if ($this->allowTableChanges) {
+            $this->allowTableChanges = false;
+        }
+        $stores = $this->storeManager->getStores();
+        $this->populateFlatTables($stores);
+        $this->switchTables($stores);
+
+        $this->allowTableChanges = true;
+
+        return $this;
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php
new file mode 100644
index 0000000000000000000000000000000000000000..dcdb9e84343d43a90928c6bd47fcb73602e19e7d
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Action/Rows.php
@@ -0,0 +1,183 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Action;
+
+class Rows extends \Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction
+{
+    /**
+     * @var \Magento\Catalog\Model\CategoryFactory
+     */
+    protected $categoryFactory;
+
+    /**
+     * @param \Magento\App\Resource $resource
+     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
+     * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
+     */
+    public function __construct(
+        \Magento\App\Resource $resource,
+        \Magento\Core\Model\StoreManagerInterface $storeManager,
+        \Magento\Catalog\Model\Resource\Helper $resourceHelper,
+        \Magento\Catalog\Model\CategoryFactory $categoryFactory
+    ) {
+        $this->categoryFactory = $categoryFactory;
+        parent::__construct($resource, $storeManager, $resourceHelper);
+    }
+
+    /**
+     * Return index table name
+     *
+     * @param \Magento\Core\Model\Store $store
+     * @param bool $useTempTable
+     * @return string
+     */
+    protected function getTableNameByStore(\Magento\Core\Model\Store $store, $useTempTable)
+    {
+        $tableName = $this->getMainStoreTable($store->getId());
+        return $useTempTable ? $this->addTemporaryTableSuffix($tableName) : $tableName;
+    }
+
+    /**
+     * Refresh entities index
+     *
+     * @param int[] $entityIds
+     * @param bool $useTempTable
+     * @return Rows
+     */
+    public function reindex(array $entityIds = array(), $useTempTable = false)
+    {
+        $stores = $this->storeManager->getStores();
+
+        /* @var $category \Magento\Catalog\Model\Category */
+        $category = $this->categoryFactory->create();
+
+        /* @var $store \Magento\Core\Model\Store */
+        foreach ($stores as $store) {
+            $tableName = $this->getTableNameByStore($store, $useTempTable);
+
+            if (!$this->getWriteAdapter()->isTableExists($tableName)) {
+                continue;
+            }
+
+            /** @TODO Do something with chunks */
+            $categoriesIdsChunks = array_chunk($entityIds, 500);
+            foreach ($categoriesIdsChunks as $categoriesIdsChunk) {
+
+                $categoriesIdsChunk = $this->filterIdsByStore($categoriesIdsChunk, $store);
+
+                $attributesData = $this->getAttributeValues($categoriesIdsChunk, $store->getId());
+                $data = array();
+                foreach ($categoriesIdsChunk as $categoryId) {
+                    if (!isset($attributesData[$categoryId])) {
+                        continue;
+                    }
+
+                    if ($category->load($categoryId)->getId()) {
+                        $data[] = $this->prepareValuesToInsert(
+                            array_merge(
+                                $category->getData(),
+                                $attributesData[$categoryId],
+                                array('store_id' => $store->getId())
+                            )
+                        );
+                    }
+                }
+                foreach ($data as $row) {
+                    $updateFields = array();
+                    foreach (array_keys($row) as $key) {
+                        $updateFields[$key] = $key;
+                    }
+                    $this->getWriteAdapter()->insertOnDuplicate(
+                        $tableName,
+                        $row,
+                        $updateFields
+                    );
+                }
+            }
+            $this->deleteNonStoreCategories($store, $useTempTable);
+        }
+
+        return $this;
+    }
+
+    /**
+     * Delete non stores categories
+     *
+     * @param \Magento\Core\Model\Store $store
+     * @param bool $useTempTable
+     */
+    protected function deleteNonStoreCategories(\Magento\Core\Model\Store $store, $useTempTable)
+    {
+        $rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
+
+        $rootIdExpr = $this->getWriteAdapter()->quote((string)$rootId);
+        $rootCatIdExpr = $this->getWriteAdapter()->quote("{$rootId}/{$store->getRootCategoryId()}");
+        $catIdExpr = $this->getWriteAdapter()->quote("{$rootId}/{$store->getRootCategoryId()}/%");
+
+        /** @var \Magento\DB\Select $select */
+        $select = $this->getWriteAdapter()->select()
+            ->from(array('cf' => $this->getTableNameByStore($store, $useTempTable)))
+            ->joinLeft(
+                array('ce' => $this->getWriteAdapter()->getTableName($this->getTableName('catalog_category_entity'))),
+                'cf.path = ce.path',
+                array()
+            )
+            ->where("cf.path = {$rootIdExpr} OR cf.path = {$rootCatIdExpr} OR cf.path like {$catIdExpr}")
+            ->where('ce.entity_id IS NULL');
+
+        $sql = $select->deleteFromSelect('cf');
+        $this->getWriteAdapter()->query($sql);
+    }
+
+    /**
+     * Filter category ids by store
+     *
+     * @param int[] $ids
+     * @param \Magento\Core\Model\Store $store
+     * @return int[]
+     */
+    protected function filterIdsByStore(array $ids, $store)
+    {
+        $rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
+
+        $rootIdExpr = $this->getReadAdapter()->quote((string)$rootId);
+        $rootCatIdExpr = $this->getReadAdapter()->quote("{$rootId}/{$store->getRootCategoryId()}");
+        $catIdExpr = $this->getReadAdapter()->quote("{$rootId}/{$store->getRootCategoryId()}/%");
+
+        $select = $this->getReadAdapter()->select()
+            ->from(
+                $this->getReadAdapter()->getTableName($this->getTableName('catalog_category_entity')),
+                array('entity_id')
+            )
+            ->where("path = {$rootIdExpr} OR path = {$rootCatIdExpr} OR path like {$catIdExpr}")
+            ->where('entity_id IN (?)', $ids);
+
+        $resultIds = array();
+        foreach ($this->getReadAdapter()->fetchAll($select) as $category) {
+            $resultIds[] = $category['entity_id'];
+        }
+        return $resultIds;
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/AbstractStore.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/AbstractStore.php
new file mode 100644
index 0000000000000000000000000000000000000000..0676aed5d2cec56f3d08fb745591147bbcdf315e
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/AbstractStore.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class AbstractStore
+{
+    /**
+     * @var \Magento\Indexer\Model\IndexerInterface
+     */
+    protected $indexer;
+
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\State
+     */
+    protected $state;
+
+    /**
+     * @param \Magento\Indexer\Model\IndexerInterface $indexer
+     * @param \Magento\Catalog\Model\Indexer\Category\Flat\State $state
+     */
+    public function __construct(
+        \Magento\Indexer\Model\IndexerInterface $indexer,
+        \Magento\Catalog\Model\Indexer\Category\Flat\State $state
+    ) {
+        $this->indexer = $indexer;
+        $this->state = $state;
+    }
+
+    /**
+     * Return own indexer object
+     *
+     * @return \Magento\Indexer\Model\IndexerInterface
+     */
+    protected function getIndexer()
+    {
+        if (!$this->indexer->getId()) {
+            $this->indexer->load(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID);
+        }
+        return $this->indexer;
+    }
+
+    /**
+     * Invalidate indexer
+     */
+    protected function invalidateIndexer()
+    {
+        if ($this->state->isFlatEnabled()) {
+            $this->getIndexer()->invalidate();
+        }
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php
new file mode 100644
index 0000000000000000000000000000000000000000..9eb313c6286bc326e7da718c5f8366ace7edba50
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class IndexerConfigData
+{
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\State
+     */
+    protected $state;
+
+    /**
+     * @param \Magento\Catalog\Model\Indexer\Category\Flat\State $state
+     */
+    public function __construct(\Magento\Catalog\Model\Indexer\Category\Flat\State $state)
+    {
+        $this->state = $state;
+    }
+
+    /**
+     * Unset indexer data in configuration if flat is disabled
+     *
+     * @param array $arguments
+     * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @return mixed
+     */
+    public function aroundGet(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
+    {
+        $data = $invocationChain->proceed($arguments);
+
+        if (!$this->state->isFlatEnabled()) {
+            $indexerId = \Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID;
+            if ((!isset($arguments['path']) || !$arguments['path']) && isset($data[$indexerId])) {
+                unset($data[$indexerId]);
+            } elseif (isset($arguments['path'])) {
+                list($firstKey, ) = explode('/', $arguments['path']);
+                if ($firstKey == $indexerId) {
+                    $data = isset($arguments['default']) ? $arguments['default'] : null;
+                }
+            }
+        }
+
+        return $data;
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php
new file mode 100644
index 0000000000000000000000000000000000000000..700c20bd72216a0c56a3bcd3ea51d556c127eb92
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class StoreGroup extends AbstractStore
+{
+    /**
+     * @param array $arguments
+     * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     */
+    public function aroundSave(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
+    {
+        /** @var \Magento\Core\Model\Store\Group $group */
+        $group = $arguments[0];
+        $needInvalidating = $group->dataHasChangedFor('root_category_id') && !$group->isObjectNew();
+        $objectResource = $invocationChain->proceed($arguments);
+        if ($needInvalidating) {
+            $this->invalidateIndexer();
+        }
+
+        return $objectResource;
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php
new file mode 100644
index 0000000000000000000000000000000000000000..67ad38099f9a6989bf3bfd0240358b8781bc57d1
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreView.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class StoreView extends AbstractStore
+{
+    /**
+     * @param array $arguments
+     * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     */
+    public function aroundSave(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
+    {
+        /** @var \Magento\Core\Model\Store $store */
+        $store = $arguments[0];
+        $needInvalidating = $store->isObjectNew() || $store->dataHasChangedFor('group_id');
+        $objectResource = $invocationChain->proceed($arguments);
+        if ($needInvalidating) {
+            $this->invalidateIndexer();
+        }
+
+        return $objectResource;
+    }
+}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/State.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/State.php
new file mode 100644
index 0000000000000000000000000000000000000000..9836e47d0d0e0c18ddc3cce96af3943f053f08c5
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/State.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer\Category\Flat;
+
+class State extends \Magento\Catalog\Model\Indexer\AbstractFlatState
+{
+    /**
+     * Indexer ID in configuration
+     */
+    const INDEXER_ID = 'catalog_category_flat';
+
+    /**
+     * Flat Is Enabled Config XML Path
+     */
+    const INDEXER_ENABLED_XML_PATH = 'catalog/frontend/flat_catalog_category';
+}
diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php
similarity index 68%
rename from app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php
rename to app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php
index 23db87c2c098f1b7dd1dfeb7cf05bc2cad33f1b9..eb64fe93de11b2a93b278c55135cdf883c7f7104 100644
--- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php
@@ -18,32 +18,28 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Catalog
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
+namespace Magento\Catalog\Model\Indexer\Category\Flat\System\Config;
+
 /**
  * Flat category on/off backend
  */
-namespace Magento\Catalog\Model\System\Config\Backend\Catalog\Category;
-
-class Flat extends \Magento\Core\Model\Config\Value
+class Mode extends \Magento\Core\Model\Config\Value
 {
     /**
-     * Indexer factory
-     *
-     * @var \Magento\Index\Model\IndexerFactory
+     * @var \Magento\Indexer\Model\IndexerInterface
      */
-    protected $_indexerFactory;
+    protected $flatIndexer;
 
     /**
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\App\ConfigInterface $config
-     * @param \Magento\Index\Model\IndexerFactory $indexerFactory
+     * @param \Magento\Indexer\Model\IndexerInterface $flatIndexer
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
@@ -53,28 +49,40 @@ class Flat extends \Magento\Core\Model\Config\Value
         \Magento\Core\Model\Registry $registry,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\App\ConfigInterface $config,
-        \Magento\Index\Model\IndexerFactory $indexerFactory,
+        \Magento\Indexer\Model\IndexerInterface $flatIndexer,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
         array $data = array()
     ) {
-        $this->_indexerFactory = $indexerFactory;
+        $this->flatIndexer = $flatIndexer;
         parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data);
     }
 
     /**
-     * After enable flat category required reindex
+     * Set after commit callback
      *
-     * @return \Magento\Catalog\Model\System\Config\Backend\Catalog\Category\Flat
+     * @return $this
      */
     protected function _afterSave()
     {
-        if ($this->isValueChanged() && $this->getValue()) {
-            $this->_indexerFactory->create()
-                ->getProcessByCode(\Magento\Catalog\Helper\Category\Flat::CATALOG_CATEGORY_FLAT_PROCESS_CODE)
-                ->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX);
-        }
-
+        $this->_getResource()->addCommitCallback(array($this, 'processValue'));
         return $this;
     }
+
+    /**
+     * Process flat enabled mode change
+     *
+     * @return void
+     */
+    public function processValue()
+    {
+        if ($this->isValueChanged()) {
+            $this->flatIndexer->load(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID);
+            if ($this->getValue()) {
+                $this->flatIndexer->invalidate();
+            } else {
+                $this->flatIndexer->setScheduled(false);
+            }
+        }
+    }
 }
diff --git a/app/code/Magento/Catalog/Model/Indexer/Url.php b/app/code/Magento/Catalog/Model/Indexer/Url.php
index 44fbeb9e86a4377f12b565fd4647a7e793a54268..139d0ec3a9905e6a55545dbc23ac4867d19ded54 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Url.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Url.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Indexer;
 
 /**
  * Catalog url rewrites index model.
@@ -33,8 +34,6 @@
  *  - Store group save (changed root category or group website) - require reindex all data
  *  - Seo config settings change - require reindex all data
  */
-namespace Magento\Catalog\Model\Indexer;
-
 class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
 {
     /**
@@ -66,6 +65,11 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
         ),
     );
 
+    /**
+     * Related Config Settings
+     *
+     * @var array
+     */
     protected $_relatedConfigSettings = array(
         \Magento\Catalog\Helper\Category::XML_PATH_CATEGORY_URL_SUFFIX,
         \Magento\Catalog\Helper\Product::XML_PATH_PRODUCT_URL_SUFFIX,
@@ -87,6 +91,8 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
     protected $_catalogResourceUrl;
 
     /**
+     * Constructor
+     *
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Catalog\Model\Resource\Url $catalogResourceUrl
@@ -180,6 +186,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
+     * @return $this
      */
     protected function _registerEvent(\Magento\Index\Model\Event $event)
     {
@@ -187,7 +194,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
         $entity = $event->getEntity();
         switch ($entity) {
             case \Magento\Catalog\Model\Product::ENTITY:
-               $this->_registerProductEvent($event);
+                $this->_registerProductEvent($event);
                 break;
 
             case \Magento\Catalog\Model\Category::ENTITY:
@@ -208,6 +215,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register event data during product save process
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerProductEvent(\Magento\Index\Model\Event $event)
     {
@@ -225,6 +233,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register event data during category save process
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerCategoryEvent(\Magento\Index\Model\Event $event)
     {
@@ -246,6 +255,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Process event
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _processEvent(\Magento\Index\Model\Event $event)
     {
@@ -260,7 +270,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
             $this->_catalogUrl->setShouldSaveRewritesHistory($dataObject->getData('save_rewrites_history'));
         }
 
-        if(isset($data['rewrite_product_ids'])) {
+        if (isset($data['rewrite_product_ids'])) {
             $this->_catalogUrl->clearStoreInvalidRewrites(); // Maybe some products were moved or removed from website
             foreach ($data['rewrite_product_ids'] as $productId) {
                 $this->_catalogUrl->refreshProductRewrite($productId);
@@ -276,6 +286,9 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer
 
     /**
      * Rebuild all index data
+     *
+     * @return void
+     * @throws \Exception
      */
     public function reindexAll()
     {
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php
index 1ca838796f36d454b558512c5bf0ec3d178d4005..230c65ac54ae302e1b07b739751d3fd8f362ab55 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/AbstractFilter.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Layer\Filter;
 
 /**
  * Layer category filter abstract model
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Layer\Filter;
-
 abstract class AbstractFilter extends \Magento\Object
 {
     /**
@@ -135,7 +134,9 @@ abstract class AbstractFilter extends \Magento\Object
     /**
      * Apply filter to collection
      *
-     * @param  \Zend_Controller_Request_Abstract $request
+     * @param \Zend_Controller_Request_Abstract $request
+     * @param \Magento\Object $filterBlock
+     * @return $this
      */
     public function apply(\Zend_Controller_Request_Abstract $request, $filterBlock)
     {
@@ -168,7 +169,7 @@ abstract class AbstractFilter extends \Magento\Object
     /**
      * Get data array for building filter items
      *
-     * result array should have next structure:
+     * Result array should have next structure:
      * array(
      *      $index => array(
      *          'label' => $label,
@@ -313,7 +314,7 @@ abstract class AbstractFilter extends \Magento\Object
      * Set store id scope
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Layer\Filter\AbstractFilter
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -338,7 +339,7 @@ abstract class AbstractFilter extends \Magento\Object
      * Set Website ID scope
      *
      * @param int $websiteId
-     * @return \Magento\Catalog\Model\Layer\Filter\AbstractFilter
+     * @return $this
      */
     public function setWebsiteId($websiteId)
     {
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php b/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php
index 9902f95ffcf8c4c78633c665b8a5c270f3bbae8f..89e49c85af290943d750432993201759114c5986 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Attribute.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Layer\Filter;
 
 /**
@@ -50,6 +49,8 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
     protected $string;
 
     /**
+     * Constructor
+     *
      * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Catalog\Model\Layer $catalogLayer
@@ -97,7 +98,7 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      *
      * @param   \Zend_Controller_Request_Abstract $request
      * @param   \Magento\Object $filterBlock
-     * @return  \Magento\Catalog\Model\Layer\Filter\Attribute
+     * @return  $this
      */
     public function apply(\Zend_Controller_Request_Abstract $request, $filterBlock)
     {
@@ -152,8 +153,7 @@ class Attribute extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
                             'count' => $optionsCount[$option['value']],
                         );
                     }
-                }
-                else {
+                } else {
                     $data[] = array(
                         'label' => $option['label'],
                         'value' => $option['value'],
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php
index d8cec4fbe5ef707688ca89132572f7554264e34c..f0e3fd6659ae5a11777be92c9ceb5d21ccf71a46 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Category.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Category.php
@@ -100,7 +100,7 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
     /**
      * Get filter value for reset current filter state
      *
-     * @return mixed
+     * @return mixed|null
      */
     public function getResetValue()
     {
@@ -122,7 +122,7 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      *
      * @param   \Zend_Controller_Request_Abstract $request
      * @param   \Magento\View\Element\AbstractBlock $filterBlock
-     * @return  \Magento\Catalog\Model\Layer\Filter\Category
+     * @return  $this
      */
     public function apply(\Zend_Controller_Request_Abstract $request, $filterBlock)
     {
@@ -152,8 +152,8 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
     /**
      * Validate category for be using as filter
      *
-     * @param   \Magento\Catalog\Model\Category $category
-     * @return unknown
+     * @param  \Magento\Catalog\Model\Category $category
+     * @return mixed
      */
     protected function _isValidCategory($category)
     {
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php
index bebb115674b1eb3d5f762cf9db0b84b8ac1eecd8..8bc9520fdf92ea918fc8e0db1d62358efafadebd 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Decimal.php
@@ -81,7 +81,7 @@ class Decimal extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      *
      * @param \Zend_Controller_Request_Abstract $request
      * @param \Magento\Catalog\Block\Layer\Filter\Decimal $filterBlock
-     * @return \Magento\Catalog\Model\Layer\Filter\Decimal
+     * @return $this
      */
     public function apply(\Zend_Controller_Request_Abstract $request, $filterBlock)
     {
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php
index 8e3a1a8ff762cf508184201b589f62c77c4a8d9f..9022eb4cfb47838aad3841da0fc8dc3e717d4fbc 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Price.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Price.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Layer\Filter;
 
 /**
  * Layer price filter
@@ -31,9 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Catalog\Model\Layer\Filter;
-
 class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
 {
     /**
@@ -213,10 +211,10 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
     /**
      * Prepare text of item label
      *
+     * @param      int $range
+     * @param      float $value
+     * @return     string
      * @deprecated since 1.7.0.0
-     * @param   int $range
-     * @param   float $value
-     * @return  string
      */
     protected function _renderItemLabel($range, $value)
     {
@@ -354,7 +352,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
     /**
      * Apply price range filter to collection
      *
-     * @return \Magento\Catalog\Model\Layer\Filter\Price
+     * @return $this
      */
     protected function _applyPriceRange()
     {
@@ -387,9 +385,8 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      * Apply price range filter
      *
      * @param \Zend_Controller_Request_Abstract $request
-     * @param $filterBlock
-     *
-     * @return \Magento\Catalog\Model\Layer\Filter\Price
+     * @param \Magento\Object $filterBlock
+     * @return $this
      */
     public function apply(\Zend_Controller_Request_Abstract $request, $filterBlock)
     {
@@ -439,10 +436,10 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
     /**
      * Apply filter value to product collection based on filter range and selected value
      *
-     * @deprecated since 1.7.0.0
      * @param int $range
      * @param int $index
      * @return \Magento\Catalog\Model\Layer\Filter\Price
+     * @deprecated since 1.7.0.0
      */
     protected function _applyToCollection($range, $index)
     {
@@ -468,7 +465,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      * Set active customer group id for filter
      *
      * @param int $customerGroupId
-     * @return \Magento\Catalog\Model\Layer\Filter\Price
+     * @return $this
      */
     public function setCustomerGroupId($customerGroupId)
     {
@@ -496,7 +493,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      * Set active currency rate for filter
      *
      * @param float $rate
-     * @return \Magento\Catalog\Model\Layer\Filter\Price
+     * @return $this
      */
     public function setCurrencyRate($rate)
     {
@@ -565,7 +562,7 @@ class Price extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter
      * @param null|int $offset
      * @param null|int $lowerPrice
      * @param null|int $upperPrice
-     * @return array|false
+     * @return array
      */
     public function loadPrices($limit, $offset = null, $lowerPrice = null, $upperPrice = null)
     {
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Price/Algorithm.php b/app/code/Magento/Catalog/Model/Layer/Filter/Price/Algorithm.php
index 64ed1102a80680448ef56efa92c9210c7723d932..0c1328bcd7ce1cd0ccd1b9bcffd727ff3bde9d47 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Price/Algorithm.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Price/Algorithm.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Layer\Filter\Price;
 
 /**
  * Algorithm for layer price filter
@@ -31,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Layer\Filter\Price;
-
 class Algorithm
 {
     /**
@@ -153,7 +152,7 @@ class Algorithm
      * Returns -1 if index was not found
      *
      * @param float $value
-     * @param null|array $limits search [from, to]
+     * @param null|float[] $limits search [from, to]
      * @return int
      */
     protected function _binarySearch($value, $limits = null)
@@ -197,7 +196,7 @@ class Algorithm
      * @param float $max
      * @param float $standardDeviation
      * @param int $count
-     * @return \Magento\Catalog\Model\Layer\Filter\Price\Algorithm
+     * @return $this
      */
     public function setStatistics($min, $max, $standardDeviation, $count)
     {
@@ -226,7 +225,7 @@ class Algorithm
      * Set prices model
      *
      * @param \Magento\Catalog\Model\Layer\Filter\Price $pricesModel
-     * @return \Magento\Catalog\Model\Layer\Filter\Price\Algorithm
+     * @return $this
      */
     public function setPricesModel($pricesModel)
     {
@@ -277,7 +276,7 @@ class Algorithm
      * Get quantile interval
      *
      * @param int $quantileNumber should be from 1 to n-1 where n is number of intervals
-     * @return null|array [floatMin,floatMax]
+     * @return null|float[] [floatMin,floatMax]
      */
     protected function _getQuantileInterval($quantileNumber)
     {
@@ -307,8 +306,8 @@ class Algorithm
     /**
      * Merge new round prices with old ones
      *
-     * @param array $oldRoundPrices
-     * @param array $newRoundPrices
+     * @param array &$oldRoundPrices
+     * @param array &$newRoundPrices
      * @return void
      */
     protected function _mergeRoundPrices(&$oldRoundPrices, &$newRoundPrices)
@@ -503,7 +502,7 @@ class Algorithm
      *
      * @param int $quantileNumber
      * @param array $separators
-     * @return bool|array [deflection, separatorPrice, $priceIndex]
+     * @return array|false [deflection, separatorPrice, $priceIndex]
      */
     protected function _findBestSeparator($quantileNumber, $separators)
     {
diff --git a/app/code/Magento/Catalog/Model/Layer/State.php b/app/code/Magento/Catalog/Model/Layer/State.php
index 0f2a44bb286257bbc93abb5f733851e36b8fa3a9..446b5e06e56184b52eaf8f987fbf9ecec2072125 100644
--- a/app/code/Magento/Catalog/Model/Layer/State.php
+++ b/app/code/Magento/Catalog/Model/Layer/State.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Layer;
 
 /**
  * Layered navigation state model
@@ -31,15 +32,13 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Layer;
-
 class State extends \Magento\Object
 {
     /**
      * Add filter item to layer state
      *
      * @param   \Magento\Catalog\Model\Layer\Filter\Item $filter
-     * @return  \Magento\Catalog\Model\Layer\State
+     * @return  $this
      */
     public function addFilter($filter)
     {
@@ -52,8 +51,8 @@ class State extends \Magento\Object
     /**
      * Set layer state filter items
      *
-     * @param   array $filters
-     * @return  \Magento\Catalog\Model\Layer\State
+     * @param  array $filters
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function setFilters($filters)
diff --git a/app/code/Magento/Catalog/Model/Observer.php b/app/code/Magento/Catalog/Model/Observer.php
index 12bf8d2369f73ca3723f5d5273510ef0ab1646b5..b5aa32f9a7d0b241a30b81b68b6a7b3bb2ed1a19 100644
--- a/app/code/Magento/Catalog/Model/Observer.php
+++ b/app/code/Magento/Catalog/Model/Observer.php
@@ -18,44 +18,31 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Catalog
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
-/**
- * Catalog Observer
- *
- * @category   Magento
- * @package    Magento_Catalog
- * @author     Magento Core Team <core@magentocommerce.com>
- */
 namespace Magento\Catalog\Model;
 
 class Observer
 {
     /**
-     * Catalog category flat
-     *
-     * @var \Magento\Catalog\Helper\Category\Flat
+     * @var Indexer\Category\Flat\State
      */
-    protected $_catalogCategoryFlat = null;
+    protected $categoryFlatConfig;
 
     /**
      * Catalog data
      *
      * @var \Magento\Catalog\Helper\Data
      */
-    protected $_catalogData = null;
+    protected $_catalogData;
 
     /**
      * Catalog category
      *
      * @var \Magento\Catalog\Helper\Category
      */
-    protected $_catalogCategory = null;
+    protected $_catalogCategory;
     
     /**
      * @var \Magento\App\ReinitableConfigInterface
@@ -104,13 +91,6 @@ class Observer
      */
     protected $_urlFactory;
 
-    /**
-     * Factory for category flat resource
-     *
-     * @var \Magento\Catalog\Model\Resource\Category\FlatFactory
-     */
-    protected $_flatResourceFactory;
-
     /**
      * Factory for product resource
      *
@@ -119,8 +99,6 @@ class Observer
     protected $_productResourceFactory;
 
     /**
-     * Constructor
-     *
      * @param \Magento\Catalog\Model\UrlFactory $urlFactory
      * @param \Magento\Catalog\Model\Resource\Category $categoryResource
      * @param \Magento\Catalog\Model\Resource\Product $catalogProduct
@@ -129,9 +107,8 @@ class Observer
      * @param \Magento\Index\Model\Indexer $indexIndexer
      * @param \Magento\Catalog\Helper\Category $catalogCategory
      * @param \Magento\Catalog\Helper\Data $catalogData
-     * @param \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat
+     * @param Indexer\Category\Flat\State $categoryFlatState
      * @param \Magento\App\ReinitableConfigInterface $coreConfig
-     * @param \Magento\Catalog\Model\Resource\Category\FlatFactory $flatResourceFactory
      * @param \Magento\Catalog\Model\Resource\ProductFactory $productResourceFactory
      */
     public function __construct(
@@ -143,9 +120,8 @@ class Observer
         \Magento\Index\Model\Indexer $indexIndexer,
         \Magento\Catalog\Helper\Category $catalogCategory,
         \Magento\Catalog\Helper\Data $catalogData,
-        \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat,
+        \Magento\Catalog\Model\Indexer\Category\Flat\State $categoryFlatState,
         \Magento\App\ReinitableConfigInterface $coreConfig,
-        \Magento\Catalog\Model\Resource\Category\FlatFactory $flatResourceFactory,
         \Magento\Catalog\Model\Resource\ProductFactory $productResourceFactory
     ) {
         $this->_urlFactory = $urlFactory;
@@ -157,152 +133,15 @@ class Observer
         $this->_coreConfig = $coreConfig;
         $this->_catalogCategory = $catalogCategory;
         $this->_catalogData = $catalogData;
-        $this->_catalogCategoryFlat = $catalogCategoryFlat;
-        $this->_flatResourceFactory = $flatResourceFactory;
+        $this->categoryFlatConfig = $categoryFlatState;
         $this->_productResourceFactory = $productResourceFactory;
     }
 
-    /**
-     * Process catalog ata related with store data changes
-     *
-     * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Catalog\Model\Observer
-     */
-    public function storeEdit(\Magento\Event\Observer $observer)
-    {
-        /** @var $store \Magento\Core\Model\Store */
-        $store = $observer->getEvent()->getStore();
-        if ($store->dataHasChangedFor('group_id')) {
-            $this->_storeManager->reinitStores();
-            /** @var $categoryFlatHelper \Magento\Catalog\Helper\Category\Flat */
-            $categoryFlatHelper = $this->_catalogCategoryFlat;
-            if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
-                $this->_flatResourceFactory->create()
-                    ->synchronize(null, array($store->getId()));
-            }
-            $this->_catalogProduct->refreshEnabledIndex($store);
-        }
-        return $this;
-    }
-
-    /**
-     * Process catalog data related with new store
-     *
-     * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Catalog\Model\Observer
-     */
-    public function storeAdd(\Magento\Event\Observer $observer)
-    {
-        /* @var $store \Magento\Core\Model\Store */
-        $store = $observer->getEvent()->getStore();
-        $this->_storeManager->reinitStores();
-        $this->_coreConfig->reinit();
-        /** @var $categoryFlatHelper \Magento\Catalog\Helper\Category\Flat */
-        $categoryFlatHelper = $this->_catalogCategoryFlat;
-        if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
-            $this->_flatResourceFactory->create()
-                ->synchronize(null, array($store->getId()));
-        }
-        $this->_productResourceFactory->create()->refreshEnabledIndex($store);
-        return $this;
-    }
-
-    /**
-     * Process catalog data related with store group root category
-     *
-     * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Catalog\Model\Observer
-     */
-    public function storeGroupSave(\Magento\Event\Observer $observer)
-    {
-        /* @var $group \Magento\Core\Model\Store\Group */
-        $group = $observer->getEvent()->getGroup();
-        if ($group->dataHasChangedFor('root_category_id') || $group->dataHasChangedFor('website_id')) {
-            $this->_storeManager->reinitStores();
-            foreach ($group->getStores() as $store) {
-                /** @var $categoryFlatHelper \Magento\Catalog\Helper\Category\Flat */
-                $categoryFlatHelper = $this->_catalogCategoryFlat;
-                if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
-                    $this->_flatResourceFactory->create()
-                        ->synchronize(null, array($store->getId()));
-                }
-            }
-        }
-        return $this;
-    }
-
-    /**
-     * Process delete of store
-     *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Observer
-     */
-    public function storeDelete(\Magento\Event\Observer $observer)
-    {
-        /** @var $categoryFlatHelper \Magento\Catalog\Helper\Category\Flat */
-        $categoryFlatHelper = $this->_catalogCategoryFlat;
-        if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
-            $store = $observer->getEvent()->getStore();
-            $this->_flatResourceFactory->create()->deleteStores($store->getId());
-        }
-        return $this;
-    }
-
-    /**
-     * Process catalog data after category move
-     *
-     * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Catalog\Model\Observer
-     */
-    public function categoryMove(\Magento\Event\Observer $observer)
-    {
-        $categoryId = $observer->getEvent()->getCategoryId();
-        $prevParentId = $observer->getEvent()->getPrevParentId();
-        $parentId = $observer->getEvent()->getParentId();
-        /** @var $categoryFlatHelper \Magento\Catalog\Helper\Category\Flat */
-        $categoryFlatHelper = $this->_catalogCategoryFlat;
-        if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
-            $this->_flatResourceFactory->create()
-                ->move($categoryId, $prevParentId, $parentId);
-        }
-        return $this;
-    }
-
-    /**
-     * Process catalog data after products import
-     *
-     * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Catalog\Model\Observer
-     */
-    public function catalogProductImportAfter(\Magento\Event\Observer $observer)
-    {
-        $this->_urlFactory->create()->refreshRewrites();
-        $this->_categoryResource->refreshProductIndex();
-        return $this;
-    }
-
-    /**
-     * After save event of category
-     *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Observer
-     */
-    public function categorySaveAfter(\Magento\Event\Observer $observer)
-    {
-        /** @var $categoryFlatHelper \Magento\Catalog\Helper\Category\Flat */
-        $categoryFlatHelper = $this->_catalogCategoryFlat;
-        if ($categoryFlatHelper->isAvailable() && $categoryFlatHelper->isBuilt()) {
-            $category = $observer->getEvent()->getCategory();
-            $this->_flatResourceFactory->create()->synchronize($category);
-        }
-        return $this;
-    }
-
     /**
      * Checking whether the using static urls in WYSIWYG allowed event
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Observer
+     * @return void
      */
     public function catalogCheckIsUsingStaticUrlsAllowed(\Magento\Event\Observer $observer)
     {
@@ -315,6 +154,7 @@ class Observer
      * Cron job method for product prices to reindex
      *
      * @param \Magento\Cron\Model\Schedule $schedule
+     * @return void
      */
     public function reindexProductPrices(\Magento\Cron\Model\Schedule $schedule)
     {
@@ -328,6 +168,7 @@ class Observer
      * Adds catalog categories to top menu
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function addCatalogToTopmenuItems(\Magento\Event\Observer $observer)
     {
@@ -342,6 +183,7 @@ class Observer
      *
      * @param \Magento\Data\Tree\Node\Collection|array $categories
      * @param \Magento\Data\Tree\Node $parentCategoryNode
+     * @return void
      */
     protected function _addCategoriesToMenu($categories, $parentCategoryNode)
     {
@@ -362,7 +204,7 @@ class Observer
             $categoryNode = new \Magento\Data\Tree\Node($categoryData, 'id', $tree, $parentCategoryNode);
             $parentCategoryNode->addChild($categoryNode);
 
-            if ($this->_catalogCategoryFlat->isEnabled()) {
+            if ($this->categoryFlatConfig->isFlatEnabled()) {
                 $subcategories = (array)$category->getChildrenNodes();
             } else {
                 $subcategories = $category->getChildren();
@@ -397,6 +239,7 @@ class Observer
      * Change product type on the fly depending on selected options
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function transitionProductType(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Catalog/Model/Observer/Reindex.php b/app/code/Magento/Catalog/Model/Observer/Reindex.php
index ba737f5b852293ee9ef4339761b53983dfb644f7..de0376884ad75a9e68bdc4af0281b253120b0b51 100644
--- a/app/code/Magento/Catalog/Model/Observer/Reindex.php
+++ b/app/code/Magento/Catalog/Model/Observer/Reindex.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Observer;
 
 /**
  * Catalog Observer Reindex
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Observer;
-
 class Reindex
 {
     /**
@@ -56,7 +55,7 @@ class Reindex
      * Reindex fulltext
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Observer\Reindex
+     * @return $this
      */
     public function fulltextReindex(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php
index 3eafc73268b30af8eec1be25ad37f9117052ba5a..a8f8d0b52f970812b2e5e2a857783e4c579ef92c 100644
--- a/app/code/Magento/Catalog/Model/Product.php
+++ b/app/code/Magento/Catalog/Model/Product.php
@@ -23,12 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model;
 
 /**
  * Catalog product model
  *
- * @method \Magento\Catalog\Model\Resource\Product getResource()
- * @method \Magento\Catalog\Model\Resource\Product _getResource()
+ * @method Resource\Product getResource()
+ * @method Resource\Product _getResource()
  * @method \Magento\Catalog\Model\Product setHasError(bool $value)
  * @method null|bool getHasError()
  * @method \Magento\Catalog\Model\Product setTypeId(string $typeId)
@@ -39,8 +40,6 @@
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  */
-namespace Magento\Catalog\Model;
-
 class Product extends \Magento\Catalog\Model\AbstractModel
 {
     /**
@@ -50,9 +49,25 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     const ENTITY                 = 'catalog_product';
 
     const CACHE_TAG              = 'catalog_product';
+
+    /**
+     * @var string
+     */
     protected $_cacheTag         = 'catalog_product';
+
+    /**
+     * @var string
+     */
     protected $_eventPrefix      = 'catalog_product';
+
+    /**
+     * @var string
+     */
     protected $_eventObject      = 'product';
+
+    /**
+     * @var bool
+     */
     protected $_canAffectOptions = false;
 
     /**
@@ -65,7 +80,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Product link instance
      *
-     * @var \Magento\Catalog\Model\Product\Link
+     * @var Product\Link
      */
     protected $_linkInstance;
 
@@ -79,26 +94,41 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Product Url Instance
      *
-     * @var \Magento\Catalog\Model\Product\Url
+     * @var Product\Url
      */
     protected $_urlModel = null;
 
+    /**
+     * @var string
+     */
     protected static $_url;
+
+    /**
+     * @var string
+     */
     protected static $_urlRewrite;
 
+    /**
+     * @var array
+     */
     protected $_errors = array();
 
     /**
      * Product option
      *
-     * @var \Magento\Catalog\Model\Product\Option
+     * @var Product\Option
      */
     protected $_optionInstance;
 
+    /**
+     * @var array
+     */
     protected $_options = array();
 
     /**
      * Product reserved attribute codes
+     *
+     * @var mixed
      */
     protected $_reservedAttributes;
 
@@ -145,7 +175,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Catalog product type
      *
-     * @var \Magento\Catalog\Model\Product\Type
+     * @var Product\Type
      */
     protected $_catalogProductType;
 
@@ -159,21 +189,21 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Catalog product media config
      *
-     * @var \Magento\Catalog\Model\Product\Media\Config
+     * @var Product\Media\Config
      */
     protected $_catalogProductMediaConfig;
 
     /**
      * Catalog product status
      *
-     * @var \Magento\Catalog\Model\Product\Status
+     * @var Product\Status
      */
     protected $_catalogProductStatus;
 
     /**
      * Catalog product visibility
      *
-     * @var \Magento\Catalog\Model\Product\Visibility
+     * @var Product\Visibility
      */
     protected $_catalogProductVisibility;
 
@@ -218,10 +248,10 @@ class Product extends \Magento\Catalog\Model\AbstractModel
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param Product\Url $url
      * @param Product\Link $productLink
-     * @param Product\Configuration\Item\OptionFactory $itemOptionFactory
+     * @param \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory
      * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory
-     * @param ProductFactory $productFactory
-     * @param CategoryFactory $categoryFactory
+     * @param \Magento\Catalog\Model\ProductFactory $productFactory
+     * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
      * @param Product\Option $catalogProductOption
      * @param Product\Visibility $catalogProductVisibility
      * @param Product\Status $catalogProductStatus
@@ -243,23 +273,23 @@ class Product extends \Magento\Catalog\Model\AbstractModel
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Catalog\Model\Product\Url $url,
-        \Magento\Catalog\Model\Product\Link $productLink,
+        Product\Url $url,
+        Product\Link $productLink,
         \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory,
         \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory,
         \Magento\Catalog\Model\ProductFactory $productFactory,
         \Magento\Catalog\Model\CategoryFactory $categoryFactory,
-        \Magento\Catalog\Model\Product\Option $catalogProductOption,
-        \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
-        \Magento\Catalog\Model\Product\Status $catalogProductStatus,
-        \Magento\Catalog\Model\Product\Media\Config $catalogProductMediaConfig,
+        Product\Option $catalogProductOption,
+        Product\Visibility $catalogProductVisibility,
+        Product\Status $catalogProductStatus,
+        Product\Media\Config $catalogProductMediaConfig,
         \Magento\Index\Model\Indexer $indexIndexer,
-        \Magento\Catalog\Model\Product\Type $catalogProductType,
+        Product\Type $catalogProductType,
         \Magento\Catalog\Helper\Image $catalogImage,
         \Magento\Catalog\Helper\Data $catalogData,
         \Magento\Catalog\Helper\Product $catalogProduct,
-        \Magento\Catalog\Model\Resource\Product $resource,
-        \Magento\Catalog\Model\Resource\Product\Collection $resourceCollection,
+        Resource\Product $resource,
+        Resource\Product\Collection $resourceCollection,
         \Magento\Data\CollectionFactory $collectionFactory,
         \Magento\App\Filesystem $filesystem,
         array $data = array()
@@ -286,6 +316,8 @@ class Product extends \Magento\Catalog\Model\AbstractModel
 
     /**
      * Initialize resources
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -320,7 +352,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Get product url model
      *
-     * @return \Magento\Catalog\Model\Product\Url
+     * @return Product\Url
      */
     public function getUrlModel()
     {
@@ -395,7 +427,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     public function getStatus()
     {
         if (is_null($this->_getData('status'))) {
-            $this->setData('status', \Magento\Catalog\Model\Product\Status::STATUS_ENABLED);
+            $this->setData('status', Product\Status::STATUS_ENABLED);
         }
         return $this->_getData('status');
     }
@@ -430,7 +462,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Retrieve link instance
      *
-     * @return  \Magento\Catalog\Model\Product\Link
+     * @return  Product\Link
      */
     public function getLinkInstance()
     {
@@ -571,6 +603,8 @@ class Product extends \Magento\Catalog\Model\AbstractModel
 
     /**
      * Check product options and type options and save them, too
+     *
+     * @return void
      */
     protected function _beforeSave()
     {
@@ -685,7 +719,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Init indexing process after product delete commit
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return void
      */
     protected function _afterDeleteCommit()
     {
@@ -698,7 +732,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Load product options if they exists
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -718,7 +752,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Clear cache related with product id
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return $this
      */
     public function cleanCache()
     {
@@ -749,8 +783,8 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Get product tier price by qty
      *
-     * @param   double $qty
-     * @return  double
+     * @param   float $qty
+     * @return  float|array
      */
     public function getTierPrice($qty=null)
     {
@@ -770,7 +804,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Get formated by currency tier price
      *
-     * @param   double $qty
+     * @param   float $qty
      * @return  array || double
      */
     public function getFormatedTierPrice($qty=null)
@@ -807,8 +841,8 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Get product final price
      *
-     * @param double $qty
-     * @return double
+     * @param float $qty
+     * @return float
      */
     public function getFinalPrice($qty=null)
     {
@@ -1137,7 +1171,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Retrieve product media config
      *
-     * @return \Magento\Catalog\Model\Product\Media\Config
+     * @return Product\Media\Config
      */
     public function getMediaConfig()
     {
@@ -1151,7 +1185,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
      */
     public function isConfigurable()
     {
-        return $this->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE;
+        return $this->getTypeId() == Product\Type::TYPE_CONFIGURABLE;
     }
 
     /**
@@ -1318,7 +1352,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
      */
     public function isInStock()
     {
-        return $this->getStatus() == \Magento\Catalog\Model\Product\Status::STATUS_ENABLED;
+        return $this->getStatus() == Product\Status::STATUS_ENABLED;
     }
 
     /**
@@ -1374,7 +1408,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Formats URL key
      *
-     * @param $str URL
+     * @param string $str URL
      * @return string
      */
     public function formatUrlKey($str)
@@ -1537,7 +1571,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Retrieve option instance
      *
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return Product\Option
      */
     public function getOptionInstance()
     {
@@ -1560,10 +1594,10 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Add option to array of product options
      *
-     * @param \Magento\Catalog\Model\Product\Option $option
+     * @param Product\Option $option
      * @return \Magento\Catalog\Model\Product
      */
-    public function addOption(\Magento\Catalog\Model\Product\Option $option)
+    public function addOption(Product\Option $option)
     {
         $this->_options[$option->getId()] = $option;
         return $this;
@@ -1573,7 +1607,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
      * Get option from options array of product by given option id
      *
      * @param int $optionId
-     * @return \Magento\Catalog\Model\Product\Option | null
+     * @return Product\Option|null
      */
     public function getOptionById($optionId)
     {
@@ -1609,8 +1643,8 @@ class Product extends \Magento\Catalog\Model\AbstractModel
      *
      * @param   string $code    Option code
      * @param   mixed  $value   Value of the option
-     * @param   int    $product Product ID
-     * @return  \Magento\Catalog\Model\Product
+     * @param   int|Product    $product Product ID
+     * @return  $this
      */
     public function addCustomOption($code, $value, $product=null)
     {
@@ -1784,7 +1818,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
     /**
      * Get cache tags associated with object id
      *
-     * @return array
+     * @return string[]
      */
     public function getCacheIdTags()
     {
@@ -1953,7 +1987,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel
      */
     public function isDisabled()
     {
-        return $this->getStatus() == \Magento\Catalog\Model\Product\Status::STATUS_DISABLED;
+        return $this->getStatus() == Product\Status::STATUS_DISABLED;
     }
 
     /**
diff --git a/app/code/Magento/Catalog/Model/Product/Action.php b/app/code/Magento/Catalog/Model/Product/Action.php
index 3e5011859cb037f262b4da567359cf9982a13981..c9a33e9c422e96816d7f7e730b2a9c7c420cd96f 100644
--- a/app/code/Magento/Catalog/Model/Product/Action.php
+++ b/app/code/Magento/Catalog/Model/Product/Action.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Product;
 
 /**
  * Catalog Product Mass Action processing model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product;
-
 class Action extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -76,6 +74,7 @@ class Action extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -98,7 +97,7 @@ class Action extends \Magento\Core\Model\AbstractModel
      * @param array $productIds
      * @param array $attrData
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Product\Action
+     * @return $this
      */
     public function updateAttributes($productIds, $attrData, $storeId)
     {
@@ -125,13 +124,14 @@ class Action extends \Magento\Core\Model\AbstractModel
     /**
      * Update websites for product action
      *
-     * allowed types:
+     * Allowed types:
      * - add
      * - remove
      *
      * @param array $productIds
      * @param array $websiteIds
      * @param string $type
+     * @return void
      */
     public function updateWebsites($productIds, $websiteIds, $type)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Boolean.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Boolean.php
index 900efb443e83aedbe7c4f68691bdff088f84c7ba..7f0965137e04e0a71b2385beba2ad7a60ee4ee27 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Boolean.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Boolean.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
 /**
  * Product attribute for enable/disable option
@@ -31,15 +32,13 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Attribute\Backend;
-
 class Boolean extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
      * Set attribute default value if value empty
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Boolean
+     * @return $this
      */
     public function beforeSave($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Category.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Category.php
index 5c3fb9b64849bf5a1729f00d8ea37da5ecae087e..f889fe422d39bccba899f2e7095df997336a3db0 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Category.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Category.php
@@ -39,7 +39,7 @@ class Category extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke
      * Set category ids to product data
      *
      * @param \Magento\Catalog\Model\Product $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
+     * @return $this
      */
     public function afterLoad($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php
index 3aa56d5ba6cedf4650f5d585b2f3377dceec1586..f0a633b1b1bd8396609e7ba6eb0fed599f642f6e 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php
@@ -249,7 +249,7 @@ abstract class AbstractGroupprice
      * Assign group prices to product data
      *
      * @param \Magento\Catalog\Model\Product $object
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Groupprice\AbstractGroupprice
+     * @return $this
      */
     public function afterLoad($object)
     {
@@ -287,7 +287,7 @@ abstract class AbstractGroupprice
      * After Save Attribute manipulation
      *
      * @param \Magento\Catalog\Model\Product $object
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Groupprice\AbstractGroupprice
+     * @return $this
      */
     public function afterSave($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php
index 95affc66f284fba0a24d6c4cd74d61d0c2773d07..af397d302eaf6f9407432b2a09f1b3d5d77e2b09 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php
@@ -33,8 +33,13 @@
  */
 namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
+use Magento\Core\Exception;
+
 class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
+    /**
+     * @var array
+     */
     protected $_renamedImages = array();
 
     /**
@@ -145,6 +150,11 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
         return $this;
     }
 
+    /**
+     * @param string $key
+     * @param string[] &$image
+     * @return string
+     */
     protected function _getDefaultValue($key, &$image)
     {
         if (isset($image[$key . '_default'])) {
@@ -158,8 +168,8 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Validate media_gallery attribute data
      *
      * @param \Magento\Catalog\Model\Product $object
-     * @throws \Magento\Core\Exception
      * @return bool
+     * @throws Exception
      */
     public function validate($object)
     {
@@ -174,7 +184,7 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
         if ($this->getAttribute()->getIsUnique()) {
             if (!$this->getAttribute()->getEntity()->checkAttributeUniqueValue($this->getAttribute(), $object)) {
                 $label = $this->getAttribute()->getFrontend()->getLabel();
-                throw new \Magento\Core\Exception(
+                throw new Exception(
                     __('The value of attribute "%1" must be unique.', $label)
                 );
             }
@@ -183,6 +193,10 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
         return true;
     }
 
+    /**
+     * @param \Magento\Object $object
+     * @return $this|void
+     */
     public function beforeSave($object)
     {
         $attrCode = $this->getAttribute()->getAttributeCode();
@@ -269,6 +283,10 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
         return $file;
     }
 
+    /**
+     * @param \Magento\Object $object
+     * @return void
+     */
     public function afterSave($object)
     {
         if ($object->getIsDuplicate() == true) {
@@ -340,25 +358,25 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param string                     $file              file path of image in file system
-     * @param string|array               $mediaAttribute    code of attribute with type 'media_image',
+     * @param string|string[]            $mediaAttribute    code of attribute with type 'media_image',
      *                                                      leave blank if image should be only in gallery
      * @param boolean                    $move              if true, it will move source file
      * @param boolean                    $exclude           mark image as disabled in product page view
      * @return string
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      */
     public function addImage(\Magento\Catalog\Model\Product $product, $file,
         $mediaAttribute = null, $move = false, $exclude = true
     ) {
         $file = $this->_mediaDirectory->getRelativePath($file);
         if (!$this->_mediaDirectory->isFile($file)) {
-            throw new \Magento\Core\Exception(__('The image does not exist.'));
+            throw new Exception(__('The image does not exist.'));
         }
 
         $pathinfo = pathinfo($file);
         $imgExtensions = array('jpg','jpeg','gif','png');
         if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), $imgExtensions)) {
-            throw new \Magento\Core\Exception(__('Please correct the image file type.'));
+            throw new Exception(__('Please correct the image file type.'));
         }
 
         $fileName       = \Magento\Core\Model\File\Uploader::getCorrectFileName($pathinfo['basename']);
@@ -384,7 +402,7 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
                 $this->_mediaDirectory->changePermissions($destinationFile, 0777);
             }
         } catch (\Exception $e) {
-            throw new \Magento\Core\Exception(
+            throw new Exception(
                 __('We couldn\'t move this file: %1.', $e->getMessage())
             );
         }
@@ -465,7 +483,7 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * @param \Magento\Catalog\Model\Product $product
      * @param string $file
      * @param array $data
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function updateImage(\Magento\Catalog\Model\Product $product, $file, $data)
     {
@@ -503,7 +521,7 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param string $file
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function removeImage(\Magento\Catalog\Model\Product $product, $file)
     {
@@ -554,8 +572,8 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Clear media attribute value
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @param string|array $mediaAttribute
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Media
+     * @param string|string[] $mediaAttribute
+     * @return $this
      */
     public function clearMediaAttribute(\Magento\Catalog\Model\Product $product, $mediaAttribute)
     {
@@ -578,9 +596,9 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Set media attribute value
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @param string|array $mediaAttribute
+     * @param string|string[] $mediaAttribute
      * @param string $value
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function setMediaAttribute(\Magento\Catalog\Model\Product $product, $mediaAttribute, $value)
     {
@@ -668,6 +686,7 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      *
      * @param string $file
      * @return string
+     * @throws Exception
      */
     protected function _copyImage($file)
     {
@@ -694,12 +713,16 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
             return str_replace('\\', '/', $destinationFile);
         } catch (\Exception $e) {
             $file = $this->_mediaConfig->getMediaPath($file);
-            throw new \Magento\Core\Exception(
+            throw new Exception(
                 __('We couldn\'t copy file %1. Please delete media with non-existing images and try again.', $file)
             );
         }
     }
 
+    /**
+     * @param \Magento\Object $object
+     * @return $this
+     */
     public function duplicate($object)
     {
         $attrCode = $this->getAttribute()->getAttributeCode();
@@ -722,9 +745,9 @@ class Media extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Get filename which is not duplicated with other files in media temporary and media directories
      *
-     * @param String $fileName
-     * @param String $dispretionPath
-     * @return String
+     * @param string $fileName
+     * @param string $dispretionPath
+     * @return string
      */
     protected function _getNotDuplicatedFilename($fileName, $dispretionPath)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Msrp.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Msrp.php
index 95262793272e11cbd596a078b74ff7cc12b94fe9..b3f512697a2dc2ca304760770c6ab62657957ab3 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Msrp.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Msrp.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
 /**
  * Product attribute for `Apply MAP` enable/disable option
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Attribute\Backend;
-
 class Msrp extends \Magento\Catalog\Model\Product\Attribute\Backend\Boolean
 {
     /**
@@ -43,6 +42,8 @@ class Msrp extends \Magento\Catalog\Model\Product\Attribute\Backend\Boolean
     protected $_catalogData = null;
 
     /**
+     * Constructor
+     *
      * @param \Magento\Logger $logger
      * @param \Magento\Catalog\Helper\Data $catalogData
      */
@@ -58,7 +59,7 @@ class Msrp extends \Magento\Catalog\Model\Product\Attribute\Backend\Boolean
      * Disable MAP if it's bundle with dynamic price type
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return bool
+     * @return $this
      */
     public function beforeSave($product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php
index 96c5d04af8d6807db0d02e71867766853933fd49..8850c0f93f567a9749747aeda2cab13a5f98b584 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
 /**
  * Catalog product price attribute backend model
@@ -32,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Attribute\Backend;
-
 class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
@@ -92,7 +90,7 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Rewrite for redefine attribute scope
      *
      * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Price
+     * @return $this
      */
     public function setAttribute($attribute)
     {
@@ -105,7 +103,7 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Redefine Attribute scope
      *
      * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Price
+     * @return $this
      */
     public function setScope($attribute)
     {
@@ -122,7 +120,7 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * After Save Attribute manipulation
      *
      * @param \Magento\Catalog\Model\Product $object
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Price
+     * @return $this
      */
     public function afterSave($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Recurring.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Recurring.php
index d027e6f130e8d1779df1033bf1895db55b85abb1..796877cbeddf70526bd4b10cdc359e7e8053fea0 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Recurring.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Recurring.php
@@ -34,7 +34,9 @@ extends \Magento\Eav\Model\Entity\Attribute\Backend\Serialized
 {
     /**
      * Serialize or remove before saving
+     *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     public function beforeSave($product)
     {
@@ -49,7 +51,9 @@ extends \Magento\Eav\Model\Entity\Attribute\Backend\Serialized
 
     /**
      * Unserialize or remove on failure
+     *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     protected function _unserialize(\Magento\Object $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php
index 8518352350621b846f7f14d079c2fc6c8acf3090..04ff1d9f2940f1246219f5c17a2929d211a1d0c8 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php
@@ -24,7 +24,6 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-
 /**
  * Catalog product SKU backend attribute model
  *
@@ -34,6 +33,8 @@
  */
 namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
+use Magento\Catalog\Model\Product;
+
 class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
@@ -65,7 +66,7 @@ class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Validate SKU
      *
-     * @param \Magento\Catalog\Model\Product $object
+     * @param Product $object
      * @throws \Magento\Core\Exception
      * @return bool
      */
@@ -88,7 +89,8 @@ class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Generate and set unique SKU to product
      *
-     * @param $object \Magento\Catalog\Model\Product
+     * @param Product $object
+     * @return void
      */
     protected function _generateUniqueSku($object)
     {
@@ -109,8 +111,8 @@ class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Make SKU unique before save
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Product\Attribute\Backend\Sku
+     * @param Product $object
+     * @return $this
      */
     public function beforeSave($object)
     {
@@ -122,7 +124,7 @@ class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Return increment needed for SKU uniqueness
      *
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
-     * @param \Magento\Catalog\Model\Product $object
+     * @param Product $object
      * @return int
      */
     protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php
index 04cd43c2a4d40d503bd5de2803b65a8840d33919..4f9ee7e28a182fd5d75220e7f15182c4e23f1ee7 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
 /**
  *
@@ -32,9 +33,6 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Catalog\Model\Product\Attribute\Backend;
-
 class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime
 {
     /**
@@ -45,6 +43,8 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime
     protected $_date;
 
     /**
+     * Constructor
+     *
      * @param \Magento\Logger $logger
      * @param \Magento\Core\Model\LocaleInterface $locale
      * @param \Magento\Core\Model\Date $date
@@ -78,13 +78,13 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime
         return $startDate;
     }
 
-   /**
-    * Before save hook.
-    * Prepare attribute value for save
-    *
-    * @param \Magento\Object $object
-    * @return \Magento\Catalog\Model\Product\Attribute\Backend\Startdate
-    */
+    /**
+     * Before save hook.
+     * Prepare attribute value for save
+     *
+     * @param \Magento\Object $object
+     * @return $this
+     */
     public function beforeSave($object)
     {
         $startDate = $this->_getValueForSave($object);
@@ -97,14 +97,14 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime
         return $this;
     }
 
-   /**
-    * Product from date attribute validate function.
-    * In case invalid data throws exception.
-    *
-    * @param \Magento\Object $object
-    * @throws \Magento\Eav\Model\Entity\Attribute\Exception
-    * @return bool
-    */
+    /**
+     * Product from date attribute validate function.
+     * In case invalid data throws exception.
+     *
+     * @param \Magento\Object $object
+     * @throws \Magento\Eav\Model\Entity\Attribute\Exception
+     * @return bool
+     */
     public function validate($object)
     {
         $attr      = $this->getAttribute();
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php
index 1bdc260117a6baff2a1d85309613a25fdfe951dd..df4eec0a9c6ed1b31f8830666b9b55837497d1bf 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Stock.php
@@ -34,6 +34,8 @@
  */
 namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
+use Magento\Catalog\Model\Product;
+
 class Stock extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
@@ -60,8 +62,8 @@ class Stock extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Set inventory data to custom attribute
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
+     * @param Product $object
+     * @return $this
      */
     public function afterLoad($object)
     {
@@ -80,8 +82,8 @@ class Stock extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Prepare inventory data from custom attribute
      *
-     * @param \Magento\Catalog\Model\Product $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|void
+     * @param Product $object
+     * @return void
      */
     public function beforeSave($object)
     {
@@ -99,7 +101,7 @@ class Stock extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
     /**
      * Validate
      *
-     * @param \Magento\Catalog\Model\Product $object
+     * @param Product $object
      * @throws \Magento\Core\Exception
      * @return bool
      */
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Urlkey.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Urlkey.php
index 45b574e298590e3b7cc1f4ecb86cc9ef788df799..fa8b8486e21d8096b3c09da010170529b9e99a23 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Urlkey.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Urlkey.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Attribute\Backend;
 
 /**
  * Product url key attribute backend
@@ -31,11 +32,12 @@
  * @package    Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Catalog\Model\Product\Attribute\Backend;
-
 class Urlkey extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
+    /**
+     * @param \Magento\Object $object
+     * @return $this
+     */
     public function beforeSave($object)
     {
         $attributeName = $this->getAttribute()->getName();
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php
index 37b23109f743e451e010c235ad57f96aa9e7a1bf..96c34b41d3621355cfc5b618eefac48144cc8c7c 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php
@@ -75,7 +75,7 @@ class Countryofmanufacture
     /**
      * Get list of all available countries
      *
-     * @return mixed
+     * @return array
      */
     public function getAllOptions()
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php
index d0ca9d5ce0e205b8dcb08d87af2056e86c04199a..58452446ce6b92d5295d83a62a23f26e611460b3 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Attribute\Source;
 
 /**
  * Catalog product landing page attribute source
@@ -31,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Attribute\Source;
-
 class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
     /**
@@ -53,6 +52,9 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
         $this->_pageSourceLayout = $pageSourceLayout;
     }
 
+    /**
+     * @return array
+     */
     public function getAllOptions()
     {
         if (!$this->_options) {
diff --git a/app/code/Magento/Catalog/Model/Product/CatalogPrice.php b/app/code/Magento/Catalog/Model/Product/CatalogPrice.php
index 47dca13bd137edfe321b04859ec3108100ac2965..1f51183310db5164d7334d145788dfa8cd1debb0 100644
--- a/app/code/Magento/Catalog/Model/Product/CatalogPrice.php
+++ b/app/code/Magento/Catalog/Model/Product/CatalogPrice.php
@@ -76,8 +76,8 @@ class CatalogPrice implements CatalogPriceInterface
      * Regular catalog price
      *
      * @param \Magento\Catalog\Model\Product $product
+     * @return float
      * @throws \UnexpectedValueException
-     * @return null
      */
     public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php b/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php
index 4f5896ef26a9f86f25990f168dc6326680de8c12..505270d324a9d9b5631f1faecad110e1c7e596c0 100644
--- a/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php
+++ b/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php
@@ -43,7 +43,7 @@ interface CatalogPriceInterface
      * Calculate price without discount for external catalogs if applicable
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return mixed
+     * @return float|null
      */
     public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product);
 }
\ No newline at end of file
diff --git a/app/code/Magento/Catalog/Model/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Product/Compare/Item.php
index b22e870ea5460b8d4d048aa797bb3d46a0952a50..5298d7e7d9098590dc826e8057dcc5a6d210e6e1 100644
--- a/app/code/Magento/Catalog/Model/Product/Compare/Item.php
+++ b/app/code/Magento/Catalog/Model/Product/Compare/Item.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Compare;
 
+use Magento\Catalog\Model\Product;
 
 /**
  * Catalog Compare Item Model
@@ -40,8 +42,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Compare;
-
 class Item extends \Magento\Core\Model\AbstractModel
 {
 
@@ -121,6 +121,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resourse model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -140,7 +141,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Set current store before save
      *
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -156,7 +157,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Add customer data from customer object
      *
      * @param \Magento\Customer\Model\Customer $customer
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @return $this
      */
     public function addCustomerData(\Magento\Customer\Model\Customer $customer)
     {
@@ -168,7 +169,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Set visitor
      *
      * @param int $visitorId
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @return $this
      */
     public function addVisitorId($visitorId)
     {
@@ -179,8 +180,8 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Load compare item by product
      *
-     * @param mixed $product
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @param Product|int $product
+     * @return $this
      */
     public function loadByProduct($product)
     {
@@ -191,15 +192,14 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Set product data
      *
-     * @param mixed $product
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @param Product|int $product
+     * @return $this
      */
     public function addProductData($product)
     {
-        if ($product instanceof \Magento\Catalog\Model\Product) {
+        if ($product instanceof Product) {
             $this->setProductId($product->getId());
-        }
-        else if(intval($product)) {
+        } elseif (intval($product)) {
             $this->setProductId(intval($product));
         }
 
@@ -224,7 +224,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Customer login bind process
      *
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @return $this
      */
     public function bindCustomerLogin()
     {
@@ -238,7 +238,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Customer logout bind process
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @return $this
      */
     public function bindCustomerLogout(\Magento\Event\Observer $observer = null)
     {
@@ -251,7 +251,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Clean compare items
      *
-     * @return \Magento\Catalog\Model\Product\Compare\Item
+     * @return $this
      */
     public function clean()
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php
index 20360950900634aa4d4059316c7f38ac92bd9b9a..36c91702ebe40a2fee0dd03b2a1c0cb04af360cf 100644
--- a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php
+++ b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Catalog\Model\Product\Compare;
 
+use Magento\Catalog\Model\Resource\Product\Compare\Item\Collection;
+
 /**
  * Product Compare List Model
  *
@@ -98,7 +100,7 @@ class ListCompare extends \Magento\Object
      * Add product to Compare List
      *
      * @param int|\Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Compare\ListCompare
+     * @return $this
      */
     public function addProduct($product)
     {
@@ -118,8 +120,8 @@ class ListCompare extends \Magento\Object
     /**
      * Add products to compare list
      *
-     * @param array $productIds
-     * @return \Magento\Catalog\Model\Product\Compare\ListCompare
+     * @param string[] $productIds
+     * @return $this
      */
     public function addProducts($productIds)
     {
@@ -134,7 +136,7 @@ class ListCompare extends \Magento\Object
     /**
      * Retrieve Compare Items Collection
      *
-     * @return product_compare_item_collection
+     * @return Collection
      */
     public function getItemCollection()
     {
@@ -145,7 +147,7 @@ class ListCompare extends \Magento\Object
      * Remove product from compare list
      *
      * @param int|\Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Compare\ListCompare
+     * @return $this
      */
     public function removeProduct($product)
     {
@@ -165,7 +167,7 @@ class ListCompare extends \Magento\Object
      * Add visitor and customer data to compare item
      *
      * @param \Magento\Catalog\Model\Product\Compare\Item $item
-     * @return \Magento\Catalog\Model\Product\Compare\ListCompare
+     * @return $this
      */
     protected function _addVisitorToItem($item)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Condition.php b/app/code/Magento/Catalog/Model/Product/Condition.php
index 1cc3135913f487d1f4883c79d788020929aa075b..38ac43a0e4cee23c1da3894f665ed152fe668b69 100644
--- a/app/code/Magento/Catalog/Model/Product/Condition.php
+++ b/app/code/Magento/Catalog/Model/Product/Condition.php
@@ -26,8 +26,16 @@
 
 namespace Magento\Catalog\Model\Product;
 
+use Magento\DB\Adapter\AdapterInterface;
+use Magento\DB\Select;
+use Magento\Eav\Model\Entity\Collection\AbstractCollection;
+
 class Condition extends \Magento\Object implements \Magento\Catalog\Model\Product\Condition\ConditionInterface
 {
+    /**
+     * @param AbstractCollection $collection
+     * @return $this
+     */
     public function applyToCollection($collection)
     {
         if ($this->getTable() && $this->getPkFieldName()) {
@@ -40,6 +48,10 @@ class Condition extends \Magento\Object implements \Magento\Catalog\Model\Produc
         return $this;
     }
 
+    /**
+     * @param AdapterInterface $dbAdapter
+     * @return Select|string
+     */
     public function getIdsSelect($dbAdapter)
     {
         if ($this->getTable() && $this->getPkFieldName()) {
diff --git a/app/code/Magento/Catalog/Model/Product/Condition/ConditionInterface.php b/app/code/Magento/Catalog/Model/Product/Condition/ConditionInterface.php
index f750900394fdb988dc7b18e7e23cd43e27be8a3d..22f3b91c3a9f19927bc124e2190c9d383799952d 100644
--- a/app/code/Magento/Catalog/Model/Product/Condition/ConditionInterface.php
+++ b/app/code/Magento/Catalog/Model/Product/Condition/ConditionInterface.php
@@ -26,8 +26,21 @@
 
 namespace Magento\Catalog\Model\Product\Condition;
 
+use Magento\DB\Adapter\AdapterInterface;
+use Magento\DB\Select;
+use Magento\Eav\Model\Entity\Collection\AbstractCollection;
+
 interface ConditionInterface
 {
+    /**
+     * @param AbstractCollection $collection
+     * @return $this
+     */
     public function applyToCollection($collection);
+
+    /**
+     * @param AdapterInterface $dbAdapter
+     * @return Select|string
+     */
     public function getIdsSelect($dbAdapter);
 }
diff --git a/app/code/Magento/Catalog/Model/Product/Configuration/Item/Option.php b/app/code/Magento/Catalog/Model/Product/Configuration/Item/Option.php
index 45f85695da42eb3b230c771b764aa49e5e59ba8d..e2e2f7d852a48607e696a14ebaadd4d3b74a216e 100644
--- a/app/code/Magento/Catalog/Model/Product/Configuration/Item/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Configuration/Item/Option.php
@@ -38,6 +38,7 @@ class Option extends \Magento\Object
 {
     /**
      * Returns value of this option
+     *
      * @return mixed
      */
     public function getValue()
diff --git a/app/code/Magento/Catalog/Model/Product/CopyConstructor/Composite.php b/app/code/Magento/Catalog/Model/Product/CopyConstructor/Composite.php
index d52fedd25ac1a99aee5b0e78374194350c4dfb7a..e40c85fbc617a67502be81cd8efc76e77781bfe1 100644
--- a/app/code/Magento/Catalog/Model/Product/CopyConstructor/Composite.php
+++ b/app/code/Magento/Catalog/Model/Product/CopyConstructor/Composite.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Product\CopyConstructor;
 
 use Magento\Catalog\Model\Product\CopyConstructorInterface;
@@ -36,7 +35,7 @@ class Composite implements CopyConstructorInterface
 
     /**
      * @param CopyConstructorFactory $factory
-     * @param array $constructors
+     * @param string[] $constructors
      */
     public function __construct(CopyConstructorFactory $factory, array $constructors = array())
     {
@@ -50,6 +49,7 @@ class Composite implements CopyConstructorInterface
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param \Magento\Catalog\Model\Product $duplicate
+     * @return void
      */
     public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate)
     {
@@ -57,4 +57,4 @@ class Composite implements CopyConstructorInterface
             $constructor->build($product, $duplicate);
         }
     }
-} 
+}
diff --git a/app/code/Magento/Catalog/Model/Product/CopyConstructor/CrossSell.php b/app/code/Magento/Catalog/Model/Product/CopyConstructor/CrossSell.php
index fa2ca0dcaaab785aaa2f9144042e2c4eda725de4..f6b75b03d33ea10fbe93330bce2e58527edc08e2 100644
--- a/app/code/Magento/Catalog/Model/Product/CopyConstructor/CrossSell.php
+++ b/app/code/Magento/Catalog/Model/Product/CopyConstructor/CrossSell.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Product\CopyConstructor;
 
 class CrossSell implements \Magento\Catalog\Model\Product\CopyConstructorInterface
@@ -31,6 +30,7 @@ class CrossSell implements \Magento\Catalog\Model\Product\CopyConstructorInterfa
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param \Magento\Catalog\Model\Product $duplicate
+     * @return void
      */
     public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate)
     {
@@ -49,4 +49,4 @@ class CrossSell implements \Magento\Catalog\Model\Product\CopyConstructorInterfa
         }
         $duplicate->setCrossSellLinkData($data);
     }
-} 
+}
diff --git a/app/code/Magento/Catalog/Model/Product/CopyConstructor/Related.php b/app/code/Magento/Catalog/Model/Product/CopyConstructor/Related.php
index a5c31177e02bbcaf4b710618ba46873f1a43c45e..97abebb8781e16e1deeee10525ae74dc80a41e70 100644
--- a/app/code/Magento/Catalog/Model/Product/CopyConstructor/Related.php
+++ b/app/code/Magento/Catalog/Model/Product/CopyConstructor/Related.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Product\CopyConstructor;
 
 class Related implements \Magento\Catalog\Model\Product\CopyConstructorInterface
@@ -31,6 +30,7 @@ class Related implements \Magento\Catalog\Model\Product\CopyConstructorInterface
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param \Magento\Catalog\Model\Product $duplicate
+     * @return void
      */
     public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate)
     {
@@ -50,4 +50,4 @@ class Related implements \Magento\Catalog\Model\Product\CopyConstructorInterface
         }
         $duplicate->setRelatedLinkData($data);
     }
-} 
+}
diff --git a/app/code/Magento/Catalog/Model/Product/CopyConstructor/UpSell.php b/app/code/Magento/Catalog/Model/Product/CopyConstructor/UpSell.php
index 0408c85c32cf9968aa2014642979fc2784e140ee..efd1f221afb81aa6e0c6bdaab3c52ff2e37e49fe 100644
--- a/app/code/Magento/Catalog/Model/Product/CopyConstructor/UpSell.php
+++ b/app/code/Magento/Catalog/Model/Product/CopyConstructor/UpSell.php
@@ -31,6 +31,7 @@ class UpSell implements \Magento\Catalog\Model\Product\CopyConstructorInterface
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param \Magento\Catalog\Model\Product $duplicate
+     * @return void
      */
     public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate)
     {
@@ -49,4 +50,4 @@ class UpSell implements \Magento\Catalog\Model\Product\CopyConstructorInterface
         }
         $duplicate->setUpSellLinkData($data);
     }
-} 
+}
diff --git a/app/code/Magento/Catalog/Model/Product/CopyConstructorInterface.php b/app/code/Magento/Catalog/Model/Product/CopyConstructorInterface.php
index 2688fc7f762c81d220e1fecc4e05e630e2c00420..5ade3a054ac3b07f04131eb027c7a50d3ef1139d 100644
--- a/app/code/Magento/Catalog/Model/Product/CopyConstructorInterface.php
+++ b/app/code/Magento/Catalog/Model/Product/CopyConstructorInterface.php
@@ -31,6 +31,7 @@ interface CopyConstructorInterface
      *
      * @param \Magento\Catalog\Model\Product $product
      * @param \Magento\Catalog\Model\Product $duplicate
+     * @return void
      */
     public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate);
-} 
+}
diff --git a/app/code/Magento/Catalog/Model/Product/Flat/Flag.php b/app/code/Magento/Catalog/Model/Product/Flat/Flag.php
index 887d04c252c3f17a2e834266ca380fb9ae4d0e5d..a64df7dd3ede588ab3741992fedb978d8c1b6486 100644
--- a/app/code/Magento/Catalog/Model/Product/Flat/Flag.php
+++ b/app/code/Magento/Catalog/Model/Product/Flat/Flag.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Product\Flat;
 
 /**
  * Calatog Product Flat Flag Model
@@ -32,8 +32,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Flat;
-
 class Flag extends \Magento\Core\Model\Flag
 {
     /**
@@ -78,7 +76,7 @@ class Flag extends \Magento\Core\Model\Flag
      *
      * @param bool $flag
      *
-     * @return \Magento\Catalog\Model\Product\Flat\Flag
+     * @return $this
      */
     public function setIsBuilt($flag)
     {
@@ -91,11 +89,10 @@ class Flag extends \Magento\Core\Model\Flag
     /**
      * Set Catalog Product Flat Data is built flag
      *
-     * @deprecated after 1.7.0.0 use \Magento\Catalog\Model\Product\Flat\Flag::setIsBuilt() instead
-     *
      * @param bool $flag
+     * @return $this
      *
-     * @return \Magento\Catalog\Model\Product\Flat\Flag
+     * @deprecated after 1.7.0.0 use \Magento\Catalog\Model\Product\Flat\Flag::setIsBuilt() instead
      */
     public function setIsBuild($flag)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Flat/Indexer.php b/app/code/Magento/Catalog/Model/Product/Flat/Indexer.php
index 148389a4f57053810812f775cd3fb938e82a9f54..70608ed1f257385b3e54ffd7af7e9f222e627acf 100644
--- a/app/code/Magento/Catalog/Model/Product/Flat/Indexer.php
+++ b/app/code/Magento/Catalog/Model/Product/Flat/Indexer.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Product\Flat;
 
 /**
  * Catalog Product Flat Indexer Model
@@ -51,8 +51,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Flat;
-
 class Indexer extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -103,8 +101,9 @@ class Indexer extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * Standart model resource initialization
+     * Standard model resource initialization
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -114,8 +113,8 @@ class Indexer extends \Magento\Core\Model\AbstractModel
     /**
      * Rebuild Catalog Product Flat Data
      *
-     * @param mixed $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @param int $store
+     * @return $this
      */
     public function rebuild($store = null)
     {
@@ -138,7 +137,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      * @param string $attributeCode
      * @param int $store
      * @param int|array $productIds
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function updateAttribute($attributeCode, $store = null, $productIds = null)
     {
@@ -162,7 +161,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      * Prepare datastorage for catalog product flat
      *
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function prepareDataStorage($store = null)
     {
@@ -183,7 +182,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      * Update events observer attributes
      *
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function updateEventAttributes($store = null)
     {
@@ -208,7 +207,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      * @param int $productId
      * @param int $status
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function updateProductStatus($productId, $status, $store = null)
     {
@@ -234,7 +233,8 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      *
      * @param int|array $productIds
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
+     * @throws \Exception
      */
     public function updateProduct($productIds, $store = null)
     {
@@ -265,7 +265,8 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      *
      * @param int|array $productIds
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
+     * @throws \Exception
      */
     public function saveProduct($productIds, $store = null)
     {
@@ -296,7 +297,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      *
      * @param int|array $productIds
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function removeProduct($productIds, $store = null)
     {
@@ -316,7 +317,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
      * Delete store process
      *
      * @param int $store
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function deleteStore($store)
     {
@@ -327,7 +328,7 @@ class Indexer extends \Magento\Core\Model\AbstractModel
     /**
      * Rebuild Catalog Product Flat Data for all stores
      *
-     * @return \Magento\Catalog\Model\Product\Flat\Indexer
+     * @return $this
      */
     public function reindexAll()
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Flat/Observer.php b/app/code/Magento/Catalog/Model/Product/Flat/Observer.php
index a0ac83d5ce319dd9036755f768d8a676be84d3bb..24f5847f311ae17aaa2b399300756d11e7fb1d84 100644
--- a/app/code/Magento/Catalog/Model/Product/Flat/Observer.php
+++ b/app/code/Magento/Catalog/Model/Product/Flat/Observer.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Product\Flat;
 
+use Magento\Event\Observer as EventObserver;
+
 /**
  * Catalog Product Flat observer
  *
@@ -86,17 +87,18 @@ class Observer
      *
      * @return \Magento\Catalog\Model\Product\Flat\Indexer
      */
-    protected function _getIndexer() {
+    protected function _getIndexer()
+    {
         return $this->_catalogProductFlatIndexer;
     }
 
     /**
      * Catalog Entity attribute after save process
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function catalogEntityAttributeSaveAfter(\Magento\Event\Observer $observer)
+    public function catalogEntityAttributeSaveAfter(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -121,8 +123,7 @@ class Observer
         if ($enableBefore && !$enableAfter) {
             // delete attribute data from flat
             $this->_getIndexer()->prepareDataStorage();
-        }
-        else {
+        } else {
             $this->_getIndexer()->updateAttribute($attribute->getAttributeCode());
         }
 
@@ -132,10 +133,10 @@ class Observer
     /**
      * Catalog Product Status Update
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function catalogProductStatusUpdate(\Magento\Event\Observer $observer)
+    public function catalogProductStatusUpdate(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -154,10 +155,10 @@ class Observer
     /**
      * Catalog Product Website(s) update
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function catalogProductWebsiteUpdate(\Magento\Event\Observer $observer)
+    public function catalogProductWebsiteUpdate(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -171,8 +172,7 @@ class Observer
             foreach ($website->getStores() as $store) {
                 if ($observer->getEvent()->getAction() == 'remove') {
                     $this->_getIndexer()->removeProduct($productIds, $store->getId());
-                }
-                else {
+                } else {
                     $this->_getIndexer()->updateProduct($productIds, $store->getId());
                 }
             }
@@ -184,10 +184,10 @@ class Observer
     /**
      * Catalog Product After Save
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function catalogProductSaveAfter(\Magento\Event\Observer $observer) {
+    public function catalogProductSaveAfter(EventObserver $observer) {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
         }
@@ -203,10 +203,10 @@ class Observer
     /**
      * Add new store flat process
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function storeAdd(\Magento\Event\Observer $observer)
+    public function storeAdd(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -222,10 +222,10 @@ class Observer
     /**
      * Store edit action, check change store group
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function storeEdit(\Magento\Event\Observer $observer)
+    public function storeEdit(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -243,10 +243,10 @@ class Observer
     /**
      * Store delete after process
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function storeDelete(\Magento\Event\Observer $observer)
+    public function storeDelete(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -263,10 +263,10 @@ class Observer
     /**
      * Store Group Save process
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function storeGroupSave(\Magento\Event\Observer $observer)
+    public function storeGroupSave(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -288,10 +288,10 @@ class Observer
     /**
      * Catalog Product Import After process
      *
-     * @param \Magento\Event\Observer $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function catalogProductImportAfter(\Magento\Event\Observer $observer)
+    public function catalogProductImportAfter(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
@@ -305,10 +305,10 @@ class Observer
     /**
      * Customer Group save after process
      *
-     * @param \Magento\Event\Observer\Collection $observer
-     * @return \Magento\Catalog\Model\Product\Flat\Observer
+     * @param EventObserver $observer
+     * @return $this
      */
-    public function customerGroupSaveAfter(\Magento\Event\Observer $observer)
+    public function customerGroupSaveAfter(EventObserver $observer)
     {
         if (!$this->_getHelper()->isAvailable() || !$this->_getHelper()->isBuilt()) {
             return $this;
diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php
index ea6461360d853541d267c78e39079c2e400a90e2..adbedcf7f72ba969c3a4890213079c0348e2c657 100644
--- a/app/code/Magento/Catalog/Model/Product/Image.php
+++ b/app/code/Magento/Catalog/Model/Product/Image.php
@@ -34,30 +34,103 @@
 namespace Magento\Catalog\Model\Product;
 
 use Magento\Core\Model\Store;
+use Magento\Image as MagentoImage;
 
 class Image extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * @var int
+     */
     protected $_width;
+
+    /**
+     * @var int
+     */
     protected $_height;
+
+    /**
+     * @var int
+     */
     protected $_quality = 90;
 
+    /**
+     * @var bool
+     */
     protected $_keepAspectRatio  = true;
+
+    /**
+     * @var bool
+     */
     protected $_keepFrame        = true;
+
+    /**
+     * @var bool
+     */
     protected $_keepTransparency = true;
+
+    /**
+     * @var bool
+     */
     protected $_constrainOnly    = false;
+
+    /**
+     * @var int[]
+     */
     protected $_backgroundColor  = array(255, 255, 255);
 
+    /**
+     * @var string
+     */
     protected $_baseFile;
+
+    /**
+     * @var bool
+     */
     protected $_isBaseFilePlaceholder;
+
+    /**
+     * @var string|bool
+     */
     protected $_newFile;
+
+    /**
+     * @var MagentoImage
+     */
     protected $_processor;
+
+    /**
+     * @var string
+     */
     protected $_destinationSubdir;
+
+    /**
+     * @var int
+     */
     protected $_angle;
 
+    /**
+     * @var string
+     */
     protected $_watermarkFile;
+
+    /**
+     * @var int
+     */
     protected $_watermarkPosition;
+
+    /**
+     * @var int
+     */
     protected $_watermarkWidth;
+
+    /**
+     * @var int
+     */
     protected $_watermarkHeigth;
+
+    /**
+     * @var int
+     */
     protected $_watermarkImageOpacity = 70;
 
     /**
@@ -151,8 +224,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @param $width
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param int $width
+     * @return $this
      */
     public function setWidth($width)
     {
@@ -160,13 +233,17 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @return int
+     */
     public function getWidth()
     {
         return $this->_width;
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param int $height
+     * @return $this
      */
     public function setHeight($height)
     {
@@ -174,6 +251,9 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @return int
+     */
     public function getHeight()
     {
         return $this->_height;
@@ -183,7 +263,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set image quality, values in percentage from 0 to 100
      *
      * @param int $quality
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setQuality($quality)
     {
@@ -202,7 +282,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param bool $keep
+     * @return $this
      */
     public function setKeepAspectRatio($keep)
     {
@@ -211,7 +292,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param bool $keep
+     * @return $this
      */
     public function setKeepFrame($keep)
     {
@@ -220,7 +302,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param bool $keep
+     * @return $this
      */
     public function setKeepTransparency($keep)
     {
@@ -229,7 +312,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param bool $flag
+     * @return $this
      */
     public function setConstrainOnly($flag)
     {
@@ -238,7 +322,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param int[] $rgbArray
+     * @return $this
      */
     public function setBackgroundColor(array $rgbArray)
     {
@@ -247,7 +332,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param string $size
+     * @return $this
      */
     public function setSize($size)
     {
@@ -266,12 +352,19 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param string|null $file
+     * @return bool
+     */
     protected function _checkMemory($file = null)
     {
         return $this->_getMemoryLimit() > ($this->_getMemoryUsage() + $this->_getNeedMemoryForFile($file))
             || $this->_getMemoryLimit() == -1;
     }
 
+    /**
+     * @return string
+     */
     protected function _getMemoryLimit()
     {
         $memoryLimit = trim(strtoupper(ini_get('memory_limit')));
@@ -292,6 +385,9 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $memoryLimit;
     }
 
+    /**
+     * @return int
+     */
     protected function _getMemoryUsage()
     {
         if (function_exists('memory_get_usage')) {
@@ -300,6 +396,10 @@ class Image extends \Magento\Core\Model\AbstractModel
         return 0;
     }
 
+    /**
+     * @param string|null $file
+     * @return float|int
+     */
     protected function _getNeedMemoryForFile($file = null)
     {
         $file = is_null($file) ? $this->getBaseFile() : $file;
@@ -332,7 +432,7 @@ class Image extends \Magento\Core\Model\AbstractModel
     /**
      * Convert array of 3 items (decimal r, g, b) to string of their hex values
      *
-     * @param array $rgbArray
+     * @param int[] $rgbArray
      * @return string
      */
     protected function _rgbToString($rgbArray)
@@ -352,7 +452,8 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set filenames for base file and new file
      *
      * @param string $file
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
+     * @throws \Exception
      */
     public function setBaseFile($file)
     {
@@ -433,18 +534,25 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getBaseFile()
     {
         return $this->_baseFile;
     }
 
+    /**
+     * @return bool|string
+     */
     public function getNewFile()
     {
         return $this->_newFile;
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param MagentoImage $processor
+     * @return $this
      */
     public function setImageProcessor($processor)
     {
@@ -453,7 +561,7 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Image
+     * @return MagentoImage
      */
     public function getImageProcessor()
     {
@@ -472,7 +580,7 @@ class Image extends \Magento\Core\Model\AbstractModel
 
     /**
      * @see \Magento\Image\Adapter\AbstractAdapter
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function resize()
     {
@@ -484,7 +592,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param int $angle
+     * @return $this
      */
     public function rotate($angle)
     {
@@ -499,7 +608,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * This func actually affects only the cache filename.
      *
      * @param int $angle
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setAngle($angle)
     {
@@ -517,7 +626,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * @param int $width
      * @param int $heigth
      * @param int $imageOpacity
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setWatermark($file, $position=null, $size=null, $width=null, $heigth=null, $imageOpacity=null)
     {
@@ -561,7 +670,7 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function saveFile()
     {
@@ -591,7 +700,8 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param string $dir
+     * @return $this
      */
     public function setDestinationSubdir($dir)
     {
@@ -607,6 +717,9 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $this->_destinationSubdir;
     }
 
+    /**
+     * @return bool|void
+     */
     public function isCached()
     {
         if (is_string($this->_newFile)) {
@@ -618,7 +731,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set watermark file name
      *
      * @param string $file
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setWatermarkFile($file)
     {
@@ -677,7 +790,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set watermark position
      *
      * @param string $position
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setWatermarkPosition($position)
     {
@@ -699,7 +812,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set watermark image opacity
      *
      * @param int $imageOpacity
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setWatermarkImageOpacity($imageOpacity)
     {
@@ -721,7 +834,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set watermark size
      *
      * @param array $size
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setWatermarkSize($size)
     {
@@ -736,7 +849,7 @@ class Image extends \Magento\Core\Model\AbstractModel
      * Set watermark width
      *
      * @param int $width
-     * @return \Magento\Catalog\Model\Product\Image
+     * @return $this
      */
     public function setWatermarkWidth($width)
     {
@@ -755,14 +868,14 @@ class Image extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * Set watermark heigth
+     * Set watermark height
      *
-     * @param int $heigth
-     * @return \Magento\Catalog\Model\Product\Image
+     * @param int $height
+     * @return $this
      */
-    public function setWatermarkHeight($heigth)
+    public function setWatermarkHeight($height)
     {
-        $this->_watermarkHeigth = $heigth;
+        $this->_watermarkHeigth = $height;
         return $this;
     }
 
@@ -776,6 +889,9 @@ class Image extends \Magento\Core\Model\AbstractModel
         return $this->_watermarkHeigth;
     }
 
+    /**
+     * @return void
+     */
     public function clearCache()
     {
         $directory = $this->_catalogProductMediaConfig->getBaseMediaPath() . '/cache';
diff --git a/app/code/Magento/Catalog/Model/Product/Image/View.php b/app/code/Magento/Catalog/Model/Product/Image/View.php
index ce2af7cb90ac5208d21c6de7b0c3f2e67b9dbcfd..424a67e870fffedfdc47858a4015c3037d7adb30 100644
--- a/app/code/Magento/Catalog/Model/Product/Image/View.php
+++ b/app/code/Magento/Catalog/Model/Product/Image/View.php
@@ -114,7 +114,7 @@ class View extends \Magento\Object
      * @param \Magento\Catalog\Model\Product $product
      * @param string $location
      * @param string $module
-     * @return \Magento\Catalog\Model\Product\Image\View
+     * @return $this
      */
     public function init(\Magento\Catalog\Model\Product $product, $location, $module = null)
     {
@@ -208,7 +208,7 @@ class View extends \Magento\Object
      * Getter config view config var by suffix
      *
      * @param string $suffix
-     * @return string mixed
+     * @return string|false
      */
     protected function _getImageVar($suffix)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php b/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php
index bdb2f886196c2c31e48db27ef5a91d7b5fc75e90..9ab9f641a5e3f8419e2f91665c59c0e35fde0da2 100644
--- a/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php
+++ b/app/code/Magento/Catalog/Model/Product/Indexer/Eav.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Product\Indexer;
 
 /**
  * Catalog Product Eav Indexer Model
@@ -42,8 +42,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Indexer;
-
 class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
 {
     /**
@@ -110,6 +108,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -120,6 +119,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerEvent(\Magento\Index\Model\Event $event)
     {
@@ -168,7 +168,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Product\Indexer\Eav
+     * @return $this
      */
     protected function _registerCatalogProductSaveEvent(\Magento\Index\Model\Event $event)
     {
@@ -195,7 +195,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Product\Indexer\Eav
+     * @return $this
      */
     protected function _registerCatalogProductDeleteEvent(\Magento\Index\Model\Event $event)
     {
@@ -214,7 +214,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Product\Indexer\Eav
+     * @return $this
      */
     protected function _registerCatalogProductMassActionEvent(\Magento\Index\Model\Event $event)
     {
@@ -250,7 +250,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process attribute save in event object
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Product\Indexer\Eav
+     * @return $this
      */
     protected function _registerCatalogAttributeSaveEvent(\Magento\Index\Model\Event $event)
     {
@@ -278,6 +278,7 @@ class Eav extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Process event
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _processEvent(\Magento\Index\Model\Event $event)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Indexer/Flat.php b/app/code/Magento/Catalog/Model/Product/Indexer/Flat.php
index 1e9c43b530f3cdb381fcb08e2f0e57d128b09a1d..460f02747b9bf8dbf3b2694be50178de9c5e65d5 100644
--- a/app/code/Magento/Catalog/Model/Product/Indexer/Flat.php
+++ b/app/code/Magento/Catalog/Model/Product/Indexer/Flat.php
@@ -1,7 +1,4 @@
 <?php
-
-namespace Magento\Catalog\Model\Product\Indexer;
-
 /**
  * Magento
  *
@@ -25,7 +22,12 @@ namespace Magento\Catalog\Model\Product\Indexer;
  * @package     Magento_Catalog
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- *
+ */
+namespace Magento\Catalog\Model\Product\Indexer;
+
+use Magento\Catalog\Helper\Product\Flat as ProductFlat;
+
+/**
  * @SuppressWarnings(PHPMD.LongVariable)
  */
 class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
@@ -69,7 +71,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
     /**
      * Catalog product flat
      *
-     * @var \Magento\Catalog\Helper\Product\Flat
+     * @var ProductFlat
      */
     protected $_catalogProductFlat = null;
 
@@ -100,7 +102,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * @param \Magento\Catalog\Model\Product\Flat\IndexerFactory $flatIndexerFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Catalog\Model\Product\Flat\Indexer $catalogProductFlatIndexer
-     * @param \Magento\Catalog\Helper\Product\Flat $catalogProductFlat
+     * @param ProductFlat $catalogProductFlat
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
@@ -111,7 +113,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
         \Magento\Catalog\Model\Product\Flat\IndexerFactory $flatIndexerFactory,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Catalog\Model\Product\Flat\Indexer $catalogProductFlatIndexer,
-        \Magento\Catalog\Helper\Product\Flat $catalogProductFlat,
+        ProductFlat $catalogProductFlat,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
         array $data = array()
@@ -123,9 +125,12 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return bool
+     */
     public function isVisible()
     {
-        /** @var $productFlatHelper \Magento\Catalog\Helper\Product\Flat */
+        /** @var $productFlatHelper ProductFlat */
         $productFlatHelper = $this->_catalogProductFlat;
         return $productFlatHelper->isEnabled() || !$productFlatHelper->isBuilt();
     }
@@ -160,7 +165,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      */
     public function matchEvent(\Magento\Index\Model\Event $event)
     {
-        /** @var $productFlatHelper \Magento\Catalog\Helper\Product\Flat */
+        /** @var $productFlatHelper ProductFlat */
         $productFlatHelper = $event->getFlatHelper() ?: $this->_catalogProductFlat;
         if (!$productFlatHelper->isAvailable() || !$productFlatHelper->isBuilt()) {
             return false;
@@ -236,7 +241,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Whether an attribute available for matching or not
      *
      * @param \Magento\Index\Model\Event $event
-     * @param $productFlatHelper
+     * @param ProductFlat $productFlatHelper
      * @return bool
      */
     protected function _matchAttributeEvent(\Magento\Index\Model\Event $event, $productFlatHelper)
@@ -262,12 +267,12 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Whether an attribute available for matching or not
      *
      * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
-     * @param \Magento\Catalog\Helper\Product\Flat $productFlatHelper
+     * @param ProductFlat $productFlatHelper
      * @param bool $before
      * @return bool
      */
-    protected function _isAttributeEnabled($attribute, $productFlatHelper, $before = true) {
-
+    protected function _isAttributeEnabled($attribute, $productFlatHelper, $before = true)
+    {
         $method = $before ? 'getOrigData': 'getData';
 
         return $attribute && (($attribute->$method('backend_type') == 'static')
@@ -281,6 +286,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerEvent(\Magento\Index\Model\Event $event)
     {
@@ -314,7 +320,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by catalog product process in event object
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Product\Indexer\Flat
+     * @return $this
      */
     protected function _registerCatalogProductEvent(\Magento\Index\Model\Event $event)
     {
@@ -373,7 +379,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register core store delete process
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Product\Indexer\Flat
+     * @return $this
      */
     protected function _registerCoreStoreEvent(\Magento\Index\Model\Event $event)
     {
@@ -389,6 +395,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Process event
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _processEvent(\Magento\Index\Model\Event $event)
     {
@@ -439,6 +446,7 @@ class Flat extends \Magento\Index\Model\Indexer\AbstractIndexer
     /**
      * Rebuild all index data
      *
+     * @return void
      */
     public function reindexAll()
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Indexer/Price.php b/app/code/Magento/Catalog/Model/Product/Indexer/Price.php
index 67f8352b2796a6391dd05b890a4afe30574ae204..bcb8cb36c0355920b587ec135773c699d82bcce1 100644
--- a/app/code/Magento/Catalog/Model/Product/Indexer/Price.php
+++ b/app/code/Magento/Catalog/Model/Product/Indexer/Price.php
@@ -23,6 +23,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Indexer;
+
 /**
  * @method \Magento\Catalog\Model\Resource\Product\Indexer\Price _getResource()
  * @method \Magento\Catalog\Model\Resource\Product\Indexer\Price getResource()
@@ -48,8 +50,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Indexer;
-
 class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
 {
     /**
@@ -82,6 +82,9 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
         )
     );
 
+    /**
+     * @var string[]
+     */
     protected $_relatedConfigSettings = array(
         \Magento\Catalog\Helper\Data::XML_PATH_PRICE_SCOPE,
         \Magento\CatalogInventory\Model\Stock\Item::XML_PATH_MANAGE_STOCK
@@ -90,6 +93,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -119,7 +123,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
     /**
      * Retrieve attribute list has an effect on product price
      *
-     * @return array
+     * @return string[]
      */
     protected function _getDependentAttributes()
     {
@@ -171,6 +175,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by catalog product delete process
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerCatalogProductDeleteEvent(\Magento\Index\Model\Event $event)
     {
@@ -187,6 +192,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by catalog product save process
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerCatalogProductSaveEvent(\Magento\Index\Model\Event $event)
     {
@@ -210,6 +216,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
 
     /**
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerCatalogProductMassActionEvent(\Magento\Index\Model\Event $event)
     {
@@ -244,6 +251,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _registerEvent(\Magento\Index\Model\Event $event)
     {
@@ -283,6 +291,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer
      * Process event
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     protected function _processEvent(\Magento\Index\Model\Event $event)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Link.php b/app/code/Magento/Catalog/Model/Product/Link.php
index 7b3e099bc0a5ac2488664a65ecf90e0afb3ece3b..60cb878810ca6955b434c0cb99a68990fcfc1f79 100644
--- a/app/code/Magento/Catalog/Model/Product/Link.php
+++ b/app/code/Magento/Catalog/Model/Product/Link.php
@@ -23,7 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product;
 
+use Magento\Catalog\Model\Resource\Product\Link\Collection;
+use Magento\Catalog\Model\Resource\Product\Link\Product\Collection as ProductCollection;
 
 /**
  * Catalog product link model
@@ -41,14 +44,15 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product;
-
 class Link extends \Magento\Core\Model\AbstractModel
 {
     const LINK_TYPE_RELATED     = 1;
     const LINK_TYPE_UPSELL      = 4;
     const LINK_TYPE_CROSSSELL   = 5;
 
+    /**
+     * @var mixed
+     */
     protected $_attributeCollection = null;
 
     /**
@@ -90,18 +94,26 @@ class Link extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initialize resource
+     *
+     * @return void
      */
     protected function _construct()
     {
         $this->_init('Magento\Catalog\Model\Resource\Product\Link');
     }
 
+    /**
+     * @return $this
+     */
     public function useRelatedLinks()
     {
         $this->setLinkTypeId(self::LINK_TYPE_RELATED);
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     public function useUpSellLinks()
     {
         $this->setLinkTypeId(self::LINK_TYPE_UPSELL);
@@ -109,7 +121,7 @@ class Link extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @return \Magento\Catalog\Model\Product\Link
+     * @return $this
      */
     public function useCrossSellLinks()
     {
@@ -130,6 +142,8 @@ class Link extends \Magento\Core\Model\AbstractModel
 
     /**
      * Retrieve linked product collection
+     *
+     * @return ProductCollection
      */
     public function getProductCollection()
     {
@@ -140,6 +154,8 @@ class Link extends \Magento\Core\Model\AbstractModel
 
     /**
      * Retrieve link collection
+     *
+     * @return Collection
      */
     public function getLinkCollection()
     {
@@ -148,6 +164,10 @@ class Link extends \Magento\Core\Model\AbstractModel
         return $collection;
     }
 
+    /**
+     * @param int $type
+     * @return array
+     */
     public function getAttributes($type=null)
     {
         if (is_null($type)) {
@@ -160,7 +180,7 @@ class Link extends \Magento\Core\Model\AbstractModel
      * Save data for product relations
      *
      * @param   \Magento\Catalog\Model\Product $product
-     * @return  \Magento\Catalog\Model\Product\Link
+     * @return  $this
      */
     public function saveProductRelations($product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Media/Config.php b/app/code/Magento/Catalog/Model/Product/Media/Config.php
index 56b09e0b956251881509d6a36f299c81747ca002..16c8cb0f160e2e1d393fa323227b262448833ba1 100644
--- a/app/code/Magento/Catalog/Model/Product/Media/Config.php
+++ b/app/code/Magento/Catalog/Model/Product/Media/Config.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Product\Media;
 
 /**
  * Catalog product media config
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Media;
-
 class Config implements ConfigInterface
 {
     /**
@@ -46,7 +44,8 @@ class Config implements ConfigInterface
     /**
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      */
-    public function __construct(\Magento\Core\Model\StoreManagerInterface $storeManager) {
+    public function __construct(\Magento\Core\Model\StoreManagerInterface $storeManager)
+    {
         $this->storeManager = $storeManager;
     }
 
@@ -128,7 +127,7 @@ class Config implements ConfigInterface
     }
 
     /**
-     * @param $file
+     * @param string $file
      * @return string
      */
     public function getTmpMediaUrl($file)
@@ -160,7 +159,7 @@ class Config implements ConfigInterface
     }
 
     /**
-     * @param $file
+     * @param string $file
      * @return string
      */
     public function getTmpMediaPath($file)
@@ -169,7 +168,7 @@ class Config implements ConfigInterface
     }
 
     /**
-     * @param $file
+     * @param string $file
      * @return string
      */
     protected function _prepareFile($file)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 9e77d4ddcee63423e4abf7b800a28d7091f3a405..8506ddde4c11e8e748bb321dd1106b41e17c9f52 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -23,6 +23,12 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product;
+
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Resource\Product\Option\Value\Collection;
+use Magento\Core\Exception;
+use Magento\Core\Model\AbstractModel;
 
 /**
  * Catalog product option model
@@ -51,9 +57,8 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product;
 
-class Option extends \Magento\Core\Model\AbstractModel
+class Option extends AbstractModel
 {
     const OPTION_GROUP_TEXT   = 'text';
     const OPTION_GROUP_FILE   = 'file';
@@ -71,16 +76,25 @@ class Option extends \Magento\Core\Model\AbstractModel
     const OPTION_TYPE_DATE_TIME = 'date_time';
     const OPTION_TYPE_TIME      = 'time';
 
+    /**
+     * @var Product
+     */
     protected $_product;
 
+    /**
+     * @var array
+     */
     protected $_options = array();
 
+    /**
+     * @var array
+     */
     protected $_values = array();
 
     /**
      * Catalog product option value
      *
-     * @var \Magento\Catalog\Model\Product\Option\Value
+     * @var Option\Value
      */
     protected $_productOptionValue;
 
@@ -99,7 +113,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
-     * @param \Magento\Catalog\Model\Product\Option\Value $productOptionValue
+     * @param Option\Value $productOptionValue
      * @param \Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory
      * @param \Magento\Stdlib\String $string
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
@@ -109,7 +123,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     public function __construct(
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
-        \Magento\Catalog\Model\Product\Option\Value $productOptionValue,
+        Option\Value $productOptionValue,
         \Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory,
         \Magento\Stdlib\String $string,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
@@ -132,6 +146,9 @@ class Option extends \Magento\Core\Model\AbstractModel
         return $this->_resource ?: parent::_getResource();
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Catalog\Model\Resource\Product\Option');
@@ -141,10 +158,10 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Add value of option to values array
      *
-     * @param \Magento\Catalog\Model\Product\Option\Value $value
-     * @return \Magento\Catalog\Model\Product\Option
+     * @param Option\Value $value
+     * @return $this
      */
-    public function addValue(\Magento\Catalog\Model\Product\Option\Value $value)
+    public function addValue(Option\Value $value)
     {
         $this->_values[$value->getId()] = $value;
         return $this;
@@ -154,7 +171,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      * Get value by given id
      *
      * @param int $valueId
-     * @return \Magento\Catalog\Model\Product\Option\Value
+     * @return Option\Value|null
      */
     public function getValueById($valueId)
     {
@@ -165,6 +182,9 @@ class Option extends \Magento\Core\Model\AbstractModel
         return null;
     }
 
+    /**
+     * @return Option\Value[]
+     */
     public function getValues()
     {
         return $this->_values;
@@ -173,7 +193,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve value instance
      *
-     * @return \Magento\Catalog\Model\Product\Option\Value
+     * @return Option\Value
      */
     public function getValueInstance()
     {
@@ -184,7 +204,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      * Add option for save it
      *
      * @param array $option
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function addOption($option)
     {
@@ -206,7 +226,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      * Set options for array
      *
      * @param array $options
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function setOptions($options)
     {
@@ -217,7 +237,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Set options to empty array
      *
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function unsetOptions()
     {
@@ -228,7 +248,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve product instance
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -238,10 +258,10 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Set product instance
      *
-     * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Option
+     * @param Product $product
+     * @return $this
      */
-    public function setProduct(\Magento\Catalog\Model\Product $product = null)
+    public function setProduct(Product $product = null)
     {
         $this->_product = $product;
         return $this;
@@ -279,7 +299,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      *
      * @param string $type Option type
      * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      */
     public function groupFactory($type)
     {
@@ -289,13 +309,13 @@ class Option extends \Magento\Core\Model\AbstractModel
                 'Magento\Catalog\Model\Product\Option\Type\\' . $this->string->upperCaseWords($group)
             );
         }
-        throw new \Magento\Core\Exception(__('The option type to get group instance is incorrect.'));
+        throw new Exception(__('The option type to get group instance is incorrect.'));
     }
 
     /**
      * Save options.
      *
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function saveOptions()
     {
@@ -356,11 +376,16 @@ class Option extends \Magento\Core\Model\AbstractModel
                         }
                     }
                 }
-                $this->save();            }
+                $this->save();
+            }
         }//eof foreach()
         return $this;
     }
 
+    /**
+     * @return AbstractModel
+     * @throws Exception
+     */
     protected function _afterSave()
     {
         $this->getValueInstance()->unsetValues();
@@ -372,7 +397,7 @@ class Option extends \Magento\Core\Model\AbstractModel
             $this->getValueInstance()->setOption($this)
                 ->saveValues();
         } elseif ($this->getGroupByType($this->getType()) == self::OPTION_GROUP_SELECT) {
-            throw new \Magento\Core\Exception(__('Select type options required values rows.'));
+            throw new Exception(__('Select type options required values rows.'));
         }
 
         return parent::_afterSave();
@@ -383,7 +408,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      *  return converted percent to price
      *
      * @param bool $flag
-     * @return decimal
+     * @return float
      */
     public function getPrice($flag=false)
     {
@@ -399,7 +424,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      * Delete prices of option
      *
      * @param int $option_id
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function deletePrices($option_id)
     {
@@ -411,7 +436,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      * Delete titles of option
      *
      * @param int $option_id
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function deleteTitles($option_id)
     {
@@ -420,12 +445,12 @@ class Option extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * get Product Option Collection
+     * Get Product Option Collection
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
      */
-    public function getProductOptionCollection(\Magento\Catalog\Model\Product $product)
+    public function getProductOptionCollection(Product $product)
     {
         $collection = $this->getCollection()
             ->addFieldToFilter('product_id', $product->getId())
@@ -445,7 +470,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Get collection of values for current option
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return Collection
      */
     public function getValuesCollection()
     {
@@ -460,7 +485,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      *
      * @param array $optionIds
      * @param int $store_id
-     * @return unknown
+     * @return Collection
      */
     public function getOptionValuesByOptionId($optionIds, $store_id)
     {
@@ -495,7 +520,7 @@ class Option extends \Magento\Core\Model\AbstractModel
      *
      * @param int $oldProductId
      * @param int $newProductId
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     public function duplicate($oldProductId, $newProductId)
     {
@@ -519,7 +544,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Clearing object's data
      *
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     protected function _clearData()
     {
@@ -531,7 +556,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Clearing cyclic references
      *
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return $this
      */
     protected function _clearReferences()
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php
index c8cd832c7377419b0aa0fb79534a7ded78eb086c..09b21ebeae13c095bec7af23a67ae6c8c6e2fb17 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Option\Type;
 
 /**
  * Catalog product option date type
@@ -31,12 +32,10 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Option\Type;
-
 class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 {
     /**
-     * @var mixed
+     * @var string
      */
     protected $_formattedOptionValue = null;
 
@@ -66,9 +65,9 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Validate user input for option
      *
-     * @throws \Magento\Core\Exception
      * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return $this
+     * @throws \Magento\Core\Exception
      */
     public function validateUserValue($values)
     {
@@ -115,7 +114,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
             } elseif (!$timeValid) {
                 throw new \Magento\Core\Exception(__('Please specify time required option(s).'));
             } else {
-                throw new \Magento\Core\Exception(__('Please specify the product required option(s).'));
+                throw new \Magento\Core\Exception(__('Please specify the product\'s required option(s).'));
             }
         } else {
             $this->setUserValue(null);
@@ -128,8 +127,8 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Prepare option value for cart
      *
+     * @return string|null Prepared option value
      * @throws \Magento\Core\Exception
-     * @return mixed Prepared option value
      */
     public function prepareForCart()
     {
@@ -255,7 +254,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      * Prepare option value for info buy request
      *
      * @param string $optionValue
-     * @return mixed
+     * @return array
      */
     public function prepareOptionValueForRequest($optionValue)
     {
@@ -296,7 +295,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Year range start
      *
-     * @return mixed
+     * @return string|false
      */
     public function getYearStart()
     {
@@ -311,7 +310,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Year range end
      *
-     * @return mixed
+     * @return string|false
      */
     public function getYearEnd()
     {
@@ -327,7 +326,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      * Save internal value of option in infoBuy_request
      *
      * @param string $internalValue Datetime value in internal format
-     * @return \Magento\Catalog\Model\Product\Option\Type\Date
+     * @return void
      */
     protected function _setInternalInRequest($internalValue)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
index fdee0a0e32c883beb8829c87b803186a60171f64..40a508d3eba570043d3e980949f8a6b3b61135ca 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Option\Type;
+
+use Magento\Core\Exception;
 
 /**
  * Catalog product option default type
@@ -31,8 +34,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Option\Type;
-
 class DefaultType extends \Magento\Object
 {
     /**
@@ -52,9 +53,9 @@ class DefaultType extends \Magento\Object
 
 
     /**
-     * description
+     * TODO: Fill in description
      *
-     * @var    mixed
+     * @var array
      */
     protected $_productOptions = array();
 
@@ -93,7 +94,7 @@ class DefaultType extends \Magento\Object
      * Option Instance setter
      *
      * @param \Magento\Catalog\Model\Product\Option $option
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return $this
      */
     public function setOption($option)
     {
@@ -104,7 +105,7 @@ class DefaultType extends \Magento\Object
     /**
      * Option Instance getter
      *
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      * @return \Magento\Catalog\Model\Product\Option
      */
     public function getOption()
@@ -112,14 +113,14 @@ class DefaultType extends \Magento\Object
         if ($this->_option instanceof \Magento\Catalog\Model\Product\Option) {
             return $this->_option;
         }
-        throw new \Magento\Core\Exception(__('The option instance type in options group is incorrect.'));
+        throw new Exception(__('The option instance type in options group is incorrect.'));
     }
 
     /**
      * Product Instance setter
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return $this
      */
     public function setProduct($product)
     {
@@ -130,7 +131,7 @@ class DefaultType extends \Magento\Object
     /**
      * Product Instance getter
      *
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      * @return \Magento\Catalog\Model\Product
      */
     public function getProduct()
@@ -138,14 +139,14 @@ class DefaultType extends \Magento\Object
         if ($this->_product instanceof \Magento\Catalog\Model\Product) {
             return $this->_product;
         }
-        throw new \Magento\Core\Exception(__('The product instance type in options group is incorrect.'));
+        throw new Exception(__('The product instance type in options group is incorrect.'));
     }
 
     /**
      * Getter for Configuration Item Option
      *
      * @return \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      */
     public function getConfigurationItemOption()
     {
@@ -158,14 +159,14 @@ class DefaultType extends \Magento\Object
             return $this->_getData('quote_item_option');
         }
 
-        throw new \Magento\Core\Exception(__('The configuration item option instance in options group is incorrect.'));
+        throw new Exception(__('The configuration item option instance in options group is incorrect.'));
     }
 
     /**
      * Getter for Configuration Item
      *
      * @return \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      */
     public function getConfigurationItem()
     {
@@ -178,21 +179,21 @@ class DefaultType extends \Magento\Object
             return $this->_getData('quote_item');
         }
 
-        throw new \Magento\Core\Exception(__('The configuration item instance in options group is incorrect.'));
+        throw new Exception(__('The configuration item instance in options group is incorrect.'));
     }
 
     /**
      * Getter for Buy Request
      *
      * @return \Magento\Object
-     * @throws \Magento\Core\Exception
+     * @throws Exception
      */
     public function getRequest()
     {
         if ($this->_getData('request') instanceof \Magento\Object) {
             return $this->_getData('request');
         }
-        throw new \Magento\Core\Exception(__('The BuyRequest instance in options group is incorrect.'));
+        throw new Exception(__('The BuyRequest instance in options group is incorrect.'));
     }
 
     /**
@@ -209,9 +210,9 @@ class DefaultType extends \Magento\Object
     /**
      * Validate user input for option
      *
-     * @throws \Magento\Core\Exception
      * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return $this
+     * @throws Exception
      */
     public function validateUserValue($values)
     {
@@ -221,7 +222,7 @@ class DefaultType extends \Magento\Object
 
         $option = $this->getOption();
         if (!isset($values[$option->getId()]) && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) {
-            throw new \Magento\Core\Exception(__('Please specify the product required option(s).'));
+            throw new Exception(__('Please specify the product\'s required option(s).'));
         } elseif (isset($values[$option->getId()])) {
             $this->setUserValue($values[$option->getId()]);
             $this->setIsValid(true);
@@ -243,15 +244,15 @@ class DefaultType extends \Magento\Object
     /**
      * Prepare option value for cart
      *
-     * @throws \Magento\Core\Exception
-     * @return mixed Prepared option value
+     * @return string|null Prepared option value
+     * @throws Exception
      */
     public function prepareForCart()
     {
         if ($this->getIsValid()) {
             return $this->getUserValue();
         }
-        throw new \Magento\Core\Exception(__('We couldn\'t add the product to the cart because of an option validation issue.'));
+        throw new Exception(__('We couldn\'t add the product to the cart because of an option validation issue.'));
     }
 
     /**
@@ -325,7 +326,7 @@ class DefaultType extends \Magento\Object
      * Prepare option value for info buy request
      *
      * @param string $optionValue
-     * @return mixed
+     * @return string|null
      */
     public function prepareOptionValueForRequest($optionValue)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php
index 7522fa5dfdf971ef9e1714ec0dd5a703b970a8e7..0208b7a23880ca6548f7b250b848a38105e589eb 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Product\Option\Type;
+
+use Magento\Core\Exception;
 
 /**
  * Catalog product option file type
@@ -31,8 +34,6 @@
  * @package    Magento_Catalog
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Product\Option\Type;
-
 class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 {
     /**
@@ -42,7 +43,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     protected $_customOptionDownloadUrl = 'sales/download/downloadCustomOption';
 
     /**
-     * @var mixed
+     * @var string|null
      */
     protected $_formattedOptionValue = null;
 
@@ -162,7 +163,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      * Return option html
      *
      * @param array $optionInfo
-     * @return string
+     * @return string|void
      */
     public function getCustomizedView($optionInfo)
     {
@@ -225,9 +226,9 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Validate user input for option
      *
-     * @throws \Magento\Core\Exception
      * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
-     * @return \Magento\Catalog\Model\Product\Option\Type\File
+     * @return $this
+     * @throws Exception
      */
     public function validateUserValue($values)
     {
@@ -269,7 +270,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
                 $this->setUserValue(null);
                 return $this;
             } else {
-                throw new \Magento\Core\Exception($e->getMessage());
+                throw new Exception($e->getMessage());
             }
         }
         return $this;
@@ -278,8 +279,8 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Validate uploaded file
      *
-     * @throws \Magento\Core\Exception
-     * @return \Magento\Catalog\Model\Product\Option\Type\File
+     * @return $this
+     * @throws Exception
      */
     protected function _validateUploadedFile()
     {
@@ -308,14 +309,14 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
             if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $maxFileSize) {
                 $this->setIsValid(false);
                 $value = $this->getFileSizeService()->getMaxFileSizeInMb();
-                throw new \Magento\Core\Exception(
+                throw new Exception(
                     __("The file you uploaded is larger than %1 Megabytes allowed by server", $value)
                 );
             } else {
                 switch ($this->getProcessMode())
                 {
                     case \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL:
-                        throw new \Magento\Core\Exception(
+                        throw new Exception(
                             __('Please specify the product\'s required option(s).')
                         );
                         break;
@@ -418,11 +419,11 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 
             if (count($errors) > 0) {
                 $this->setIsValid(false);
-                throw new \Magento\Core\Exception( implode("\n", $errors) );
+                throw new Exception( implode("\n", $errors) );
             }
         } else {
             $this->setIsValid(false);
-            throw new \Magento\Core\Exception(__('Please specify the product required option(s).'));
+            throw new Exception(__('Please specify the product\'s required option(s).'));
         }
         return $this;
     }
@@ -430,9 +431,9 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Validate file
      *
-     * @throws \Magento\Core\Exception
      * @param array $optionValue
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return bool|void
+     * @throws Exception
      */
     protected function _validateFile($optionValue)
     {
@@ -515,20 +516,20 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 
             if (count($errors) > 0) {
                 $this->setIsValid(false);
-                throw new \Magento\Core\Exception( implode("\n", $errors) );
+                throw new Exception( implode("\n", $errors) );
             }
         } else {
             $this->setIsValid(false);
-            throw new \Magento\Core\Exception(__('Please specify the product required option(s).'));
+            throw new Exception(__('Please specify the product\'s required option(s).'));
         }
     }
 
     /**
      * Get Error messages for validator Errors
      *
-     * @param array $errors Array of validation failure message codes @see \Zend_Validate::getErrors()
+     * @param string[] $errors Array of validation failure message codes @see \Zend_Validate::getErrors()
      * @param array $fileInfo File info
-     * @return array Array of error messages
+     * @return string[] Array of error messages
      */
     protected function _getValidatorErrors($errors, $fileInfo)
     {
@@ -558,7 +559,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Prepare option value for cart
      *
-     * @return mixed Prepared option value
+     * @return string|null Prepared option value
      */
     public function prepareForCart()
     {
@@ -630,6 +631,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      *
      * @param string|array $optionValue Serialized string of option data or its data array
      * @return string
+     * @throws Exception
      */
     protected function _getOptionHtml($optionValue)
     {
@@ -653,14 +655,14 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
                 $sizes
             );
         } catch (\Exception $e) {
-            throw new \Magento\Core\Exception(__("The file options format is not valid."));
+            throw new Exception(__("The file options format is not valid."));
         }
     }
 
     /**
      * Create a value from a storable representation
      *
-     * @param mixed $value
+     * @param string|array $value
      * @return array
      */
     protected function _unserializeValue($value)
@@ -733,7 +735,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      * Prepare option value for info buy request
      *
      * @param string $optionValue
-     * @return mixed
+     * @return string|null
      */
     public function prepareOptionValueForRequest($optionValue)
     {
@@ -748,7 +750,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Quote item to order item copy process
      *
-     * @return \Magento\Catalog\Model\Product\Option\Type\File
+     * @return $this
      */
     public function copyQuoteToOrder()
     {
@@ -779,7 +781,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      * Set url to custom option download controller
      *
      * @param string $url
-     * @return \Magento\Catalog\Model\Product\Option\Type\File
+     * @return $this
      */
     public function setCustomOptionDownloadUrl($url)
     {
@@ -789,6 +791,8 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 
     /**
      * Directory structure initializing
+     *
+     * @return void
      */
     protected function _initFilesystem()
     {
@@ -806,8 +810,8 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Return URL for option file download
      *
-     * @param $route
-     * @param $params
+     * @param string|null $route
+     * @param array|null $params
      * @return string
      */
     protected function _getOptionDownloadUrl($route, $params)
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
index 424d07ed91ca41806cfe5cac3072d9a061a9a763..0e5c66c84a8c8c8b5c2ae604c1311beaa36a6169 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
@@ -23,16 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Product\Option\Type;
 
+use Magento\Core\Exception;
+
 /**
  * Catalog product option select type
  */
 class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 {
     /**
-     * @var mixed
+     * @var string|array
      */
     protected $_formattedOptionValue;
 
@@ -70,9 +71,9 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Validate user input for option
      *
-     * @throws \Magento\Core\Exception
      * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return $this
+     * @throws Exception
      */
     public function validateUserValue($values)
     {
@@ -83,14 +84,14 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 
         if (empty($value) && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) {
             $this->setIsValid(false);
-            throw new \Magento\Core\Exception(__('Please specify the product required option(s).'));
+            throw new Exception(__('Please specify the product\'s required option(s).'));
         }
         if (!$this->_isSingleSelection()) {
             $valuesCollection = $option->getOptionValuesByOptionId($value, $this->getProduct()->getStoreId())
                 ->load();
             if ($valuesCollection->count() != count($value)) {
                 $this->setIsValid(false);
-                throw new \Magento\Core\Exception(__('Please specify the product required option(s).'));
+                throw new Exception(__('Please specify the product\'s required option(s).'));
             }
         }
         return $this;
@@ -99,8 +100,7 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Prepare option value for cart
      *
-     * @throws \Magento\Core\Exception
-     * @return mixed Prepared option value
+     * @return string|null Prepared option value
      */
     public function prepareForCart()
     {
@@ -223,7 +223,7 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
      * Prepare option value for info buy request
      *
      * @param string $optionValue
-     * @return mixed
+     * @return string
      */
     public function prepareOptionValueForRequest($optionValue)
     {
@@ -298,7 +298,7 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
 
         if (!$this->_isSingleSelection()) {
             $skus = array();
-            foreach(explode(',', $optionValue) as $value) {
+            foreach (explode(',', $optionValue) as $value) {
                 $optionSku = $option->getValueById($value);
                 if ($optionSku) {
                     $skus[] = $optionSku->getSku();
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php
index 70a9af25bb5f788eb459ec6465fdf9bb3c3c6975..f8e14be6e552089fbb435d0ca41704f4bc4b42da 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Text.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Product\Option\Type;
 
+use Magento\Core\Exception;
+
 /**
  * Catalog product option text type
  */
@@ -65,9 +66,9 @@ class Text extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Validate user input for option
      *
-     * @throws \Magento\Core\Exception
      * @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
-     * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+     * @return $this
+     * @throws Exception
      */
     public function validateUserValue($values)
     {
@@ -79,14 +80,14 @@ class Text extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
         // Check requires option to have some value
         if (strlen($value) == 0 && $option->getIsRequire() && !$this->getSkipCheckRequiredOption()) {
             $this->setIsValid(false);
-            throw new \Magento\Core\Exception(__('Please specify the product\'s required option(s).'));
+            throw new Exception(__('Please specify the product\'s required option(s).'));
         }
 
         // Check maximal length limit
         $maxCharacters = $option->getMaxCharacters();
         if ($maxCharacters > 0 && $this->string->strlen($value) > $maxCharacters) {
             $this->setIsValid(false);
-            throw new \Magento\Core\Exception(__('The text is too long.'));
+            throw new Exception(__('The text is too long.'));
         }
 
         $this->setUserValue($value);
@@ -96,7 +97,7 @@ class Text extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
     /**
      * Prepare option value for cart
      *
-     * @return mixed Prepared option value
+     * @return string|null Prepared option value
      */
     public function prepareForCart()
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Product/Option/Value.php
index 9dc24be7337fdca37a121eb68e47cac107760a0f..08a2cc7e3e4da0fa5f228903c135dc7189cf58bd 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Value.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Value.php
@@ -26,6 +26,9 @@
 
 namespace Magento\Catalog\Model\Product\Option;
 
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option;
+
 /**
  * Catalog product option select type model
  *
@@ -42,10 +45,19 @@ namespace Magento\Catalog\Model\Product\Option;
  */
 class Value extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * @var array
+     */
     protected $_values = array();
 
+    /**
+     * @var Product
+     */
     protected $_product;
 
+    /**
+     * @var Option
+     */
     protected $_option;
 
     /**
@@ -75,40 +87,64 @@ class Value extends \Magento\Core\Model\AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Catalog\Model\Resource\Product\Option\Value');
     }
 
+    /**
+     * @param mixed $value
+     * @return $this
+     */
     public function addValue($value)
     {
         $this->_values[] = $value;
         return $this;
     }
 
+    /**
+     * @return array
+     */
     public function getValues()
     {
         return $this->_values;
     }
 
+    /**
+     * @param array $values
+     * @return $this
+     */
     public function setValues($values)
     {
         $this->_values = $values;
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     public function unsetValues()
     {
         $this->_values = array();
         return $this;
     }
 
-    public function setOption(\Magento\Catalog\Model\Product\Option $option)
+    /**
+     * @param Option $option
+     * @return $this
+     */
+    public function setOption(Option $option)
     {
         $this->_option = $option;
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     public function unsetOption()
     {
         $this->_option = null;
@@ -118,19 +154,26 @@ class Value extends \Magento\Core\Model\AbstractModel
     /**
      * Enter description here...
      *
-     * @return \Magento\Catalog\Model\Product\Option
+     * @return Option
      */
     public function getOption()
     {
         return $this->_option;
     }
 
+    /**
+     * @param Product $product
+     * @return $this
+     */
     public function setProduct($product)
     {
         $this->_product = $product;
         return $this;
     }
 
+    /**
+     * @return Product
+     */
     public function getProduct()
     {
         if (is_null($this->_product)) {
@@ -139,6 +182,9 @@ class Value extends \Magento\Core\Model\AbstractModel
         return $this->_product;
     }
 
+    /**
+     * @return $this
+     */
     public function saveValues()
     {
         foreach ($this->getValues() as $value) {
@@ -184,10 +230,10 @@ class Value extends \Magento\Core\Model\AbstractModel
     /**
      * Enter description here...
      *
-     * @param \Magento\Catalog\Model\Product\Option $option
+     * @param Option $option
      * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
      */
-    public function getValuesCollection(\Magento\Catalog\Model\Product\Option $option)
+    public function getValuesCollection(Option $option)
     {
         $collection = $this->_valueCollectionFactory->create()
             ->addFieldToFilter('option_id', $option->getId())
@@ -196,6 +242,12 @@ class Value extends \Magento\Core\Model\AbstractModel
         return $collection;
     }
 
+    /**
+     * @param array $optionIds
+     * @param int $option_id
+     * @param int $store_id
+     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     */
     public function getValuesByOption($optionIds, $option_id, $store_id)
     {
         $collection = $this->_valueCollectionFactory->create()
@@ -205,12 +257,20 @@ class Value extends \Magento\Core\Model\AbstractModel
         return $collection;
     }
 
+    /**
+     * @param int $option_id
+     * @return $this
+     */
     public function deleteValue($option_id)
     {
         $this->getResource()->deleteValue($option_id);
         return $this;
     }
 
+    /**
+     * @param int $option_type_id
+     * @return $this
+     */
     public function deleteValues($option_type_id)
     {
         $this->getResource()->deleteValues($option_type_id);
@@ -235,7 +295,7 @@ class Value extends \Magento\Core\Model\AbstractModel
      *
      * @param int $oldOptionId
      * @param int $newOptionId
-     * @return \Magento\Catalog\Model\Product\Option\Value
+     * @return $this
      */
     public function duplicate($oldOptionId, $newOptionId)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Status.php b/app/code/Magento/Catalog/Model/Product/Status.php
index 03447c7655f29de5e3fd46de58e990758377d206..183159a64cc445ebbc0a8c1db03f1545dc63c488 100644
--- a/app/code/Magento/Catalog/Model/Product/Status.php
+++ b/app/code/Magento/Catalog/Model/Product/Status.php
@@ -94,6 +94,7 @@ class Status extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -124,7 +125,7 @@ class Status extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve Visible Status Ids
      *
-     * @return array
+     * @return string[]
      */
     public function getVisibleStatusIds()
     {
@@ -135,7 +136,7 @@ class Status extends \Magento\Core\Model\AbstractModel
      * Retrieve Saleable Status Ids
      * Default Product Enable status
      *
-     * @return array
+     * @return int[]
      */
     public function getSaleableStatusIds()
     {
@@ -271,7 +272,6 @@ class Status extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve Select For Flat Attribute update
      *
-     * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
      * @param int $store
      * @return \Magento\DB\Select|null
      */
@@ -284,7 +284,7 @@ class Status extends \Magento\Core\Model\AbstractModel
      * Set attribute instance
      *
      * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
-     * @return \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
+     * @return $this
      */
     public function setAttribute($attribute)
     {
@@ -307,7 +307,7 @@ class Status extends \Magento\Core\Model\AbstractModel
      *
      * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
      * @param string $dir direction
-     * @return \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
+     * @return $this
      */
     public function addValueSortToCollection($collection, $dir = 'asc')
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
index 9899651f0a155689c032a4d3a86cb4088f62c612..bc1711cc48c7075553dd5a977d8b9f16aab5d10c 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
@@ -125,6 +125,7 @@ abstract class AbstractType
      * Delete data specific for this product type
      *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     abstract public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product);
 
@@ -484,7 +485,7 @@ abstract class AbstractType
     /**
      * Process File Queue
      *
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function processFileQueue()
@@ -541,6 +542,7 @@ abstract class AbstractType
      *                              (eg. ['operation'=>'move',
      *                                    'src_name'=>'filename',
      *                                    'dst_name'=>'filename2'])
+     * @return void
      */
     public function addFileQueue($queueOptions)
     {
@@ -608,7 +610,7 @@ abstract class AbstractType
      * Check if product can be bought
      *
      * @param  \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function checkProductBuyState($product)
@@ -686,7 +688,7 @@ abstract class AbstractType
      * Save type related data
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function save($product)
     {
@@ -704,6 +706,7 @@ abstract class AbstractType
      * Remove don't applicable attributes data
      *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     protected function _removeNotApplicableAttributes($product)
     {
@@ -721,7 +724,7 @@ abstract class AbstractType
      * Before save type related data
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function beforeSave($product)
     {
@@ -818,7 +821,7 @@ abstract class AbstractType
      * Default action to get weight of product
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return decimal
+     * @return float
      */
     public function getWeight($product)
     {
@@ -850,10 +853,10 @@ abstract class AbstractType
      *
      * @param array $options
      * @param \Magento\Object $option
-     * @param mixed $value
+     * @param int|float|null $value
      * @param \Magento\Catalog\Model\Product $product
      *
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function updateQtyOption($options, \Magento\Object $option, $value, $product)
     {
@@ -891,7 +894,7 @@ abstract class AbstractType
      *
      * @param $store int|\Magento\Core\Model\Store
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function setStoreFilter($store, $product)
     {
@@ -915,7 +918,7 @@ abstract class AbstractType
     /**
      * Prepare Quote Item Quantity
      *
-     * @param mixed $qty
+     * @param int|float $qty
      * @param \Magento\Catalog\Model\Product $product
      * @return float
      */
@@ -931,7 +934,7 @@ abstract class AbstractType
      * @param \Magento\Catalog\Model\Product $optionProduct
      * @param \Magento\Sales\Model\Quote\Item\Option $option
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function assignProductToOption($optionProduct, $option, $product)
     {
@@ -948,7 +951,7 @@ abstract class AbstractType
      * Setting specified product type variables
      *
      * @param array $config
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function setConfig($config)
     {
@@ -1066,7 +1069,7 @@ abstract class AbstractType
      * Set image for product without image if possible
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\AbstractType
+     * @return $this
      */
     public function setImageFromChildProduct(\Magento\Catalog\Model\Product $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Configurable.php b/app/code/Magento/Catalog/Model/Product/Type/Configurable.php
index 40e1ae1fcc44e9a5791f8e814cc48b3dcbe43d23..e68a31785d9171f59087cb412c6d1cd6e6aac08a 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Configurable.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Configurable.php
@@ -498,7 +498,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
      * Before save process
      *
      * @param  \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\Configurable
+     * @return $this
      */
     public function beforeSave($product)
     {
@@ -530,7 +530,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
      * Save configurable product depended data
      *
      * @param  \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\Configurable
+     * @return $this
      */
     public function save($product)
     {
@@ -786,7 +786,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
      * Check if product can be bought
      *
      * @param  \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Product\Type\Configurable
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function checkProductBuyState($product)
@@ -889,7 +889,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
      * weight or configurable product weight
      *
      * @param  \Magento\Catalog\Model\Product $product
-     * @return decimal
+     * @return float
      */
     public function getWeight($product)
     {
@@ -912,7 +912,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
      * @param  \Magento\Catalog\Model\Product|null $optionProduct
      * @param  \Magento\Sales\Model\Quote\Item\Option $option
      * @param  \Magento\Catalog\Model\Product|null $product
-     * @return \Magento\Catalog\Model\Product\Type\Configurable
+     * @return $this
      */
     public function assignProductToOption($optionProduct, $option, $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/Catalog/Model/Product/Type/Configurable/Attribute.php
index 556cfce47a9004ff84a310d590bad4a3b5e75da9..e05a2a9a1749eeac8f50d6ad6c13de30cb32dd66 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Configurable/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Configurable/Attribute.php
@@ -51,6 +51,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -61,7 +62,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel
      * Add price data to attribute
      *
      * @param array $priceData
-     * @return \Magento\Catalog\Model\Product\Type\Configurable\Attribute
+     * @return $this
      */
     public function addPrice($priceData)
     {
@@ -93,7 +94,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel
     /**
      * After save process
      *
-     * @return \Magento\Catalog\Model\Product\Type\Configurable\Attribute
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -107,7 +108,8 @@ class Attribute extends \Magento\Core\Model\AbstractModel
      * Load counfigurable attribute by product and product's attribute
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @param \Magento\Eav\Model\Attribute  $attribute
+     * @param \Magento\Catalog\Model\Resource\Eav\Attribute  $attribute
+     * @return void
      */
     public function loadByProductAndAttribute($product, $attribute)
     {
@@ -121,6 +123,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel
      * Delete configurable attributes by product id
      *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     public function deleteByProduct($product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Configurable/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Configurable/Price.php
index 4c8552a101c4eb94ff6ce96dfa3f875e2aaffb65..89df94dfccee05d73b64a77eb1443b8058885c11 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Configurable/Price.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Configurable/Price.php
@@ -38,9 +38,9 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price
     /**
      * Get product final price
      *
-     * @param   double $qty
+     * @param   float $qty
      * @param   \Magento\Catalog\Model\Product $product
-     * @return  double
+     * @return  float
      */
     public function getFinalPrice($qty, $product)
     {
@@ -108,12 +108,12 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price
      * Calculate configurable product selection price
      *
      * @param   array $priceInfo
-     * @param   decimal $productPrice
-     * @return  decimal
+     * @param   float $productPrice
+     * @return  float
      */
     protected function _calcSelectionPrice($priceInfo, $productPrice)
     {
-        if($priceInfo['is_percent']) {
+        if ($priceInfo['is_percent']) {
             $ratio = $priceInfo['pricing_value']/100;
             $price = $productPrice * $ratio;
         } else {
@@ -122,9 +122,14 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price
         return $price;
     }
 
+    /**
+     * @param array $values
+     * @param int $index
+     * @return array|false
+     */
     protected function _getValueByIndex($values, $index) {
         foreach ($values as $value) {
-            if($value['value_index'] == $index) {
+            if ($value['value_index'] == $index) {
                 return $value;
             }
         }
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php
index 7672df782cceae5a4368db789adc98fbaa746338..409beb8b3ef9a0681d32bb06088bc72175c2dac8 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Price.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php
@@ -33,10 +33,16 @@
  */
 namespace Magento\Catalog\Model\Product\Type;
 
+use Magento\Catalog\Model\Product;
+use Magento\Core\Model\Store;
+
 class Price
 {
     const CACHE_TAG = 'PRODUCT_PRICE';
 
+    /**
+     * @var array
+     */
     static $attributeCache = array();
 
     /**
@@ -100,7 +106,8 @@ class Price
     /**
      * Default action to get price of product
      *
-     * @return decimal
+     * @param Product $product
+     * @return float
      */
     public function getPrice($product)
     {
@@ -110,7 +117,7 @@ class Price
     /**
      * Get base price with apply Group, Tier, Special prises
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @param float|null $qty
      *
      * @return float
@@ -128,7 +135,7 @@ class Price
      * Retrieve product final price
      *
      * @param float|null $qty
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return float
      */
     public function getFinalPrice($qty, $product)
@@ -150,6 +157,13 @@ class Price
         return $finalPrice;
     }
 
+    /**
+     * @param Product $product
+     * @param float $productQty
+     * @param Product $childProduct
+     * @param float $childProductQty
+     * @return float
+     */
     public function getChildFinalPrice($product, $productQty, $childProduct, $childProductQty)
     {
         return $this->getFinalPrice($childProductQty, $childProduct);
@@ -158,7 +172,7 @@ class Price
     /**
      * Apply group price for product
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @param float $finalPrice
      * @return float
      */
@@ -174,7 +188,7 @@ class Price
     /**
      * Get product group price
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @return float
      */
     public function getGroupPrice($product)
@@ -210,7 +224,7 @@ class Price
     /**
      * Apply tier price for product if not return price that was before
      *
-     * @param   \Magento\Catalog\Model\Product $product
+     * @param   Product $product
      * @param   float $qty
      * @param   float $finalPrice
      * @return  float
@@ -232,8 +246,8 @@ class Price
      * Get product tier price by qty
      *
      * @param   float $qty
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  float
+     * @param   Product $product
+     * @return  float|array
      */
     public function getTierPrice($qty, $product)
     {
@@ -312,6 +326,10 @@ class Price
         return ($prices) ? $prices : array();
     }
 
+    /**
+     * @param Product $product
+     * @return int
+     */
     protected function _getCustomerGroupId($product)
     {
         if ($product->getCustomerGroupId()) {
@@ -323,7 +341,7 @@ class Price
     /**
      * Apply special price for product if not return price that was before
      *
-     * @param   \Magento\Catalog\Model\Product $product
+     * @param   Product $product
      * @param   float $finalPrice
      * @return  float
      */
@@ -337,7 +355,7 @@ class Price
     /**
      * Count how many tier prices we have for the product
      *
-     * @param   \Magento\Catalog\Model\Product $product
+     * @param   Product $product
      * @return  int
      */
     public function getTierPriceCount($product)
@@ -350,8 +368,8 @@ class Price
      * Get formatted by currency tier price
      *
      * @param   float $qty
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  array || float
+     * @param   Product $product
+     * @return  array|float
      */
     public function getFormatedTierPrice($qty, $product)
     {
@@ -373,7 +391,7 @@ class Price
     /**
      * Get formatted by currency product price
      *
-     * @param   \Magento\Catalog\Model\Product $product
+     * @param   Product $product
      * @return  array || float
      */
     public function getFormatedPrice($product)
@@ -384,7 +402,7 @@ class Price
     /**
      * Apply options price
      *
-     * @param \Magento\Catalog\Model\Product $product
+     * @param Product $product
      * @param int $qty
      * @param float $finalPrice
      * @return float
@@ -416,16 +434,16 @@ class Price
      * @param   string $specialPriceFrom
      * @param   string $specialPriceTo
      * @param   float|null|false $rulePrice
-     * @param   mixed $wId
-     * @param   mixed $gId
-     * @param   null|int $productId
+     * @param   mixed|null $wId
+     * @param   mixed|null $gId
+     * @param   int|null $productId
      * @return  float
      */
     public function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
             $rulePrice = false, $wId = null, $gId = null, $productId = null)
     {
         \Magento\Profiler::start('__PRODUCT_CALCULATE_PRICE__');
-        if ($wId instanceof \Magento\Core\Model\Store) {
+        if ($wId instanceof Store) {
             $sId = $wId->getId();
             $wId = $wId->getWebsiteId();
         } else {
@@ -461,7 +479,7 @@ class Price
      * @param float $specialPrice
      * @param string $specialPriceFrom
      * @param string $specialPriceTo
-     * @param mixed $store
+     * @param int|string|Store $store
      * @return float
      */
     public function calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Simple.php b/app/code/Magento/Catalog/Model/Product/Type/Simple.php
index 23fb244987a2db9c42e75f5975bdaee865e55998..05ff63a57eecf844b90615137579e0ced0eb039f 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Simple.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Simple.php
@@ -39,6 +39,7 @@ class Simple extends \Magento\Catalog\Model\Product\Type\AbstractType
      * Delete data specific for Simple product type
      *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Virtual.php b/app/code/Magento/Catalog/Model/Product/Type/Virtual.php
index 71e0f812ddc8264103f2a244cc762d81306cf73e..4e2d46ece573b5a0bcc867ccf8f871e8ed317b83 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Virtual.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Virtual.php
@@ -60,6 +60,7 @@ class Virtual extends \Magento\Catalog\Model\Product\Type\AbstractType
      * Delete data specific for Virtual product type
      *
      * @param \Magento\Catalog\Model\Product $product
+     * @return void
      */
     public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Visibility.php b/app/code/Magento/Catalog/Model/Product/Visibility.php
index dcfb0284872f3f81adc5a97e1c3410ce765156ad..48aa003dc7c3591340b05a894222b721a6c538f3 100644
--- a/app/code/Magento/Catalog/Model/Product/Visibility.php
+++ b/app/code/Magento/Catalog/Model/Product/Visibility.php
@@ -83,7 +83,7 @@ class Visibility extends \Magento\Object
     /**
      * Retrieve visible in catalog ids array
      *
-     * @return array
+     * @return string[]
      */
     public function getVisibleInCatalogIds()
     {
@@ -93,7 +93,7 @@ class Visibility extends \Magento\Object
     /**
      * Retrieve visible in search ids array
      *
-     * @return array
+     * @return string[]
      */
     public function getVisibleInSearchIds()
     {
@@ -103,7 +103,7 @@ class Visibility extends \Magento\Object
     /**
      * Retrieve visible in site ids array
      *
-     * @return array
+     * @return string[]
      */
     public function getVisibleInSiteIds()
     {
@@ -138,7 +138,7 @@ class Visibility extends \Magento\Object
     }
 
     /**
-     * Retireve all options
+     * Retrieve all options
      *
      * @return array
      */
@@ -205,7 +205,6 @@ class Visibility extends \Magento\Object
     /**
      * Retrieve Select For Flat Attribute update
      *
-     * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
      * @param int $store
      * @return \Magento\DB\Select|null
      */
@@ -219,7 +218,7 @@ class Visibility extends \Magento\Object
      * Set attribute instance
      *
      * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute
-     * @return \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
+     * @return $this
      */
     public function setAttribute($attribute)
     {
@@ -242,7 +241,7 @@ class Visibility extends \Magento\Object
      *
      * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
      * @param string $dir direction
-     * @return \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
+     * @return $this
      */
     public function addValueSortToCollection($collection, $dir = 'asc')
     {
diff --git a/app/code/Magento/Catalog/Model/Product/Website.php b/app/code/Magento/Catalog/Model/Product/Website.php
index 3ffd883aa9b202c05d3642b065f905ce5d67382b..3e38eb0e70f8ea4c4b79237c1a959587b23b74c1 100644
--- a/app/code/Magento/Catalog/Model/Product/Website.php
+++ b/app/code/Magento/Catalog/Model/Product/Website.php
@@ -44,6 +44,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -65,7 +66,7 @@ class Website extends \Magento\Core\Model\AbstractModel
      *
      * @param array $websiteIds
      * @param array $productIds
-     * @return \Magento\Catalog\Model\Product\Website
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function removeProducts($websiteIds, $productIds)
@@ -85,7 +86,7 @@ class Website extends \Magento\Core\Model\AbstractModel
      *
      * @param array $websiteIds
      * @param array $productIds
-     * @return \Magento\Catalog\Model\Product\Website
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function addProducts($websiteIds, $productIds)
diff --git a/app/code/Magento/Catalog/Model/ProductOptions/Config/Converter.php b/app/code/Magento/Catalog/Model/ProductOptions/Config/Converter.php
index 4d2e6e8fa23feea514f6903ac0e433f25aa41ef7..290534f63b2eeba3484944a9f33a8d4cf9195687 100644
--- a/app/code/Magento/Catalog/Model/ProductOptions/Config/Converter.php
+++ b/app/code/Magento/Catalog/Model/ProductOptions/Config/Converter.php
@@ -36,7 +36,7 @@ class Converter implements \Magento\Config\ConverterInterface
     {
         $output = array();
 
-        /** @var $optionNode DOMNode */
+        /** @var $optionNode \DOMNode */
         foreach ($source->getElementsByTagName('option') as $optionNode) {
             $optionName = $this->_getAttributeValue($optionNode, 'name');
             $data = array();
@@ -44,7 +44,7 @@ class Converter implements \Magento\Config\ConverterInterface
             $data['label'] = $this->_getAttributeValue($optionNode, 'label');
             $data['renderer'] = $this->_getAttributeValue($optionNode, 'renderer');
 
-            /** @var $childNode DOMNode */
+            /** @var $childNode \DOMNode */
             foreach ($optionNode->childNodes as $childNode) {
                 if ($childNode->nodeType != XML_ELEMENT_NODE) {
                     continue;
@@ -64,9 +64,9 @@ class Converter implements \Magento\Config\ConverterInterface
     /**
      * Get attribute value
      *
-     * @param DOMNode $node
+     * @param \DOMNode $node
      * @param string $attributeName
-     * @param mixed $defaultValue
+     * @param string|null $defaultValue
      * @return null|string
      */
     protected function _getAttributeValue(\DOMNode $node, $attributeName, $defaultValue = null)
diff --git a/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php b/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php
index a9997336173702537dd5c0cb34e7c49382bb8f9f..6bd7e6ab0a9793b8784d65fe763a052d7e4a7d19 100644
--- a/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php
+++ b/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php
@@ -112,7 +112,7 @@ class Converter implements \Magento\Config\ConverterInterface
      *
      * @param \DOMNode $input
      * @param string $attributeName
-     * @param mixed $default
+     * @param string|null $default
      * @return null|string
      */
     protected function _getAttributeValue(\DOMNode $input, $attributeName, $default = null)
diff --git a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php
index bea9ea30ae5d53576e2e3369f8699e352aa8336d..4fdd7b435fe3bf166cf3f8ca4d28be29f10c627d 100644
--- a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php
+++ b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource;
 
 /**
  * Catalog entity abstract model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource;
-
 abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
 {
     /**
@@ -142,8 +140,6 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
         return parent::_isCallableAttributeInstance($instance, $method, $args);
     }
 
-
-
     /**
      * Retrieve select object for loading entity attributes values
      * Join attribute store value
@@ -204,7 +200,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      *
      * @param \Magento\Catalog\Model\AbstractModel $object
      * @param array $valueRow
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _setAttributeValue($object, $valueRow)
     {
@@ -244,7 +240,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      * @param \Magento\Catalog\Model\AbstractModel $object
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
      * @param mixed $value
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _saveAttributeValue($object, $attribute, $value)
     {
@@ -306,7 +302,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      * @param \Magento\Object $object
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
      * @param mixed $value
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _insertAttribute($object, $attribute, $value)
     {
@@ -348,7 +344,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
      * @param mixed $valueId
      * @param mixed $value
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _updateAttribute($object, $attribute, $valueId, $value)
     {
@@ -362,7 +358,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      * @param object $attribute
      * @param mixed $value
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _updateAttributeForStore($object, $attribute, $value, $storeId)
     {
@@ -411,7 +407,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      * @param \Magento\Object $object
      * @param string $table
      * @param array $info
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _deleteAttributes($object, $table, $info)
     {
@@ -511,7 +507,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      *
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
      * @param mixed $value New value of the attribute.
-     * @param array $origData
+     * @param array &$origData
      * @return bool
      */
     protected function _canUpdateAttribute(
@@ -650,7 +646,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
      * @param \Magento\Object $object
      * @param integer $entityId
      * @param array|null $attributes
-     * @return \Magento\Catalog\Model\Resource\AbstractResource
+     * @return $this
      */
     public function load($object, $entityId, $attributes = array())
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php
index 9add61456d7e1505495a7d053d2698b913d53a87..3ff094235f89237db0baf5c9869e7441e5d6b933 100644
--- a/app/code/Magento/Catalog/Model/Resource/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource;
 
 /**
  * Catalog attribute resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource;
-
 class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
 {
     /**
@@ -65,7 +63,7 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
      * Perform actions before object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Catalog\Model\Resource\Attribute
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -79,8 +77,8 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
     /**
      * Perform actions after object save
      *
-     * @param  \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Catalog\Model\Resource\Attribute
+     * @param \Magento\Core\Model\AbstractModel $object
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -92,7 +90,7 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
      * Clear useless attribute values
      *
      * @param  \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Catalog\Model\Resource\Attribute
+     * @return $this
      */
     protected function _clearUselessAttributeValues(\Magento\Core\Model\AbstractModel $object)
     {
@@ -120,7 +118,7 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
      * Delete entity
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Catalog\Model\Resource\Attribute
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function deleteEntity(\Magento\Core\Model\AbstractModel $object)
diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php
index 6ad68ce9e380887a2beaf5abbab8f5f7de57a05e..8df2283e5bdd5ec41562f1a37424295bb38adbc8 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category.php
@@ -34,7 +34,7 @@
  */
 namespace Magento\Catalog\Model\Resource;
 
-class Category extends \Magento\Catalog\Model\Resource\AbstractResource
+class Category extends AbstractResource
 {
     /**
      * Category tree object
@@ -143,7 +143,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * Set store Id
      *
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -184,7 +184,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * delete child categories
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     protected function _beforeDelete(\Magento\Object $object)
     {
@@ -208,7 +208,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * Delete children categories of specific category
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     public function deleteChildren(\Magento\Object $object)
     {
@@ -241,7 +241,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * prepare path and increment children count for parent categories
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     protected function _beforeSave(\Magento\Object $object)
     {
@@ -281,7 +281,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * save related products ids and update path value
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     protected function _afterSave(\Magento\Object $object)
     {
@@ -301,7 +301,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * Update path field
      *
      * @param \Magento\Catalog\Model\Category $object
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     protected function _savePath($object)
     {
@@ -346,7 +346,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * Save category products relation
      *
      * @param \Magento\Catalog\Model\Category $category
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     protected function _saveCategoryProducts($category)
     {
@@ -647,7 +647,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * Return parent categories of category
      *
      * @param \Magento\Catalog\Model\Category $category
-     * @return array
+     * @return \Magento\Object[]
      */
     public function getParentCategories($category)
     {
@@ -823,7 +823,7 @@ class Category extends \Magento\Catalog\Model\Resource\AbstractResource
      * @param \Magento\Catalog\Model\Category $category
      * @param \Magento\Catalog\Model\Category $newParent
      * @param null|int $afterCategoryId
-     * @return \Magento\Catalog\Model\Resource\Category
+     * @return $this
      */
     public function changeParent(\Magento\Catalog\Model\Category $category, \Magento\Catalog\Model\Category $newParent,
         $afterCategoryId = null
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php
index 5944ec3c36b5f525bd1da7a5f8daf6b7cba3013a..8d000ebe70220f770914531373fd34b9fc86ec72 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Attribute;
 
 /**
  * Catalog category EAV additional attribute resource collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Attribute;
-
 class Collection
     extends \Magento\Eav\Model\Resource\Entity\Attribute\Collection
 {
@@ -50,7 +48,7 @@ class Collection
      * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
      * @param \Magento\Event\ManagerInterface $eventManager
      * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
      */
     public function __construct(
@@ -70,7 +68,7 @@ class Collection
      * Main select object initialization.
      * Joins catalog/eav_attribute table
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Attribute\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -89,7 +87,7 @@ class Collection
      * Specify attribute entity type filter
      *
      * @param int $typeId
-     * @return \Magento\Catalog\Model\Resource\Category\Attribute\Collection
+     * @return $this
      */
     public function setEntityTypeFilter($typeId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php
index 7bc25029ff545c61fe01e5d24d6ff6192b1cecb9..3bb3d0f730d8c281c87240ad46e19c84fa6f203e 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Attribute\Frontend;
 
 /**
  * Category image attribute frontend
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Attribute\Frontend;
-
 class Image
     extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
 {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Layout.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Layout.php
index a017a4fd1e90c31df61cbadb5c4c027e83719943..14d773b790bf9687a703204e1199277989283baf 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Layout.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Layout.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Attribute\Source;
 
 /**
  * Catalog category landing page attribute source
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Attribute\Source;
-
 class Layout
     extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Mode.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Mode.php
index 5b63d55aa122342c968971806736d1df7f3fa213..787481bebbd72c91f56cb085ad306b0bb7530d4d 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Mode.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Mode.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Attribute\Source;
 
 /**
  * Catalog category landing page attribute source
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Attribute\Source;
-
 class Mode extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
     /**
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Page.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Page.php
index 46260fd38c28cef234f9cb492acb4bca32768b59..3648cb6919960f6bac0d3394cd995dbe05cad8dc 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Page.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Source/Page.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Attribute\Source;
 
 /**
  * Catalog category landing page attribute source
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Attribute\Source;
-
 class Page
     extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Collection.php
index 111924c2b3eee7eb0bec9cc879aa4bf292993913..27fe6a5e97d21e16944560f4644e0fde0995706b 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category;
 
 /**
  * Category resource collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category;
-
 class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractCollection
 {
     /**
@@ -81,6 +79,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Init collection and determine table names
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -94,7 +93,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Add Id filter
      *
      * @param array $categoryIds
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addIdFilter($categoryIds)
     {
@@ -122,7 +121,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Set flag for loading product count
      *
      * @param boolean $flag
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function setLoadProductCount($flag)
     {
@@ -133,7 +132,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Before collection load
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     protected function _beforeLoad()
     {
@@ -145,7 +144,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * After collection load
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -159,7 +158,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Set id of the store that we should count products on
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function setProductStoreId($storeId)
     {
@@ -185,7 +184,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param bool $printQuery
      * @param bool $logQuery
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function load($printQuery = false, $logQuery = false)
     {
@@ -210,6 +209,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Load categories product count
      *
+     * @return void
      */
     protected function _loadProductCount()
     {
@@ -222,7 +222,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * @param array $items
      * @param boolean $countRegular get product count for regular (non-anchor) categories
      * @param boolean $countAnchor get product count for anchor categories
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function loadProductCount($items, $countRegular = true, $countAnchor = true)
     {
@@ -307,7 +307,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Add category path filter
      *
      * @param string $regexp
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addPathFilter($regexp)
     {
@@ -318,7 +318,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Joins url rewrite rules to collection
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function joinUrlRewrite()
     {
@@ -339,7 +339,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add active category filter
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addIsActiveFilter()
     {
@@ -352,7 +352,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add name attribute to result
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addNameToResult()
     {
@@ -363,7 +363,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add url rewrite rules to collection
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addUrlRewriteToResult()
     {
@@ -375,7 +375,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Add category path filter
      *
      * @param array|string $paths
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addPathsFilter($paths)
     {
@@ -397,7 +397,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Add category level filter
      *
      * @param int|string $level
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addLevelFilter($level)
     {
@@ -408,7 +408,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add root category filter
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addRootLevelFilter()
     {
@@ -421,7 +421,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Add order field
      *
      * @param string $field
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return $this
      */
     public function addOrderField($field)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php
index a7a9368f0773bce4653f8029adabde15f619c1eb..7e1d06eb5c5c00df86fd3f6d6445d089c380b71c 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php
@@ -18,12 +18,9 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Catalog
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Resource\Category;
 
 /**
@@ -38,86 +35,35 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @var int
      */
-    protected $_storeId                  = null;
+    protected $_storeId;
 
     /**
      * Loaded
      *
      * @var boolean
      */
-    protected $_loaded                   = false;
+    protected $_loaded = false;
 
     /**
      * Nodes
      *
      * @var array
      */
-    protected $_nodes                    = array();
-
-    /**
-     * Columns
-     *
-     * @var array
-     */
-    protected $_columns                  = null;
-
-    /**
-     * Columns sql
-     *
-     * @var array
-     */
-    protected $_columnsSql               = null;
-
-    /**
-     * Attribute codes
-     *
-     * @var array
-     */
-    protected $_attributeCodes           = null;
+    protected $_nodes = array();
 
     /**
      * Inactive categories ids
      *
      * @var array
      */
-    protected $_inactiveCategoryIds      = null;
-
-    /**
-     * Store flag which defines if Catalog Category Flat Data has been initialized
-     *
-     * @var bool|null
-     */
-    protected $_isBuilt                  = null;
-
-    /**
-     * Store flag which defines if Catalog Category Flat Data has been initialized
-     *
-     * @deprecated after 1.7.0.0 use $this->_isBuilt instead
-     *
-     * @var bool|null
-     */
-    protected $_isRebuilt                = null;
-
-    /**
-     * array with root category id per store
-     *
-     * @var array
-     */
-    protected $_storesRootCategories;
+    protected $_inactiveCategoryIds;
 
     /**
      * Core event manager proxy
      *
      * @var \Magento\Event\ManagerInterface
      */
-    protected $_eventManager = null;
-
-    /**
-     * Catalog category
-     *
-     * @var \Magento\Catalog\Model\Category
-     */
-    protected $_catalogCategory;
+    protected $_eventManager;
 
     /**
      * Catalog config
@@ -148,23 +94,12 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
     protected $_categoryFactory;
 
     /**
-     * Catalog resource helper
-     *
-     * @var \Magento\Catalog\Model\Resource\Helper
-     */
-    protected $_resourceHelper;
-
-    /**
-     * Class constructor
-     *
      * @param \Magento\App\Resource $resource
      * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
      * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Catalog\Model\Config $catalogConfig
-     * @param \Magento\Catalog\Model\Category $catalogCategory
      * @param \Magento\Event\ManagerInterface $eventManager
-     * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
      */
     public function __construct(
         \Magento\App\Resource $resource,
@@ -172,23 +107,20 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
         \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Catalog\Model\Config $catalogConfig,
-        \Magento\Catalog\Model\Category $catalogCategory,
-        \Magento\Event\ManagerInterface $eventManager,
-        \Magento\Catalog\Model\Resource\Helper $resourceHelper
+        \Magento\Event\ManagerInterface $eventManager
     ) {
         $this->_categoryFactory = $categoryFactory;
         $this->_categoryCollectionFactory = $categoryCollectionFactory;
         $this->_storeManager = $storeManager;
         $this->_catalogConfig = $catalogConfig;
-        $this->_catalogCategory = $catalogCategory;
         $this->_eventManager = $eventManager;
-        $this->_resourceHelper = $resourceHelper;
         parent::__construct($resource);
     }
 
     /**
      * Resource initializations
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -199,7 +131,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
      * Set store id
      *
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -241,7 +173,8 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
         if (is_string($storeId)) {
             $storeId = intval($storeId);
         }
-        if ($this->getUseStoreTables() && $storeId) {
+
+        if ($storeId) {
             $suffix = sprintf('store_%d', $storeId);
             $table = $this->getTable('catalog_category_flat_' . $suffix);
         } else {
@@ -251,21 +184,11 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
         return $table;
     }
 
-    /**
-     * Return true if need use for each store different table of flat categories data.
-     *
-     * @return boolean
-     */
-    public function getUseStoreTables()
-    {
-        return true;
-    }
-
     /**
      * Add inactive categories ids
      *
-     * @param unknown_type $ids
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
+     * @param array $ids
+     * @return $this
      */
     public function addInactiveCategoryIds($ids)
     {
@@ -279,7 +202,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Retrieve inactive categories ids
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
+     * @return $this
      */
     protected function _initInactiveCategoryIds()
     {
@@ -308,7 +231,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
      * @param \Magento\Catalog\Model\Category|int $parentNode
      * @param integer $recursionLevel
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
+     * @return array
      */
     protected function _loadNodes($parentNode = null, $recursionLevel = 0, $storeId = 0)
     {
@@ -441,8 +364,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
                 $childrenNodes = $this->_nodes[$parentNode->getId()];
                 if ($childrenNodes->getChildrenNodes()) {
                     $this->_nodes = $childrenNodes->getChildrenNodes();
-                }
-                else {
+                } else {
                     $this->_nodes = array();
                 }
                 $this->_loaded = true;
@@ -508,730 +430,10 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
         return array();
     }
 
-    /**
-     * Check if Catalog Category Flat Data has been initialized
-     *
-     * @return bool
-     */
-    public function isBuilt()
-    {
-        if ($this->_isBuilt === null) {
-            $defaultStoreView = $this->_storeManager->getDefaultStoreView();
-            if ($defaultStoreView === null) {
-                $defaultStoreId = \Magento\Core\Model\Store::DEFAULT_STORE_ID;
-            } else {
-                $defaultStoreId = $defaultStoreView->getId();
-            }
-            $select = $this->_getReadAdapter()->select()
-                ->from($this->getMainStoreTable($defaultStoreId), 'entity_id')
-                ->limit(1);
-            try {
-                $this->_isBuilt = (bool)$this->_getReadAdapter()->fetchOne($select);
-            } catch (\Exception $e) {
-                $this->_isBuilt = false;
-            }
-        }
-        return $this->_isBuilt;
-    }
-
-    /**
-     * Rebuild flat data from eav
-     *
-     * @param array|null $stores
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function rebuild($stores = null)
-    {
-        if ($stores === null) {
-            $stores = $this->_storeManager->getStores();
-        }
-
-        if (!is_array($stores)) {
-            $stores = array($stores);
-        }
-
-        $this->_createTables($stores);
-        $this->_populateFlatTables($stores);
-
-        return $this;
-    }
-
-    /**
-     * Populate category flat tables with data
-     *
-     * @param array $stores
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected function _populateFlatTables($stores)
-    {
-        $rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
-        $categories = array();
-        $categoriesIds = array();
-        /* @var $store \Magento\Core\Model\Store */
-        foreach ($stores as $store) {
-
-            if (!isset($categories[$store->getRootCategoryId()])) {
-                $select = $this->_getWriteAdapter()->select()
-                    ->from($this->getTable('catalog_category_entity'))
-                    ->where('path = ?', (string)$rootId)
-                    ->orWhere('path = ?', "{$rootId}/{$store->getRootCategoryId()}")
-                    ->orWhere('path LIKE ?', "{$rootId}/{$store->getRootCategoryId()}/%");
-                $categories[$store->getRootCategoryId()] = $this->_getWriteAdapter()->fetchAll($select);
-                $categoriesIds[$store->getRootCategoryId()] = array();
-                foreach ($categories[$store->getRootCategoryId()] as $category) {
-                    $categoriesIds[$store->getRootCategoryId()][] = $category['entity_id'];
-                }
-            }
-            $categoriesIdsChunks = array_chunk($categoriesIds[$store->getRootCategoryId()], 500);
-            foreach ($categoriesIdsChunks as $categoriesIdsChunk) {
-                $attributesData = $this->_getAttributeValues($categoriesIdsChunk, $store->getId());
-                $data = array();
-                foreach ($categories[$store->getRootCategoryId()] as $category) {
-                    if (!isset($attributesData[$category['entity_id']])) {
-                        continue;
-                    }
-                    $category['store_id'] = $store->getId();
-                    $data[] = $this->_prepareValuesToInsert(
-                        array_merge($category, $attributesData[$category['entity_id']])
-                    );
-                }
-                $this->_getWriteAdapter()->insertMultiple($this->getMainStoreTable($store->getId()), $data);
-            }
-        }
-        return $this;
-    }
-
-    /**
-     * Prepare array of column and columnValue pairs
-     *
-     * @param array $data
-     * @return array
-     */
-    protected function _prepareValuesToInsert($data)
-    {
-        $values = array();
-        foreach (array_keys($this->_columns) as $key => $column) {
-            if (isset($data[$column])) {
-                $values[$column] = $data[$column];
-            } else {
-                $values[$column] = null;
-            }
-        }
-        return $values;
-    }
-
-    /**
-     * Create category flat table for specified store.
-     * Table is created only if DDL operations are allowed
-     *
-     * @param int $store
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function createTable($store)
-    {
-        if ($this->_getWriteAdapter()->getTransactionLevel() > 0) {
-            return $this;
-        }
-        return $this->_createTable($store);
-    }
-
-    /**
-     * Create table and add attributes as fields for specified store.
-     * This routine assumes that DDL operations are allowed
-     *
-     * @param int $store
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected function _createTable($store)
-    {
-        $tableName = $this->getMainStoreTable($store);
-        $_writeAdapter = $this->_getWriteAdapter();
-        $_writeAdapter->dropTable($tableName);
-        $table = $this->_getWriteAdapter()
-            ->newTable($tableName)
-            ->setComment(sprintf('Catalog Category Flat (Store %d)', $store));
-
-        //Adding columns
-        if ($this->_columnsSql === null) {
-            $this->_columns = array_merge($this->_getStaticColumns(), $this->_getEavColumns());
-            foreach ($this->_columns as $fieldName => $fieldProp) {
-                $default = $fieldProp['default'];
-                if ($fieldProp['type'][0] == \Magento\DB\Ddl\Table::TYPE_TIMESTAMP
-                    && $default == 'CURRENT_TIMESTAMP') {
-                    $default = \Magento\DB\Ddl\Table::TIMESTAMP_INIT;
-                }
-                $table->addColumn($fieldName, $fieldProp['type'][0], $fieldProp['type'][1], array(
-                    'nullable' => $fieldProp['nullable'],
-                    'unsigned' => $fieldProp['unsigned'],
-                    'default'  => $default,
-                    'primary'  => isset($fieldProp['primary']) ? $fieldProp['primary'] : false,
-                ), ($fieldProp['comment'] != '') ?
-                    $fieldProp['comment'] :
-                    ucwords(str_replace('_', ' ', $fieldName))
-                );
-            }
-        }
-
-        // Adding indexes
-        $table->addIndex(
-            $_writeAdapter->getIndexName($tableName, array('entity_id')),
-            array('entity_id'),
-            array('type' => 'primary')
-        );
-        $table->addIndex(
-            $_writeAdapter->getIndexName($tableName, array('store_id')), array('store_id'), array('type' => 'index')
-        );
-        $table->addIndex(
-            $_writeAdapter->getIndexName($tableName, array('path')), array('path'), array('type' => 'index')
-        );
-        $table->addIndex(
-            $_writeAdapter->getIndexName($tableName, array('level')), array('level'), array('type' => 'index')
-        );
-
-        // Adding foreign keys
-        $table->addForeignKey(
-            $_writeAdapter->getForeignKeyName(
-                $tableName, 'entity_id', $this->getTable('catalog_category_entity'), 'entity_id'
-            ),
-            'entity_id', $this->getTable('catalog_category_entity'), 'entity_id',
-            \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE);
-        $table->addForeignKey(
-            $_writeAdapter->getForeignKeyName($tableName, 'store_id', $this->getTable('core_store'), 'store_id'),
-            'store_id', $this->getTable('core_store'), 'store_id',
-            \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE);
-        $_writeAdapter->createTable($table);
-        return $this;
-    }
-
-    /**
-     * Return array of static columns
-     *
-     * @return array
-     */
-    protected function _getStaticColumns()
-    {
-        $columns = array();
-        $columnsToSkip = array('entity_type_id', 'attribute_set_id');
-        $describe = $this->_getWriteAdapter()->describeTable($this->getTable('catalog_category_entity'));
-
-        foreach ($describe as $column) {
-            if (in_array($column['COLUMN_NAME'], $columnsToSkip)) {
-                continue;
-            }
-            $_is_unsigned = '';
-            $ddlType = $this->_resourceHelper->getDdlTypeByColumnType($column['DATA_TYPE']);
-            $column['DEFAULT'] = trim($column['DEFAULT'],"' ");
-            switch ($ddlType) {
-                case \Magento\DB\Ddl\Table::TYPE_SMALLINT:
-                case \Magento\DB\Ddl\Table::TYPE_INTEGER:
-                case \Magento\DB\Ddl\Table::TYPE_BIGINT:
-                    $_is_unsigned = (bool)$column['UNSIGNED'];
-                    if ($column['DEFAULT'] === '') {
-                        $column['DEFAULT'] = null;
-                    }
-
-                    $options = null;
-                    if ($column['SCALE'] > 0) {
-                        $ddlType = \Magento\DB\Ddl\Table::TYPE_DECIMAL;
-                    } else {
-                        break;
-                    }
-                // fall-through intentional
-                case \Magento\DB\Ddl\Table::TYPE_DECIMAL:
-                    $options = $column['PRECISION'] . ',' . $column['SCALE'];
-                    $_is_unsigned = null;
-                    if ($column['DEFAULT'] === '') {
-                        $column['DEFAULT'] = null;
-                    }
-                    break;
-                case \Magento\DB\Ddl\Table::TYPE_TEXT:
-                    $options = $column['LENGTH'];
-                    $_is_unsigned = null;
-                    break;
-                case \Magento\DB\Ddl\Table::TYPE_TIMESTAMP:
-                    $options = null;
-                    $_is_unsigned = null;
-                    break;
-                case \Magento\DB\Ddl\Table::TYPE_DATETIME:
-                    $_is_unsigned = null;
-                    break;
-
-            }
-            $columns[$column['COLUMN_NAME']] = array(
-                'type' => array($ddlType, $options),
-                'unsigned' => $_is_unsigned,
-                'nullable' => $column['NULLABLE'],
-                'default' => ($column['DEFAULT'] === null ? false : $column['DEFAULT']),
-                'comment' => $column['COLUMN_NAME']
-            );
-        }
-        $columns['store_id'] = array(
-            'type' => array(\Magento\DB\Ddl\Table::TYPE_SMALLINT, 5),
-            'unsigned' => true,
-            'nullable' => false,
-            'default' => '0',
-            'comment' => 'Store Id'
-        );
-        return $columns;
-    }
-
-    /**
-     * Return array of eav columns, skip attribute with static type
-     *
-     * @return array
-     */
-    protected function _getEavColumns()
-    {
-        $columns = array();
-        $attributes = $this->_getAttributes();
-        foreach ($attributes as $attribute) {
-            if ($attribute['backend_type'] == 'static') {
-                continue;
-            }
-            $columns[$attribute['attribute_code']] = array();
-            switch ($attribute['backend_type']) {
-                case 'varchar':
-                    $columns[$attribute['attribute_code']] = array(
-                        'type' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, 255),
-                        'unsigned' => null,
-                        'nullable' => true,
-                        'default' => null,
-                        'comment' => (string)$attribute['frontend_label']
-                    );
-                    break;
-                case 'int':
-                    $columns[$attribute['attribute_code']] = array(
-                        'type' => array(\Magento\DB\Ddl\Table::TYPE_INTEGER, null),
-                        'unsigned' => null,
-                        'nullable' => true,
-                        'default' => null,
-                        'comment' => (string)$attribute['frontend_label']
-                    );
-                    break;
-                case 'text':
-                    $columns[$attribute['attribute_code']] = array(
-                        'type' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, '64k'),
-                        'unsigned' => null,
-                        'nullable' => true,
-                        'default' => null,
-                        'comment' => (string)$attribute['frontend_label']
-                    );
-                    break;
-                case 'datetime':
-                    $columns[$attribute['attribute_code']] = array(
-                        'type' => array(\Magento\DB\Ddl\Table::TYPE_DATETIME, null),
-                        'unsigned' => null,
-                        'nullable' => true,
-                        'default' => null,
-                        'comment' => (string)$attribute['frontend_label']
-                    );
-                    break;
-                case 'decimal':
-                    $columns[$attribute['attribute_code']] = array(
-                        'type' => array(\Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4'),
-                        'unsigned' => null,
-                        'nullable' => true,
-                        'default' => null,
-                        'comment' => (string)$attribute['frontend_label']
-                    );
-                    break;
-            }
-        }
-        return $columns;
-    }
-
-    /**
-     * Return array of attribute codes for entity type 'catalog_category'
-     *
-     * @return array
-     */
-    protected function _getAttributes()
-    {
-        if ($this->_attributeCodes === null) {
-            $select = $this->_getWriteAdapter()->select()
-                ->from($this->getTable('eav_entity_type'), array())
-                ->join(
-                    $this->getTable('eav_attribute'),
-                    $this->getTable('eav_attribute')
-                        . '.entity_type_id = ' . $this->getTable('eav_entity_type') . '.entity_type_id',
-                    $this->getTable('eav_attribute').'.*'
-                )
-                ->where(
-                    $this->getTable('eav_entity_type') . '.entity_type_code = ?', \Magento\Catalog\Model\Category::ENTITY
-                );
-            $this->_attributeCodes = array();
-            foreach ($this->_getWriteAdapter()->fetchAll($select) as $attribute) {
-                $this->_attributeCodes[$attribute['attribute_id']] = $attribute;
-            }
-        }
-        return $this->_attributeCodes;
-    }
-
-    /**
-     * Return attribute values for given entities and store
-     *
-     * @param array $entityIds
-     * @param integer $store_id
-     * @return array
-     */
-    protected function _getAttributeValues($entityIds, $store_id)
-    {
-        if (!is_array($entityIds)) {
-            $entityIds = array($entityIds);
-        }
-        $values = array();
-
-        foreach ($entityIds as $entityId) {
-            $values[$entityId] = array();
-        }
-        $attributes = $this->_getAttributes();
-        $attributesType = array(
-            'varchar',
-            'int',
-            'decimal',
-            'text',
-            'datetime'
-        );
-        foreach ($attributesType as $type) {
-            foreach ($this->_getAttributeTypeValues($type, $entityIds, $store_id) as $row) {
-                $values[$row['entity_id']][$attributes[$row['attribute_id']]['attribute_code']] = $row['value'];
-            }
-        }
-        return $values;
-    }
-
-    /**
-     * Return attribute values for given entities and store of specific attribute type
-     *
-     * @param string $type
-     * @param array $entityIds
-     * @param integer $storeId
-     * @return array
-     */
-    protected function _getAttributeTypeValues($type, $entityIds, $storeId)
-    {
-        $select = $this->_getWriteAdapter()->select()
-            ->from(
-                array('def' => $this->getTable('catalog_category_entity_' . $type)),
-                array('entity_id', 'attribute_id')
-            )
-            ->joinLeft(
-                array('store' => $this->getTable(array('catalog_category_entity', $type))),
-                'store.entity_id = def.entity_id AND store.attribute_id = def.attribute_id '
-                    . 'AND store.store_id = ' . $storeId,
-                array('value' => $this->_getWriteAdapter()->getCheckSql(
-                    'store.value_id > 0',
-                    $this->_getWriteAdapter()->quoteIdentifier('store.value'),
-                    $this->_getWriteAdapter()->quoteIdentifier('def.value')
-                ))
-            )
-            ->where('def.entity_id IN (?)', $entityIds)
-            ->where('def.store_id IN (?)', array(\Magento\Core\Model\Store::DEFAULT_STORE_ID, $storeId));
-        return $this->_getWriteAdapter()->fetchAll($select);
-    }
-
-    /**
-     * Delete store table(s) of given stores;
-     *
-     * @param array|integer $stores
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function deleteStores($stores)
-    {
-        $this->_deleteTable($stores);
-        return $this;
-    }
-
-    /**
-     * Delete table(s) of given stores.
-     *
-     * @param array|integer $stores
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected function _deleteTable($stores)
-    {
-        if (!is_array($stores)) {
-            $stores = array($stores);
-        }
-        foreach ($stores as $store) {
-            $this->_getWriteAdapter()->dropTable($this->getMainStoreTable($store));
-        }
-        return $this;
-    }
-
-    /**
-     * Synchronize flat data with eav model for category
-     *
-     * @param \Magento\Object $category
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected function _synchronize($category)
-    {
-        $table = $this->getMainStoreTable($category->getStoreId());
-        $data  = $this->_prepareDataForAllFields($category);
-        $this->_getWriteAdapter()->insertOnDuplicate($table, $data);
-        return $this;
-    }
-
-    /**
-     * Synchronize flat data with eav model.
-     *
-     * @param \Magento\Catalog\Model\Category|int $category
-     * @param array $storeIds
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function synchronize($category = null, $storeIds = array())
-    {
-        if (is_null($category)) {
-            if (empty($storeIds)) {
-                $storeIds = null;
-            }
-            $stores = $this->getStoresRootCategories($storeIds);
-
-            $storesObjects = array();
-            foreach ($stores as $storeId => $rootCategoryId) {
-                $_store = new \Magento\Object(array(
-                    'store_id'          => $storeId,
-                    'root_category_id'  => $rootCategoryId
-                ));
-                $_store->setIdFieldName('store_id');
-                $storesObjects[] = $_store;
-            }
-
-            $this->rebuild($storesObjects);
-        } else if ($category instanceof \Magento\Catalog\Model\Category) {
-            $categoryId = $category->getId();
-            foreach ($category->getStoreIds() as $storeId) {
-                if ($storeId == \Magento\Core\Model\Store::DEFAULT_STORE_ID) {
-                    continue;
-                }
-
-                $attributeValues = $this->_getAttributeValues($categoryId, $storeId);
-                $data = new \Magento\Object($category->getData());
-                $data->addData($attributeValues[$categoryId])
-                    ->setStoreId($storeId);
-                $this->_synchronize($data);
-            }
-        } else if (is_numeric($category)) {
-            $write  = $this->_getWriteAdapter();
-            $select = $write->select()
-                ->from($this->getTable('catalog_category_entity'))
-                ->where('entity_id=?', $category);
-            $row    = $write->fetchRow($select);
-            if (!$row) {
-                return $this;
-            }
-
-            $stores = $this->getStoresRootCategories();
-            $path   = explode('/', $row['path']);
-            foreach ($stores as $storeId => $rootCategoryId) {
-                if (in_array($rootCategoryId, $path)) {
-                    $attributeValues = $this->_getAttributeValues($category, $storeId);
-                    $data = new \Magento\Object($row);
-                    $data->addData($attributeValues[$category])
-                        ->setStoreId($storeId);
-                    $this->_synchronize($data);
-                } else {
-                    $where = $write->quoteInto('entity_id = ?', $category);
-                    $write->delete($this->getMainStoreTable($storeId), $where);
-                }
-            }
-        }
-
-        return $this;
-    }
-
-    /**
-     * Remove table of given stores
-     *
-     * @param int|array $stores
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function removeStores($stores)
-    {
-        $this->_deleteTable($stores);
-        return $this;
-    }
-
-    /**
-     * Synchronize flat category data after move by affected category ids
-     *
-     * @param array $affectedCategoryIds
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function move(array $affectedCategoryIds)
-    {
-        $write  = $this->_getWriteAdapter();
-        $select = $write->select()
-            ->from($this->getTable('catalog_category_entity'), array('entity_id', 'path'))
-            ->where('entity_id IN(?)', $affectedCategoryIds);
-        $pairs  = $write->fetchPairs($select);
-
-        $pathCond  = array($write->quoteInto('entity_id IN(?)', $affectedCategoryIds));
-        $parentIds = array();
-
-        foreach ($pairs as $path) {
-            $pathCond[] = $write->quoteInto('path LIKE ?', $path . '/%');
-            $parentIds  = array_merge($parentIds, explode('/', $path));
-        }
-
-        $stores = $this->getStoresRootCategories();
-        $where  = join(' OR ', $pathCond);
-        $lastId = 0;
-        while (true) {
-            $select = $write->select()
-                ->from($this->getTable('catalog_category_entity'))
-                ->where('entity_id>?', $lastId)
-                ->where($where)
-                ->order('entity_id')
-                ->limit(500);
-            $rowSet = $write->fetchAll($select);
-
-            if (!$rowSet) {
-                break;
-            }
-
-            $addStores = array();
-            $remStores = array();
-
-            foreach ($rowSet as &$row) {
-                $lastId = $row['entity_id'];
-                $path = explode('/', $row['path']);
-                foreach ($stores as $storeId => $rootCategoryId) {
-                    if (in_array($rootCategoryId, $path)) {
-                        $addStores[$storeId][$row['entity_id']] = $row;
-                    } else {
-                        $remStores[$storeId][] = $row['entity_id'];
-                    }
-                }
-            }
-
-            // remove
-            foreach ($remStores as $storeId => $categoryIds) {
-                $where = $write->quoteInto('entity_id IN(?)', $categoryIds);
-                $write->delete($this->getMainStoreTable($storeId), $where);
-            }
-
-            // add/update
-            foreach ($addStores as $storeId => $storeCategoryIds) {
-                $attributeValues = $this->_getAttributeValues(array_keys($storeCategoryIds), $storeId);
-                foreach ($storeCategoryIds as $row) {
-                    $data = new \Magento\Object($row);
-                    $data->addData($attributeValues[$row['entity_id']])
-                        ->setStoreId($storeId);
-                    $this->_synchronize($data);
-                }
-            }
-        }
-
-        return $this;
-    }
-
-    /**
-     * Synchronize flat data with eav after moving category
-     *
-     * @param integer $categoryId
-     * @param integer $prevParentId
-     * @param integer $parentId
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function moveold($categoryId, $prevParentId, $parentId)
-    {
-        $catalogCategoryTable = $this->getTable('catalog_category_entity');
-        $_staticFields = array(
-            'parent_id',
-            'path',
-            'level',
-            'position',
-            'children_count',
-            'updated_at'
-        );
-        $prevParent = $this->_categoryFactory->create()->load($prevParentId);
-        $parent = $this->_categoryFactory->create()->load($parentId);
-        if ($prevParent->getStore()->getWebsiteId() != $parent->getStore()->getWebsiteId()) {
-            foreach ($prevParent->getStoreIds() as $storeId) {
-                $this->_getWriteAdapter()->delete(
-                    $this->getMainStoreTable($storeId),
-                    $this->_getWriteAdapter()->quoteInto('entity_id = ?', $categoryId)
-                );
-            }
-            $select = $this->_getReadAdapter()->select()
-                ->from($catalogCategoryTable, 'path')
-                ->where('entity_id = ?', $categoryId);
-
-            $categoryPath = $this->_getWriteAdapter()->fetchOne($select);
-
-            $select = $this->_getWriteAdapter()->select()
-                ->from($catalogCategoryTable, 'entity_id')
-                ->where('path LIKE ?', "$categoryPath/%")
-                ->orWhere('path = ?', $categoryPath);
-            $_categories = $this->_getWriteAdapter()->fetchAll($select);
-            foreach ($_categories as $_category) {
-                foreach ($parent->getStoreIds() as $storeId) {
-                    $_tmpCategory = $this->_categoryFactory->create()
-                        ->setStoreId($storeId)
-                        ->load($_category['entity_id']);
-                    $this->_synchronize($_tmpCategory);
-                }
-            }
-        } else {
-            foreach ($parent->getStoreIds() as $store) {
-                $mainStoreTable = $this->getMainStoreTable($store);
-
-                $update = "UPDATE {$mainStoreTable}, {$catalogCategoryTable} SET";
-                foreach ($_staticFields as $field) {
-                    $update .= " {$mainStoreTable}.".$field."={$catalogCategoryTable}.".$field.",";
-                }
-                $update = substr($update, 0, -1);
-                $update .= " WHERE {$mainStoreTable}.entity_id = {$catalogCategoryTable}.entity_id AND " .
-                    "($catalogCategoryTable}.path like '{$parent->getPath()}/%' OR " .
-                    "{$catalogCategoryTable}.path like '{$prevParent->getPath()}/%')";
-                $this->_getWriteAdapter()->query($update);
-            }
-        }
-        $prevParent   = null;
-        $parent       = null;
-        $_tmpCategory = null;
-//        $this->_move($categoryId, $prevParentPath, $parentPath);
-        return $this;
-    }
-
-    /**
-     * Prepare array of category data to insert or update.
-     * array(
-     *  'field_name' => 'value'
-     * )
-     *
-     * @param \Magento\Object $category
-     * @param array $replaceFields
-     * @return array
-     */
-    protected function _prepareDataForAllFields($category, $replaceFields = array())
-    {
-        $table = $this->getMainStoreTable($category->getStoreId());
-        $this->_getWriteAdapter()->resetDdlCache($table);
-        $table = $this->_getWriteAdapter()->describeTable($table);
-        $data = array();
-        $idFieldName = $this->_catalogCategory->getIdFieldName();
-        foreach ($table as $column => $columnData) {
-            if ($column != $idFieldName || null !== $category->getData($column)) {
-                if (key_exists($column, $replaceFields)) {
-                    $value = $category->getData($replaceFields[$column]);
-                } else {
-                    $value = $category->getData($column);
-                }
-                if (is_array($value)) {
-                    $value = implode(',', $value);
-                }
-                $data[$column] = $value;
-            }
-        }
-        return $data;
-    }
-
     /**
      * Retrieve attribute instance
-     * Special for non static flat table
+     *
+     * Special for non static flat table.
      *
      * @param mixed $attribute
      * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
@@ -1281,7 +483,7 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
      * Return parent categories of category
      *
      * @param \Magento\Catalog\Model\Category $category
-     * @param unknown_type $isActive
+     * @param bool $isActive
      * @return array
      */
     public function getParentCategories($category, $isActive = true)
@@ -1362,8 +564,8 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
      * Return children ids of category
      *
      * @param \Magento\Catalog\Model\Category $category
-     * @param unknown_type $recursive
-     * @param unknown_type $isActive
+     * @param bool $recursive
+     * @param bool $isActive
      * @return array
      */
     public function getChildren($category, $recursive = true, $isActive = true)
@@ -1414,45 +616,6 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
         return $this->_getReadAdapter()->fetchOne($select);
     }
 
-    /**
-     * Get design update data of parent categories
-     *
-     * @param \Magento\Catalog\Model\Category $category
-     * @return array
-     */
-    public function getDesignUpdateData($category)
-    {
-        $categories = array();
-        $pathIds = array();
-        foreach (array_reverse($category->getParentIds()) as $pathId) {
-            if ($pathId == $this->_storeManager->getStore()->getRootCategoryId()) {
-                $pathIds[] = $pathId;
-                break;
-            }
-            $pathIds[] = $pathId;
-        }
-        $select = $this->_getReadAdapter()->select()
-            ->from(
-                array('main_table' => $this->getMainStoreTable($category->getStoreId())),
-                array(
-                    'main_table.entity_id',
-                    'main_table.custom_design',
-                    'main_table.custom_design_apply',
-                    'main_table.custom_design_from',
-                    'main_table.custom_design_to',
-                )
-            )
-            ->where('main_table.entity_id IN (?)', $pathIds)
-            ->where('main_table.is_active = ?', '1')
-            ->order('main_table.path ' . \Magento\DB\Select::SQL_DESC);
-        $result = $this->_getReadAdapter()->fetchAll($select);
-        foreach ($result as $row) {
-            $row['id'] = $row['entity_id'];
-            $categories[$row['entity_id']] = $this->_categoryFactory->create()->setData($row);
-        }
-        return $categories;
-    }
-
     /**
      * Retrieve anchors above
      *
@@ -1469,92 +632,4 @@ class Flat extends \Magento\Index\Model\Resource\AbstractResource
 
         return $this->_getReadAdapter()->fetchCol($select);
     }
-
-    /**
-     * Retrieve array with root category id per store
-     *
-     * @param int|array $storeIds   result limitation
-     * @return array
-     */
-    public function getStoresRootCategories($storeIds = null)
-    {
-        if (is_null($this->_storesRootCategories)) {
-            $select = $this->_getWriteAdapter()->select()
-                ->from(array('cs' => $this->getTable('core_store')), array('store_id'))
-                ->join(
-                    array('csg' => $this->getTable('core_store_group')),
-                    'csg.group_id = cs.group_id',
-                    array('root_category_id'))
-                ->where('cs.store_id <> ?', \Magento\Core\Model\Store::DEFAULT_STORE_ID);
-            $this->_storesRootCategories = $this->_getWriteAdapter()->fetchPairs($select);
-        }
-
-        if (!is_null($storeIds)) {
-            if (!is_array($storeIds)) {
-                $storeIds = array($storeIds);
-            }
-
-            $stores = array();
-            foreach ($this->_storesRootCategories as $storeId => $rootId) {
-                if (in_array($storeId, $storeIds)) {
-                    $stores[$storeId] = $rootId;
-                }
-            }
-            return $stores;
-        }
-
-        return $this->_storesRootCategories;
-    }
-
-    /**
-     * Create category flat tables and add attributes as fields.
-     * Tables are created only if DDL operations are allowed
-     *
-     * @param array $stores if empty, create tables for all stores of the application
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected function _createTables($stores = array())
-    {
-        if ($this->_getWriteAdapter()->getTransactionLevel() > 0) {
-            return $this;
-        }
-        if (empty($stores)) {
-            $stores = $this->_storeManager->getStores();
-        }
-        foreach ($stores as $store) {
-            $this->_createTable($store->getId());
-        }
-        return $this;
-    }
-
-    /**
-     * Transactional rebuild flat data from eav
-     *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    public function reindexAll()
-    {
-        $this->_createTables();
-        $this->beginTransaction();
-        try {
-            $this->rebuild();
-            $this->commit();
-        } catch (\Exception $e) {
-            $this->rollBack();
-            throw $e;
-        }
-        return $this;
-    }
-
-    /**
-     * Check if Catalog Category Flat Data has been initialized
-     *
-     * @deprecated use \Magento\Catalog\Model\Resource\Category\Flat::isBuilt() instead
-     *
-     * @return bool
-     */
-    public function isRebuilt()
-    {
-        return $this->isBuilt();
-    }
 }
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php
index 49fa1dad5527b3b7d8afd3b325e011ee785bd16b..616bade7e6442f11aebee947f148ce46016eca5b 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Flat;
 
 /**
  * Catalog category flat collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Flat;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -70,7 +68,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
      * @param \Magento\Event\ManagerInterface $eventManager
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
      */
     public function __construct(
@@ -87,8 +85,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     *  Collection initialization
+     * Collection initialization
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -96,7 +95,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -110,8 +109,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add filter by entity id(s).
      *
-     * @param mixed $categoryIds
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @param array|int|string $categoryIds
+     * @return $this
      */
     public function addIdFilter($categoryIds)
     {
@@ -138,7 +137,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Before collection load
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     protected function _beforeLoad()
     {
@@ -149,7 +148,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * After collection load
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -161,7 +160,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set store id
      *
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -187,7 +186,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by path to collection
      *
      * @param string $parent
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addParentPathFilter($parent)
     {
@@ -198,7 +197,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add store filter
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addStoreFilter()
     {
@@ -210,7 +209,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set field to sort by
      *
      * @param string $sorted
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addSortedField($sorted)
     {
@@ -223,7 +222,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addIsActiveFilter()
     {
@@ -236,7 +235,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add name field to result
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addNameToResult()
     {
@@ -248,7 +247,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add attribute to select
      *
      * @param array|string $attribute
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addAttributeToSelect($attribute = '*')
     {
@@ -299,7 +298,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param string $attribute
      * @param string $dir
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
     {
@@ -314,8 +313,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Emulate simple add attribute filter to collection
      *
      * @param string $attribute
-     * @param mixed $condition
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @param null|string|array $condition
+     * @return $this
      */
     public function addAttributeToFilter($attribute, $condition = null)
     {
@@ -327,7 +326,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addUrlRewriteToResult()
     {
@@ -345,7 +344,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * @param string|array $paths
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addPathsFilter($paths)
     {
@@ -367,7 +366,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * @param string $level
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addLevelFilter($level)
     {
@@ -377,7 +376,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * @param string $field
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function addOrderField($field)
     {
@@ -390,7 +389,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param integer $pageNum
      * @param integer $pageSize
-     * @return \Magento\Catalog\Model\Resource\Category\Flat\Collection
+     * @return $this
      */
     public function setPage($pageNum, $pageSize)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Indexer/Product.php b/app/code/Magento/Catalog/Model/Resource/Category/Indexer/Product.php
index f23b2496fadd01368f95aa888cd66f7af68417b0..40d526f32aa26c381bb6f41c848881bdd1a984b7 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Indexer/Product.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Indexer/Product.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Category\Indexer;
 
 /**
  * Resource model for category product indexer
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Category\Indexer;
-
 class Product extends \Magento\Index\Model\Resource\AbstractResource
 {
     /**
@@ -98,6 +96,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Model initialization
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -115,7 +114,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
      * when product was saved and assigned categories was changed.
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     public function catalogProductSave(\Magento\Index\Model\Event $event)
     {
@@ -169,7 +168,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
      * Process Catalog Product mass action
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     public function catalogProductMassAction(\Magento\Index\Model\Event $event)
     {
@@ -241,6 +240,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
      * Process category index after category save
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     public function catalogCategorySave(\Magento\Index\Model\Event $event)
     {
@@ -342,7 +342,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
      * Reindex not anchor root categories
      *
      * @param array $categoryIds
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     protected function _refreshNotAnchorRootCategories(array $categoryIds = null)
     {
@@ -452,7 +452,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param null|array $categoryIds
      * @param null|array $productIds
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     protected function _refreshDirectRelations($categoryIds = null, $productIds = null)
     {
@@ -535,7 +535,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param null | array $categoryIds
      * @param null | array $productIds
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     protected function _refreshAnchorRelations($categoryIds = null, $productIds = null)
     {
@@ -635,10 +635,10 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
     }
 
     /**
-     * Add product association with root store category for products which are not assigned to any another category
+     * Add product association with root store category for products which are not assigned to another category
      *
      * @param int | array $productIds
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     protected function _refreshRootRelations($productIds)
     {
@@ -787,7 +787,7 @@ class Product extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Rebuild all index data
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Indexer\Product
+     * @return $this
      */
     public function reindexAll()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php
index 3354124e01f71f089cfb013fc9d707e294592f7b..64f671d4086286a9628a7a7b76a7ca5792cb741b 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Tree.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Tree.php
@@ -48,7 +48,7 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Categories resource collection
      *
-     * @var \Magento\Catalog\Model\Resource\Category\Collection
+     * @var Collection
      */
     protected $_collection;
 
@@ -74,7 +74,7 @@ class Tree extends \Magento\Data\Tree\Dbp
     protected $_inactiveCategoryIds              = null;
 
     /**
-     * store id
+     * Store id
      *
      * @var integer
      */
@@ -149,7 +149,7 @@ class Tree extends \Magento\Data\Tree\Dbp
      * Set store id
      *
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -173,12 +173,12 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Enter description here...
      *
-     * @param \Magento\Catalog\Model\Resource\Category\Collection $collection
+     * @param Collection $collection
      * @param boolean $sorted
      * @param array $exclude
      * @param boolean $toLoad
      * @param boolean $onlyActive
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @return $this
      */
     public function addCollectionData($collection = null, $sorted = false, $exclude = array(), $toLoad = true,
         $onlyActive = false
@@ -238,8 +238,8 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Add inactive categories ids
      *
-     * @param unknown_type $ids
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @param mixed $ids
+     * @return $this
      */
     public function addInactiveCategoryIds($ids)
     {
@@ -253,7 +253,7 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Retrieve inactive categories ids
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @return $this
      */
     protected function _initInactiveCategoryIds()
     {
@@ -279,7 +279,7 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Return disable category ids
      *
-     * @param \Magento\Catalog\Model\Resource\Category\Collection $collection
+     * @param Collection $collection
      * @return array
      */
     protected function _getDisabledIds($collection)
@@ -337,7 +337,7 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Retrieve inactive category item ids
      *
-     * @param \Magento\Catalog\Model\Resource\Category\Collection $collection
+     * @param Collection $collection
      * @param int $storeId
      * @return array
      */
@@ -388,7 +388,7 @@ class Tree extends \Magento\Data\Tree\Dbp
      * Get categories collection
      *
      * @param boolean $sorted
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return Collection
      */
     public function getCollection($sorted = false)
     {
@@ -401,7 +401,8 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Clean unneeded collection
      *
-     * @param \Magento\Catalog\Model\Resource\Category\Collection|array $object
+     * @param Collection|array $object
+     * @return void
      */
     protected function _clean($object)
     {
@@ -416,8 +417,8 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Enter description here...
      *
-     * @param \Magento\Catalog\Model\Resource\Category\Collection $collection
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @param Collection $collection
+     * @return $this
      */
     public function setCollection($collection)
     {
@@ -432,7 +433,7 @@ class Tree extends \Magento\Data\Tree\Dbp
      * Enter description here...
      *
      * @param boolean $sorted
-     * @return \Magento\Catalog\Model\Resource\Category\Collection
+     * @return Collection
      */
     protected function _getDefaultCollection($sorted = false)
     {
@@ -456,9 +457,10 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Executing parents move method and cleaning cache after it
      *
-     * @param unknown_type $category
-     * @param unknown_type $newParent
-     * @param unknown_type $prevNode
+     * @param mixed $category
+     * @param mixed $newParent
+     * @param mixed $prevNode
+     * @return void
      */
     public function move($category, $newParent, $prevNode = null)
     {
@@ -472,7 +474,7 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Move tree after
      *
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @return $this
      */
     protected function _afterMove()
     {
@@ -486,7 +488,7 @@ class Tree extends \Magento\Data\Tree\Dbp
      * @param array $ids
      * @param bool $addCollectionData
      * @param bool $updateAnchorProductCount
-     * @return \Magento\Catalog\Model\Resource\Category\Tree
+     * @return $this|bool
      */
     public function loadByIds($ids, $addCollectionData = true, $updateAnchorProductCount = true)
     {
@@ -586,7 +588,8 @@ class Tree extends \Magento\Data\Tree\Dbp
     /**
      * Replace products count with self products count, if category is non-anchor
      *
-     * @param array $data
+     * @param array &$data
+     * @return void
      */
     protected function _updateAnchorProductCount(&$data)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php
index 47f3b62e12ba3489d7da811f112fe761cb01e8a1..de3ed97d95e332605ac39cd15b36f9d0ce916df2 100644
--- a/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Collection;
 
 /**
  * Catalog EAV collection resource abstract model
@@ -33,8 +33,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Collection;
-
 class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCollection
 {
     /**
@@ -62,7 +60,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo
      * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
      * @param \Magento\Validator\UniversalFactory $universalFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * 
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -98,7 +96,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo
      * Set store scope
      *
      * @param int|string|\Magento\Core\Model\Store $store
-     * @return \Magento\Catalog\Model\Resource\Collection\AbstractCollection
+     * @return $this
      */
     public function setStore($store)
     {
@@ -110,7 +108,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo
      * Set store scope
      *
      * @param int|string|\Magento\Core\Model\Store $storeId
-     * @return \Magento\Catalog\Model\Resource\Collection\AbstractCollection
+     * @return $this
      */
     public function setStoreId($storeId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Config.php b/app/code/Magento/Catalog/Model/Resource/Config.php
index f308f6015d98fa85d171549acb4377cc8618e767..f55fbaabfd4a1ff961b1532dd113adae48a2ad83 100644
--- a/app/code/Magento/Catalog/Model/Resource/Config.php
+++ b/app/code/Magento/Catalog/Model/Resource/Config.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource;
 
 /**
  * Catalog Config Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource;
-
 class Config extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -82,6 +80,7 @@ class Config extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -92,7 +91,7 @@ class Config extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Set store id
      *
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Config
+     * @return $this
      */
     public function setStoreId($storeId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
index 62d214b492e2eda398cf67e17027323fdbebd6d6..17c0ba2d98a8204e567c197318e97a73801c2c95 100644
--- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Resource\Eav;
 
 /**
  * Catalog attribute model
@@ -70,8 +71,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Eav;
-
 class Attribute extends \Magento\Eav\Model\Entity\Attribute
 {
     const SCOPE_STORE                           = 0;
@@ -160,6 +159,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
         );
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Catalog\Model\Resource\Attribute');
@@ -168,8 +170,8 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
     /**
      * Processing object before save data
      *
-     * @throws \Magento\Core\Exception
      * @return \Magento\Core\Model\AbstractModel
+     * @throws \Magento\Core\Exception
      */
     protected function _beforeSave()
     {
@@ -218,7 +220,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
     /**
      * Register indexing event before delete catalog eav attribute
      *
-     * @return \Magento\Catalog\Model\Resource\Eav\Attribute
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeDelete()
@@ -235,7 +237,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
     /**
      * Init indexing process after catalog eav attribute delete commit
      *
-     * @return \Magento\Catalog\Model\Resource\Eav\Attribute
+     * @return $this
      */
     protected function _afterDeleteCommit()
     {
@@ -304,7 +306,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
      * Retrieve apply to products array
      * Return empty array if applied to all products
      *
-     * @return array
+     * @return string[]
      */
     public function getApplyTo()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Helper.php b/app/code/Magento/Catalog/Model/Resource/Helper.php
index 7fe2682269d5a7379142fc915d095fe155746b25..55a48ba22e654ba5729612efe94e8ab39f4f8852 100644
--- a/app/code/Magento/Catalog/Model/Resource/Helper.php
+++ b/app/code/Magento/Catalog/Model/Resource/Helper.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource;
 
 /**
  * Eav Mysql resource helper model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource;
-
 class Helper extends \Magento\Eav\Model\Resource\Helper
 {
     /**
diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php
index 8e7b8a7ed04827a69208f8efec796728d995690f..acbe52924ed3b12924cd6cd54bc830338de0c216 100644
--- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Attribute.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Layer\Filter;
 
 /**
  * Catalog Layer Attribute Filter Resource Model
@@ -32,13 +32,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Layer\Filter;
-
 class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Initialize connection and define main table name
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -50,7 +49,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Catalog\Model\Layer\Filter\Attribute $filter
      * @param int $value
-     * @return \Magento\Catalog\Model\Resource\Layer\Filter\Attribute
+     * @return $this
      */
     public function applyFilterToCollection($filter, $value)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php
index 75be32946b5bd78ab8786165f4d88c22f3b8da37..e288e7b4b5545fb821d6fd72c318441e79c3dadc 100644
--- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php
+++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Decimal.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Layer\Filter;
 
 /**
  * Catalog Layer Decimal attribute Filter Resource Model
@@ -32,13 +32,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Layer\Filter;
-
 class Decimal extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Initialize connection and define main table name
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -51,7 +50,7 @@ class Decimal extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\Catalog\Model\Layer\Filter\Decimal $filter
      * @param float $range
      * @param int $index
-     * @return \Magento\Catalog\Model\Resource\Layer\Filter\Decimal
+     * @return $this
      */
     public function applyFilterToCollection($filter, $range, $index)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php
index 8bfcdd116e1b53141a9a60bac25e35d6fd054ba7..99d37f3e519c16bf4591e00d7fbc9228ae5053ac 100644
--- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php
+++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Layer\Filter;
 
 /**
  * Catalog Layer Price Filter resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Layer\Filter;
-
 class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -61,6 +59,7 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection and define main table name
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -166,10 +165,11 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Prepare response object and dispatch prepare price event
      * Return response object
      *
-     * @deprecated since 1.7.0.0
      * @param \Magento\Catalog\Model\Layer\Filter\Price $filter
      * @param \Magento\DB\Select $select
      * @return \Magento\Object
+     *
+     * @deprecated since 1.7.0.0
      */
     protected function _dispatchPreparePriceEvent($filter, $select)
     {
@@ -183,9 +183,10 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Retrieve maximal price for attribute
      *
-     * @deprecated since 1.7.0.0
      * @param \Magento\Catalog\Model\Layer\Filter\Price $filter
      * @return float
+     *
+     * @deprecated since 1.7.0.0
      */
     public function getMaxPrice($filter)
     {
@@ -278,11 +279,12 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Apply attribute filter to product collection
      *
-     * @deprecated since 1.7.0.0
      * @param \Magento\Catalog\Model\Layer\Filter\Price $filter
      * @param int $range
-     * @param int $index    the range factor
-     * @return \Magento\Catalog\Model\Resource\Layer\Filter\Price
+     * @param int $index the range factor
+     * @return $this
+     *
+     * @deprecated since 1.7.0.0
      */
     public function applyFilterToCollection($filter, $range, $index)
     {
@@ -330,6 +332,7 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\Catalog\Model\Layer\Filter\Price $filter
      * @param float $price
      * @param int $index
+     * @param null|int $lowerPrice
      * @return array|false
      */
     public function loadPreviousPrices($filter, $price, $index, $lowerPrice = null)
@@ -355,7 +358,7 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param float $price
      * @param int $rightIndex
      * @param null|int $upperPrice
-     * @return array
+     * @return array|false
      */
     public function loadNextPrices($filter, $price, $rightIndex, $upperPrice = null)
     {
@@ -390,7 +393,7 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Apply price range filter to product collection
      *
      * @param \Magento\Catalog\Model\Layer\Filter\Price $filter
-     * @return \Magento\Catalog\Model\Resource\Layer\Filter\Price
+     * @return $this
      */
     public function applyPriceRange($filter)
     {
@@ -422,6 +425,5 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb
         }
 
         return $this;
-
     }
 }
diff --git a/app/code/Magento/Catalog/Model/Resource/Product.php b/app/code/Magento/Catalog/Model/Resource/Product.php
index 9b5e5c7bf1568460245ba332f0784247066a4bb8..0d17048e6d7a9ac4000381a70f4e86af32f0cdfb 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Resource;
 
 /**
@@ -31,7 +30,7 @@ namespace Magento\Catalog\Model\Resource;
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  */
-class Product extends \Magento\Catalog\Model\Resource\AbstractResource
+class Product extends AbstractResource
 {
     /**
      * Product to website linkage table
@@ -50,7 +49,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
     /**
      * Catalog category
      *
-     * @var \Magento\Catalog\Model\Resource\Category
+     * @var Category
      */
     protected $_catalogCategory;
 
@@ -73,7 +72,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Catalog\Model\Factory $modelFactory
      * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory
-     * @param \Magento\Catalog\Model\Resource\Category $catalogCategory
+     * @param Category $catalogCategory
      * @param array $data
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -88,7 +87,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Catalog\Model\Factory $modelFactory,
         \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory,
-        \Magento\Catalog\Model\Resource\Category $catalogCategory,
+        Category $catalogCategory,
         $data = array()
     ) {
         $this->_categoryCollectionFactory = $categoryCollectionFactory;
@@ -112,7 +111,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
     /**
      * Default product attributes
      *
-     * @return array
+     * @return string[]
      */
     protected function _getDefaultAttributes()
     {
@@ -206,7 +205,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * Process product data before save
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     protected function _beforeSave(\Magento\Object $object)
     {
@@ -234,7 +233,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * Save data related with product
      *
      * @param \Magento\Object $product
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     protected function _afterSave(\Magento\Object $product)
     {
@@ -247,7 +246,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * Save product website relations
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     protected function _saveWebsiteIds($product)
     {
@@ -296,7 +295,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * Save product category relations
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     protected function _saveCategories(\Magento\Object $object)
     {
@@ -355,7 +354,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * Refresh Product Enabled Index
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     public function refreshIndex($product)
     {
@@ -421,7 +420,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      * @param \Magento\Core\Model\Store $store
      * @param \Magento\Catalog\Model\Product $product
      * @throws \Magento\Core\Exception
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     public function refreshEnabledIndex($store = null, $product = null)
     {
@@ -614,7 +613,7 @@ class Product extends \Magento\Catalog\Model\Resource\AbstractResource
      *
      * @param int $oldId
      * @param int $newId
-     * @return \Magento\Catalog\Model\Resource\Product
+     * @return $this
      */
     public function duplicate($oldId, $newId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Action.php b/app/code/Magento/Catalog/Model/Resource/Product/Action.php
index e6fa74b044f66c3c16294c132690f73536002700..da8e2915e6b2485d73b2344fdf35a708721bc637 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Action.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Action.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product;
 
 /**
  * Catalog Product Mass processing resource model
@@ -32,13 +32,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Action extends \Magento\Catalog\Model\Resource\AbstractResource
 {
     /**
-     * Intialize connection
+     * Initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -56,7 +55,8 @@ class Action extends \Magento\Catalog\Model\Resource\AbstractResource
      * @param array $entityIds
      * @param array $attrData
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Action
+     * @return $this
+     * @throws \Exception
      */
     public function updateAttributes($entityIds, $attrData, $storeId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php
index bacd59df2cf0cb3769d22080eb345e4a3a1414b2..8b0013b39b73218a4d01aa845ab5cc6fdfad8af9 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
 
+use Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice\AbstractGroupprice;
 
 /**
  * Catalog product group price backend attribute model
@@ -32,14 +34,13 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
-
 class Groupprice
-    extends \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice\AbstractGroupprice
+    extends AbstractGroupprice
 {
     /**
      * Initialize connection and define main table
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php
index d1f30c6260239f1befdf1a06f67e71778b80769b..5d9180ab6f20d17e726011b0b42097084e0eff8c 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php
@@ -42,7 +42,7 @@ abstract class AbstractGroupprice
      *
      * @param int $productId
      * @param int $websiteId
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Tierprice
+     * @return array
      */
     public function loadPriceData($productId, $websiteId = null)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php
index b50c1e55259f813e11a016de8ffa6d7284ac03f3..af158fe07dc697777392247afc458c73346432b6 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Image.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
 
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
 
 /**
  * Product image attribute backend
@@ -32,10 +34,7 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
-
-class Image
-    extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
+class Image extends AbstractBackend
 {
     /**
      * Filesystem facade
@@ -70,7 +69,7 @@ class Image
      * After save
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Image
+     * @return $this|void
      */
     public function afterSave($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php
index 94ecd7db35fa3991ed389b69a164c591003deec7..0723237079eae20393120aa2b65a72158a8d63ab 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Media.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
 
 /**
  * Catalog product media gallery attribute backend resource
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
-
 class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     const GALLERY_TABLE       = 'catalog_product_entity_media_gallery';
@@ -41,6 +39,8 @@ class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -92,8 +92,8 @@ class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Remove duplicates
      *
-     * @param array $result
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media
+     * @param array &$result
+     * @return $this
      */
     protected function _removeDuplicates(&$result)
     {
@@ -131,7 +131,7 @@ class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete gallery value in db
      *
      * @param array|integer $valueId
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function deleteGallery($valueId)
     {
@@ -151,7 +151,7 @@ class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Insert gallery value for store to db
      *
      * @param array $data
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function insertGalleryValueInStore($data)
     {
@@ -166,7 +166,7 @@ class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param integer $valueId
      * @param integer $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function deleteGalleryValueInStore($valueId, $storeId)
     {
@@ -189,7 +189,7 @@ class Media extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param array $newFiles
      * @param int $originalProductId
      * @param int $newProductId
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media
+     * @return $this
      */
     public function duplicate($object, $newFiles, $originalProductId, $newProductId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Tierprice.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Tierprice.php
index ff14825461e656d511be1bd5d6d23bff3490a8a2..50a16278b5af9db7aa72a0941513e85449738a04 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Tierprice.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Tierprice.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
 
+use Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice\AbstractGroupprice;
 
 /**
  * Catalog product tier price backend attribute model
@@ -32,14 +34,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
-
-class Tierprice
-    extends \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice\AbstractGroupprice
+class Tierprice extends AbstractGroupprice
 {
     /**
      * Initialize connection and define main table
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Urlkey.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Urlkey.php
index 616f2da572a5ac0943abf001ce43ec5740e1f9b6..d2afbe4d5e38bea247fd7180a7218028d7dcb1a2 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Urlkey.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Backend/Urlkey.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
 
 /**
  * Product url key attribute backend
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Attribute\Backend;
-
 class Urlkey
     extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
@@ -58,7 +56,7 @@ class Urlkey
      * Before save
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Urlkey
+     * @return $this
      */
     public function beforeSave($object)
     {
@@ -78,7 +76,7 @@ class Urlkey
      * Refresh product rewrites
      *
      * @param \Magento\Object $object
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Urlkey
+     * @return $this
      */
     public function afterSave($object)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php
index ab204018612b27406eff995ac77512067932cfdc..a4b2accb0c1625b7ae82d225a4ed021695729df3 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Attribute/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Attribute;
 
 /**
  * Catalog product EAV additional attribute resource collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Attribute;
-
 class Collection
     extends \Magento\Eav\Model\Resource\Entity\Attribute\Collection
 {
@@ -50,7 +48,7 @@ class Collection
      * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
      * @param \Magento\Event\ManagerInterface $eventManager
      * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
      */
     public function __construct(
@@ -69,6 +67,7 @@ class Collection
     /**
      * Resource model initialization
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -76,9 +75,9 @@ class Collection
     }
 
     /**
-     * initialize select object
+     * Initialize select object
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -108,7 +107,7 @@ class Collection
      * Entity type is defined.
      *
      * @param  int $typeId
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function setEntityTypeFilter($typeId)
     {
@@ -118,7 +117,7 @@ class Collection
     /**
      * Return array of fields to load attribute values
      *
-     * @return array
+     * @return string[]
      */
     protected function _getLoadDataFields()
     {
@@ -137,7 +136,7 @@ class Collection
     /**
      * Remove price from attribute list
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function removePriceFilter()
     {
@@ -147,7 +146,7 @@ class Collection
     /**
      * Specify "is_visible_in_advanced_search" filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addDisplayInAdvancedSearchFilter()
     {
@@ -157,7 +156,7 @@ class Collection
     /**
      * Specify "is_filterable" filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addIsFilterableFilter()
     {
@@ -167,7 +166,7 @@ class Collection
     /**
      * Add filterable in search filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addIsFilterableInSearchFilter()
     {
@@ -177,7 +176,7 @@ class Collection
     /**
      * Specify filter by "is_visible" field
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addVisibleFilter()
     {
@@ -187,7 +186,7 @@ class Collection
     /**
      * Specify "is_searchable" filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addIsSearchableFilter()
     {
@@ -198,7 +197,7 @@ class Collection
      * Specify filter for attributes that have to be indexed
      *
      * @param bool $addRequiredCodes
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addToIndexFilter($addRequiredCodes = false)
     {
@@ -223,7 +222,7 @@ class Collection
     /**
      * Specify filter for attributes used in quick search
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection
+     * @return $this
      */
     public function addSearchableAttributeFilter()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php
index 4259d45a8d2fc78933193b5bb322e913d11b28f1..84b025da64c614c8c1b3feac1bb2fbdc6c032d0e 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php
@@ -23,9 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Resource\Product;
 
+use Magento\Core\Model\Store;
+use Magento\Core\Model\Website;
+
 /**
  * Product collection
  */
@@ -276,7 +278,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * @param \Magento\Core\Model\LocaleInterface $locale
      * @param \Magento\Customer\Model\Session $customerSession
      * @param \Magento\Stdlib\DateTime $dateTime
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * 
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -339,7 +341,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Prepare additional price expression sql part
      *
      * @param \Magento\DB\Select $select
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _preparePriceExpressionParameters($select)
     {
@@ -436,6 +438,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Initialize resources
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -453,7 +456,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param string $model
      * @param string $entityModel
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _init($model, $entityModel)
     {
@@ -476,7 +479,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Prepare static entity fields
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _prepareStaticFields()
     {
@@ -505,7 +508,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Set entity to use for attributes
      *
      * @param \Magento\Eav\Model\Entity\AbstractEntity $entity
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function setEntity($entity)
     {
@@ -520,7 +523,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Set Store scope for collection
      *
      * @param mixed $store
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function setStore($store)
     {
@@ -536,7 +539,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Redeclared for remove entity_type_id condition
      * in catalog_product_entity we store just products
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -561,7 +564,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param bool $printQuery
      * @param bool $logQuery
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function _loadAttributes($printQuery = false, $logQuery = false)
     {
@@ -577,7 +580,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param array|string|integer|\Magento\Core\Model\Config\Element $attribute
      * @param bool|string $joinType
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addAttributeToSelect($attribute, $joinType = false)
     {
@@ -612,7 +615,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Processing collection items after loading
      * Adding url rewrites, minimal prices, final prices, tax percents
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -638,7 +641,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Prepare Url Data object
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _prepareUrlDataObject()
     {
@@ -671,7 +674,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param mixed $productId
      * @param boolean $exclude
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addIdFilter($productId, $exclude = false)
     {
@@ -704,7 +707,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Adding product website names to result collection
      * Add for each product websites information
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addWebsiteNamesToResult()
     {
@@ -741,8 +744,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Add store availability filter. Include availability product
      * for store website
      *
-     * @param mixed $store
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @param null|string|bool|int|Store $store
+     * @return $this
      */
     public function addStoreFilter($store = null)
     {
@@ -751,7 +754,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
         }
         $store = $this->_storeManager->getStore($store);
 
-        if ($store->getId() != \Magento\Core\Model\Store::DEFAULT_STORE_ID) {
+        if ($store->getId() != Store::DEFAULT_STORE_ID) {
             $this->setStoreId($store);
             $this->_productLimitationFilters['store_id'] = $store->getId();
             $this->_applyProductLimitations();
@@ -763,8 +766,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add website filter to collection
      *
-     * @param mixed $websites
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @param null|bool|int|string|Website|array $websites
+     * @return $this
      */
     public function addWebsiteFilter($websites = null)
     {
@@ -792,7 +795,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Specify category filter for product collection
      *
      * @param \Magento\Catalog\Model\Category $category
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
     {
@@ -803,7 +806,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
             $this->_productLimitationFilters['category_is_anchor'] = 1;
         }
 
-        if ($this->getStoreId() == \Magento\Core\Model\Store::DEFAULT_STORE_ID) {
+        if ($this->getStoreId() == Store::DEFAULT_STORE_ID) {
             $this->_applyZeroStoreProductLimitations();
         } else {
             $this->_applyProductLimitations();
@@ -815,7 +818,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Join minimal price attribute to result
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function joinMinimalPrice()
     {
@@ -828,7 +831,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Retrieve max value by attribute
      *
      * @param string $attribute
-     * @return mixed
+     * @return array|null
      */
     public function getMaxAttributeValue($attribute)
     {
@@ -994,7 +997,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Prepare statistics data
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _prepareStatisticsData()
     {
@@ -1093,7 +1096,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Destruct product count select
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function unsProductCountSelect()
     {
@@ -1105,7 +1108,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Adding product count to categories collection
      *
      * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $categoryCollection
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addCountToCategories($categoryCollection)
     {
@@ -1190,7 +1193,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Joins url rewrite rules to collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function joinUrlRewrite()
     {
@@ -1210,7 +1213,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * If collection loadded - run processing else set flag
      *
      * @param int|string $categoryId
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addUrlRewrite($categoryId = '')
     {
@@ -1234,6 +1237,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add URL rewrites to collection
      *
+     * @return void
      */
     protected function _addUrlRewrite()
     {
@@ -1272,7 +1276,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add minimal price data to result
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addMinimalPrice()
     {
@@ -1282,7 +1286,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add price data for calculate final price
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addFinalPrice()
     {
@@ -1292,7 +1296,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Join prices from price rules to products collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _joinPriceRules()
     {
@@ -1348,7 +1352,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Set all ids
      *
      * @param array $value
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function setAllIdsCache($value)
     {
@@ -1361,7 +1365,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param int $customerGroupId
      * @param int $websiteId
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addPriceData($customerGroupId = null, $websiteId = null)
     {
@@ -1392,7 +1396,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|string $attribute
      * @param array $condition
      * @param string $joinType
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner')
     {
@@ -1453,7 +1457,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add requere tax percent flag for product collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addTaxPercents()
     {
@@ -1475,7 +1479,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Adding product custom options to result collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addOptionsToResult()
     {
@@ -1504,7 +1508,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Filter products with required options
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addFilterByRequiredOptions()
     {
@@ -1516,7 +1520,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Set product visibility filter for enabled products
      *
      * @param array $visibility
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function setVisibility($visibility)
     {
@@ -1531,7 +1535,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param string $attribute
      * @param string $dir
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
     {
@@ -1590,7 +1594,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Prepare limitation filters
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _prepareProductLimitationFilters()
     {
@@ -1619,7 +1623,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Join website product limitation
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _productLimitationJoinWebsite()
     {
@@ -1666,7 +1670,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Join additional (alternative) store visibility filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _productLimitationJoinStore()
     {
@@ -1738,7 +1742,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Join Product Price Table
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _productLimitationJoinPrice()
     {
@@ -1750,7 +1754,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @see \Magento\Catalog\Model\Resource\Product\Collection::_productLimitationJoinPrice()
      * @param bool $joinLeft
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _productLimitationPrice($joinLeft = false)
     {
@@ -1798,7 +1802,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Apply front-end price limitation filters to the collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function applyFrontendPriceLimitations()
     {
@@ -1821,7 +1825,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * for different combinations of store_id/category_id/visibility filter states
      * Method supports multiple changes in one collection object for this parameters
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _applyProductLimitations()
     {
@@ -1872,7 +1876,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      * Method allows using one time category product table
      * for combinations of category_id filter states
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     protected function _applyZeroStoreProductLimitations()
     {
@@ -1907,7 +1911,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add category ids to loaded items
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addCategoryIds()
     {
@@ -1952,7 +1956,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Add tier price data to loaded items
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function addTierPriceData()
     {
@@ -2030,7 +2034,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param string $comparisonFormat - expression for sprintf()
      * @param array $fields - list of fields
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      * @throws \Exception
      */
     public function addPriceDataFieldFilter($comparisonFormat, $fields)
@@ -2053,7 +2057,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
     /**
      * Clear collection
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function clear()
     {
@@ -2079,7 +2083,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl
      *
      * @param string $attribute
      * @param string $dir
-     * @return \Magento\Catalog\Model\Resource\Product\Collection
+     * @return $this
      */
     public function setOrder($attribute, $dir = 'desc')
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection/AssociatedProduct.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection/AssociatedProduct.php
index 464b49b9fa1e4e21772ebd741984e35ba7d4bccf..ad08cb48a706ef3915251841b938305a51028a08 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Collection/AssociatedProduct.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection/AssociatedProduct.php
@@ -23,13 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Catalog compare item resource model
- */
 namespace Magento\Catalog\Model\Resource\Product\Collection;
 
 /**
+ * Catalog compare item resource model
+ *
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class AssociatedProduct
@@ -78,7 +76,7 @@ class AssociatedProduct
      * @param \Magento\Core\Model\Registry $registryManager
      * @param \Magento\Catalog\Model\Product\Type\Configurable $productType
      * @param \Magento\Catalog\Helper\Product\Configuration $configurationHelper
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * 
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -154,6 +152,8 @@ class AssociatedProduct
 
     /**
      * Add attributes to select
+     *
+     * @return $this
      */
     public function _initSelect()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php
index acd3b3f64357866b6aeea81cfb212008557c8c70..8db12ddc7bce813dbee7768ddc5cebea9b6aacc2 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Compare;
 
 /**
  * Catalog compare item resource model
@@ -32,13 +32,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Compare;
-
 class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -48,8 +47,8 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Load object by product
      *
-     * @param \Magento\Core\Model\AbstractModel $object
-     * @param mixed $product
+     * @param \Magento\Catalog\Model\Product\Compare\Item $object
+     * @param \Magento\Catalog\Model\Product|int $product
      * @return bool
      */
     public function loadByProduct(\Magento\Catalog\Model\Product\Compare\Item $object, $product)
@@ -103,7 +102,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Clean compare table
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item
+     * @return $this
      */
     public function clean()
     {
@@ -136,7 +135,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Purge visitor data after customer logout
      *
      * @param \Magento\Catalog\Model\Product\Compare\Item $object
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item
+     * @return $this
      */
     public function purgeVisitorByCustomer($object)
     {
@@ -159,7 +158,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
      * After Login process
      *
      * @param \Magento\Catalog\Model\Product\Compare\Item $object
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item
+     * @return $this
      */
     public function updateCustomerFromVisitor($object)
     {
@@ -227,7 +226,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $visitorId
      * @param int $customerId
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item
+     * @return $this
      */
     public function clearItems($visitorId = null, $customerId = null)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php
index 7b180b65ab57bb97d292bb411321d5617807826b..abb1b7c647841eee7e27e5ffa9519d8d8ac950f1 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Resource\Product\Compare\Item;
 
 /**
@@ -93,7 +92,7 @@ class Collection
      * @param \Magento\Stdlib\DateTime $dateTime
      * @param \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem
      * @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * 
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -147,6 +146,8 @@ class Collection
 
     /**
      * Initialize resources
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -158,7 +159,7 @@ class Collection
      * Set customer filter to collection
      *
      * @param int $customerId
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return $this
      */
     public function setCustomerId($customerId)
     {
@@ -171,7 +172,7 @@ class Collection
      * Set visitor filter to collection
      *
      * @param int $visitorId
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return $this
      */
     public function setVisitorId($visitorId)
     {
@@ -221,7 +222,7 @@ class Collection
     /**
      * Add join to select
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return $this
      */
     public function _addJoinToSelect()
     {
@@ -346,7 +347,7 @@ class Collection
     /**
      * Load Comparable attributes
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return $this
      */
     public function loadComparableAttributes()
     {
@@ -363,7 +364,7 @@ class Collection
     /**
      * Use product as collection item
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return $this
      */
     public function useProductItem()
     {
@@ -378,7 +379,7 @@ class Collection
     /**
      * Retrieve product ids from collection
      *
-     * @return array
+     * @return int[]
      */
     public function getProductIds()
     {
@@ -393,7 +394,7 @@ class Collection
     /**
      * Clear compare items by condition
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Compare\Item\Collection
+     * @return $this
      */
     public function clear()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php
index 2c46625674bea246736e3949c71dfbe7c0288504..6267066827a77e247fb452171db83c6502223659 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Resource\Product;
 
+use Magento\Core\Model\Store;
 
 /**
  * Catalog Product Flat resource model
@@ -32,8 +34,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Flat extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -75,6 +75,7 @@ class Flat extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Init connection and resource table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -95,8 +96,8 @@ class Flat extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Set store for resource model
      *
-     * @param mixed $store
-     * @return \Magento\Catalog\Model\Resource\Product\Flat
+     * @param null|string|bool|int|Store $store
+     * @return $this
      */
     public function setStoreId($store)
     {
@@ -216,7 +217,7 @@ class Flat extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Retrieve entity id field name in entity table
-     * Rewrited for EAV collection compatible
+     * Rewrote for EAV collection compatibility
      *
      * @return string
      */
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Flat/Indexer.php b/app/code/Magento/Catalog/Model/Resource/Product/Flat/Indexer.php
index a77d1eed20c48a5a10dbc584ed69e36777a17336..4f5974714d9c2c3ab47a1a78a23de84710b683f2 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Flat/Indexer.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Flat/Indexer.php
@@ -21,13 +21,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Flat;
 
 /**
  * Catalog Product Flat Indexer Resource Model
  */
-namespace Magento\Catalog\Model\Resource\Product\Flat;
-
 class Indexer extends \Magento\Index\Model\Resource\AbstractResource
 {
     /**
@@ -57,7 +55,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Required system attributes for preload
      *
-     * @var array
+     * @var string[]
      */
     protected $_systemAttributes     = array('status', 'required_options', 'tax_class_id', 'weight');
 
@@ -130,7 +128,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
     protected $_maxIndexCount;
 
     /**
-     * @var array
+     * @var string[]
      */
     protected $_flatAttributeGroups;
 
@@ -186,7 +184,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      * @param \Magento\Catalog\Model\Product\Type $productType
      * @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
      * @param string $maxIndexCount
-     * @param array $flatAttributeGroups
+     * @param string[] $flatAttributeGroups
      */
     public function __construct(
         \Magento\App\Resource $resource,
@@ -223,6 +221,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -233,7 +232,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      * Rebuild Catalog Product Flat Data
      *
      * @param \Magento\Core\Model\Store|int $store
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function rebuild($store = null)
     {
@@ -649,7 +648,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int $storeId
      * @throws \Magento\Core\Exception
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function prepareFlatTable($storeId)
     {
@@ -864,7 +863,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int $storeId
      * @param int|array $productIds update only product(s)
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function updateStaticAttributes($storeId, $productIds = null)
     {
@@ -940,7 +939,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int $storeId
      * @param int|array $productIds
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function cleanNonWebsiteProducts($storeId, $productIds = null)
     {
@@ -987,7 +986,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      * @param \Magento\Eav\Model\Entity\Attribute $attribute
      * @param int $storeId
      * @param int|array $productIds update only product(s)
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function updateAttribute($attribute, $storeId, $productIds = null)
     {
@@ -1048,7 +1047,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int $storeId
      * @param int|array $productIds update only product(s)
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function updateEavAttributes($storeId, $productIds = null)
     {
@@ -1069,6 +1068,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      * Update events observer attributes
      *
      * @param int $storeId
+     * @return void
      */
     public function updateEventAttributes($storeId = null)
     {
@@ -1104,7 +1104,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int $storeId
      * @param int|array $productIds Update child product(s) only
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function updateRelationProducts($storeId, $productIds = null)
     {
@@ -1163,7 +1163,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int $storeId
      * @param int|array $productIds
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function updateChildrenDataFromParent($storeId, $productIds = null)
     {
@@ -1200,7 +1200,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      * Clean unused relation products
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function cleanRelationProducts($storeId)
     {
@@ -1259,7 +1259,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int|array $productIds
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function removeProduct($productIds, $storeId)
     {
@@ -1284,7 +1284,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int|array $productIds
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function removeProductChildren($productIds, $storeId)
     {
@@ -1305,7 +1305,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int|array $productIds
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function updateProduct($productIds, $storeId)
     {
@@ -1329,7 +1329,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      *
      * @param int|array $productIds
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function saveProduct($productIds, $storeId)
     {
@@ -1347,7 +1347,7 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
      * Delete flat table process
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
      */
     public function deleteFlatTable($storeId)
     {
@@ -1419,7 +1419,8 @@ class Indexer extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Transactional rebuild Catalog Product Flat Data
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Flat\Indexer
+     * @return $this
+     * @throws \Exception
      */
     public function reindexAll()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php
index adb174e37bd6069b921e479f24e326dc00fc0020..8fa4541a9b8536a7bf45b43a7ba0e339f2735e12 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer;
 
 /**
  * Catalog Product Indexer Abstract Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer;
-
 abstract class AbstractIndexer extends \Magento\Index\Model\Resource\AbstractResource
 {
     /**
@@ -75,8 +73,8 @@ abstract class AbstractIndexer extends \Magento\Index\Model\Resource\AbstractRes
      *
      * @param \Magento\DB\Select $select
      * @param string $attrCode              the attribute code
-     * @param string|Zend_Db_Expr $entity   the entity field or expression for condition
-     * @param string|Zend_Db_Expr $store    the store field or expression for condition
+     * @param string|\Zend_Db_Expr $entity   the entity field or expression for condition
+     * @param string|\Zend_Db_Expr $store    the store field or expression for condition
      * @param \Zend_Db_Expr $condition       the limitation condition
      * @param bool $required                if required or has condition used INNER join, else - LEFT
      * @return \Zend_Db_Expr                 the attribute value expression
@@ -133,10 +131,10 @@ abstract class AbstractIndexer extends \Magento\Index\Model\Resource\AbstractRes
      *  csg for store group table (joined by website default group)
      *  cs for store table (joined by website default store)
      *
-     * @param \Magento\DB\Select $select              the select object
-     * @param bool $store                           add default store join
-     * @param string|Zend_Db_Expr $joinCondition    the limitation for website_id
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexer
+     * @param \Magento\DB\Select $select the select object
+     * @param bool $store add default store join
+     * @param string|\Zend_Db_Expr $joinCondition the limitation for website_id
+     * @return $this
      */
     protected function _addWebsiteJoinToSelect($select, $store = true, $joinCondition = null)
     {
@@ -168,10 +166,10 @@ abstract class AbstractIndexer extends \Magento\Index\Model\Resource\AbstractRes
      * Add join for catalog/product_website table
      * Joined table has alias pw
      *
-     * @param \Magento\DB\Select $select          the select object
-     * @param string|Zend_Db_Expr $website      the limitation of website_id
-     * @param string|Zend_Db_Expr $product      the limitation of product_id
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexer
+     * @param \Magento\DB\Select $select the select object
+     * @param string|\Zend_Db_Expr $website the limitation of website_id
+     * @param string|\Zend_Db_Expr $product the limitation of product_id
+     * @return $this
      */
     protected function _addProductWebsiteJoinToSelect($select, $website, $product)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php
index 06faef029eb2c7c068c2d5523825a1955552fbc9..758992296e8588e2bb317436890b401fc663b709 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer;
 
 /**
  * Catalog Product Eav Indexer Resource Model
@@ -32,9 +32,7 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer;
-
-class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexer
+class Eav extends AbstractIndexer
 {
     /**
      * EAV Indexers by type
@@ -77,6 +75,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
     /**
      * Define main index table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -122,7 +121,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
      * when product was saved and assigned categories was changed.
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav
+     * @return $this
      */
     public function catalogProductSave(\Magento\Index\Model\Event $event)
     {
@@ -148,7 +147,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
      * Process Product Delete
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav
+     * @return $this
      */
     public function catalogProductDelete(\Magento\Index\Model\Event $event)
     {
@@ -169,7 +168,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
      * Process Product Mass Update
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav
+     * @return $this
      */
     public function catalogProductMassAction(\Magento\Index\Model\Event $event)
     {
@@ -190,7 +189,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
      * Process Catalog Eav Attribute Save
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav
+     * @return $this
      */
     public function catalogEavAttributeSave(\Magento\Index\Model\Event $event)
     {
@@ -209,7 +208,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
     /**
      * Rebuild all index data
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav
+     * @return $this
      */
     public function reindexAll()
     {
@@ -231,7 +230,7 @@ class Eav extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexe
     public function getIdxTable($table = null)
     {
         if ($this->useIdxTable()) {
-           return $this->getTable('catalog_product_index_eav_idx');
+            return $this->getTable('catalog_product_index_eav_idx');
         }
         return $this->getTable('catalog_product_index_eav_tmp');
     }
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php
index 866185217bfdc9e96d09f4cbb8c0dc2f1e2ed230..42c6a5906802209668ba9ceacef6bf7f9ef89f16 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer\Eav;
 
 /**
  * Catalog Product Eav Attributes abstract indexer resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer\Eav;
-
 abstract class AbstractEav
     extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexer
 {
@@ -63,8 +61,8 @@ abstract class AbstractEav
     /**
      * Rebuild all index data
      *
-     *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @return $this
+     * @throws \Exception
      */
     public function reindexAll()
     {
@@ -91,7 +89,7 @@ abstract class AbstractEav
      *
      *
      * @param int|array $processIds
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @return $this
      * @throws \Exception
      */
     public function reindexEntities($processIds)
@@ -141,7 +139,7 @@ abstract class AbstractEav
      *
      * @param int $attributeId
      * @param bool $isIndexable
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @return $this
      */
     public function reindexAttribute($attributeId, $isIndexable = true)
     {
@@ -171,7 +169,7 @@ abstract class AbstractEav
     /**
      * Remove Not Visible products from temporary data index
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @return $this
      */
     protected function _removeNotVisibleEntityFromIndex()
     {
@@ -199,8 +197,8 @@ abstract class AbstractEav
     /**
      * Prepare data index for product relations
      *
-     * @param array $parentIds  the parent entity ids limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @param array $parentIds the parent entity ids limitation
+     * @return $this
      */
     protected function _prepareRelationIndex($parentIds = null)
     {
@@ -263,7 +261,8 @@ abstract class AbstractEav
      * Remove index data from index by attribute id
      *
      * @param int $attributeId
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @return $this
+     * @throws \Exception
      */
     protected function _removeAttributeIndexData($attributeId)
     {
@@ -285,7 +284,7 @@ abstract class AbstractEav
      * Synchronize temporary index table with index table by attribute id
      *
      * @param int $attributeId
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+     * @return $this
      * @throws \Exception
      */
     protected function _synchronizeAttributeIndexData($attributeId)
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php
index 078a21dd1ce66edb64a169bdb97f5be74aa7b47a..3dd27d218ff535ef83b2f56db1403bff34554934 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Decimal.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer\Eav;
 
 /**
  * Catalog Product Eav Decimal Attributes Indexer resource model
@@ -32,14 +32,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer\Eav;
-
-class Decimal
-    extends \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+class Decimal extends AbstractEav
 {
     /**
      * Initialize connection and define main index table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -49,9 +47,9 @@ class Decimal
     /**
      * Prepare data index for indexable attributes
      *
-     * @param array $entityIds      the entity ids limitation
-     * @param int $attributeId      the attribute id limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\Decimal
+     * @param array $entityIds the entity ids limitation
+     * @param int $attributeId the attribute id limitation
+     * @return $this
      */
     protected function _prepareIndex($entityIds = null, $attributeId = null)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
index 9043a1da97fe3ba4653e1a04858e24b84283a701..83b22ca216cf6b8625013e5cc254cd39dfd34b82 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer\Eav;
 
 /**
  * Catalog Product Eav Select and Multiply Select Attributes Indexer resource model
@@ -32,10 +32,7 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer\Eav;
-
-class Source
-    extends \Magento\Catalog\Model\Resource\Product\Indexer\Eav\AbstractEav
+class Source extends AbstractEav
 {
     /**
      * Catalog resource helper
@@ -65,6 +62,7 @@ class Source
     /**
      * Initialize connection and define main index table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -101,9 +99,9 @@ class Source
     /**
      * Prepare data index for indexable attributes
      *
-     * @param array $entityIds      the entity ids limitation
-     * @param int $attributeId      the attribute id limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\Source
+     * @param array $entityIds the entity ids limitation
+     * @param int $attributeId the attribute id limitation
+     * @return $this
      */
     protected function _prepareIndex($entityIds = null, $attributeId = null)
     {
@@ -116,9 +114,9 @@ class Source
     /**
      * Prepare data index for indexable select attributes
      *
-     * @param array $entityIds      the entity ids limitation
-     * @param int $attributeId      the attribute id limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\Source
+     * @param array $entityIds the entity ids limitation
+     * @param int $attributeId the attribute id limitation
+     * @return $this
      */
     protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
     {
@@ -194,9 +192,9 @@ class Source
     /**
      * Prepare data index for indexable multiply select attributes
      *
-     * @param array $entityIds      the entity ids limitation
-     * @param int $attributeId      the attribute id limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\Source
+     * @param array $entityIds the entity ids limitation
+     * @param int $attributeId the attribute id limitation
+     * @return $this
      */
     protected function _prepareMultiselectIndex($entityIds = null, $attributeId = null)
     {
@@ -292,7 +290,7 @@ class Source
      * Save a data to temporary source index table
      *
      * @param array $data
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Eav\Source
+     * @return $this
      */
     protected function _saveIndexData(array $data)
     {
@@ -307,7 +305,7 @@ class Source
     /**
      * Retrieve temporary source index table name
      *
-     * @param unknown_type $table
+     * @param string|null $table
      * @return string
      */
     public function getIdxTable($table = null)
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php
index fb6ca5e5a87e605856774c6087ec7393bb88e310..c3e74fca295ab33d805ed57ffca3a01fd324db58 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer;
 
 /**
  * Catalog Product Price Indexer Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer;
-
 class Price extends \Magento\Index\Model\Resource\AbstractResource
 {
     /**
@@ -130,6 +128,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Define main index table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -162,7 +161,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * If the deleted product was found in a composite product(s) update it
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     public function catalogProductDelete(\Magento\Index\Model\Event $event)
     {
@@ -193,7 +192,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * Copy data from temporary index table to main table by defined ids
      *
      * @param array $processIds
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      * @throws \Exception
      */
     protected function _copyIndexDataToMainTable($processIds)
@@ -226,7 +225,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * when product was saved and changed attribute(s) has an effect on price.
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     public function catalogProductSave(\Magento\Index\Model\Event $event)
     {
@@ -284,7 +283,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * Process product mass update action
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     public function catalogProductMassAction(\Magento\Index\Model\Event $event)
     {
@@ -327,7 +326,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * Reindex product prices for specified product ids
      *
      * @param array | int $ids
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     public function reindexProductIds($ids)
     {
@@ -443,7 +442,8 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Rebuild all index data
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
+     * @throws \Exception
      */
     public function reindexAll()
     {
@@ -494,7 +494,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * Prepare tier price index table
      *
      * @param int|array $entityIds the entity ids limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     protected function _prepareTierPriceIndex($entityIds = null)
     {
@@ -537,7 +537,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * Prepare group price index table
      *
      * @param int|array $entityIds the entity ids limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     protected function _prepareGroupPriceIndex($entityIds = null)
     {
@@ -582,8 +582,8 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
      * @package array|int $excludeIds
      *
      * @param array|int $parentIds
-     * @param unknown_type $excludeIds
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @param mixed $excludeIds
+     * @return $this
      */
     protected function _copyRelationIndexData($parentIds, $excludeIds = null)
     {
@@ -621,7 +621,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Prepare website current dates table
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price
+     * @return $this
      */
     protected function _prepareWebsiteDateTable()
     {
@@ -682,7 +682,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource
     /**
      * Retrieve temporary index table name
      *
-     * @param unknown_type $table
+     * @param string|null $table
      * @return string
      */
     public function getIdxTable($table = null)
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php
index f1d4102d3bec5248cc2242ddeac5c425158a8976..a9507fd30d9768d818b3511d9bdf44e3138df5a0 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer\Price;
 
 /**
  * Default Product Type Price Indexer Resource model
@@ -33,11 +33,9 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer\Price;
-
 class DefaultPrice
     extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexer
-    implements \Magento\Catalog\Model\Resource\Product\Indexer\Price\PriceInterface
+    implements PriceInterface
 {
     /**
      * Product type code
@@ -87,6 +85,7 @@ class DefaultPrice
     /**
      * Define main price index table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -97,7 +96,7 @@ class DefaultPrice
      * Set Product Type code
      *
      * @param string $typeCode
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     public function setTypeId($typeCode)
     {
@@ -123,7 +122,7 @@ class DefaultPrice
      * Set Product Type Composite flag
      *
      * @param bool $flag
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     public function setIsComposite($flag)
     {
@@ -144,7 +143,8 @@ class DefaultPrice
     /**
      * Reindex temporary (price result data) for all products
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
+     * @throws \Exception
      */
     public function reindexAll()
     {
@@ -166,7 +166,7 @@ class DefaultPrice
      * Reindex temporary (price result data) for defined product(s)
      *
      * @param int|array $entityIds
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     public function reindexEntity($entityIds)
     {
@@ -194,7 +194,7 @@ class DefaultPrice
     /**
      * Prepare final price temporary index table
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     protected function _prepareDefaultFinalPriceTable()
     {
@@ -215,8 +215,8 @@ class DefaultPrice
     /**
      * Prepare products default final price in temporary index table
      *
-     * @param int|array $entityIds  the entity ids limitation
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @param int|array $entityIds the entity ids limitation
+     * @return $this
      */
     protected function _prepareFinalPriceData($entityIds = null)
     {
@@ -366,7 +366,7 @@ class DefaultPrice
     /**
      * Prepare table structure for custom option temporary aggregation data
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     protected function _prepareCustomOptionAggregateTable()
     {
@@ -377,7 +377,7 @@ class DefaultPrice
     /**
      * Prepare table structure for custom option prices data
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     protected function _prepareCustomOptionPriceTable()
     {
@@ -388,7 +388,7 @@ class DefaultPrice
     /**
      * Apply custom option minimal and maximal price to temporary final price index table
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     protected function _applyCustomOption()
     {
@@ -569,7 +569,7 @@ class DefaultPrice
     /**
      * Mode Final Prices index to primary temporary index table
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Indexer\Price\DefaultPrice
+     * @return $this
      */
     protected function _movePriceDataToIndexTable()
     {
@@ -623,10 +623,10 @@ class DefaultPrice
      * Register data required by product type process in event object
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
     public function registerEvent(\Magento\Index\Model\Event $event)
     {
-
     }
 
     /**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/PriceInterface.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/PriceInterface.php
index 5871ce5c410dce550773ade267c029233b6a8d9a..f677a0836cedf0c57b38aae81c82370407646ac7 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/PriceInterface.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/PriceInterface.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Indexer\Price;
 
 /**
  * Catalog Product Type Price Indexer interface
@@ -32,30 +32,28 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Indexer\Price;
-
 interface PriceInterface
 {
     /**
      * Reindex temporary (price result data) for all products
      *
+     * @return $this
      */
-    public function reindexAll()
-;
+    public function reindexAll();
 
     /**
      * Reindex temporary (price result data) for defined product(s)
      *
      * @param int|array $entityIds
+     * @return $this
      */
-    public function reindexEntity($entityIds)
-;
+    public function reindexEntity($entityIds);
 
     /**
      * Register data required by product type process in event object
      *
      * @param \Magento\Index\Model\Event $event
+     * @return void
      */
-    public function registerEvent(\Magento\Index\Model\Event $event)
-;
+    public function registerEvent(\Magento\Index\Model\Event $event);
 }
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link.php b/app/code/Magento/Catalog/Model/Resource/Product/Link.php
index 0a873217447ec1041460e96d256d76a2097491c2..ecb5cf1463babb7126bc23fc75addf2cf277df5c 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Link.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Link.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product;
 
 /**
  * Catalog product link resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Link extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -46,17 +44,17 @@ class Link extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Catalog product relation
      *
-     * @var \Magento\Catalog\Model\Resource\Product\Relation
+     * @var Relation
      */
     protected $_catalogProductRelation;
 
     /**
      * @param \Magento\App\Resource $resource
-     * @param \Magento\Catalog\Model\Resource\Product\Relation $catalogProductRelation
+     * @param Relation $catalogProductRelation
      */
     public function __construct(
         \Magento\App\Resource $resource,
-        \Magento\Catalog\Model\Resource\Product\Relation $catalogProductRelation
+        Relation $catalogProductRelation
     ) {
         $this->_catalogProductRelation = $catalogProductRelation;
         parent::__construct($resource);
@@ -64,6 +62,8 @@ class Link extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Define main table name and attributes table
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -77,7 +77,7 @@ class Link extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\Catalog\Model\Product $product
      * @param array $data
      * @param int $typeId
-     * @return \Magento\Catalog\Model\Resource\Product\Link
+     * @return $this
      */
     public function saveProductLinks($product, $data, $typeId)
     {
@@ -235,7 +235,7 @@ class Link extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int|array $childId
      * @param int $typeId
-     * @return array
+     * @return string[]
      */
     public function getParentIdsByChild($childId, $typeId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php
index 90ff20bea10a99ec60009dadb301c6fabb58b9cd..1eb1b495042d92aef6fedc776c7080ee8582b6e8 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Link/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Link;
 
 /**
  * Catalog product links collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Link;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -59,6 +57,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -69,7 +69,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Declare link model and initialize type attributes join
      *
      * @param \Magento\Catalog\Model\Product\Link $linkModel
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Collection
+     * @return $this
      */
     public function setLinkModel(\Magento\Catalog\Model\Product\Link $linkModel)
     {
@@ -94,7 +94,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Initialize collection parent product and add limitation join
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Collection
+     * @return $this
      */
     public function setProduct(\Magento\Catalog\Model\Product $product)
     {
@@ -115,7 +115,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add link's type to filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Collection
+     * @return $this
      */
     public function addLinkTypeIdFilter()
     {
@@ -128,12 +128,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add product to filter
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Collection
+     * @return $this
      */
     public function addProductIdFilter()
     {
         if ($this->getProduct() && $this->getProduct()->getId()) {
-            $this->addFieldToFilter('product_id',  array('eq' => $this->getProduct()->getId()));
+            $this->addFieldToFilter('product_id', array('eq' => $this->getProduct()->getId()));
         }
         return $this;
     }
@@ -141,7 +141,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Join attributes
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Collection
+     * @return $this
      */
     public function joinAttributes()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php
index 5ee30c71fe3b725df9525c6a854726f346ce970b..595d58c0d0e89e0f642970f30d06f641bb28b3f3 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Link\Product;
 
 /**
  * Catalog product linked products collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Link\Product;
-
 class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
 {
     /**
@@ -75,7 +73,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      * Declare link model and initialize type attributes join
      *
      * @param \Magento\Catalog\Model\Product\Link $linkModel
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setLinkModel(\Magento\Catalog\Model\Product\Link $linkModel)
     {
@@ -89,7 +87,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Enable strong mode for inner join of linked products
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setIsStrongMode()
     {
@@ -111,7 +109,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      * Initialize collection parent product and add limitation join
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setProduct(\Magento\Catalog\Model\Product $product)
     {
@@ -136,7 +134,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      * Exclude products from filter
      *
      * @param array $products
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function addExcludeProductFilter($products)
     {
@@ -154,7 +152,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      * Add products to filter
      *
      * @param array|int|string $products
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function addProductFilter($products)
     {
@@ -172,7 +170,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Add random sorting order
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setRandomOrder()
     {
@@ -184,7 +182,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      * Setting group by to exclude duplications in collection
      *
      * @param string $groupBy
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setGroupBy($groupBy = 'e.entity_id')
     {
@@ -195,7 +193,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Join linked products when specified link model
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     protected function _beforeLoad()
     {
@@ -208,7 +206,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Join linked products and their attributes
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     protected function _joinLinks()
     {
@@ -243,13 +241,11 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
         return $this;
     }
 
-
-
     /**
      * Enable sorting products by its position
      *
      * @param string $dir sort type asc|desc
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setPositionOrder($dir = self::SORT_ORDER_ASC)
     {
@@ -263,7 +259,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      * Enable sorting products by its attribute set name
      *
      * @param string $dir sort type asc|desc
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setAttributeSetIdOrder($dir = self::SORT_ORDER_ASC)
     {
@@ -280,7 +276,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Join attributes
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function joinAttributes()
     {
@@ -315,7 +311,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
      *
      * @param string|array $attribute
      * @param string $dir
-     * @return \Magento\Catalog\Model\Resource\Product\Link\Product\Collection
+     * @return $this
      */
     public function setOrder($attribute, $dir = self::SORT_ORDER_ASC)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php
index a7fbd81e406cf2f49e6bb977d60e4eb9acacc4ac..d39170d898c295ef4c8e9e13a0c9f0976842f0cf 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product;
 
 /**
  * Catalog product custom option resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -80,6 +78,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main table and initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -104,7 +103,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save value prices
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Catalog\Model\Resource\Product\Option
+     * @return $this
      */
     protected function _saveValuePrices(\Magento\Core\Model\AbstractModel $object)
     {
@@ -170,8 +169,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
 
             $scope = (int) $this->_storeManager->getStore()->getConfig(\Magento\Core\Model\Store::XML_PATH_PRICE_SCOPE);
 
-            if ($object->getStoreId() != '0' && $scope == \Magento\Core\Model\Store::PRICE_SCOPE_WEBSITE
-                && !$object->getData('scope', 'price')) {
+            if ($object->getStoreId() != '0' && $scope == \Magento\Core\Model\Store::PRICE_SCOPE_WEBSITE) {
 
                 $baseCurrency = $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
                     'default');
@@ -248,7 +246,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save titles
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Catalog\Model\Resource\Product\Option
+     * @return void
      */
     protected function _saveValueTitles(\Magento\Core\Model\AbstractModel $object)
     {
@@ -351,7 +349,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete prices
      *
      * @param int $optionId
-     * @return \Magento\Catalog\Model\Resource\Product\Option
+     * @return $this
      */
     public function deletePrices($optionId)
     {
@@ -369,7 +367,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete titles
      *
      * @param int $optionId
-     * @return \Magento\Catalog\Model\Resource\Product\Option
+     * @return $this
      */
     public function deleteTitles($optionId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php
index 0a1570a5fb55f59a52b072837e2b5f41ced6c493..3e4594264224031538099b984ab45db5311591b2 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Collection.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Resource\Product\Option;
 
 /**
@@ -54,7 +53,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * @param \Magento\Event\ManagerInterface $eventManager
      * @param \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $optionValueCollectionFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
      */
     public function __construct(
@@ -74,6 +73,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -84,7 +85,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Adds title, price & price_type attributes to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function getOptions($storeId)
     {
@@ -98,7 +99,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add title to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function addTitleToResult($storeId)
     {
@@ -131,7 +132,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add price to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function addPriceToResult($storeId)
     {
@@ -178,7 +179,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add value to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function addValuesToResult($storeId = null)
     {
@@ -214,7 +215,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add product_id filter to select
      *
      * @param array|\Magento\Catalog\Model\Product|int $product
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function addProductToFilter($product)
     {
@@ -235,7 +236,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add is_required filter to select
      *
      * @param bool $required
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function addRequiredFilter($required = true)
     {
@@ -246,8 +247,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add filtering by option ids
      *
-     * @param mixed $optionIds
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @param string|array $optionIds
+     * @return $this
      */
     public function addIdsToFilter($optionIds)
     {
@@ -258,7 +259,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Call of protected method reset
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Collection
+     * @return $this
      */
     public function reset()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php
index 606ebee79d072c4da55cd629767ede74b8a619a7..83121f83f88d14e21dcdb11c22c9487bdbdd7d85 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Option;
 
 /**
  * Catalog product custom option resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Option;
-
 class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -80,6 +78,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main table and initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -105,6 +104,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save option value price data
      *
      * @param \Magento\Core\Model\AbstractModel $object
+     * @return void
      */
     protected function _saveValuePrices(\Magento\Core\Model\AbstractModel $object)
     {
@@ -147,8 +147,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
 
         $scope = (int)$this->_storeManager->getStore()->getConfig(\Magento\Core\Model\Store::XML_PATH_PRICE_SCOPE);
 
-        if ($object->getStoreId() != '0' && $scope == \Magento\Core\Model\Store::PRICE_SCOPE_WEBSITE
-            && !$object->getData('scope', 'price')) {
+        if ($object->getStoreId() != '0' && $scope == \Magento\Core\Model\Store::PRICE_SCOPE_WEBSITE) {
 
             $baseCurrency = $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE,
                 'default');
@@ -215,6 +214,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save option value title data
      *
      * @param \Magento\Core\Model\AbstractModel $object
+     * @return void
      */
     protected function _saveValueTitles(\Magento\Core\Model\AbstractModel $object)
     {
@@ -285,7 +285,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete values by option id
      *
      * @param int $optionId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value
+     * @return $this
      */
     public function deleteValue($optionId)
     {
@@ -313,6 +313,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete values by option type
      *
      * @param int $optionTypeId
+     * @return void
      */
     public function deleteValues($optionTypeId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php
index affcf10feedda498070feadd20756faaf759e8e4..ff45fb5c5cc84235b8692badc0776a212d3b9372 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Option\Value;
 
 /**
  * Catalog product option values collection
@@ -32,13 +32,13 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Option\Value;
-
 class Collection
     extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -49,7 +49,7 @@ class Collection
      * Add price, title to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return $this
      */
     public function getValues($storeId)
     {
@@ -63,7 +63,7 @@ class Collection
      * Add titles to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return $this
      */
     public function addTitlesToResult($storeId)
     {
@@ -131,7 +131,7 @@ class Collection
      * Add title result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return $this
      */
     public function addTitleToResult($storeId)
     {
@@ -164,7 +164,7 @@ class Collection
      * Add price to result
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return $this
      */
     public function addPriceToResult($storeId)
     {
@@ -210,7 +210,7 @@ class Collection
      *
      * @param array $optionIds
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return $this
      */
     public function getValuesByOption($optionIds, $storeId = null)
     {
@@ -225,7 +225,7 @@ class Collection
      * Add option to filter
      *
      * @param array|\Magento\Catalog\Model\Product\Option|int $option
-     * @return \Magento\Catalog\Model\Resource\Product\Option\Value\Collection
+     * @return $this
      */
     public function addOptionToFilter($option)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Relation.php b/app/code/Magento/Catalog/Model/Resource/Product/Relation.php
index 9e16dbc3d6c7b1e87011b828461adc04555736eb..dd5f633f9ee03b02a34bb27bb466505e0defacc1 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Relation.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Relation.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product;
 
 /**
  * Catalog Product Relations Resource model
@@ -32,13 +32,12 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Relation extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Initialize resource model and define main table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -50,7 +49,7 @@ class Relation extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $parentId
      * @param array $childIds
-     * @return \Magento\Catalog\Model\Resource\Product\Relation
+     * @return $this
      */
     public function processRelations($parentId, $childIds)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Status.php b/app/code/Magento/Catalog/Model/Resource/Product/Status.php
index 9eb921ea894ab6dc988a5f9e00f36a02c27def83..c2a8a4855a21c76ce1f9c0654ec32bd4ab7c03de 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Status.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Status.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Catalog\Model\Resource\Product;
 
+use Magento\Core\Model\Config\Element;
 
 /**
  * Catalog product website resource model
@@ -32,8 +34,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Status extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -85,6 +85,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -105,7 +106,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Retrieve product attribute
      *
-     * @param unknown_type $attribute
+     * @param string|integer|Element $attribute
      * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
      */
     protected function _getProductAttribute($attribute)
@@ -121,7 +122,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $productId
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Product\Status
+     * @return $this
      */
     public function refreshEnabledIndex($productId, $storeId)
     {
@@ -142,9 +143,9 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Update product status for store
      *
      * @param int $productId
-     * @param int $storId
+     * @param int $storeId
      * @param int $value
-     * @return \Magento\Catalog\Model\Resource\Product\Status
+     * @return $this
      */
     public function updateProductStatus($productId, $storeId, $value)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable.php b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable.php
index 7639cdbcb9a9df3d102215bffa3b7519d6e2960e..a4d19b4faeb34dc2d16d8bd63709bef065e849b4 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Type;
 
 /**
  * Configurable product type resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Type;
-
 class Configurable extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -58,6 +56,7 @@ class Configurable extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Init resource
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -69,7 +68,7 @@ class Configurable extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Catalog\Model\Product $mainProduct the parent id
      * @param array $productIds the children id array
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable
+     * @return $this
      */
     public function saveProducts($mainProduct, $productIds)
     {
@@ -146,7 +145,7 @@ class Configurable extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve parent ids array by requered child
      *
      * @param int|array $childId
-     * @return array
+     * @return string[]
      */
     public function getParentIdsByChild($childId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute.php
index 82b8b63c09359537f1aadb79810ff78ec29358a7..bd6af62c4a87e868cae82b313eaca38d1da71fa7 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Type\Configurable;
 
 /**
  * Catalog super product attribute resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Type\Configurable;
-
 class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -82,6 +80,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Inititalize connection and define tables
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -104,7 +103,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save Custom labels for Attribute name
      *
      * @param \Magento\Catalog\Model\Product\Type\Configurable\Attribute $attribute
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute
+     * @return $this
      */
     public function saveLabel($attribute)
     {
@@ -146,7 +145,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save Options prices (Depends from price save scope)
      *
      * @param \Magento\Catalog\Model\Product\Type\Configurable\Attribute $attribute
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute
+     * @return $this
      */
     public function savePrices($attribute)
     {
@@ -277,7 +276,6 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
             $write->insertMultiple($this->_priceTable, $insert);
         }
 
-
         return $this;
     }
 
@@ -313,9 +311,8 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Get configurable attribute id by product id and attribute id
      *
      * @param \Magento\Catalog\Model\Product\Type\Configurable\Attribute $attribute
-     * @param $productId
-     * @param $attributeId
-     *
+     * @param mixed $productId
+     * @param mixed $attributeId
      * @return string
      */
     public function getIdByProductIdAndAttributeId($attribute, $productId, $attributeId)
@@ -330,7 +327,8 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Delete configurable attributes by product id
      *
-     * @param $productId
+     * @param mixed $productId
+     * @return void
      */
     public function deleteAttributesByProductId($productId)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php
index a075ced75222724436edfa695f16b191a40ef6a7..10880d8c55cde99aead678d491009749d3455c65 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Attribute/Collection.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute;
 
 /**
@@ -85,7 +84,7 @@ class Collection
      * @param \Magento\Catalog\Model\Product\Type\Configurable $catalogProductTypeConfigurable
      * @param \Magento\Catalog\Helper\Data $catalogData
      * @param \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute $resource
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      */
     public function __construct(
         \Magento\Core\Model\EntityFactory $entityFactory,
@@ -107,6 +106,7 @@ class Collection
     /**
      * Initialize connection and define table names
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -122,7 +122,7 @@ class Collection
      * Set Product filter (Configurable)
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     public function setProductFilter($product)
     {
@@ -144,11 +144,11 @@ class Collection
      * Set order collection by Position
      *
      * @param string $dir
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     public function orderByPosition($dir = self::SORT_ORDER_ASC)
     {
-        $this->setOrder('position ',  $dir);
+        $this->setOrder('position ', $dir);
         return $this;
     }
 
@@ -165,7 +165,7 @@ class Collection
     /**
      * After load collection process
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -188,7 +188,7 @@ class Collection
     /**
      * Add product attributes to collection items
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     protected function _addProductAttributes()
     {
@@ -203,7 +203,7 @@ class Collection
     /**
      * Add Associated Product Filters (From Product Type Instance)
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     public function _addAssociatedProductFilters()
     {
@@ -216,7 +216,7 @@ class Collection
     /**
      * Load attribute labels
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     protected function _loadLabels()
     {
@@ -248,11 +248,11 @@ class Collection
                 ->where('def.product_super_attribute_id IN (?)', array_keys($this->_items))
                 ->where('def.store_id = ?', 0);
 
-                $result = $this->getConnection()->fetchAll($select);
-                foreach ($result as $data) {
-                    $this->getItemById($data['product_super_attribute_id'])->setLabel($data['label']);
-                    $this->getItemById($data['product_super_attribute_id'])->setUseDefault($data['use_default']);
-                }
+            $result = $this->getConnection()->fetchAll($select);
+            foreach ($result as $data) {
+                $this->getItemById($data['product_super_attribute_id'])->setLabel($data['label']);
+                $this->getItemById($data['product_super_attribute_id'])->setUseDefault($data['use_default']);
+            }
         }
         return $this;
     }
@@ -260,7 +260,7 @@ class Collection
     /**
      * Load attribute prices information
      *
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection
+     * @return $this
      */
     protected function _loadPrices()
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Product/Collection.php
index baea7aaaf8319de163bb6b05211de294879cbd30..ac31f521daf264be377e9c94462ba3ca20d7c851 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Product/Collection.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Type/Configurable/Product/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product\Type\Configurable\Product;
 
 /**
  * Catalog super product link collection
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product\Type\Configurable\Product;
-
 class Collection
     extends \Magento\Catalog\Model\Resource\Product\Collection
 {
@@ -46,6 +44,8 @@ class Collection
 
     /**
      * Assign link table name
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -55,7 +55,8 @@ class Collection
 
     /**
      * Init select
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Product\Collection
+     *
+     * @return $this|\Magento\Catalog\Model\Resource\Product\Collection
      */
     protected function _initSelect()
     {
@@ -72,7 +73,7 @@ class Collection
      * Set Product filter to result
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Catalog\Model\Resource\Product\Type\Configurable\Product\Collection
+     * @return $this
      */
     public function setProductFilter($product)
     {
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Website.php b/app/code/Magento/Catalog/Model/Resource/Product/Website.php
index 2fa182feeb7c2e5adeb4675a70e747700a232c12..e4438e63cfafc5a938a46a4f868ad0d6b336e830 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Website.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Website.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource\Product;
 
 /**
  * Catalog Product Website Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource\Product;
-
 class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -68,6 +66,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection and define resource table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -79,7 +78,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param array $websiteIds
      * @param array $productIds
-     * @return \Magento\Catalog\Model\Resource\Product\Website
+     * @return $this
      * @throws \Exception
      */
     public function removeProducts($websiteIds, $productIds)
@@ -114,7 +113,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param array $websiteIds
      * @param array $productIds
-     * @return \Magento\Catalog\Model\Resource\Product\Website
+     * @return $this
      * @throws \Exception
      */
     public function addProducts($websiteIds, $productIds)
diff --git a/app/code/Magento/Catalog/Model/Resource/Setup.php b/app/code/Magento/Catalog/Model/Resource/Setup.php
index 02f45a46f02d0b0611a746bcafc6fdde50323589..44c09334c1fdb76bd1dbaffcfc4baf0158aa41be 100755
--- a/app/code/Magento/Catalog/Model/Resource/Setup.php
+++ b/app/code/Magento/Catalog/Model/Resource/Setup.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource;
 
 /**
  * Catalog entity setup
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource;
-
 class Setup extends \Magento\Eav\Model\Entity\Setup
 {
     /**
@@ -96,18 +94,6 @@ class Setup extends \Magento\Eav\Model\Entity\Setup
         return $this->_categoryFactory->create($data);
     }
 
-    /**
-     * Creates indexer model
-     *
-     * @param array $data
-     * @return \Magento\Index\Model\Indexer
-     */
-    public function createIndexer($data = array())
-    {
-        return $this->_indexerFactory
-            ->create($data);
-    }
-
     /**
      * Creates setup migration model
      *
diff --git a/app/code/Magento/Catalog/Model/Resource/Url.php b/app/code/Magento/Catalog/Model/Resource/Url.php
index f2af68b6714138799772df2d4e6d6e526d4742c1..8730b428a181f4408c51f6198c5b741d0704deb3 100644
--- a/app/code/Magento/Catalog/Model/Resource/Url.php
+++ b/app/code/Magento/Catalog/Model/Resource/Url.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Catalog\Model\Resource;
 
 /**
  * Catalog url rewrite resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Catalog
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Catalog\Model\Resource;
-
 class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -107,6 +105,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Load core Url rewrite model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -141,7 +140,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve stores array or store model
      *
      * @param int $storeId
-     * @return \Magento\Core\Model\Store|array
+     * @return \Magento\Core\Model\Store|\Magento\Core\Model\Store[]
      */
     public function getStores($storeId = null)
     {
@@ -350,7 +349,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param array $rewriteData
      * @param int|\Magento\Object $rewrite
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function saveRewrite($rewriteData, $rewrite)
@@ -386,7 +385,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Saves rewrite history
      *
      * @param array $rewriteData
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function saveRewriteHistory($rewriteData)
     {
@@ -406,7 +405,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Object $category
      * @param string $attributeCode
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function saveCategoryAttribute(\Magento\Object $category, $attributeCode)
     {
@@ -556,7 +555,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Object $product
      * @param string $attributeCode
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function saveProductAttribute(\Magento\Object $product, $attributeCode)
     {
@@ -695,7 +694,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Prepare category parentId
      *
      * @param \Magento\Object $category
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     protected function _prepareCategoryParentId(\Magento\Object $category)
     {
@@ -711,8 +710,8 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Prepare stores root categories
      *
-     * @param array $stores
-     * @return array
+     * @param \Magento\Core\Model\Store[] $stores
+     * @return \Magento\Core\Model\Store[]
      */
     protected function _prepareStoreRootCategories($stores)
     {
@@ -839,7 +838,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $categoryId
      * @param int $storeId
-     * @return \Magento\Object
+     * @return \Magento\Object|false
      */
     public function getCategory($categoryId, $storeId)
     {
@@ -859,7 +858,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int|array $categoryIds
      * @param int $storeId
-     * @return array
+     * @return array|false
      */
     public function getCategories($categoryIds, $storeId)
     {
@@ -989,7 +988,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int|array $productIds
      * @param int $storeId
      * @param int $entityId
-     * @param int $lastEntityId
+     * @param int &$lastEntityId
      * @return array
      */
     protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId)
@@ -1064,7 +1063,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $productId
      * @param int $storeId
-     * @return \Magento\Object
+     * @return \Magento\Object|false
      */
     public function getProduct($productId, $storeId)
     {
@@ -1080,7 +1079,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve Product data obects for store
      *
      * @param int $storeId
-     * @param int $lastEntityId
+     * @param int &$lastEntityId
      * @return array
      */
     public function getProductsByStore($storeId, &$lastEntityId)
@@ -1092,7 +1091,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve Product data objects in category
      *
      * @param \Magento\Object $category
-     * @param int $lastEntityId
+     * @param int &$lastEntityId
      * @return array
      */
     public function getProductsByCategory(\Magento\Object $category, &$lastEntityId)
@@ -1109,7 +1108,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * (either to other category or deleted), so rewrite "category_id-product_id" is invalid
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function clearCategoryProduct($storeId)
     {
@@ -1145,7 +1144,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int $productId Product entity Id
      * @param int $storeId Store Id for rewrites
      * @param array $excludeCategoryIds Array of category Ids that should be skipped
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function clearProductRewrites($productId, $storeId, $excludeCategoryIds = array())
     {
@@ -1170,7 +1169,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * left from the times when categories/products belonged to store
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function clearStoreCategoriesInvalidRewrites($storeId)
     {
@@ -1204,7 +1203,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $storeId
      * @param int|array|null $productId
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function clearStoreProductsInvalidRewrites($storeId, $productId = null)
     {
@@ -1246,7 +1245,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * b) product rewrites left from products that once belonged to this site, but then deleted or just removed from website
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function clearStoreInvalidRewrites($storeId)
     {
@@ -1259,8 +1258,8 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete rewrites for associated to category products
      *
      * @param int $categoryId
-     * @param array $productIds
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @param array|int|null $productIds
+     * @return $this
      */
     public function deleteCategoryProductRewrites($categoryId, $productIds)
     {
@@ -1274,7 +1273,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int $categoryId
      * @param array|int|null $productIds
      * @param null|int $storeId
-     * @return \Magento\Catalog\Model\Resource\Url
+     * @return $this
      */
     public function deleteCategoryProductStoreRewrites($categoryId, $productIds = null, $storeId = null)
     {
@@ -1365,8 +1364,8 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param string $requestPath
      * @param int $storeId
-     * @param array $_checkedPaths internal varible to prevent infinite loops.
-     * @return string | bool
+     * @param array &$_checkedPaths internal variable to prevent infinite loops.
+     * @return string|bool
      */
     public function findFinalTargetPath($requestPath, $storeId, &$_checkedPaths = array())
     {
diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php
index 159e7ac3f4d795596d8241f869e6980b0e092092..daa6852da4ec966f414e5c4ec22fee111e0097c1 100644
--- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php
+++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php
@@ -65,7 +65,7 @@ class Flat extends \Magento\Core\Model\Config\Value
     /**
      * After enable flat products required reindex
      *
-     * @return \Magento\Catalog\Model\System\Config\Backend\Catalog\Product\Flat
+     * @return $this
      */
     protected function _afterSave()
     {
diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php
index 85063da36fb393d7d3727ad19d83b67611e82099..8c7d423f7e8665a610026c6cdf91696edec11da0 100644
--- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php
+++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php
@@ -65,7 +65,7 @@ class Suffix extends \Magento\Core\Model\Config\Value
     /**
      * Check url rewrite suffix - whether we can support it
      *
-     * @return \Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Catalog/Model/Url.php b/app/code/Magento/Catalog/Model/Url.php
index 4a0756f4e945056ea66f1c38d599b80920440178..e5322a21e1bf3e169e1c3bbdf29c20805ed2bfc4 100644
--- a/app/code/Magento/Catalog/Model/Url.php
+++ b/app/code/Magento/Catalog/Model/Url.php
@@ -107,10 +107,10 @@ class Url
     protected $_saveRewritesHistory = null;
 
      /**
-     * Singleton of category model for building URL path
-     *
-     * @var \Magento\Catalog\Model\Category
-     */
+      * Singleton of category model for building URL path
+      *
+      * @var \Magento\Catalog\Model\Category
+      */
     static protected $_categoryForUrlPath;
 
     /**
@@ -208,7 +208,7 @@ class Url
      * Retrieve stores array or store model
      *
      * @param int $storeId
-     * @return \Magento\Core\Model\Store|array
+     * @return \Magento\Core\Model\Store|\Magento\Core\Model\Store[]
      */
     public function getStores($storeId = null)
     {
@@ -254,7 +254,8 @@ class Url
      * @param int $storeId
      * @return \Magento\Object
      */
-    public function getStoreRootCategory($storeId) {
+    public function getStoreRootCategory($storeId)
+    {
         if (!array_key_exists($storeId, $this->_rootCategories)) {
             $category = null;
             $store = $this->getStores($storeId);
@@ -272,7 +273,7 @@ class Url
      * Force Rewrites History save bypass config settings
      *
      * @param bool $flag
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     public function setShouldSaveRewritesHistory($flag)
     {
@@ -299,7 +300,7 @@ class Url
      * Used to make full reindexing of url rewrites
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     public function refreshRewrites($storeId = null)
     {
@@ -324,15 +325,14 @@ class Url
      * @param \Magento\Object $category
      * @param string $parentPath
      * @param bool $refreshProducts
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     protected function _refreshCategoryRewrites(\Magento\Object $category, $parentPath = null, $refreshProducts = true)
     {
         if ($category->getId() != $this->getStores($category->getStoreId())->getRootCategoryId()) {
             if ($category->getUrlKey() == '') {
                 $urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
-            }
-            else {
+            } else {
                 $urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
             }
 
@@ -364,8 +364,7 @@ class Url
                 $category->setUrlPath($requestPath);
                 $this->getResource()->saveCategoryAttribute($category, 'url_path');
             }
-        }
-        else {
+        } else {
             if ($category->getUrlPath() != '') {
                 $category->setUrlPath('');
                 $this->getResource()->saveCategoryAttribute($category, 'url_path');
@@ -388,7 +387,7 @@ class Url
      *
      * @param \Magento\Object $product
      * @param \Magento\Object $category
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     protected function _refreshProductRewrite(\Magento\Object $product, \Magento\Object $category)
     {
@@ -397,8 +396,7 @@ class Url
         }
         if ($product->getUrlKey() == '') {
             $urlKey = $this->getProductModel()->formatUrlKey($product->getName());
-        }
-        else {
+        } else {
             $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
         }
 
@@ -442,10 +440,10 @@ class Url
     }
 
     /**
-     * Refresh products for catwgory
+     * Refresh products for category
      *
      * @param \Magento\Object $category
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     protected function _refreshCategoryProductRewrites(\Magento\Object $category)
     {
@@ -489,13 +487,13 @@ class Url
     }
 
     /**
-     * Refresh category and childs rewrites
+     * Refresh category and children rewrites
      * Called when reindexing all rewrites and as a reaction on category change that affects rewrites
      *
      * @param int $categoryId
      * @param int|null $storeId
      * @param bool $refreshProducts
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     public function refreshCategoryRewrite($categoryId, $storeId = null, $refreshProducts = true)
     {
@@ -532,7 +530,7 @@ class Url
      *
      * @param int $productId
      * @param int|null $storeId
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     public function refreshProductRewrite($productId, $storeId = null)
     {
@@ -582,7 +580,7 @@ class Url
      * Refresh all product rewrites for designated store
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     public function refreshProductRewrites($storeId)
     {
@@ -642,7 +640,7 @@ class Url
      * Deletes old rewrites for store, left from the times when store had some other root category
      *
      * @param int $storeId
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     public function clearStoreInvalidRewrites($storeId = null)
     {
@@ -932,16 +930,14 @@ class Url
             if (!$product) {
                 if ($category->getUrlKey() == '') {
                     $urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
-                }
-                else {
+                } else {
                     $urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
                 }
 
                 $categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
                 if (null === $parentPath) {
                     $parentPath = $this->getResource()->getCategoryParentPath($category);
-                }
-                elseif ($parentPath == '/') {
+                } elseif ($parentPath == '/') {
                     $parentPath = '';
                 }
                 $parentPath = $this->_catalogCategory->getCategoryUrlPath($parentPath,
@@ -961,8 +957,7 @@ class Url
 
             if ($product->getUrlKey() == '') {
                 $urlKey = $this->getProductModel()->formatUrlKey($product->getName());
-            }
-            else {
+            } else {
                 $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
             }
             $productUrlSuffix  = $this->getProductUrlSuffix($category->getStoreId());
@@ -1011,7 +1006,7 @@ class Url
      *
      * @param array $rewriteData New rewrite data
      * @param \Magento\Object $rewrite Rewrite model
-     * @return \Magento\Catalog\Model\Url
+     * @return $this
      */
     protected function _saveRewriteHistory($rewriteData, $rewrite)
     {
diff --git a/app/code/Magento/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.13-1.6.0.0.14.php b/app/code/Magento/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.13-1.6.0.0.14.php
index 0f9eac643cdb2d7b6ae05750c4a99f7b8c2ee1e3..227975a1a2ce664e5890161dd8537e2fadaf0ebb 100644
--- a/app/code/Magento/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.13-1.6.0.0.14.php
+++ b/app/code/Magento/Catalog/data/catalog_setup/data-upgrade-1.6.0.0.13-1.6.0.0.14.php
@@ -61,8 +61,4 @@ if ($attributeTableOld != $attributeTableNew) {
         ->enableTableKeys($attributeTableNew);
 }
 
-$process = $installer->createIndexer()
-    ->getProcessByCode(\Magento\Catalog\Helper\Category\Flat::CATALOG_CATEGORY_FLAT_PROCESS_CODE);
-$process->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX);
-
 $installer->endSetup();
diff --git a/app/code/Magento/Catalog/etc/adminhtml/system.xml b/app/code/Magento/Catalog/etc/adminhtml/system.xml
index ca393e7d79734b1b9a63d8fc33c366470260fd35..474044fe5d5412630bd4ad8fd826ddbd1733ed7d 100644
--- a/app/code/Magento/Catalog/etc/adminhtml/system.xml
+++ b/app/code/Magento/Catalog/etc/adminhtml/system.xml
@@ -82,8 +82,7 @@
                 </field>
                 <field id="flat_catalog_category" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0">
                     <label>Use Flat Catalog Category</label>
-                    <frontend_model>Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select\Flatcatalog</frontend_model>
-                    <backend_model>Magento\Catalog\Model\System\Config\Backend\Catalog\Category\Flat</backend_model>
+                    <backend_model>Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode</backend_model>
                     <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model>
                 </field>
                 <field id="flat_catalog_product" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="0" showInStore="0">
diff --git a/app/code/Magento/Catalog/etc/catalog_attributes.xml b/app/code/Magento/Catalog/etc/catalog_attributes.xml
index 1c0b62c4ea06e325b530972b4ad8b24b379afd09..471c3b61d6075d61ac29df845beea18e17c150b3 100644
--- a/app/code/Magento/Catalog/etc/catalog_attributes.xml
+++ b/app/code/Magento/Catalog/etc/catalog_attributes.xml
@@ -69,7 +69,6 @@
         <attribute name="media_gallery_content" />
         <attribute name="group_price" />
         <attribute name="tier_price" />
-        <attribute name="recurring_profileinit_may_fail" />
         <attribute name="gift_message_available" />
         <attribute name="inventory_manage_stock" />
     </group>
diff --git a/app/code/Magento/Catalog/etc/crontab.xml b/app/code/Magento/Catalog/etc/crontab.xml
index d2528fada02c9b9b0aea812211daf40a46d8b813..8bfea016cdec330560604d9a5c9a499a53fe5093 100644
--- a/app/code/Magento/Catalog/etc/crontab.xml
+++ b/app/code/Magento/Catalog/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="catalog_product_index_price_reindex_all" instance="Magento\Catalog\Model\Observer" method="reindexProductPrices">
-        <schedule>0 2 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="catalog_product_index_price_reindex_all" instance="Magento\Catalog\Model\Observer" method="reindexProductPrices">
+            <schedule>0 2 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 40b3d657c57276e529c30acaa3d29e6b7edbd75e..6f08517387457b21c026d9b02c96a0cc4bccbeb1 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -42,11 +42,6 @@
             <instance type="Magento\Catalog\Model\Product\Status\Proxy" />
         </param>
     </type>
-    <type name="Magento\Catalog\Model\Resource\Category\Flat">
-        <param name="catalogCategory">
-            <instance type="Magento\Catalog\Model\Category\Proxy" />
-        </param>
-    </type>
     <type name="Magento\Catalog\Model\Resource\Product\Flat\Indexer">
         <param name="maxIndexCount">
             <value type="int">64</value>
@@ -149,6 +144,35 @@
             <instance type="Magento\Catalog\Model\System\Config\Source\InputtypeFactory" />
         </param>
     </type>
+    <type name="Magento\Catalog\Model\Category">
+        <param name="flatIndexer">
+            <instance type="Magento\Indexer\Model\IndexerInterface" shared="false"/>
+        </param>
+    </type>
+    <type name="Magento\Catalog\Model\Indexer\Category\Flat\System\Config\Mode">
+        <param name="flatIndexer">
+            <instance type="Magento\Indexer\Model\IndexerInterface" shared="false"/>
+        </param>
+    </type>
+    <type name="Magento\Core\Model\Resource\Store">
+        <plugin name="storeViewResourceAroundSave" type="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\StoreView"/>
+    </type>
+    <type name="Magento\Core\Model\Resource\Store\Group">
+        <plugin name="storeGroupResourceAroundSave" type="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\StoreGroup"/>
+    </type>
+    <type name="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\AbstractStore">
+        <param name="indexer">
+            <instance type="Magento\Indexer\Model\IndexerInterface" shared="false"/>
+        </param>
+    </type>
+    <type name="Magento\Indexer\Model\Config\Data">
+        <plugin name="indexerConfigGet" type="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData"/>
+    </type>
+    <type name="Magento\Catalog\Model\Indexer\Category\Flat">
+        <param name="indexer">
+            <instance type="Magento\Indexer\Model\IndexerInterface" shared="false"/>
+        </param>
+    </type>
     <type name="Magento\Catalog\Model\Product\LinkTypeProvider">
         <param name="linkTypes">
             <array>
diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml
index 311d0f60dbe2dcf5bfebbb8acc0fae6969473e3d..f0857e93fc1e48f41c1c365f6b524c00a5874d25 100644
--- a/app/code/Magento/Catalog/etc/frontend/di.xml
+++ b/app/code/Magento/Catalog/etc/frontend/di.xml
@@ -47,4 +47,22 @@
     <type name="Magento\Catalog\Controller\Product\Compare">
         <plugin name="sessionInitializer" type="compareProductInitSession" />
     </type>
+    <type name="Magento\Catalog\Model\Indexer\AbstractFlatState">
+        <param name="isAvailable">
+            <value type="bool">true</value>
+        </param>
+    </type>
+    <virtualType name="Magento\Catalog\Block\ShortcutButtons\InCatalog" type="Magento\Catalog\Block\ShortcutButtons">
+        <param name="isCatalogProduct">
+            <value type="bool">true</value>
+        </param>
+    </virtualType>
+    <virtualType name="Magento\Catalog\Block\ShortcutButtons\InCatalog\PositionAfter" type="Magento\Catalog\Block\ShortcutButtons">
+        <param name="isCatalogProduct">
+            <value type="bool">true</value>
+        </param>
+        <param name="orPosition">
+            <value type="const">Magento\Catalog\Block\ShortcutButtons::POSITION_AFTER</value>
+        </param>
+    </virtualType>
 </config>
diff --git a/app/code/Magento/Catalog/etc/indexer.xml b/app/code/Magento/Catalog/etc/indexer.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66d7642fadf8c7a50ef8aba90ea33de206eeea9e
--- /dev/null
+++ b/app/code/Magento/Catalog/etc/indexer.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <indexer id="catalog_category_flat" view_id="catalog_category_flat" class="Magento\Catalog\Model\Indexer\Category\Flat">
+        <title translate="true">Category Flat Data</title>
+        <description translate="true">Reorganize EAV category structure to flat structure</description>
+    </indexer>
+</config>
diff --git a/app/code/Magento/Catalog/etc/indexers.xml b/app/code/Magento/Catalog/etc/indexers.xml
index ab95c73168e8aae7f629a7d14bfef827f36bb668..0ae4f1783bde8527d6552e6363ccc8ac7d275d11 100644
--- a/app/code/Magento/Catalog/etc/indexers.xml
+++ b/app/code/Magento/Catalog/etc/indexers.xml
@@ -28,6 +28,5 @@
     <indexer name="catalog_product_price" instance="Magento\Catalog\Model\Product\Indexer\Price" />
     <indexer name="catalog_url" instance="Magento\Catalog\Model\Indexer\Url" />
     <indexer name="catalog_product_flat" instance="Magento\Catalog\Model\Product\Indexer\Flat" />
-    <indexer name="catalog_category_flat" instance="Magento\Catalog\Model\Category\Indexer\Flat" />
     <indexer name="catalog_category_product" instance="Magento\Catalog\Model\Category\Indexer\Product" />
 </config>
diff --git a/app/code/Magento/Catalog/etc/module.xml b/app/code/Magento/Catalog/etc/module.xml
index e7c9201c9c65aef707e5932caf2a4c624b480748..e0ebf1ee4a0c9abada71d7a5469a506441e4cbca 100755
--- a/app/code/Magento/Catalog/etc/module.xml
+++ b/app/code/Magento/Catalog/etc/module.xml
@@ -55,6 +55,7 @@
             <module name="Magento_Weee"/>
             <module name="Magento_ProductAlert"/>
             <module name="Magento_Rating"/>
+            <module name="Magento_Indexer"/>
         </depends>
     </module>
 </config>
diff --git a/app/code/Magento/Catalog/etc/mview.xml b/app/code/Magento/Catalog/etc/mview.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4025c180e6e67d0601693917295f66716a4062d3
--- /dev/null
+++ b/app/code/Magento/Catalog/etc/mview.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <view id="catalog_category_flat" class="Magento\Catalog\Model\Indexer\Category\Flat" group="indexer">
+        <subscriptions>
+            <table name="catalog_category_entity" entity_column="entity_id" />
+            <table name="catalog_category_entity_decimal" entity_column="entity_id" />
+            <table name="catalog_category_entity_int" entity_column="entity_id" />
+            <table name="catalog_category_entity_text" entity_column="entity_id" />
+            <table name="catalog_category_entity_varchar" entity_column="entity_id" />
+            <table name="catalog_category_entity_datetime" entity_column="entity_id" />
+        </subscriptions>
+    </view>
+</config>
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit.phtml
index d277f332bcaeb08fb56daa7857954a0f2c37b3aa..cc8b65140a07e3792fe477655a46561b666f2e7f 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit.phtml
@@ -149,7 +149,7 @@ jQuery(function($) {
 
             $.each(this._masks, function(field, mask) {
                 var $field = $('#' + field);
-                if (!$field.val() && mask.length > 0 && !self.varRegexp.test(mask)) {
+                if (!$field.val() && mask && mask.length > 0 && !self.varRegexp.test(mask)) {
                     $field.val(mask);
                 }
                 $field.trigger('change');
@@ -182,13 +182,15 @@ jQuery(function($) {
             var self = this;
             var fieldReverseIndex = {};
             $.each(masks, function(field, mask) {
-                $.each(mask.toString().match(self.varsRegexp) || [], function(key, maskName) {
-                    var fieldName = maskName.slice(2, -2);
-                    if (!(fieldName in fieldReverseIndex)) {
-                        fieldReverseIndex[fieldName] = [];
-                    }
-                    fieldReverseIndex[fieldName].push(field);
-                })
+                if (mask) {
+                    $.each(mask.toString().match(self.varsRegexp) || [], function (key, maskName) {
+                        var fieldName = maskName.slice(2, -2);
+                        if (!(fieldName in fieldReverseIndex)) {
+                            fieldReverseIndex[fieldName] = [];
+                        }
+                        fieldReverseIndex[fieldName].push(field);
+                    })
+                }
             });
             return fieldReverseIndex;
         }
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/attribute_set.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/attribute_set.phtml
index 0333067fdfbdef9872394e7ba3b4d525e25b794c..556a945ef2e6587c0c41ad228ba68fc930a95955 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/attribute_set.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/attribute_set.phtml
@@ -29,13 +29,13 @@
 {{if !term && items.length && !$data.allShown()}}
 <h5 class="title">Recent Items</h5>
 {{/if}}
-<ul data-mage-init="{&quot;menu&quot;:[]}">
+<ul data-mage-init='{"menu":[]}'>
     {{each items}}
     <li {{html optionData($value)}}><a href="#">${$value.label}</a></li>
     {{/each}}
 </ul>
 {{if !term && items.length && !$data.allShown()}}
-<button data-mage-init="{actionLink:{event:&quot;showAll&quot;}}" class="action-show-all">
+<button data-mage-init='{"actionLink":{"event":"showAll"}}' class="action-show-all">
     <span>Show all Templates...</span>
 </button>
 {{/if}}
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-js-template.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-js-template.phtml
index 9b293db2cc9895622d4f665da1679dab38a553af..5e9891b3ac850bee93a8e64d133e0a99dbff0459 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-js-template.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-js-template.phtml
@@ -104,10 +104,10 @@
                                                     <div class="field field-pricing-measure">
                                                         <div class="actions-split actions-select">
                                                             <input name="product[configurable_attributes_data][${attribute.id}][values][${option.value}][is_percent]" type="hidden" value="0"/>
-                                                            <button type="button" class="action-toggle" data-toggle="dropdown" data-mage-init="{dropdown:{}}">
+                                                            <button type="button" class="action-toggle" data-toggle="dropdown" data-mage-init='{"dropdown":{}}'>
                                                                 <span><?php echo $this->getBaseCurrency()->getSymbol() ?></span>
                                                             </button>
-                                                            <ul class="dropdown-menu" data-role="dropdown-menu" data-mage-init="{menu:{}}">
+                                                            <ul class="dropdown-menu" data-role="dropdown-menu" data-mage-init='{"menu":{}}'>
                                                                 <li data-value="0"><a class="item"><?php echo $this->getBaseCurrency()->getSymbol() ?></a></li>
                                                                 <li data-value="1"><a class="item"><?php echo __('%')?></a></li>
                                                             </ul>
@@ -174,10 +174,10 @@
                             <div class="actions-split actions-select">
                                 <input type="hidden" value="0"
                                     name="product[configurable_attributes_data][${attribute.id}][values][${option.id}][is_percent]"/>
-                                <button type="button" class="action-toggle" data-toggle="dropdown" data-mage-init="{dropdown:{}}">
+                                <button type="button" class="action-toggle" data-toggle="dropdown" data-mage-init='{"dropdown":{}}'>
                                     <span><?php echo $this->getBaseCurrency()->getSymbol() ?></span>
                                 </button>
-                                <ul class="dropdown-menu" data-role="dropdown-menu" data-mage-init="{menu:{}}">
+                                <ul class="dropdown-menu" data-role="dropdown-menu" data-mage-init='{"menu":{}}'>
                                     <li data-value="0"><a class="item"><?php echo $this->getBaseCurrency()->getSymbol() ?></a></li>
                                     <li data-value="1"><a class="item"><?php echo __('%')?></a></li>
                                 </ul>
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-template.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-template.phtml
index 8581e9d02c3d767d732f4023a4f6b9995edcb51c..9ea5db6549bdda3cd8b61f485ed087e563901a90 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-template.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/attribute-template.phtml
@@ -141,10 +141,10 @@ $id = $this->escapeHtml($attribute['attribute_id']);
                                                     <div class="field field-pricing-measure">
                                                         <div class="actions-split actions-select">
                                                             <input name="<?php echo $namePrefix ?>[<?php echo $valueIndex ?>][is_percent]" type="hidden" value="<?php echo $isPercent ? 1 : 0; ?>"/>
-                                                            <button type="button" class="action-toggle" data-toggle="dropdown" data-mage-init="{dropdown:{}}">
+                                                            <button type="button" class="action-toggle" data-toggle="dropdown" data-mage-init='{"dropdown":{}}'>
                                                                 <span><?php echo $isPercent ? __('%') : $this->getBaseCurrency()->getSymbol() ?></span>
                                                             </button>
-                                                            <ul class="dropdown-menu" data-role="dropdown-menu" data-mage-init="{menu:{}}">
+                                                            <ul class="dropdown-menu" data-role="dropdown-menu" data-mage-init='{"menu":{}}'>
                                                                 <li data-value="0"><a class="item"><?php echo $this->getBaseCurrency()->getSymbol() ?></a></li>
                                                                 <li data-value="1"><a class="item"><?php echo __('%')?></a></li>
                                                             </ul>
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/generator.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/generator.phtml
index 712f9d64682c5ea9bfe09565009b83b502af0972..cf1a127a40562d7ee9df18e7ba12ee387b4ed852 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/generator.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/generator.phtml
@@ -25,7 +25,7 @@
 ?>
 <div data-role="product-variations-generator">
     <!-- Configurable Attributes list -->
-    <div id="configurable-attributes-container" data-mage-init="{variationsAttributes:{}}">
+    <div id="configurable-attributes-container" data-mage-init='{"variationsAttributes":{}}'>
         <?php echo $this->getChildHtml('template'); ?>
         <?php
         foreach ($this->getAttributes() as $attribute) {
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/matrix.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/matrix.phtml
index a04df895435df2d4a57a212fbc80378653153663..af9b502207533ecd1295d1ea67d99371f69542dd 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/matrix.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/edit/super/matrix.phtml
@@ -179,7 +179,7 @@ $productByUsedAttributes = $this->getAssociatedProducts();
                                        name="variations-matrix[<?php echo $key?>][image]"
                                        type="hidden" <?php echo $disabled;?>/>
                             </div>
-                            <button type="button" class="action-toggle no-display" data-toggle="dropdown" data-mage-init="{dropdown:{}}">
+                            <button type="button" class="action-toggle no-display" data-toggle="dropdown" data-mage-init='{"dropdown":{}}'>
                                 <span><?php echo __('Select'); ?></span>
                             </button>
                             <ul class="dropdown-menu">
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/helper/gallery.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/helper/gallery.phtml
index 0d2a2adfd99432b48e72b589e5c24ccd2a5871ea..efbe373aacd9eada55b17129bf354de1e716b4d3 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/helper/gallery.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/helper/gallery.phtml
@@ -28,7 +28,7 @@ $elementName = $this->getElement()->getName() . '[images]';
 ?>
 <div id="<?php echo $this->getHtmlId() ?>"
      class='gallery'
-     data-mage-init="{'productGallery':{template:'#<?php echo $this->getHtmlId() ?>-template'}}"
+     data-mage-init='{"productGallery":{"template":"#<?php echo $this->getHtmlId() ?>-template"}}'
      data-images="<?php echo $this->escapeHtml($this->getImagesJson()) ?>"
      data-types="<?php echo $this->escapeHtml(
          $this->helper('Magento\Core\Helper\Data')->jsonEncode($this->getImageTypes())
diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/js.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/js.phtml
index f50f05c19a46c2a6f4efe48f54c95862c03c15db..fbd8570aad9cac374edcad030fea36bfce7103f3 100644
--- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/js.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/js.phtml
@@ -29,13 +29,12 @@
 Event.observe(window, 'load', recalculateTax);
 Event.observe(window, 'load', registerTaxRecalcs);
 
-function registerTaxRecalcs()
-{
+function registerTaxRecalcs() {
     if (typeof dynamicTaxes == 'undefined') {
         return;
     }
 
-    for (var i=0; i<dynamicTaxes.length; i++) {
+    for (var i = 0; i < dynamicTaxes.length; i++) {
         Event.observe($(dynamicTaxes[i]), 'change', recalculateTax);
     }
     Event.observe($('tax_class_id'), 'change', recalculateTax);
@@ -44,13 +43,12 @@ function registerTaxRecalcs()
 var priceFormat = <?php echo $this->helper('Magento\Tax\Helper\Data')->getPriceFormat($this->getStore()); ?>;
 var taxRates = <?php echo $this->helper('Magento\Tax\Helper\Data')->getAllRatesByProductClass($this->getStore()); ?>;
 
-function recalculateTax()
-{
+function recalculateTax() {
     if (typeof dynamicTaxes == 'undefined') {
         return;
     }
 
-    for (var i=0; i<dynamicTaxes.length; i++) {
+    for (var i = 0; i < dynamicTaxes.length; i++) {
         var code = dynamicTaxes[i];
         var span = $('dynamic-tax-' + code);
         var input = $(code);
@@ -60,9 +58,9 @@ function recalculateTax()
             continue;
         }
 
-        var rate = 0;
-        var taxClass = $('tax_class_id').options[$('tax_class_id').selectedIndex].value;
-        eval('var value = taxRates.value_' + taxClass);
+        var rate = 0,
+            taxClass = $('tax_class_id').options[$('tax_class_id').selectedIndex].value,
+            value = taxRates['value_' + taxClass];
 
         if (value != undefined) {
             rate = value;
@@ -70,7 +68,7 @@ function recalculateTax()
 
         var spanValue = '';
         if (rate != 0) {
-            spanValue = ' ' + formatCurrency(input.value/(100+rate)*rate, priceFormat);
+            spanValue = ' ' + formatCurrency(input.value / (100 + rate) * rate, priceFormat);
         }
         span.innerHTML = spanValue;
     }
@@ -80,7 +78,7 @@ function recalculateTax()
 function bindActiveProductTab(event, ui) {
     var anchor = jQuery(ui.newTab).find('a');
     if (anchor && anchor.name && $('store_switcher')) {
-        $('store_switcher').switchParams = 'active_tab/'+anchor.name+'/';
+        $('store_switcher').switchParams = 'active_tab/' + anchor.name + '/';
     }
 }
 //varienGlobalEvents.attachEventHandler('showTab', bindActiveProductTab);
@@ -88,7 +86,7 @@ jQuery(document).on('tabsactivate', bindActiveProductTab);
 
 // bind active tab
 <?php if($tabsBlock = $this->getLayout()->getBlock('product_tabs')): ?>
-jQuery(document).ready(function(){
+jQuery(document).ready(function () {
     if (jQuery('#<?php echo $tabsBlock->getId() ?>').length && jQuery('#<?php echo $tabsBlock->getId() ?>').is(':mage-tabs')) {
         var activeAnchor = jQuery('#<?php echo $tabsBlock->getId() ?>').tabs('activeAnchor');
         if (activeAnchor && $('store_switcher')) {
diff --git a/app/code/Magento/Catalog/view/adminhtml/product/edit/attribute/search.phtml b/app/code/Magento/Catalog/view/adminhtml/product/edit/attribute/search.phtml
index 4841b30aa4a2f65084ecbba015d3304c41873e58..1d139fc69bff6d5413cb7f39863923d2ac090fae 100644
--- a/app/code/Magento/Catalog/view/adminhtml/product/edit/attribute/search.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/product/edit/attribute/search.phtml
@@ -40,7 +40,7 @@
     </div>
 
 <script data-template-for="product-attribute-search" type="text/x-jquery-tmpl">
-    <ul data-mage-init="{menu:[]}">
+    <ul data-mage-init='{"menu":[]}'>
         {{if items.length}}
         {{each items}}
         <li {{html optionData($value)}}><a href="#">${$value.label}</a></li>
diff --git a/app/code/Magento/Catalog/view/adminhtml/product/edit/tabs.phtml b/app/code/Magento/Catalog/view/adminhtml/product/edit/tabs.phtml
index 0325d914ce7133f6d18e30e5e2fdaf897f421ef2..012fb48cc1047213d30a1497815fd0fb62cd9a10 100644
--- a/app/code/Magento/Catalog/view/adminhtml/product/edit/tabs.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/product/edit/tabs.phtml
@@ -32,20 +32,20 @@
     \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::ADVANCED_TAB_GROUP_CODE
 );?>
 <div id="<?php echo $this->getId() ?>"
-    data-mage-init="{tabs:{
-        active: '<?php echo $this->getActiveTabId() ?>',
-        destination: '#<?php echo $this->getDestElementId() ?>',
-        shadowTabs: <?php echo $this->getAllShadowTabs()?>,
-        tabsBlockPrefix: '<?php echo $this->getId() ?>_',
-        tabIdArgument: 'active_tab',
-        groups: 'ul.tabs'
-    }}">
+    data-mage-init='{"tabs":{
+        "active": "<?php echo $this->getActiveTabId() ?>",
+        "destination": "#<?php echo $this->getDestElementId() ?>",
+        "shadowTabs": "<?php echo $this->getAllShadowTabs()?>",
+        "tabsBlockPrefix": "<?php echo $this->getId() ?>_",
+        "tabIdArgument": "active_tab",
+        "groups": "ul.tabs"
+    }}'>
     <?php foreach ($tabGroups as $tabGroupCode): ?>
     <?php $tabGroupId = $this->getId() . '-' . $tabGroupCode; ?>
     <?php $isBasic = $tabGroupCode == \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs::BASIC_TAB_GROUP_CODE; ?>
     <div id="<?php echo $tabGroupId ?>"
         <?php if (!$isBasic): ?>
-        data-mage-init="{accordion: {active: <?php echo $this->isAdvancedTabGroupActive() ? '0' : 'false' ?>, collapsible: true}}"
+        data-mage-init='{"accordion":{"active":<?php echo $this->isAdvancedTabGroupActive() ? '0' : 'false' ?>, "collapsible": true}}'
         <?php endif;?>>
         <h3 <?php echo $this->getUiId('title') ?>>
             <?php echo $isBasic ? __('Basic Settings')
diff --git a/app/code/Magento/Catalog/view/frontend/js/msrp.js b/app/code/Magento/Catalog/view/frontend/js/msrp.js
index a7d80e15530aa2097506b550858a287ca73f6a5b..89b02aac43e99c5cff0e75b6ea664517b60e21d4 100644
--- a/app/code/Magento/Catalog/view/frontend/js/msrp.js
+++ b/app/code/Magento/Catalog/view/frontend/js/msrp.js
@@ -23,7 +23,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 
-/*jshint evil:true browser:true jquery:true*/
+/*jshint browser:true jquery:true*/
 (function($) {
     $.widget('mage.addToCart', {
         options: {
diff --git a/app/code/Magento/Catalog/view/frontend/js/price-option.js b/app/code/Magento/Catalog/view/frontend/js/price-option.js
index c5c2eadca6548313bc87a52875cac0d506df60c7..3e133df658e7303f81a612e2c818e709b5b6aecd 100644
--- a/app/code/Magento/Catalog/view/frontend/js/price-option.js
+++ b/app/code/Magento/Catalog/view/frontend/js/price-option.js
@@ -22,7 +22,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
-/*jshint evil:true browser:true jquery:true*/
+/*jshint browser:true jquery:true*/
 
 (function($, undefined) {
     "use strict";
@@ -218,4 +218,4 @@
             }
         }
     });
-})(jQuery);
\ No newline at end of file
+})(jQuery);
diff --git a/app/code/Magento/Catalog/view/frontend/js/tier-price.js b/app/code/Magento/Catalog/view/frontend/js/tier-price.js
index a9f6a7e7d5c4e9dd61a519edc945e2af4b0bc266..ddfc4602b53c4227b1341dc540036ebf3a23aa90 100644
--- a/app/code/Magento/Catalog/view/frontend/js/tier-price.js
+++ b/app/code/Magento/Catalog/view/frontend/js/tier-price.js
@@ -23,7 +23,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 
-/*jshint evil:true browser:true jquery:true*/
+/*jshint browser:true jquery:true*/
 (function($) {
     $.widget('mage.tierPrice', {
         options: {
@@ -49,18 +49,18 @@
          * @return {Boolean}
          */
         _showTierPrice: function(e) {
-            var json = eval('(' + $(e.target).data('tier-price') + ')');
+            var data = $(e.target).data('tier-price');
             $(this.options.popupCartButtonId).off('click');
             $(this.options.popupCartButtonId).on('click', $.proxy(function() {
-                this.element.find(this.options.inputQty).val(json.qty);
+                this.element.find(this.options.inputQty).val(data.qty);
                 this.element.submit();
             }, this));
-            $(this.options.popupHeading).text(json.name);
-            $(this.options.popupPrice).html($(json.price)).find('[id^="product-price-"]').attr('id', function() {
+            $(this.options.popupHeading).text(data.name);
+            $(this.options.popupPrice).html($(data.price)).find('[id^="product-price-"]').attr('id', function() {
                 // change price element id, so price option won't update the tier price
                 return 'tier' + $(this).attr('id');
             });
-            $(this.options.popupMsrp).html(json.msrp);
+            $(this.options.popupMsrp).html(data.msrp);
             var width = $(this.options.popup).width();
             var offsetX = e.pageX - (width / 2) + "px";
             $(this.options.popup).css({left: offsetX, top: e.pageY}).show();
diff --git a/app/code/Magento/Catalog/view/frontend/js/zoom.js b/app/code/Magento/Catalog/view/frontend/js/zoom.js
index c9b7b507b86938c3080e19703009ec2264918e19..f8f0e6560d0128b94a57b984b805d0d96fff22f3 100644
--- a/app/code/Magento/Catalog/view/frontend/js/zoom.js
+++ b/app/code/Magento/Catalog/view/frontend/js/zoom.js
@@ -22,7 +22,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
-/*jshint evil:true browser:true jquery:true expr:true*/
+/*jshint browser:true jquery:true expr:true*/
 (function($) {
     $.widget('mage.zoom', {
         options: {
@@ -208,4 +208,4 @@
             this._draggableImage();
         }
     });
-}(jQuery));
\ No newline at end of file
+}(jQuery));
diff --git a/app/code/Magento/Catalog/view/frontend/layout/MAP_popup.xml b/app/code/Magento/Catalog/view/frontend/layout/MAP_popup.xml
index ebb1630ffdfbca099ac1e5ce0b7ca8e13eb65913..fdb23d5ef7000c18b4df8cf8cfd822060e8d30c2 100644
--- a/app/code/Magento/Catalog/view/frontend/layout/MAP_popup.xml
+++ b/app/code/Magento/Catalog/view/frontend/layout/MAP_popup.xml
@@ -25,6 +25,8 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceContainer name="content">
-        <block class="Magento\View\Element\Template" template="Magento_Catalog::msrp/popup.phtml" name="product.tooltip"/>
+        <block class="Magento\View\Element\Template" template="Magento_Catalog::msrp/popup.phtml" name="product.tooltip">
+            <block class="Magento\Catalog\Block\ShortcutButtons\InCatalog\PositionAfter" name="map.shortcut.buttons"/>
+        </block>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
index 7b8eba2f9c14c31db88461e4ad4d909af26f3a10..3db5375d3d64253c62de394b7178e3427bd3ac2a 100644
--- a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
+++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
@@ -138,6 +138,9 @@
         </block>
         <block class="Magento\Catalog\Block\Product\View\Additional" name="product.info.additional" as="product_additional_data"/>
     </referenceContainer>
+    <referenceBlock name="product.info.addtocart">
+        <block class="Magento\Catalog\Block\ShortcutButtons\InCatalog" name="addtocart.shortcut.buttons"/>
+    </referenceBlock>
     <update handle="MAP_popup"/>
     <update handle="MAP_price_msrp_item"/>
 </layout>
diff --git a/app/code/Magento/Catalog/view/frontend/product/list.phtml b/app/code/Magento/Catalog/view/frontend/product/list.phtml
index bc368edf893b7b4c9d79fedc5d60333fc0797cbc..b9190580774084669caf3a02b367b90a35608b17 100644
--- a/app/code/Magento/Catalog/view/frontend/product/list.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/list.phtml
@@ -93,7 +93,7 @@ $imageBlock =  $this->getLayout()->createBlock('Magento\Catalog\Block\Product\Im
                                 <?php if ($_product->isSaleable()): ?>
                                     <?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?>
                                         <button type="button" title="<?php echo __('Add to Cart') ?>" class="action tocart"
-                                                data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_product) ?>'}}">
+                                                data-mage-init='{"redirectUrl":{"url":"<?php echo $this->getAddToCartUrl($_product) ?>"}}'>
                                             <span><?php echo __('Add to Cart') ?></span>
                                         </button>
                                     <?php else: ?>
diff --git a/app/code/Magento/Catalog/view/frontend/product/list/items.phtml b/app/code/Magento/Catalog/view/frontend/product/list/items.phtml
index 18d94f90ecdfa90c1aaeed40232c505cc561f006..9433a4e2bd15b12fc5107af825d543d29647a6a0 100644
--- a/app/code/Magento/Catalog/view/frontend/product/list/items.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/list/items.phtml
@@ -231,7 +231,7 @@ switch($type=$this->getType()) {
                             <div class="primary">
                                 <?php if($_item->isSaleable()): ?>
                                     <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
-                                        <button class="action tocart" data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>'}}" type="button" title="<?php echo __('Add to Cart') ?>">
+                                        <button class="action tocart" data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}' type="button" title="<?php echo __('Add to Cart') ?>">
                                             <span><?php echo __('Add to Cart') ?></span>
                                         </button>
                                     <?php else: ?>
diff --git a/app/code/Magento/Catalog/view/frontend/product/list/toolbar.phtml b/app/code/Magento/Catalog/view/frontend/product/list/toolbar.phtml
index a4aaa848dd6fd9938477936e3476540c19b6b4a9..8d9f3d698c6e9b09a0d197fe66a295a816c331aa 100644
--- a/app/code/Magento/Catalog/view/frontend/product/list/toolbar.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/list/toolbar.phtml
@@ -54,7 +54,7 @@
         <?php endif; ?>
         <div class="sorter">
             <label class="label" for="sorter"><?php echo __('Sort By') ?></label>
-            <select id="sorter" data-mage-init="{redirectUrl: {event:'change'}}">
+            <select id="sorter" data-mage-init='{"redirectUrl":{"event":"change"}}'>
                 <?php foreach ($this->getAvailableOrders() as $_key => $_order): ?>
                     <option
                         value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if ($this->isOrderCurrent($_key)): ?>
@@ -88,7 +88,7 @@
         </p>
         <div class="limiter">
             <strong class="label"><?php echo __('Show') ?></strong>
-            <select id="limiter" data-mage-init="{redirectUrl: {event:'change'}}">
+            <select id="limiter" data-mage-init='{"redirectUrl":{"event":"change"}}'>
                 <?php foreach ($this->getAvailableLimit() as $_key => $_limit): ?>
                     <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if ($this->isLimitCurrent($_key)): ?>
                         selected="selected"<?php endif ?>>
diff --git a/app/code/Magento/Catalog/view/frontend/product/price_msrp_noform.phtml b/app/code/Magento/Catalog/view/frontend/product/price_msrp_noform.phtml
index 680df763ad54f2e7e2acc682a93254dea4c2a870..634d3e2b1191da8842bb84cfd48b22e95c3aa0eb 100644
--- a/app/code/Magento/Catalog/view/frontend/product/price_msrp_noform.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/price_msrp_noform.phtml
@@ -36,6 +36,7 @@
     /** @var $_product \Magento\Catalog\Model\Product */
     $_product = $this->getProduct();
     $_msrpPrice = "";
+    $priceElementId = 'product-price-' . $_product->getId() . $this->getIdSuffix();
 ?>
     <div class="price-box map-info">
     <?php $_price = $this->helper('Magento\Tax\Helper\Data')->getPrice($_product, $_product->getMsrp()) ?>
diff --git a/app/code/Magento/Catalog/view/frontend/product/view/addto.phtml b/app/code/Magento/Catalog/view/frontend/product/view/addto.phtml
index 1af64b1c8b79822130d84bca40119320f3f08249..0f081898022b6a35a6ea62cc26c2a5bb6a60e04a 100644
--- a/app/code/Magento/Catalog/view/frontend/product/view/addto.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/view/addto.phtml
@@ -42,7 +42,7 @@ $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');
 </div>
 <script type="text/javascript">
     head.js("<?php echo $this->getViewFileUrl('Magento_Wishlist::js/add-to-wishlist.js') ?>", function () {
-        jQuery('.product.info.main').addToWishlist(
+        jQuery('body').addToWishlist(
             <?php echo $this->helper('Magento\Core\Helper\Data')->jsonEncode(array('productType' => $_product->getTypeId()))?>
         );
     });
diff --git a/app/code/Magento/Catalog/view/frontend/product/view/tierprices.phtml b/app/code/Magento/Catalog/view/frontend/product/view/tierprices.phtml
index f87467367367f0a50609f9cc009c57e2efdad953..d6bd53c9d3bdfc6c2ec396a11649f751baa950de 100644
--- a/app/code/Magento/Catalog/view/frontend/product/view/tierprices.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/view/tierprices.phtml
@@ -188,11 +188,24 @@ if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_product, array(1,
         <?php if ($_catalogHelper->isShowPriceOnGesture($_product)):?>
             <?php $popupId = 'msrp-popup-' . $_product->getId() . $this->getRandomString(20); ?>
             <?php
-            $addToCartUrl = $this->getProduct()->isSalable()
-                ? $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty']))
-                : '';
+            $tierPriceData = [
+                'addToCartUrl' => $this->getProduct()->isSalable()
+                        ? $this->getAddToCartUrl($_product, array('qty' => $_price['price_qty']))
+                        : '',
+                'name' => $_product->getName(),
+                'price' => $_price['real_price_html'],
+                'msrp' => $this->helper('Magento\Core\Helper\Data')->currency($_product->getMsrp(), true, false),
+            ];
+            if ($this->getCanDisplayQty() !== false) {
+                $tierPriceData['qty'] = $_price['price_qty'];
+            }
             ?>
-            <a href="#" id="<?php echo($popupId);?>" data-tier-price='{addToCartUrl:"<?php echo $addToCartUrl; ?>", name:"<?php echo $_product->getName() ?>", price:<?php echo json_encode($_price['real_price_html']) ?>, msrp:"<?php echo $this->helper('Magento\Core\Helper\Data')->currency($_product->getMsrp(),true,false) ?>"<?php if ($this->getCanDisplayQty() !== false): ?>, qty:"<?php echo $_price['price_qty']?>"<?php endif ?>}'><?php echo __('Click for price'); ?></a>
+            <a href="#"
+               id="<?php echo($popupId);?>"
+               data-tier-price="<?php $this->escapeHtml(
+                   $this->helper('Magento\Core\Helper\Data')->jsonEncode($tierPriceData)
+               )?>"
+            ><?php echo __('Click for price'); ?></a>
         <?php else: ?>
             <span class="msrp-price-hide-message">
                 <?php echo $_catalogHelper->getMsrpPriceMessage($_product) ?>
diff --git a/app/code/Magento/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml b/app/code/Magento/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml
index 9f30e0fcf7f3e8e5beaa7a195e2f0a921f8f0887..8212610e26a51ea8faeac98ee3dc4884d2469cce 100644
--- a/app/code/Magento/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/widget/new/column/new_default_list.phtml
@@ -53,7 +53,7 @@
                                     <?php if($_product->isSaleable()): ?>
                                         <?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?>
                                             <button type="button" title="<?php echo __('Add to Cart') ?>" class="action tocart"
-                                                    data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_product) ?>'}}">
+                                                    data-mage-init='{"redirectUrl":{"url":"<?php echo $this->getAddToCartUrl($_product) ?>"}}'>
                                                 <span><?php echo __('Add to Cart') ?></span>
                                             </button>
                                         <?php else: ?>
diff --git a/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_grid.phtml b/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_grid.phtml
index e5db932f33826cfffbe2d43018ca11a36bdef82f..0c6673ddcced6c4a2b85fe10fe4fc314b8a46823 100644
--- a/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_grid.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_grid.phtml
@@ -77,7 +77,7 @@ if ($exist = ($this->getProductCollection() && $this->getProductCollection()->ge
                                             <?php if($_item->isSaleable()): ?>
                                                 <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
                                                     <button class="action tocart"
-                                                            data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>'}}"
+                                                            data-mage-init='{"redirectUrl":{"url":"<?php echo $this->getAddToCartUrl($_item) ?>"}}'
                                                             type="button" title="<?php echo __('Add to Cart') ?>">
                                                         <span><?php echo __('Add to Cart') ?></span>
                                                     </button>
@@ -130,4 +130,4 @@ if ($exist = ($this->getProductCollection() && $this->getProductCollection()->ge
             </ol>
         </div>
     </div>
-<?php endif;?>
\ No newline at end of file
+<?php endif;?>
diff --git a/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_list.phtml b/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_list.phtml
index b54adc15891d8117e6d260510ea555c032b5aeb2..18e9f23d067d45035a190e0772d94fe85890d9b4 100644
--- a/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_list.phtml
+++ b/app/code/Magento/Catalog/view/frontend/product/widget/new/content/new_list.phtml
@@ -77,7 +77,7 @@ if ($exist = ($this->getProductCollection() && $this->getProductCollection()->ge
                                             <?php if($_item->isSaleable()): ?>
                                                 <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
                                                     <button class="action tocart"
-                                                            data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>'}}"
+                                                            data-mage-init='{"redirectUrl":{"url":"<?php echo $this->getAddToCartUrl($_item) ?>"}}'
                                                             type="button" title="<?php echo __('Add to Cart') ?>">
                                                         <span><?php echo __('Add to Cart') ?></span>
                                                     </button>
diff --git a/app/code/Magento/CatalogInventory/view/frontend/stockqty/composite.phtml b/app/code/Magento/CatalogInventory/view/frontend/stockqty/composite.phtml
index e4996917e17d36fc1f531c54a703f39ebf0f70ad..c2c6d3c871a98a7d4a3bb8d8727ca33250a1b3ec 100644
--- a/app/code/Magento/CatalogInventory/view/frontend/stockqty/composite.phtml
+++ b/app/code/Magento/CatalogInventory/view/frontend/stockqty/composite.phtml
@@ -30,7 +30,7 @@
 <?php if($this->isMsgVisible()): ?>
     <div class="availability only">
         <a href="#"
-           data-mage-init='{toggleAdvanced: {selectorsToggleClass: "active", baseToggleClass: "expanded", toggleContainers: "#<?php echo $this->getDetailsPlaceholderId() ?>"}}'
+           data-mage-init='{"toggleAdvanced": {"selectorsToggleClass": "active", "baseToggleClass": "expanded", "toggleContainers": "#<?php echo $this->getDetailsPlaceholderId() ?>"}}'
            id="<?php echo $this->getPlaceholderId() ?>"
            title="<?php echo __('Only %1 left', ($this->getStockQty())) ?>"
            class="action show">
diff --git a/app/code/Magento/CatalogRule/etc/crontab.xml b/app/code/Magento/CatalogRule/etc/crontab.xml
index ea303281c959bd6cf51f810fd3208d56def20064..b667c9627203c08270bc13f17ea9a601ab17a02a 100644
--- a/app/code/Magento/CatalogRule/etc/crontab.xml
+++ b/app/code/Magento/CatalogRule/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="catalogrule_apply_all" instance="Magento\CatalogRule\Model\Observer" method="dailyCatalogUpdate">
-        <schedule>0 1 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="catalogrule_apply_all" instance="Magento\CatalogRule\Model\Observer" method="dailyCatalogUpdate">
+            <schedule>0 1 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced.php b/app/code/Magento/CatalogSearch/Controller/Advanced.php
index e42dacbabc99bfd8aef4bf4e7b5333fa12cc385b..bd7e5e2fc01ba62a35af51779b7821e6c0e45b9c 100644
--- a/app/code/Magento/CatalogSearch/Controller/Advanced.php
+++ b/app/code/Magento/CatalogSearch/Controller/Advanced.php
@@ -107,7 +107,6 @@ class Advanced extends \Magento\App\Action\Action
                 ->getUrl('*/*/');
             $this->getResponse()->setRedirect($this->_redirect->error($defaultUrl));
         }
-        $this->_view->getLayout()->initMessages();
         $this->_view->renderLayout();
     }
 }
diff --git a/app/code/Magento/CatalogSearch/view/frontend/layout/default.xml b/app/code/Magento/CatalogSearch/view/frontend/layout/default.xml
index 0e90294f6c50591956a687405d97328e38f0dda1..51688f0d84a434bf403697a45f9d929ea2ddabd3 100644
--- a/app/code/Magento/CatalogSearch/view/frontend/layout/default.xml
+++ b/app/code/Magento/CatalogSearch/view/frontend/layout/default.xml
@@ -24,9 +24,9 @@
  */
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <referenceBlock name="header-wrapper">
+    <referenceContainer name="header-wrapper">
         <block class="Magento\View\Element\Template" name="top.search" as="topSearch" template="Magento_CatalogSearch::form.mini.phtml"/>
-    </referenceBlock>
+    </referenceContainer>
     <referenceBlock name="footer_links">
         <block class="Magento\View\Element\Html\Link\Current" ifconfig="catalog/seo/search_terms" name="catalog-search-term-popular-link">
             <arguments>
diff --git a/app/code/Magento/Centinel/Block/Adminhtml/Validation.php b/app/code/Magento/Centinel/Block/Adminhtml/Validation.php
index 778959a3b1c9cab0ddb47fc24439eee59ad30eac..4d49901d656bd666fbdeaeb28b1a9ff414438760 100644
--- a/app/code/Magento/Centinel/Block/Adminhtml/Validation.php
+++ b/app/code/Magento/Centinel/Block/Adminhtml/Validation.php
@@ -32,7 +32,9 @@ namespace Magento\Centinel\Block\Adminhtml;
 class Validation extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate
 {
     /**
-     * construct
+     * Construct
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Centinel/Block/Authentication.php b/app/code/Magento/Centinel/Block/Authentication.php
index 4ca57bc93be5a59ebbaf21520d8d6108038b7acd..1f0c53efdb2a613c7ae7843a59a761bf9c9e80f0 100644
--- a/app/code/Magento/Centinel/Block/Authentication.php
+++ b/app/code/Magento/Centinel/Block/Authentication.php
@@ -47,9 +47,9 @@ class Authentication extends \Magento\View\Element\Template
 
     /**
      * Flag - authentication start mode
-     * @see self::setAuthenticationStartMode
      *
      * @var bool
+     * @see self::setAuthenticationStartMode
      */
     protected $_authenticationStartMode = false;
 
@@ -72,7 +72,7 @@ class Authentication extends \Magento\View\Element\Template
      * Add identifier of related block
      *
      * @param string $blockId
-     * @return \Magento\Centinel\Block\Authentication
+     * @return $this
      */
     public function addRelatedBlock($blockId)
     {
diff --git a/app/code/Magento/Centinel/Model/AbstractState.php b/app/code/Magento/Centinel/Model/AbstractState.php
index e6b1a25ba4cfbbb038ff6eeaf61820a21d988f52..837883af7aa2f29c02951251455a0737265aecf8 100644
--- a/app/code/Magento/Centinel/Model/AbstractState.php
+++ b/app/code/Magento/Centinel/Model/AbstractState.php
@@ -42,7 +42,7 @@ abstract class AbstractState extends \Magento\Object
      * Setter for storage data model
      *
      * @param \Magento\Object $dataStorageModel
-     * @return \Magento\Centinel\Model\AbstractState
+     * @return $this
      */
     public function setDataStorage($dataStorageModel)
     {
@@ -67,11 +67,11 @@ abstract class AbstractState extends \Magento\Object
      * Otherwise it will return value of the attribute specified by $key
      *
      * $index parameter is ignored
-     * @see \Magento\Session\SessionManager::getData()
      *
      * @param string $key
      * @param string|int $index
      * @return mixed
+     * @see \Magento\Session\SessionManager::getData()
      */
     public function getData($key='', $index=null)
     {
@@ -81,14 +81,14 @@ abstract class AbstractState extends \Magento\Object
     /**
      * Overwrite data in the object.
      *
-     * $key can be string or array.
+     * Parameter $key can be string or array.
      * If $key is string, the attribute value will be overwritten by $value
      *
      * If $key is an array, it will overwrite all the data in the object.
      *
      * @param string|array $key
      * @param mixed $value
-     * @return \Magento\Centinel\Model\AbstractState
+     * @return $this
      */
     public function setData($key, $value=null)
     {
@@ -100,7 +100,7 @@ abstract class AbstractState extends \Magento\Object
      * Save lookup result in state model
      *
      * @param \Magento\Object $result
-     * @return \Magento\Centinel\Model\AbstractState
+     * @return $this
      */
     public function setLookupResult($result)
     {
@@ -114,7 +114,7 @@ abstract class AbstractState extends \Magento\Object
      * Save authenticate result in state model
      *
      * @param \Magento\Object $result
-     * @return \Magento\Centinel\Model\AbstractState
+     * @return $this
      */
     public function setAuthenticateResult($result)
     {
diff --git a/app/code/Magento/Centinel/Model/Api.php b/app/code/Magento/Centinel/Model/Api.php
index 301798e816fb357a42b7006f2b07bea82f1775ab..1f0a535f6883cfac33c8df109c6d5c7dec2af057 100644
--- a/app/code/Magento/Centinel/Model/Api.php
+++ b/app/code/Magento/Centinel/Model/Api.php
@@ -44,6 +44,8 @@ class Api extends \Magento\Object
     protected $_debugReplacePrivateDataKeys = array('TransactionPwd', 'CardNumber', 'CardExpMonth', 'CardExpYear');
 
     /**
+     * Array of ISO 4217 Currency codes and numbers
+     *
      * @var array
      */
     protected static $_iso4217Currencies = array(
@@ -278,6 +280,7 @@ class Api extends \Magento\Object
      * Log debug data to file
      *
      * @param array $debugData
+     * @return void
      */
     protected function _debug($debugData)
     {
diff --git a/app/code/Magento/Centinel/Model/Config.php b/app/code/Magento/Centinel/Model/Config.php
index 7a7b171ac97fe3d99ab4977f0d46463e1427e3a2..8c7da8cc06ff3fd74acf6e8f5e27f5ed85269d46 100644
--- a/app/code/Magento/Centinel/Model/Config.php
+++ b/app/code/Magento/Centinel/Model/Config.php
@@ -53,11 +53,15 @@ class Config
     protected $_coreStoreConfig;
 
     /**
+     * Core config interface
+     *
      * @var \Magento\App\ConfigInterface
      */
     protected $_coreConfig;
 
     /**
+     * Encryptor interface
+     *
      * @var \Magento\Encryption\EncryptorInterface
      */
     protected $_encryptor;
@@ -81,7 +85,7 @@ class Config
      * Set store to congif model
      *
      * @param int|\Magento\Core\Model\Store $store
-     * @return \Magento\Centinel\Model\Config
+     * @return $this
      */
     public function setStore($store)
     {
diff --git a/app/code/Magento/Centinel/Model/Observer.php b/app/code/Magento/Centinel/Model/Observer.php
index 62a97c35a67fd7ea39cffeb9e7d0093ebe85b4e8..48307dfceb4666de179006b9eee034e353ec8e6f 100644
--- a/app/code/Magento/Centinel/Model/Observer.php
+++ b/app/code/Magento/Centinel/Model/Observer.php
@@ -64,7 +64,7 @@ class Observer extends \Magento\Object
      * Set cmpi data to payment
      *
      * @param \Magento\Object $observer
-     * @return \Magento\Centinel\Model\Observer
+     * @return $this
      */
     public function salesEventConvertQuoteToOrder($observer)
     {
@@ -81,7 +81,7 @@ class Observer extends \Magento\Object
      * Add cmpi data to info block
      *
      * @param \Magento\Object $observer
-     * @return \Magento\Centinel\Model\Observer
+     * @return void|$this
      */
     public function paymentInfoBlockPrepareSpecificInformation($observer)
     {
@@ -112,7 +112,7 @@ class Observer extends \Magento\Object
      * Add centinel logo block into payment form
      *
      * @param \Magento\Object $observer
-     * @return \Magento\Centinel\Model\Observer
+     * @return $this
      */
     public function paymentFormBlockToHtmlBefore($observer)
     {
@@ -132,7 +132,7 @@ class Observer extends \Magento\Object
      * Reset validation data
      *
      * @param \Magento\Object $observer
-     * @return \Magento\Centinel\Model\Observer
+     * @return $this
      */
     public function checkoutSubmitAllAfter($observer)
     {
diff --git a/app/code/Magento/Centinel/Model/Service.php b/app/code/Magento/Centinel/Model/Service.php
index 03b3a7def324e3dc36c480b3fde101b5f3d90d24..aa721f74f77bf40815f5d675c16f2cadd992717c 100644
--- a/app/code/Magento/Centinel/Model/Service.php
+++ b/app/code/Magento/Centinel/Model/Service.php
@@ -97,16 +97,24 @@ class Service extends \Magento\Object
     protected $_validationState;
 
     /**
+     * Url prefix
+     *
      * @var string
      */
     protected $_urlPrefix;
 
+    /**
+     * @var \Magento\Data\Form\FormKey
+     */
+    protected $formKey;
+
     /**
      * @param \Magento\Centinel\Model\Config $config
      * @param \Magento\Centinel\Model\ApiFactory $apiFactory
      * @param \Magento\UrlInterface $url
      * @param \Magento\Session\SessionManagerInterface $centinelSession
      * @param \Magento\Centinel\Model\StateFactory $stateFactory
+     * @param \Magento\Data\Form\FormKey $formKey
      * @param string $urlPrefix
      * @param array $data
      */
@@ -116,6 +124,7 @@ class Service extends \Magento\Object
         \Magento\UrlInterface $url,
         \Magento\Session\SessionManagerInterface $centinelSession,
         \Magento\Centinel\Model\StateFactory $stateFactory,
+        \Magento\Data\Form\FormKey $formKey,
         $urlPrefix = 'centinel/index/',
         array $data = array()
     ) {
@@ -124,6 +133,7 @@ class Service extends \Magento\Object
         $this->_url = $url;
         $this->_centinelSession = $centinelSession;
         $this->_stateFactory = $stateFactory;
+        $this->formKey = $formKey;
         $this->_urlPrefix = $urlPrefix;
         parent::__construct($data);
     }
@@ -167,6 +177,7 @@ class Service extends \Magento\Object
         $params = array(
             '_secure'  => true,
             '_current' => $current,
+            'form_key' => $this->formKey->getFormKey(),
             'isIframe' => true
         );
         return $this->_url->getUrl($this->_urlPrefix . $suffix, $params);
@@ -341,7 +352,7 @@ class Service extends \Magento\Object
     /**
      * Reset validation state and drop api object
      *
-     * @return \Magento\Centinel\Model\Service
+     * @return $this
      */
     public function reset()
     {
diff --git a/app/code/Magento/Centinel/view/adminhtml/validation/form.phtml b/app/code/Magento/Centinel/view/adminhtml/validation/form.phtml
index b692872d60bf44e14324bef354a9b82c6d2b528f..a4459948b07eaf75667a31f6cc4e9707d9fe4173 100644
--- a/app/code/Magento/Centinel/view/adminhtml/validation/form.phtml
+++ b/app/code/Magento/Centinel/view/adminhtml/validation/form.phtml
@@ -26,7 +26,7 @@
 ?>
 <div class="centinel">
     <div class="authentication">
-        <iframe frameborder="0" border="0" id="<?php echo $this->getContainerId() ?>" src="" style="display:none;"></iframe>
+        <iframe frameborder="0" border="0" id="<?php echo $this->getContainerId() ?>" src="" style="display:none;" width="50%" height="350" title="<?php echo __('Card Verification')?>"></iframe>
     </div>
 </div>
 <button onclick="cardValidator.validate()" class="scalable" type="button"><span><span><span><?php echo __('Start/Reset Validation...')?></span></span></span></button>
diff --git a/app/code/Magento/Centinel/view/frontend/authentication.phtml b/app/code/Magento/Centinel/view/frontend/authentication.phtml
index 989cbac1f83a49cd576aba88944dad1a6e01ea62..934aeb6c01cbc3bca732f6eb62a6bc4688137abc 100644
--- a/app/code/Magento/Centinel/view/frontend/authentication.phtml
+++ b/app/code/Magento/Centinel/view/frontend/authentication.phtml
@@ -25,7 +25,7 @@
  */
 ?>
 <?php if ($this->getAuthenticationStart()):?>
-    <div class="centinel" id="centinel-authenticate-block" data-mage-init="{centinelAuthenticate: {frameUrl: '<?php echo $this->getFrameUrl() ?>'}}">
+    <div class="centinel" id="centinel-authenticate-block" data-mage-init='{"centinelAuthenticate": {"frameUrl": "<?php echo $this->getFrameUrl() ?>"}}'>
         <h3><?php echo __('Card Verification')?></h3>
         <p><?php echo __('Please verify the card with the issuer bank:') ?></p>
         <div class="authentication">
diff --git a/app/code/Magento/Centinel/view/frontend/logo.phtml b/app/code/Magento/Centinel/view/frontend/logo.phtml
index 01687b14fda793639638fcb3b0faa0f93fc20685..e5d52503114d592843ab119cddca6738c90bf1d2 100644
--- a/app/code/Magento/Centinel/view/frontend/logo.phtml
+++ b/app/code/Magento/Centinel/view/frontend/logo.phtml
@@ -28,8 +28,8 @@
     <label class="label"><span><?php echo __('To ensure the security of your transactions') ?></span></label>
     <div class="control">
         <div class="nested">
-            <a href="#" title="<?php echo __('Verified by Visa') ?> " data-mage-init="{popupWindow: {windowURL:'<?php echo $this->helper('Magento\Centinel\Helper\Data')->getVisaLearnMorePageUrl()?>',windowName:'verifiedByVisa',width:815,height:600,centerScreen:1,location:0,status:1,scrollbars:1,resizable:1}}"><img src="<?php echo $this->getViewFileUrl('Magento_Centinel::images/vbv_ltbg_71x57.gif'); ?>" alt="<?php echo __('Verified by Visa') ?>" /></a>
-            <a href="#" title="<?php echo __('MasterCard SecureCode'); ?>" data-mage-init="{popupWindow: {windowURL:'<?php echo $this->helper('Magento\Centinel\Helper\Data')->getMastercardLearnMorePageUrl()?>',windowName:'secureCode',width:600,height:403,centerScreen:1,location:0,status:1,scrollbars:1,resizable:1}}"><img src="<?php echo $this->getViewFileUrl('Magento_Centinel::images/sc_learn_62x34.gif'); ?>" alt="<?php echo __('MasterCard SecureCode') ?>" /></a>
+            <a href="#" title="<?php echo __('Verified by Visa') ?> " data-mage-init='{"popupWindow": {"windowURL":"<?php echo $this->helper('Magento\Centinel\Helper\Data')->getVisaLearnMorePageUrl()?>","windowName":"verifiedByVisa","width":815,"height":600,"centerScreen":1,"location":0,"status":1,"scrollbars":1,"resizable":1}}'><img src="<?php echo $this->getViewFileUrl('Magento_Centinel::images/vbv_ltbg_71x57.gif'); ?>" alt="<?php echo __('Verified by Visa') ?>" /></a>
+            <a href="#" title="<?php echo __('MasterCard SecureCode'); ?>" data-mage-init='{"popupWindow": {"windowURL":"<?php echo $this->helper('Magento\Centinel\Helper\Data')->getMastercardLearnMorePageUrl()?>","windowName":"secureCode","width":600,"height":403,"centerScreen":1,"location":0,"status":1,"scrollbars":1,"resizable":1}}'><img src="<?php echo $this->getViewFileUrl('Magento_Centinel::images/sc_learn_62x34.gif'); ?>" alt="<?php echo __('MasterCard SecureCode') ?>" /></a>
         </div>
     </div>
 </div>
diff --git a/app/code/Magento/Checkout/Block/Onepage.php b/app/code/Magento/Checkout/Block/Onepage.php
index cf51932dedc02a6d3a4be6f19255e73821eb98a3..b986495dff1acf87f1977e4a5664742d3f8aba4d 100644
--- a/app/code/Magento/Checkout/Block/Onepage.php
+++ b/app/code/Magento/Checkout/Block/Onepage.php
@@ -56,8 +56,14 @@ class Onepage extends \Magento\Checkout\Block\Onepage\AbstractOnepage
         array $data = array()
     ) {
         parent::__construct(
-            $context, $coreData, $configCacheType, $customerSession, $resourceSession,
-            $countryCollectionFactory, $regionCollectionFactory, $data
+            $context,
+            $coreData,
+            $configCacheType,
+            $customerSession,
+            $resourceSession,
+            $countryCollectionFactory,
+            $regionCollectionFactory,
+            $data
         );
         $this->_isScopePrivate = true;
     }
diff --git a/app/code/Magento/Checkout/Block/Onepage/Success.php b/app/code/Magento/Checkout/Block/Onepage/Success.php
index 5f1d1bd2fde44127fece5d0cd789d68095563db7..1b74a6cc0302e1653ac3c384bf0bb5124dac2dfd 100644
--- a/app/code/Magento/Checkout/Block/Onepage/Success.php
+++ b/app/code/Magento/Checkout/Block/Onepage/Success.php
@@ -51,12 +51,7 @@ class Success extends \Magento\View\Element\Template
     protected $_orderFactory;
 
     /**
-     * @var \Magento\Sales\Model\Billing\AgreementFactory
-     */
-    protected $_agreementFactory;
-
-    /**
-     * @var \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory
+     * @var \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory
      */
     protected $_recurringProfileCollectionFactory;
 
@@ -70,8 +65,7 @@ class Success extends \Magento\View\Element\Template
      * @param \Magento\Checkout\Model\Session $checkoutSession
      * @param \Magento\Customer\Model\Session $customerSession
      * @param \Magento\Sales\Model\OrderFactory $orderFactory
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
-     * @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $recurringProfileCollectionFactory
+     * @param \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory $recurringProfileCollectionFactory
      * @param \Magento\Sales\Model\Order\Config $orderConfig
      * @param array $data
      */
@@ -80,8 +74,7 @@ class Success extends \Magento\View\Element\Template
         \Magento\Checkout\Model\Session $checkoutSession,
         \Magento\Customer\Model\Session $customerSession,
         \Magento\Sales\Model\OrderFactory $orderFactory,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory,
-        \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $recurringProfileCollectionFactory,
+        \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory $recurringProfileCollectionFactory,
         \Magento\Sales\Model\Order\Config $orderConfig,
         array $data = array()
     ) {
@@ -89,7 +82,6 @@ class Success extends \Magento\View\Element\Template
         $this->_checkoutSession = $checkoutSession;
         $this->_customerSession = $customerSession;
         $this->_orderFactory = $orderFactory;
-        $this->_agreementFactory = $agreementFactory;
         $this->_recurringProfileCollectionFactory = $recurringProfileCollectionFactory;
         $this->_orderConfig = $orderConfig;
         $this->_isScopePrivate = true;
@@ -105,6 +97,16 @@ class Success extends \Magento\View\Element\Template
         return (bool)$this->_getData('is_order_visible');
     }
 
+    /**
+     * Render additional order information lines and return result html
+     *
+     * @return string
+     */
+    public function getAdditionalInfoHtml()
+    {
+        return $this->_layout->renderElement('order.success.additional.info');
+    }
+
     /**
      * Getter for recurring profile view page
      *
@@ -113,7 +115,7 @@ class Success extends \Magento\View\Element\Template
      */
     public function getProfileUrl(\Magento\Object $profile)
     {
-        return $this->getUrl('sales/recurring_profile/view', array('profile' => $profile->getId()));
+        return $this->getUrl('sales/recurringProfile/view', array('profile' => $profile->getId()));
     }
 
     /**
@@ -122,7 +124,6 @@ class Success extends \Magento\View\Element\Template
     protected function _beforeToHtml()
     {
         $this->_prepareLastOrder();
-        $this->_prepareLastBillingAgreement();
         $this->_prepareLastRecurringProfiles();
         return parent::_beforeToHtml();
     }
@@ -149,26 +150,6 @@ class Success extends \Magento\View\Element\Template
         }
     }
 
-    /**
-     * Prepare billing agreement data from an identifier in the session
-     */
-    protected function _prepareLastBillingAgreement()
-    {
-        $agreementId = $this->_checkoutSession->getLastBillingAgreementId();
-        $customerId = $this->_customerSession->getCustomerId();
-        if ($agreementId && $customerId) {
-            $agreement = $this->_agreementFactory->create()->load($agreementId);
-            if ($agreement->getId() && $customerId == $agreement->getCustomerId()) {
-                $this->addData(array(
-                    'agreement_ref_id' => $agreement->getReferenceId(),
-                    'agreement_url' => $this->getUrl('sales/billing_agreement/view',
-                        array('agreement' => $agreementId)
-                    ),
-                ));
-            }
-        }
-    }
-
     /**
      * Prepare recurring payment profiles from the session
      */
diff --git a/app/code/Magento/Checkout/Block/QuoteShortcutButtons.php b/app/code/Magento/Checkout/Block/QuoteShortcutButtons.php
new file mode 100644
index 0000000000000000000000000000000000000000..44757f0a754ea5f2cd44c1952c44cebcd55c3433
--- /dev/null
+++ b/app/code/Magento/Checkout/Block/QuoteShortcutButtons.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Checkout\Block;
+
+use Magento\View\Element\Template;
+
+class QuoteShortcutButtons extends \Magento\Catalog\Block\ShortcutButtons
+{
+    /**
+     * @var \Magento\Checkout\Model\Session
+     */
+    protected $_checkoutSession;
+
+    /**
+     * @param Template\Context $context
+     * @param \Magento\Checkout\Model\Session $checkoutSession
+     * @param array $data
+     */
+    public function __construct(
+        Template\Context $context,
+        \Magento\Checkout\Model\Session $checkoutSession,
+        array $data = array()
+    ) {
+        parent::__construct($context, false, null, $data);
+        $this->_checkoutSession = $checkoutSession;
+    }
+
+
+    /**
+     * Dispatch shortcuts container event
+     *
+     * @return $this
+     */
+    protected function _beforeToHtml()
+    {
+        $this->_eventManager->dispatch(
+            'shortcut_buttons_container',
+            array(
+                'container' => $this,
+                'is_catalog_product' => $this->_isCatalogProduct,
+                'or_position' => $this->_orPosition,
+                'checkout_session' => $this->_checkoutSession
+            )
+        );
+        return $this;
+    }
+}
diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php
index 8d5baa67013d1b67bef92d6198d70a9d970b95fd..49a15cc19da1e93ac0aaeec79d7389e0fae7b37f 100644
--- a/app/code/Magento/Checkout/Model/Session.php
+++ b/app/code/Magento/Checkout/Model/Session.php
@@ -360,8 +360,7 @@ class Session extends \Magento\Session\SessionManager
      */
     public function clearHelperData()
     {
-        $this->setLastBillingAgreementId(null)
-            ->setRedirectUrl(null)
+        $this->setRedirectUrl(null)
             ->setLastOrderId(null)
             ->setLastRealOrderId(null)
             ->setLastRecurringProfileIds(null)
diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php
index 84d88f364eba3808d7c63b590506078e79ea2ef0..492ba824d31e30b0833dbf7938aeeae75528fd65 100644
--- a/app/code/Magento/Checkout/Model/Type/Onepage.php
+++ b/app/code/Magento/Checkout/Model/Type/Onepage.php
@@ -703,6 +703,8 @@ class Onepage
 
         /** @var $customer \Magento\Customer\Model\Customer */
         $customer = $quote->getCustomer();
+        // Need to set proper attribute id or future updates will cause data loss.
+        $customer->setData('attribute_set_id', 1);
         /** @var $customerBilling \Magento\Customer\Model\Address */
         $customerBilling = $billing->exportCustomerAddress();
         $customer->addAddress($customerBilling);
@@ -845,12 +847,6 @@ class Onepage
             $this->_checkoutSession->setLastOrderId($order->getId())
                 ->setRedirectUrl($redirectUrl)
                 ->setLastRealOrderId($order->getIncrementId());
-
-            // as well a billing agreement can be created
-            $agreement = $order->getPayment()->getBillingAgreement();
-            if ($agreement) {
-                $this->_checkoutSession->setLastBillingAgreementId($agreement->getId());
-            }
         }
 
         // add recurring profiles information to the session
diff --git a/app/code/Magento/Checkout/etc/module.xml b/app/code/Magento/Checkout/etc/module.xml
index 9a0762091281d706eec1e6440d4126137cb9b4e1..939013e0dff469854e4146b6fead848a6930e73a 100755
--- a/app/code/Magento/Checkout/etc/module.xml
+++ b/app/code/Magento/Checkout/etc/module.xml
@@ -35,6 +35,7 @@
             <module name="Magento_Core"/>
             <module name="Magento_Customer"/>
             <module name="Magento_Catalog"/>
+            <module name="Magento_RecurringProfile"/>
             <module name="Magento_Payment"/>
             <module name="Magento_Tax"/>
             <module name="Magento_Directory"/>
diff --git a/app/code/Magento/Checkout/i18n/de_DE.csv b/app/code/Magento/Checkout/i18n/de_DE.csv
index 5d44b24a716ee649663a7fcf1bad77f642f37108..e1c9c4fba629a9fe5413397546d3ecbf8fdaaa06 100644
--- a/app/code/Magento/Checkout/i18n/de_DE.csv
+++ b/app/code/Magento/Checkout/i18n/de_DE.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","Sie haben keine Artikel in Ihrem Einkaufswagen."
 "You will receive an order confirmation email with details of your order and a link to track its progress.","Sie erhalten eine eMail mit der Bestätigung Ihrer Bestellung und einem Link, um deren Verlauf verfolgen zu können."
 "Your Checkout Progress","Ihr Abmeldeverlauf"
-"Your billing agreement # is: %s.","Die Nummer Ihrer Zustimmung zur Abrechnung lautet: %s."
 "Your order # is: %s.","Die Nummer Ihrer Bestellung lautet: %s."
 "Your order cannot be completed at this time as there is no payment methods available for it.","Ihre Bestellung kann momentan nicht abgeschlossen werden, da keine Zahlungsmethode zur Verfügung steht."
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Ihre Bestellung kann derzeit nicht abgeschlossen werden, da keine Versandart hierfür verfügbar ist. Bitte führen Sie die notwendigen Veränderungen bei Ihrer Lieferadresse durch."
diff --git a/app/code/Magento/Checkout/i18n/en_US.csv b/app/code/Magento/Checkout/i18n/en_US.csv
index 7103ae458f536e895a81d8e06bd43cbb1b83944f..b516a61b8ef484bdde420895caa3ddcad918e23e 100644
--- a/app/code/Magento/Checkout/i18n/en_US.csv
+++ b/app/code/Magento/Checkout/i18n/en_US.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","You have no items in your shopping cart."
 "You will receive an order confirmation email with details of your order and a link to track its progress.","You will receive an order confirmation email with details of your order and a link to track its progress."
 "Your Checkout Progress","Your Checkout Progress"
-"Your billing agreement # is: %s.","Your billing agreement # is: %s."
 "Your order # is: %s.","Your order # is: %s."
 "Your order cannot be completed at this time as there is no payment methods available for it.","Your order cannot be completed at this time as there is no payment methods available for it."
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address."
diff --git a/app/code/Magento/Checkout/i18n/es_ES.csv b/app/code/Magento/Checkout/i18n/es_ES.csv
index 94b5c5f5fd16eb70ef1234f52e909713fe2ce59b..81f280e2f48a55ed654ac235b0b19876eaf16a12 100644
--- a/app/code/Magento/Checkout/i18n/es_ES.csv
+++ b/app/code/Magento/Checkout/i18n/es_ES.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","No tiene artículos en su carrito de compras."
 "You will receive an order confirmation email with details of your order and a link to track its progress.","Recibirá un mensaje de correo electrónico con los detalles de su pedido y un enlace para hacer un seguimiento de su progreso."
 "Your Checkout Progress","Progreso de su compra"
-"Your billing agreement # is: %s.","Su número de acuerdo de facturación es: %s."
 "Your order # is: %s.","Su número de pedido es: %s."
 "Your order cannot be completed at this time as there is no payment methods available for it.","Su pedido no se ha podido completar porque no hay ningún método de pago disponible."
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Su pedido no puede completarse en este momento ya que no hay métodos de envío disponibles. Realice los cambios necesarios en su dirección de envío."
diff --git a/app/code/Magento/Checkout/i18n/fr_FR.csv b/app/code/Magento/Checkout/i18n/fr_FR.csv
index dd8d24a1a118556c9aff075439423cd3a7dd8fb6..9e31dedcfdd36019d861f0165377a01284f250c2 100644
--- a/app/code/Magento/Checkout/i18n/fr_FR.csv
+++ b/app/code/Magento/Checkout/i18n/fr_FR.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","Il n'y a aucun objet dans votre panier."
 "You will receive an order confirmation email with details of your order and a link to track its progress.","Vous recevrez un mail de confirmation de commande, puis un second mail vous permettant d'accéder au suivi du colis."
 "Your Checkout Progress","Progression du paiement"
-"Your billing agreement # is: %s.","Votre accord de facturation # est : %s."
 "Your order # is: %s.","Votre commande # est %s."
 "Your order cannot be completed at this time as there is no payment methods available for it.","Votre commande ne peut être terminée pour l’heure, car aucun moyen de paiement n’est disponible pour elle."
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Votre commande ne peut pas être réalisée pour le moment étant donné qu'aucune méthode de livraison n'est disponible. Veuillez apporter les modifications nécessaires à votre adresse de livraison."
diff --git a/app/code/Magento/Checkout/i18n/nl_NL.csv b/app/code/Magento/Checkout/i18n/nl_NL.csv
index 02ca950d491301c468b9f36afb5c8e1c88604eb5..2f79ee1da3f8bd9069aa9609a495b88a66c6ae8d 100644
--- a/app/code/Magento/Checkout/i18n/nl_NL.csv
+++ b/app/code/Magento/Checkout/i18n/nl_NL.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","Uw winkelwagen bevat geen artikelen."
 "You will receive an order confirmation email with details of your order and a link to track its progress.","U ontvangt een email met de bevestiging van uw bestelling en een link om uw zending te volgen."
 "Your Checkout Progress","Uw betalingsvoortgang"
-"Your billing agreement # is: %s.","Uw factureringsovereenkomst # is: %s."
 "Your order # is: %s.","Uw bestelling # is: %s."
 "Your order cannot be completed at this time as there is no payment methods available for it.","Uw bestelling kan nu niet worden afgerond omdat er geen betaalmethoden beschikbaar zijn."
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Uw bestelling kan nu niet worden afgerond omdat er geen verzendmethoden beschikbaar zijn. Maak de noodzakelijke veranderingen uw in afleveradres."
diff --git a/app/code/Magento/Checkout/i18n/pt_BR.csv b/app/code/Magento/Checkout/i18n/pt_BR.csv
index 597177a82885d0f6c4ad7c482affba4915ab6b47..6f9fb1999fc91a125004a1411e900fbbd9c969fd 100644
--- a/app/code/Magento/Checkout/i18n/pt_BR.csv
+++ b/app/code/Magento/Checkout/i18n/pt_BR.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","Você não possui itens no carrinho de compras."
 "You will receive an order confirmation email with details of your order and a link to track its progress.","Você irá receber um e-mail de confirmação de pedido com detalhes de seu pedido e um link para acompanhar o progresso."
 "Your Checkout Progress","Progresso de seu Pagamento"
-"Your billing agreement # is: %s.","Seu acordo de faturamento # está: %s."
 "Your order # is: %s.","Seu pedido # está: %s."
 "Your order cannot be completed at this time as there is no payment methods available for it.","Seu pedido não pode ser concluído neste momento pois não há métodos de pagamento disponíveis para ele."
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","Seu pedido não pode ser concluído neste momento pois não há métodos de envio disponíveis para ele. Por favor faça as mudanças necessárias no seu endereço de envio."
diff --git a/app/code/Magento/Checkout/i18n/zh_CN.csv b/app/code/Magento/Checkout/i18n/zh_CN.csv
index 2ef3aa36adc0a31dc14340c3e671f6875e08566b..9f0536a93336d642ca9272a042d46caaa0d8333c 100644
--- a/app/code/Magento/Checkout/i18n/zh_CN.csv
+++ b/app/code/Magento/Checkout/i18n/zh_CN.csv
@@ -324,7 +324,6 @@
 "You have no items in your shopping cart.","您的购物车内没有物品。"
 "You will receive an order confirmation email with details of your order and a link to track its progress.","您将会收到一份内含订单详细信息和可查询进展情况链接的确认邮件"
 "Your Checkout Progress","您的结帐流程"
-"Your billing agreement # is: %s.","您的账单编号为: %s"
 "Your order # is: %s.","您的订单编号为: %s"
 "Your order cannot be completed at this time as there is no payment methods available for it.","由于付款方法不可用,现在无法完成您的订单。"
 "Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.","由于送货方法不可用,现在无法完成您的订单。请更改您的收货地址。"
diff --git a/app/code/Magento/Checkout/view/frontend/cart/item/default.phtml b/app/code/Magento/Checkout/view/frontend/cart/item/default.phtml
index 850a12f799a869402235f44eb32f2869e81453bf..d945e3f5268a8f9c5aad46ca399edcff972bec26 100644
--- a/app/code/Magento/Checkout/view/frontend/cart/item/default.phtml
+++ b/app/code/Magento/Checkout/view/frontend/cart/item/default.phtml
@@ -50,7 +50,7 @@ $canApplyMsrp = $this->helper('Magento\Catalog\Helper\Data')->canApplyMsrp($_ite
                 <?php foreach ($_options as $_option) : ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
                 <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                     <div class="truncated full value">
                         <dl class="item options">
diff --git a/app/code/Magento/Checkout/view/frontend/js/opcheckout.js b/app/code/Magento/Checkout/view/frontend/js/opcheckout.js
index 33c724155ea29e3341f955b9cdb06687865c532c..892cb9d1da034efd97ed6fe576b0cf0db892404c 100644
--- a/app/code/Magento/Checkout/view/frontend/js/opcheckout.js
+++ b/app/code/Magento/Checkout/view/frontend/js/opcheckout.js
@@ -58,7 +58,7 @@
             }
             var events = {};
             events['click ' + this.options.checkout.continueSelector] = function(e) {
-                this._continue($(e.target));
+                this._continue($(e.currentTarget));
             };
             events['click ' + this.options.backSelector] = function() {
                 this.element.trigger('enableSection', {selector: '#' + this.element.find('.active').prev().attr('id')});
diff --git a/app/code/Magento/Checkout/view/frontend/js/overview.js b/app/code/Magento/Checkout/view/frontend/js/overview.js
index e910d3e51dd8e61dee8942a8feebff6b9996ad87..c4251093ec92913bb8c30c543e924b9dc05c47e5 100644
--- a/app/code/Magento/Checkout/view/frontend/js/overview.js
+++ b/app/code/Magento/Checkout/view/frontend/js/overview.js
@@ -31,7 +31,7 @@
             opacity: 0.5, // CSS opacity for the 'Place Order' button when it's clicked and then disabled.
             pleaseWaitLoader: 'span.please-wait', // 'Submitting order information...' Ajax loader.
             placeOrderSubmit: 'button[type="submit"]', // The 'Place Order' button.
-            agreements: '#checkout-agreements' // Container for all of the checkout billing agreements.
+            agreements: '#checkout-agreements' // Container for all of the checkout agreements and terms/conditions
         },
 
         /**
diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml
index 103313b8873fb2752ededa4b9dee284384f99802..ac5209134937c44fb1e3601eb61240044346e202 100644
--- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml
+++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml
@@ -39,6 +39,7 @@
                 <block class="Magento\Checkout\Block\Cart\Totals" name="checkout.cart.totals" as="totals" template="cart/totals.phtml" cacheable="false"/>
                 <block class="Magento\Checkout\Block\Cart" name="checkout.cart.methods.bottom" template="cart/methods.phtml" cacheable="false">
                     <container name="checkout.cart.methods" as="methods" label="Payment Methods After Checkout Button">
+                        <block class="Magento\Checkout\Block\QuoteShortcutButtons" name="checkout.cart.shortcut.buttons"/>
                         <block class="Magento\Checkout\Block\Onepage\Link" name="checkout.cart.methods.onepage.bottom" template="onepage/link.phtml" cacheable="false"/>
                     </container>
                 </block>
diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_success.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_success.xml
index e8277f2a826cd73c69b775cc13fafb7d2433570c..9fc2a91744f805def3cadad200be413b486a663d 100644
--- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_success.xml
+++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_success.xml
@@ -33,4 +33,5 @@
     <referenceContainer name="content">
         <block class="Magento\Checkout\Block\Onepage\Success" name="checkout.success" template="success.phtml" cacheable="false"/>
     </referenceContainer>
+    <container name="order.success.additional.info" label="Order Success Additional Info"/>
 </layout>
diff --git a/app/code/Magento/Checkout/view/frontend/layout/default.xml b/app/code/Magento/Checkout/view/frontend/layout/default.xml
index 08e85caa9485579453dad5ce939c43b93adf2dca..e0333555e30cb20b7e701992e7b7de3a2ff8c65f 100644
--- a/app/code/Magento/Checkout/view/frontend/layout/default.xml
+++ b/app/code/Magento/Checkout/view/frontend/layout/default.xml
@@ -32,7 +32,9 @@
         <block class="Magento\Checkout\Block\Cart\Sidebar" name="minicart" as="minicart" after="logo" template="cart/minicart.phtml" cacheable="false">
             <block class="Magento\View\Element\RendererList" name="checkout.cart.sidebar.item.renderers" as="renderer.list" />
             <container name="minicart.extra.info" as="minicart_info" label="My Cart Extra info"/>
-            <container name="topCart.extra_actions" as="extra_actions" label="My Cart Extra Actions"/>
+            <container name="topCart.extra_actions" as="extra_actions" label="My Cart Extra Actions">
+                <block class="Magento\Catalog\Block\ShortcutButtons" name="topCart.shortcut.buttons"/>
+            </container>
         </block>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Checkout/view/frontend/onepage/review/info.phtml b/app/code/Magento/Checkout/view/frontend/onepage/review/info.phtml
index a186a0fd9d7fa9812e84c6445c34305f8bb59574..c0d712c3c2f11505110990b1187310585010c9e8 100644
--- a/app/code/Magento/Checkout/view/frontend/onepage/review/info.phtml
+++ b/app/code/Magento/Checkout/view/frontend/onepage/review/info.phtml
@@ -55,7 +55,7 @@
     </table>
 </div>
 <?php echo $this->getChildHtml('items_after'); ?>
-<div id="checkout-review-submit" data-mage-init="{paymentAuthentication:{}}" class="checkout submit order">
+<div id="checkout-review-submit" data-mage-init='{"paymentAuthentication":{}}' class="checkout submit order">
     <?php echo $this->getChildHtml('agreements') ?>
     <div class="actions" id="review-buttons-container">
         <div class="primary"><?php echo $this->getChildHtml('button') ?></div>
diff --git a/app/code/Magento/Checkout/view/frontend/onepage/review/item.phtml b/app/code/Magento/Checkout/view/frontend/onepage/review/item.phtml
index b2d4149aa98035d545226d4b76253cdd70519154..f4e616a17f455ec984f320c5983a890efaa959b8 100644
--- a/app/code/Magento/Checkout/view/frontend/onepage/review/item.phtml
+++ b/app/code/Magento/Checkout/view/frontend/onepage/review/item.phtml
@@ -34,7 +34,7 @@ $_item = $this->getItem()
             <?php foreach ($_options as $_option) : ?>
             <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
-            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                 <?php if (isset($_formatedOptionValue['full_view'])): ?>
                 <div class="truncated full value">
                     <dl class="item options">
diff --git a/app/code/Magento/Checkout/view/frontend/success.phtml b/app/code/Magento/Checkout/view/frontend/success.phtml
index 3d1a1f88a337fdd80c890432895fd0c91e106a3f..34ef55a8170aea78531c9340a25431324fb39f60 100644
--- a/app/code/Magento/Checkout/view/frontend/success.phtml
+++ b/app/code/Magento/Checkout/view/frontend/success.phtml
@@ -40,9 +40,7 @@
         <?php endif;?>
     <?php endif;?>
 
-    <?php if ($this->getAgreementRefId()): ?>
-        <p><?php echo __('Your billing agreement # is: %1.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
-    <?php endif;?>
+    <?php echo $this->getAdditionalInfoHtml() ?>
 
     <?php if ($profiles = $this->getRecurringProfiles()):?>
     <p><?php echo __('Your recurring payment profiles:'); ?></p>
@@ -57,4 +55,4 @@
     <div class="actions">
         <a class="action continue" title="<?php echo __('Continue Shopping') ?>" href="<?php echo $this->getUrl() ?>"><span><?php echo __('Continue Shopping') ?></span></a>
     </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/app/code/Magento/Cms/view/adminhtml/browser/content.phtml b/app/code/Magento/Cms/view/adminhtml/browser/content.phtml
index ddcb495a7ee2944cdf48a65190f7da52f143d055..853ec31228823eeb4e16708ccf79e14b6d3d0534 100644
--- a/app/code/Magento/Cms/view/adminhtml/browser/content.phtml
+++ b/app/code/Magento/Cms/view/adminhtml/browser/content.phtml
@@ -26,7 +26,7 @@
  /** @var $this \Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content */
 ?>
 
-<div data-mage-init="{mediabrowser: <?php echo $this->escapeHtml($this->getFilebrowserSetupObject()); ?>}">
+<div data-mage-init='{"mediabrowser": <?php echo $this->escapeHtml($this->getFilebrowserSetupObject()); ?>}'>
     <div style="float:right; width: 79%">
         <div class="insert-title" id="content_header">
             <div class="insert-title-inner">
diff --git a/app/code/Magento/Cms/view/adminhtml/browser/tree.phtml b/app/code/Magento/Cms/view/adminhtml/browser/tree.phtml
index 411278810703ba264f3dd9604afe32fcb3e58998..40e63269c4d07a102313965416afde97422c4042 100644
--- a/app/code/Magento/Cms/view/adminhtml/browser/tree.phtml
+++ b/app/code/Magento/Cms/view/adminhtml/browser/tree.phtml
@@ -33,6 +33,6 @@
             <a onclick="jQuery('[data-role=tree]').jstree('open_all');"><?php echo __('Expand All'); ?></a>
         </div>
     </div>
-    <div data-role="tree" data-mage-init="<?php echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode($this->getTreeWidgetOptions())); ?>">
+    <div data-role="tree" data-mage-init='<?php echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode($this->getTreeWidgetOptions())); ?>'>
     </div>
 </div>
diff --git a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit.php b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit.php
index 9503c72f4d507994bf85e8913dcd05696da735e6..f2bb7e4a7416a2415bd923e6feb91da71aea8fc8 100644
--- a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit.php
+++ b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit.php
@@ -39,6 +39,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
      * Constructor
      *
      * Initializes edit form container, adds necessary buttons
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -74,16 +76,16 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
     }
 
     /**
-    * Get header of page
-    *
-    * @return string
-    */
+     * Get header of page
+     *
+     * @return string
+     */
     public function getHeaderText()
     {
         return __('New Extension');
     }
 
-    /*
+    /**
      * Get form submit URL
      *
      * @return string
diff --git a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/AbstractTab.php b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/AbstractTab.php
index 65a68c7e9411f3f20c0e727784ef7ee6e4c5513f..7f8d9424e142fe9df85c00429783dc35ef855186 100644
--- a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/AbstractTab.php
+++ b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/AbstractTab.php
@@ -33,22 +33,24 @@
  */
 namespace Magento\Connect\Block\Adminhtml\Extension\Custom\Edit\Tab;
 
+use Magento\View\LayoutInterface;
+
 abstract class AbstractTab
     extends \Magento\Backend\Block\Widget\Form\Generic
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
     /**
-     * TODO
+     * @var LayoutInterface[]
      */
     protected $_addRowButtonHtml;
 
     /**
-     * TODO
+     * @var LayoutInterface[]
      */
     protected $_removeRowButtonHtml;
 
     /**
-     * TODO
+     * @var LayoutInterface[]
      */
     protected $_addFileDepButtonHtml;
 
@@ -72,6 +74,8 @@ abstract class AbstractTab
 
     /**
      * TODO   remove ???
+     *
+     * @return $this
      */
     public function initForm()
     {
@@ -79,7 +83,9 @@ abstract class AbstractTab
     }
 
     /**
-     * TODO
+     * @param string $key
+     * @param string $default
+     * @return string
      */
     public function getValue($key, $default='')
     {
@@ -88,7 +94,9 @@ abstract class AbstractTab
     }
 
     /**
-     * TODO
+     * @param string $key
+     * @param string $value
+     * @return string
      */
     public function getSelected($key, $value)
     {
@@ -96,7 +104,8 @@ abstract class AbstractTab
     }
 
     /**
-     * TODO
+     * @param string $key
+     * @return string
      */
     public function getChecked($key)
     {
@@ -104,7 +113,10 @@ abstract class AbstractTab
     }
 
     /**
-     * TODO
+     * @param string $container
+     * @param string $template
+     * @param string $title
+     * @return LayoutInterface[]
      */
     public function getAddRowButtonHtml($container, $template, $title='Add')
     {
@@ -121,7 +133,8 @@ abstract class AbstractTab
     }
 
     /**
-     * TODO
+     * @param string $selector
+     * @return LayoutInterface[]
      */
     public function getRemoveRowButtonHtml($selector='span')
     {
@@ -137,6 +150,11 @@ abstract class AbstractTab
         return $this->_removeRowButtonHtml;
     }
 
+    /**
+     * @param string $selector
+     * @param string $filesClass
+     * @return LayoutInterface[]
+     */
     public function getAddFileDepsRowButtonHtml($selector='span', $filesClass='files')
     {
         if (!$this->_addFileDepButtonHtml) {
@@ -172,11 +190,17 @@ abstract class AbstractTab
         return '';
     }
 
+    /**
+     * @return bool
+     */
     public function canShowTab()
     {
         return true;
     }
 
+    /**
+     * @return bool
+     */
     public function isHidden()
     {
         return false;
diff --git a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php
index e379fc99557e6cf2897ec26a43a734cc9713e85f..ea6b0821800f60fc0f0155eaa7dd45dcac393752 100644
--- a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php
+++ b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Authors.php
@@ -101,7 +101,7 @@ class Authors
     /**
      * Return array of authors
      *
-     * @return array
+     * @return string[]
      */
     public function getAuthors()
     {
diff --git a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php
index 476127b9ad48be593872aa8e1b93c027485b1424..7911f977a3d6ad018e3537fa5481e0703d94b0aa 100644
--- a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php
+++ b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Depends.php
@@ -40,7 +40,7 @@ class Depends
     /**
      * Prepare Dependencies Form before rendering HTML
      *
-     * @return \Magento\Connect\Block\Adminhtml\Extension\Custom\Edit\Tab\Package
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php
index 6164f6121fc4a641960c4dcf7cf79742d3ed8412..14ee8715f8908032078100fb14a50cdfe7227566 100644
--- a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php
+++ b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php
@@ -61,6 +61,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Initialize Grid block
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -97,7 +98,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare grid columns
      *
-     * @return \Magento\Connect\Block\Adminhtml\Extension\Custom\Edit\Tab\Grid
+     * @return $this
      */
     protected function _prepareColumns()
     {
@@ -120,6 +121,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Self URL getter
      *
+     * @param array $params
      * @return string
      */
     public function getCurrentUrl($params = array())
@@ -133,6 +135,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Row URL getter
      *
+     * @param string $row
      * @return string
      */
     public function getRowUrl($row)
diff --git a/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php b/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php
index e0bc08158552de68c13d6860b2e8c9b0d6d8d9f5..efabc1e85f9eb422c4f3a16c02772716e4825fc0 100644
--- a/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php
+++ b/app/code/Magento/Connect/Controller/Adminhtml/Extension/Custom.php
@@ -38,6 +38,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Redirect to edit Extension Package action
      *
+     * @return void
      */
     public function indexAction()
     {
@@ -49,6 +50,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Edit Extension Package Form
      *
+     * @return void
      */
     public function editAction()
     {
@@ -62,6 +64,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Reset Extension Package form data
      *
+     * @return void
      */
     public function resetAction()
     {
@@ -72,6 +75,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Load Local Extension Package
      *
+     * @return void
      */
     public function loadAction()
     {
@@ -98,6 +102,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Save Extension Package
      *
+     * @return void
      */
     public function saveAction()
     {
@@ -141,6 +146,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Create new Extension Package
      *
+     * @return void
      */
     public function createAction()
     {
@@ -172,6 +178,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Load Grid with Local Packages
      *
+     * @return void
      */
     public function loadtabAction()
     {
@@ -182,6 +189,7 @@ class Custom extends \Magento\Backend\App\Action
     /**
      * Grid for loading packages
      *
+     * @return void
      */
     public function gridAction()
     {
diff --git a/app/code/Magento/Connect/Controller/Adminhtml/Extension/Local.php b/app/code/Magento/Connect/Controller/Adminhtml/Extension/Local.php
index cb8b9f4041bdb979fefebb5fe427c405edd32200..cfbbb4f9096a5bc7302aa9f5ac948ddca7767395 100644
--- a/app/code/Magento/Connect/Controller/Adminhtml/Extension/Local.php
+++ b/app/code/Magento/Connect/Controller/Adminhtml/Extension/Local.php
@@ -38,6 +38,7 @@ class Local extends \Magento\Backend\App\Action
     /**
      * Redirect to Magento Connect
      *
+     * @return void
      */
     public function indexAction()
     {
diff --git a/app/code/Magento/Connect/Model/Extension.php b/app/code/Magento/Connect/Model/Extension.php
index 13b11e5add23cf5155252b856042d25dc313b0df..c61726cfb3d77df258f2695af98082aade36b1b7 100644
--- a/app/code/Magento/Connect/Model/Extension.php
+++ b/app/code/Magento/Connect/Model/Extension.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Model;
 
 /**
@@ -94,7 +93,6 @@ class Extension extends \Magento\Object
         $this->writeDirectory   = $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::VAR_DIR);
         $this->logger           = $logger;
         parent::__construct($data);
-
     }
 
     /**
@@ -113,7 +111,7 @@ class Extension extends \Magento\Object
     /**
      * Set package object
      *
-     * @return \Magento\Connect\Model\Extension
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function generatePackageXml()
@@ -136,7 +134,7 @@ class Extension extends \Magento\Object
     /**
      * Set general information.
      *
-     * @return \Magento\Connect\Model\Extension
+     * @return $this
      */
     protected function _setPackage()
     {
@@ -152,7 +150,7 @@ class Extension extends \Magento\Object
     /**
      * Set release information
      *
-     * @return \Magento\Connect\Model\Extension
+     * @return $this
      */
     protected function _setRelease()
     {
@@ -168,7 +166,7 @@ class Extension extends \Magento\Object
     /**
      * Set authors
      *
-     * @return \Magento\Connect\Model\Extension
+     * @return $this
      */
     protected function _setAuthors()
     {
@@ -205,7 +203,7 @@ class Extension extends \Magento\Object
     /**
      * Set php, php extensions, another packages dependencies
      *
-     * @return \Magento\Connect\Model\Extension
+     * @return $this
      */
     protected function _setDependencies()
     {
@@ -248,7 +246,7 @@ class Extension extends \Magento\Object
     /**
      * Set contents. Add file or entire directory.
      *
-     * @return \Magento\Connect\Model\Extension
+     * @return $this
      */
     protected function _setContents()
     {
diff --git a/app/code/Magento/Connect/Model/Extension/Collection.php b/app/code/Magento/Connect/Model/Extension/Collection.php
index 7f365378e2c4ef847078debbf55a68f927ead856..d2ebb47b9431399c4f9632d93ce090426318b79e 100644
--- a/app/code/Magento/Connect/Model/Extension/Collection.php
+++ b/app/code/Magento/Connect/Model/Extension/Collection.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect\Model\Extension;
 
 /**
  * Extension packages files collection
@@ -31,7 +32,6 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Connect\Model\Extension;
 
 class Collection extends \Magento\Data\Collection\Filesystem
 {
@@ -41,7 +41,15 @@ class Collection extends \Magento\Data\Collection\Filesystem
      * @var string
      */
     protected $_allowedDirsMask     = '/^[a-z0-9\.\-]+$/i';
+
+    /**
+     * @var string
+     */
     protected $_allowedFilesMask    = '/^[a-z0-9\.\-\_]+\.(xml|ser)$/i';
+
+    /**
+     * @var string
+     */
     protected $_disallowedFilesMask = '/^package\.xml$/i';
 
     /**
diff --git a/app/code/Magento/Connect/Model/Session.php b/app/code/Magento/Connect/Model/Session.php
index 6043900d3d249a96ae303ad7806e82b4fca25d50..573562431b89fb90fdef3e8eec145a1ebaa30e60 100644
--- a/app/code/Magento/Connect/Model/Session.php
+++ b/app/code/Magento/Connect/Model/Session.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Model;
 
 /**
diff --git a/app/code/Magento/Contacts/Controller/Index.php b/app/code/Magento/Contacts/Controller/Index.php
index b91dd363e52e5f2af100a0f5e90f744f28e08802..c478a9bc6e9dbd79746f0f23706c43119b233045 100644
--- a/app/code/Magento/Contacts/Controller/Index.php
+++ b/app/code/Magento/Contacts/Controller/Index.php
@@ -142,7 +142,7 @@ class Index extends \Magento\App\Action\Action
                 return;
             } catch (\Exception $e) {
                 $translate->setTranslateInline(true);
-                $this->messageManager->addError(__('Something went wrong submitting your request.'));
+                $this->messageManager->addError(__('We can\'t process your request right now. Sorry, that\'s all we know.'));
                 $this->_redirect('*/*/');
                 return;
             }
diff --git a/app/code/Magento/Core/App/Action/Plugin/Install.php b/app/code/Magento/Core/App/Action/Plugin/Install.php
index 7b6f5c5de7d849a5d113615d8a64c705d1143c0d..c01e18ed40251bcaa9388dd50d1227e99618d4ad 100644
--- a/app/code/Magento/Core/App/Action/Plugin/Install.php
+++ b/app/code/Magento/Core/App/Action/Plugin/Install.php
@@ -71,7 +71,7 @@ class Install
      *
      * @param array $arguments
      * @param \Magento\Code\Plugin\InvocationChain $invocationChain
-     * @return \Magento\App\ResponseInterface
+     * @return mixed
      */
     public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
     {
diff --git a/app/code/Magento/Core/App/Action/Plugin/Session.php b/app/code/Magento/Core/App/Action/Plugin/Session.php
index e234583655f1f2d4d577d6321b911bd6a120b49c..1f4cb5fa6af91012d6e0df9a82df2cf3a1438733 100644
--- a/app/code/Magento/Core/App/Action/Plugin/Session.php
+++ b/app/code/Magento/Core/App/Action/Plugin/Session.php
@@ -42,7 +42,7 @@ class Session
     protected $_cookie;
 
     /**
-     * @var array
+     * @var string[]
      */
     protected $_cookieCheckActions;
 
@@ -80,7 +80,7 @@ class Session
      * @param \Magento\Core\Model\Store\Config $storeConfig
      * @param \Magento\Session\SidResolverInterface $sidResolver
      * @param string $sessionNamespace
-     * @param array $cookieCheckActions
+     * @param string[] $cookieCheckActions
      */
     public function __construct(
         \Magento\App\ActionFlag $flag,
@@ -107,7 +107,7 @@ class Session
     /**
      * @param array $arguments
      * @param \Magento\Code\Plugin\InvocationChain $invocationChain
-     * @return array
+     * @return mixed
      */
     public function aroundDispatch(array $arguments = array(), \Magento\Code\Plugin\InvocationChain $invocationChain)
     {
diff --git a/app/code/Magento/Core/App/Media.php b/app/code/Magento/Core/App/Media.php
index 53d1958344aeb5bc837a931eda8fad1ff61d8bf0..646a563bde0cd0d1d76d20c0febbc41b85a5bed0 100644
--- a/app/code/Magento/Core/App/Media.php
+++ b/app/code/Magento/Core/App/Media.php
@@ -51,7 +51,7 @@ class Media implements LauncherInterface
     /**
      * Authorization function
      *
-     * @var callable
+     * @var \Closure
      */
     protected $_isAllowed;
 
@@ -103,12 +103,12 @@ class Media implements LauncherInterface
      * @param ObjectManager $objectManager
      * @param Request $request
      * @param Response $response
-     * @param callable $isAllowed
-     * @param $workingDirectory
-     * @param $mediaDirectory
-     * @param $configCacheFile
-     * @param $relativeFileName
-     * @param \Magento\App\Filesystem $filesytem
+     * @param \Closure $isAllowed
+     * @param string $workingDirectory
+     * @param string $mediaDirectory
+     * @param string $configCacheFile
+     * @param string $relativeFileName
+     * @param \Magento\App\Filesystem $filesystem
      */
     public function __construct(
         State $applicationState,
diff --git a/app/code/Magento/Core/App/Request/RewriteService.php b/app/code/Magento/Core/App/Request/RewriteService.php
index 2f8d98d36dac4b2ce81fd9b8ed1a90ef2486a3c0..d4aefb739905e4bdcdaabfa10300bd1b44966d71 100644
--- a/app/code/Magento/Core/App/Request/RewriteService.php
+++ b/app/code/Magento/Core/App/Request/RewriteService.php
@@ -40,6 +40,11 @@ class RewriteService
      */
     protected $_routerList;
 
+    /**
+     * @param \Magento\App\RouterList $routerList
+     * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory
+     * @param \Magento\App\ConfigInterface $config
+     */
     public function __construct(
         \Magento\App\RouterList $routerList,
         \Magento\Core\Model\Url\RewriteFactory $rewriteFactory,
@@ -54,6 +59,7 @@ class RewriteService
      * Apply rewrites to current request
      *
      * @param \Magento\App\RequestInterface $request
+     * @return void
      */
     public function applyRewrites(\Magento\App\RequestInterface $request)
     {
diff --git a/app/code/Magento/Core/App/Router/Base.php b/app/code/Magento/Core/App/Router/Base.php
index fc22783c3702f69b6239376f835cd0c6ae51558c..3e4ff880af53fedf50117fc3c1d3aebd822a9bf5 100644
--- a/app/code/Magento/Core/App/Router/Base.php
+++ b/app/code/Magento/Core/App/Router/Base.php
@@ -40,7 +40,7 @@ class Base extends \Magento\App\Router\AbstractRouter
     /**
      * List of required request parameters
      * Order sensitive
-     * @var array
+     * @var string[]
      */
     protected $_requiredParams = array(
         'moduleFrontName',
@@ -98,11 +98,11 @@ class Base extends \Magento\App\Router\AbstractRouter
      * @param \Magento\App\ResponseFactory $responseFactory
      * @param \Magento\App\Route\ConfigInterface $routeConfig
      * @param \Magento\App\State $appState
-     * @param \Magento\Core\Model\Url|\Magento\UrlInterface $url
+     * @param \Magento\UrlInterface $url
      * @param \Magento\Core\Model\StoreManagerInterface|\Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Core\Model\Store\Config $storeConfig
      * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo
-     * @param $routerId
+     * @param string $routerId
      * @throws \InvalidArgumentException
      */
     public function __construct(
@@ -235,7 +235,7 @@ class Base extends \Magento\App\Router\AbstractRouter
     /**
      * Get not found controller instance
      *
-     * @param $currentModuleName
+     * @param string $currentModuleName
      * @param \Magento\App\RequestInterface $request
      * @return \Magento\App\Action\Action|null
      */
diff --git a/app/code/Magento/Core/Block/Store/Switcher.php b/app/code/Magento/Core/Block/Store/Switcher.php
index 3a8180d979b044497556d1e55e9456cdbac24c5e..4e50e54d359712b5fe6021154c2cf26cb9d1b45d 100644
--- a/app/code/Magento/Core/Block/Store/Switcher.php
+++ b/app/code/Magento/Core/Block/Store/Switcher.php
@@ -35,8 +35,19 @@ namespace Magento\Core\Block\Store;
 
 class Switcher extends \Magento\View\Element\Template
 {
+    /**
+     * @var array
+     */
     protected $_groups = array();
+
+    /**
+     * @var array
+     */
     protected $_stores = array();
+
+    /**
+     * @var bool
+     */
     protected $_loaded = false;
 
     /**
@@ -70,6 +81,9 @@ class Switcher extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_loadData();
@@ -78,6 +92,9 @@ class Switcher extends \Magento\View\Element\Template
         return parent::_construct();
     }
 
+    /**
+     * @return $this
+     */
     protected function _loadData()
     {
         if ($this->_loaded) {
@@ -107,6 +124,9 @@ class Switcher extends \Magento\View\Element\Template
         return $this;
     }
 
+    /**
+     * @return int
+     */
     public function getStoreCount()
     {
         $stores = array();
@@ -131,6 +151,9 @@ class Switcher extends \Magento\View\Element\Template
         return count($this->getStores());
     }
 
+    /**
+     * @return int
+     */
     public function getLanguageCount()
     {
         $groupId = $this->_storeManager->getStore()->getGroupId();
@@ -142,11 +165,17 @@ class Switcher extends \Magento\View\Element\Template
         return count($this->getLanguages());
     }
 
+    /**
+     * @return int
+     */
     public function getCurrentStoreId()
     {
         return $this->_storeManager->getStore()->getId();
     }
 
+    /**
+     * @return string
+     */
     public function getCurrentStoreCode()
     {
         return $this->_storeManager->getStore()->getCode();
diff --git a/app/code/Magento/Core/Block/Switcher.php b/app/code/Magento/Core/Block/Switcher.php
index 1f1ee978745ccecb1a72b34deec632acbfab613a..6d3ad349b847fbf8c30cc92efd795c38c3e91a8a 100644
--- a/app/code/Magento/Core/Block/Switcher.php
+++ b/app/code/Magento/Core/Block/Switcher.php
@@ -31,25 +31,43 @@
  */
 namespace Magento\Core\Block;
 
+use Magento\Core\Model\Store\Group;
+use Magento\Core\Model\Store;
+
 class Switcher extends \Magento\View\Element\Template
 {
+    /**
+     * @var bool
+     */
     protected $_storeInUrl;
 
+    /**
+     * @return int|null|string
+     */
     public function getCurrentWebsiteId()
     {
         return $this->_storeManager->getStore()->getWebsiteId();
     }
 
+    /**
+     * @return int|null|string
+     */
     public function getCurrentGroupId()
     {
         return $this->_storeManager->getStore()->getGroupId();
     }
 
+    /**
+     * @return int
+     */
     public function getCurrentStoreId()
     {
         return $this->_storeManager->getStore()->getId();
     }
 
+    /**
+     * @return array
+     */
     public function getRawGroups()
     {
         if (!$this->hasData('raw_groups')) {
@@ -64,13 +82,16 @@ class Switcher extends \Magento\View\Element\Template
         return $this->getData('raw_groups');
     }
 
+    /**
+     * @return array
+     */
     public function getRawStores()
     {
         if (!$this->hasData('raw_stores')) {
             $websiteStores = $this->_storeManager->getWebsite()->getStores();
             $stores = array();
             foreach ($websiteStores as $store) {
-                /* @var $store \Magento\Core\Model\Store */
+                /* @var $store Store */
                 if (!$store->getIsActive()) {
                     continue;
                 }
@@ -95,7 +116,7 @@ class Switcher extends \Magento\View\Element\Template
     /**
      * Retrieve list of store groups with default urls set
      *
-     * @return array
+     * @return Group[]
      */
     public function getGroups()
     {
@@ -106,7 +127,7 @@ class Switcher extends \Magento\View\Element\Template
             $groups = array();
             $localeCode = $this->_storeConfig->getConfig('general/locale/code');
             foreach ($rawGroups as $group) {
-                /* @var $group \Magento\Core\Model\Store\Group */
+                /* @var $group Group */
                 if (!isset($rawStores[$group->getId()])) {
                     continue;
                 }
@@ -127,6 +148,9 @@ class Switcher extends \Magento\View\Element\Template
         return $this->getData('groups');
     }
 
+    /**
+     * @return Store[]
+     */
     public function getStores()
     {
         if (!$this->getData('stores')) {
@@ -143,11 +167,17 @@ class Switcher extends \Magento\View\Element\Template
         return $this->getData('stores');
     }
 
+    /**
+     * @return string
+     */
     public function getCurrentStoreCode()
     {
         return $this->_storeManager->getStore()->getCode();
     }
 
+    /**
+     * @return bool
+     */
     public function isStoreInUrl()
     {
         if (is_null($this->_storeInUrl)) {
diff --git a/app/code/Magento/Core/Controller/Ajax.php b/app/code/Magento/Core/Controller/Ajax.php
index 6d6b8d63614e0cf77a528edbc1094df2a4bbf229..655743862ace740fdc22a56751fa9cb9f9cd77b0 100644
--- a/app/code/Magento/Core/Controller/Ajax.php
+++ b/app/code/Magento/Core/Controller/Ajax.php
@@ -27,6 +27,8 @@ class Ajax extends \Magento\App\Action\Action
 {
     /**
      * Ajax action for inline translation
+     *
+     * @return void
      */
     public function translateAction()
     {
diff --git a/app/code/Magento/Core/Controller/Index.php b/app/code/Magento/Core/Controller/Index.php
index 885ad9e164a9822071fdc247d0ecb377b01e3409..b9bf63fb5b97e65e774c7aa6f1ea879230dcc12c 100644
--- a/app/code/Magento/Core/Controller/Index.php
+++ b/app/code/Magento/Core/Controller/Index.php
@@ -28,6 +28,9 @@ namespace Magento\Core\Controller;
 
 class Index extends \Magento\App\Action\Action
 {
+    /**
+     * @return void
+     */
     public function indexAction()
     {
 
@@ -35,6 +38,8 @@ class Index extends \Magento\App\Action\Action
 
     /**
      * 404 not found action
+     *
+     * @return void
      */
     public function notFoundAction()
     {
@@ -45,6 +50,8 @@ class Index extends \Magento\App\Action\Action
 
     /**
      * No cookies action
+     *
+     * @return void
      */
     public function noCookiesAction()
     {
diff --git a/app/code/Magento/Core/Controller/Noroute.php b/app/code/Magento/Core/Controller/Noroute.php
index fa0579c18da57cd3fcf7ffac9d0be6f7c20a9e64..9861b14da3ccb6632b68d68296f54fe6ae95b13c 100644
--- a/app/code/Magento/Core/Controller/Noroute.php
+++ b/app/code/Magento/Core/Controller/Noroute.php
@@ -31,6 +31,8 @@ class Noroute extends Action
 {
     /**
      * Noroute application handler
+     *
+     * @return void
      */
     public function indexAction()
     {
diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php
index 759bf077e9e449798c88cd0a4354a1e4507021fa..7c27e83e885cdf42594f1ac061480d8950b18871 100644
--- a/app/code/Magento/Core/Helper/Data.php
+++ b/app/code/Magento/Core/Helper/Data.php
@@ -42,6 +42,9 @@ class Data extends \Magento\App\Helper\AbstractHelper
      */
     const DIVIDE_EPSILON = 10000;
 
+    /**
+     * @var string[]
+     */
     protected $_allowedFormats = array(
         \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_FULL,
         \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG,
@@ -113,7 +116,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @param   float $value
      * @param   bool $format
      * @param   bool $includeContainer
-     * @return  mixed
+     * @return  float|string
      */
     public function currency($value, $format = true, $includeContainer = true)
     {
@@ -127,7 +130,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @param   int|\Magento\Core\Model\Store $store
      * @param   bool $format
      * @param   bool $includeContainer
-     * @return  mixed
+     * @return  float|string
      */
     public function currencyByStore($value, $store = null, $format = true, $includeContainer = true)
     {
@@ -209,8 +212,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * Encode the mixed $valueToEncode into the JSON format
      *
      * @param mixed $valueToEncode
-     * @param  boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
-     * @param  array $options Additional options used during encoding
+     * @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
+     * @param array $options Additional options used during encoding
      * @return string
      */
     public function jsonEncode($valueToEncode, $cycleCheck = false, $options = array())
diff --git a/app/code/Magento/Core/Helper/File/Media.php b/app/code/Magento/Core/Helper/File/Media.php
index 1f746651b136e6b3b5abf8c5434671b7664a0494..023228c3ee677d7d2191100b8ba1c88a787131b3 100644
--- a/app/code/Magento/Core/Helper/File/Media.php
+++ b/app/code/Magento/Core/Helper/File/Media.php
@@ -45,8 +45,8 @@ class Media extends \Magento\App\Helper\AbstractHelper
      * Constructor
      *
      * @param \Magento\App\Helper\Context $context
-     * @param \Magento\App\Filesystem $filesystem
      * @param \Magento\Core\Model\Date $date
+     * @param \Magento\App\Filesystem $filesystem
      */
     public function __construct(
         \Magento\App\Helper\Context $context,
diff --git a/app/code/Magento/Core/Helper/File/Storage.php b/app/code/Magento/Core/Helper/File/Storage.php
index 8fab67b1abf48740025f12895efefb59452c589b..c982ec2934f1258f1450fa8b95f85d6a510e7fde 100644
--- a/app/code/Magento/Core/Helper/File/Storage.php
+++ b/app/code/Magento/Core/Helper/File/Storage.php
@@ -45,7 +45,7 @@ class Storage extends \Magento\App\Helper\AbstractHelper
     /**
      * List of internal storages
      *
-     * @var array
+     * @var int[]
      */
     protected $_internalStorageList = array(
         \Magento\Core\Model\File\Storage::STORAGE_MEDIA_FILE_SYSTEM
diff --git a/app/code/Magento/Core/Helper/File/Storage/Database.php b/app/code/Magento/Core/Helper/File/Storage/Database.php
index 78614853d751ba05f6e6bf5604f816adc2810d52..dafe9c3a78adecfb56eb3411c384f1db61dbd789 100644
--- a/app/code/Magento/Core/Helper/File/Storage/Database.php
+++ b/app/code/Magento/Core/Helper/File/Storage/Database.php
@@ -161,6 +161,7 @@ class Database extends \Magento\App\Helper\AbstractHelper
      * Save file in DB storage
      *
      * @param string $filename
+     * @return void
      */
     public function saveFile($filename)
     {
@@ -174,6 +175,7 @@ class Database extends \Magento\App\Helper\AbstractHelper
      *
      * @param string $oldName
      * @param string $newName
+     * @return void
      */
     public function renameFile($oldName, $newName)
     {
@@ -188,6 +190,7 @@ class Database extends \Magento\App\Helper\AbstractHelper
      *
      * @param string $oldName
      * @param string $newName
+     * @return void
      */
     public function copyFile($oldName, $newName) {
         if ($this->checkDbUsage()) {
@@ -221,8 +224,8 @@ class Database extends \Magento\App\Helper\AbstractHelper
     public function getUniqueFilename($directory, $filename)
     {
         if ($this->checkDbUsage()) {
-           $directory = $this->_removeAbsPathFromFileName($directory);
-            if($this->fileExists($directory . $filename)) {
+            $directory = $this->_removeAbsPathFromFileName($directory);
+            if ($this->fileExists($directory . $filename)) {
                 $index = 1;
                 $extension = strrchr($filename, '.');
                 $filenameWoExtension = substr($filename, 0, -1 * strlen($extension));
@@ -270,6 +273,7 @@ class Database extends \Magento\App\Helper\AbstractHelper
      * Deletes from DB files, which belong to one folder
      *
      * @param string $folderName
+     * @return void
      */
     public function deleteFolder($folderName)
     {
@@ -282,6 +286,7 @@ class Database extends \Magento\App\Helper\AbstractHelper
      * Deletes from DB files, which belong to one folder
      *
      * @param string $filename
+     * @return void
      */
     public function deleteFile($filename)
     {
diff --git a/app/code/Magento/Core/Helper/Js.php b/app/code/Magento/Core/Helper/Js.php
index 12671295b41b073b8b7fe7e7f166609ab24046cf..0c90317e9ad9870a186fac19907f36c6a1097caa 100644
--- a/app/code/Magento/Core/Helper/Js.php
+++ b/app/code/Magento/Core/Helper/Js.php
@@ -90,7 +90,7 @@ class Js extends \Magento\App\Helper\AbstractHelper
      * Retrieve framed javascript
      *
      * @param   string $script
-     * @return  script
+     * @return  string
      */
     public function getScript($script)
     {
@@ -125,6 +125,7 @@ class Js extends \Magento\App\Helper\AbstractHelper
     /**
      * Helper function that populates _translateData with default values.
      *
+     * @return void
      * @SuppressWarnings(PHPMD)
      */
     protected function _populateTranslateData()
@@ -285,8 +286,9 @@ class Js extends \Magento\App\Helper\AbstractHelper
      *
      * There is no point in having translated text added if the key is already representing the translated text.
      *
-     * @param $key
-     * @param $translatedText
+     * @param string $key
+     * @param string $translatedText
+     * @return void
      */
     protected function _addTranslation($key, $translatedText)
     {
diff --git a/app/code/Magento/Core/Helper/String.php b/app/code/Magento/Core/Helper/String.php
index 83ba987c42d300f4f50f4794fa4c035924d257c9..a7f9c1005fa65a2c635ac45890038176a2ed322b 100644
--- a/app/code/Magento/Core/Helper/String.php
+++ b/app/code/Magento/Core/Helper/String.php
@@ -37,7 +37,7 @@ class String extends \Magento\App\Helper\AbstractHelper
      * Split every part into pieces by _ and \ and uppercase every piece
      * Then join them back using \
      *
-     * @param $parts
+     * @param string[] $parts
      * @return string
      */
     public static function buildClassName($parts)
diff --git a/app/code/Magento/Core/Helper/Theme.php b/app/code/Magento/Core/Helper/Theme.php
index 3e8f8b6d42b20d3d9788c4e51c438a113f8a4024..dbafbec600cd10b826c145b325233664cbce9ba5 100644
--- a/app/code/Magento/Core/Helper/Theme.php
+++ b/app/code/Magento/Core/Helper/Theme.php
@@ -194,9 +194,9 @@ class Theme extends \Magento\App\Helper\AbstractHelper
     /**
      * Detect theme view file belongs to and set it to file data under "theme" key
      *
-     * @param array $file
+     * @param array &$file
      * @param string $designDir
-     * @return \Magento\Core\Helper\Theme
+     * @return $this
      * @throws \LogicException
      */
     protected function _detectTheme(&$file, $designDir)
@@ -234,11 +234,11 @@ class Theme extends \Magento\App\Helper\AbstractHelper
     /**
      * Detect group where file should be placed and set it to file data under "group" key
      *
-     * @param array $file
+     * @param array &$file
      * @param string $designDir
      * @param string $jsDir
      * @param string $codeDir
-     * @return \Magento\Core\Helper\Theme
+     * @return $this
      * @throws \LogicException
      */
     protected function _detectGroup(&$file, $designDir, $jsDir, $codeDir)
diff --git a/app/code/Magento/Core/Helper/Translate.php b/app/code/Magento/Core/Helper/Translate.php
index 90bc72c918644b166ec4983016e78e850739275f..2455ddaf1f3777abc2464cb5ff923854a823cb0c 100644
--- a/app/code/Magento/Core/Helper/Translate.php
+++ b/app/code/Magento/Core/Helper/Translate.php
@@ -99,7 +99,7 @@ class Translate extends \Magento\App\Helper\AbstractHelper
      * @param string $localeCode
      * @param bool $forceReload
      * @param null $area
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     public function initTranslate($localeCode, $forceReload, $area = null)
     {
diff --git a/app/code/Magento/Core/Helper/Url.php b/app/code/Magento/Core/Helper/Url.php
index 862da17e3059ea10c4e33d56f43ced7cd6b15a76..11874e07ea0ca2c17dee48f513463ac88294d74d 100644
--- a/app/code/Magento/Core/Helper/Url.php
+++ b/app/code/Magento/Core/Helper/Url.php
@@ -62,6 +62,10 @@ class Url extends \Magento\App\Helper\AbstractHelper
         return $this->urlEncode($this->_urlBuilder->getCurrentUrl());
     }
 
+    /**
+     * @param string $url
+     * @return string
+     */
     public function getEncodedUrl($url = null)
     {
         if (!$url) {
@@ -80,6 +84,10 @@ class Url extends \Magento\App\Helper\AbstractHelper
         return $this->_storeManager->getStore()->getBaseUrl();
     }
 
+    /**
+     * @param string $string
+     * @return string
+     */
     protected function _prepareString($string)
     {
         $string = preg_replace('#[^0-9a-z]+#i', '-', $string);
@@ -92,16 +100,16 @@ class Url extends \Magento\App\Helper\AbstractHelper
     /**
      * Add request parameter into url
      *
-     * @param  $url string
-     * @param  $param array( 'key' => value )
+     * @param  string $url
+     * @param  array $param array( 'key' => value )
      * @return string
      */
     public function addRequestParam($url, $param)
     {
-        $startDelimiter = (false === strpos($url,'?'))? '?' : '&';
+        $startDelimiter = (false === strpos($url, '?'))? '?' : '&';
 
         $arrQueryParams = array();
-        foreach($param as $key=>$value) {
+        foreach ($param as $key=>$value) {
             if (is_numeric($key) || is_object($value)) {
                 continue;
             }
diff --git a/app/code/Magento/Core/Helper/Url/Rewrite.php b/app/code/Magento/Core/Helper/Url/Rewrite.php
index 47e84471af52007742035845225d65d4e2c3cd3d..8b38d1d15d3aa88c863361cb230676ced24ef468 100644
--- a/app/code/Magento/Core/Helper/Url/Rewrite.php
+++ b/app/code/Magento/Core/Helper/Url/Rewrite.php
@@ -63,7 +63,9 @@ class Rewrite extends \Magento\App\Helper\AbstractHelper
      * If something is wrong with a path it throws localized error message and error code,
      * that can be checked to by wrapper func to alternate error message
      *
+     * @param string $requestPath
      * @return bool
+     * @throws \Exception
      */
     protected function _validateRequestPath($requestPath)
     {
@@ -80,7 +82,7 @@ class Rewrite extends \Magento\App\Helper\AbstractHelper
      * Validates request path
      * Either returns TRUE (success) or throws error (validation failed)
      *
-     * @param $requestPath
+     * @param string $requestPath
      * @throws \Magento\Core\Exception
      * @return bool
      */
@@ -98,7 +100,7 @@ class Rewrite extends \Magento\App\Helper\AbstractHelper
      * Validates suffix for url rewrites to inform user about errors in it
      * Either returns TRUE (success) or throws error (validation failed)
      *
-     * @param $suffix
+     * @param string $suffix
      * @throws \Magento\Core\Exception
      * @return bool
      */
diff --git a/app/code/Magento/Core/Model/AbstractModel.php b/app/code/Magento/Core/Model/AbstractModel.php
index c019285b3ef987e3e44eebaf0ebd7e3a67f2de79..e167128940f613ae0dd0e55f57711f2823c2ae58 100644
--- a/app/code/Magento/Core/Model/AbstractModel.php
+++ b/app/code/Magento/Core/Model/AbstractModel.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model;
 
 /**
@@ -82,7 +81,7 @@ abstract class AbstractModel extends \Magento\Object
      *
      * When you use true - all cache will be clean
      *
-     * @var string|array|true
+     * @var string|array|bool
      */
     protected $_cacheTag = false;
 
@@ -124,7 +123,7 @@ abstract class AbstractModel extends \Magento\Object
     protected $_cacheManager;
 
     /**
-     * @var \Magento\Core\Model\Registry
+     * @var Registry
      */
     protected $_coreRegistry;
 
@@ -170,6 +169,8 @@ abstract class AbstractModel extends \Magento\Object
 
     /**
      * Model construct that should be used for object initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -179,7 +180,7 @@ abstract class AbstractModel extends \Magento\Object
      * Standard model initialization
      *
      * @param string $resourceModel
-     * @return \Magento\Core\Model\AbstractModel
+     * @return void
      */
     protected function _init($resourceModel)
     {
@@ -188,7 +189,7 @@ abstract class AbstractModel extends \Magento\Object
     }
 
     /**
-     * @return array
+     * @return string[]
      */
     public function __sleep()
     {
@@ -199,6 +200,8 @@ abstract class AbstractModel extends \Magento\Object
 
     /**
      * Init not serializable fields
+     *
+     * @return void
      */
     public function __wakeup()
     {
@@ -219,6 +222,7 @@ abstract class AbstractModel extends \Magento\Object
      *
      * @param string $resourceName
      * @param string|null $collectionName
+     * @return void
      */
     protected function _setResourceModel($resourceName, $collectionName = null)
     {
@@ -257,6 +261,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Get collection instance
      *
+     * @deplacated
      * @throws \Magento\Core\Exception
      * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
      */
@@ -289,7 +294,7 @@ abstract class AbstractModel extends \Magento\Object
      *
      * @param integer $modelId
      * @param null|string $field
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     public function load($modelId, $field = null)
     {
@@ -319,7 +324,7 @@ abstract class AbstractModel extends \Magento\Object
      *
      * @param int $modelId
      * @param null|string $field
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _beforeLoad($modelId, $field = null)
     {
@@ -333,7 +338,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Processing object after load data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -345,7 +350,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Object after load processing. Implemented as public interface for supporting objects after load in collections
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     public function afterLoad()
     {
@@ -369,7 +374,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Save object data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      * @throws \Exception
      */
     public function save()
@@ -405,7 +410,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Callback function which called after transaction commit in resource model
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     public function afterCommitCallback()
     {
@@ -437,7 +442,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Processing object before save data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -452,7 +457,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Validate model before saving it
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _validateBeforeSave()
@@ -524,7 +529,7 @@ abstract class AbstractModel extends \Magento\Object
      * Get list of cache tags applied to model object.
      * Return false if cache tags are not supported by model
      *
-     * @return array|bool
+     * @return array|false
      */
     public function getCacheTags()
     {
@@ -550,7 +555,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Get cache tags associated with object id
      *
-     * @return array
+     * @return string[]|false
      */
     public function getCacheIdTags()
     {
@@ -571,7 +576,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Remove model object related cache
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     public function cleanModelCache()
     {
@@ -585,7 +590,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Processing object after save data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -598,7 +603,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Delete object from database
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      * @throws \Exception
      */
     public function delete()
@@ -621,7 +626,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Processing object before delete data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _beforeDelete()
     {
@@ -634,6 +639,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Safeguard func that will check, if we are in admin area
      *
+     * @return void
      * @throws \Magento\Core\Exception
      */
     protected function _protectFromNonAdmin()
@@ -649,7 +655,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Processing object after delete data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _afterDelete()
     {
@@ -661,7 +667,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Processing manipulation after main transaction commit
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _afterDeleteCommit()
     {
@@ -693,7 +699,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Clearing object for correct deleting by garbage collector
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     final public function clearInstance()
     {
@@ -706,7 +712,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Clearing cyclic references
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _clearReferences()
     {
@@ -716,7 +722,7 @@ abstract class AbstractModel extends \Magento\Object
     /**
      * Clearing object's data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _clearData()
     {
diff --git a/app/code/Magento/Core/Model/AbstractShell.php b/app/code/Magento/Core/Model/AbstractShell.php
index b4b2278c5d04863e9ee49cd253878f9f24b6ab28..2f700cada36abbbb763685767e54cdc7aa70a980 100644
--- a/app/code/Magento/Core/Model/AbstractShell.php
+++ b/app/code/Magento/Core/Model/AbstractShell.php
@@ -40,7 +40,7 @@ abstract class AbstractShell
     /**
      * Raw arguments, that should be parsed
      *
-     * @var array
+     * @var string[]
      */
     protected $_rawArgs     = array();
 
@@ -86,8 +86,8 @@ abstract class AbstractShell
     /**
      * Sets raw arguments to be parsed
      *
-     * @param array $args
-     * @return \Magento\Core\Model\AbstractShell
+     * @param string[] $args
+     * @return $this
      */
     public function setRawArgs($args)
     {
@@ -99,7 +99,7 @@ abstract class AbstractShell
     /**
      * Parses .htaccess file and apply php settings to shell script
      *
-     * @return \Magento\Core\Model\AbstractShell
+     * @return $this
      */
     protected function _applyPhpVariables()
     {
@@ -127,7 +127,7 @@ abstract class AbstractShell
     /**
      * Parses input arguments
      *
-     * @return \Magento\Core\Model\AbstractShell
+     * @return $this
      */
     protected function _parseArgs()
     {
@@ -158,7 +158,7 @@ abstract class AbstractShell
     /**
      * Runs script
      *
-     * @return \Magento\Core\Model\AbstractShell
+     * @return $this
      */
     abstract public function run();
 
diff --git a/app/code/Magento/Core/Model/Acl/Cache.php b/app/code/Magento/Core/Model/Acl/Cache.php
index 9dfcaaf450c5acd34fef6c62bb72a41376538fc6..79082b4ee63864a79384eb70fdd50188e060286f 100644
--- a/app/code/Magento/Core/Model/Acl/Cache.php
+++ b/app/code/Magento/Core/Model/Acl/Cache.php
@@ -83,6 +83,7 @@ class Cache implements \Magento\Acl\CacheInterface
      * Save ACL object to cache
      *
      * @param \Magento\Acl $acl
+     * @return void
      */
     public function save(\Magento\Acl $acl)
     {
@@ -92,6 +93,8 @@ class Cache implements \Magento\Acl\CacheInterface
 
     /**
      * Clear ACL instance cache
+     *
+     * @return void
      */
     public function clean()
     {
diff --git a/app/code/Magento/Core/Model/App.php b/app/code/Magento/Core/Model/App.php
index ab9506aac54906fa22cddd3d95d242d5cf00a473..4c74f1300c6e33187bbf0e444ab8012067b4f411 100644
--- a/app/code/Magento/Core/Model/App.php
+++ b/app/code/Magento/Core/Model/App.php
@@ -23,16 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model;
 
 /**
  * Application model
  *
  * Application should have: areas, store, locale, translator, design package
  */
-namespace Magento\Core\Model;
-
-use Magento\App\CacheInterface;
-
 class App implements \Magento\AppInterface
 {
     /**#@+
@@ -53,8 +50,7 @@ class App implements \Magento\AppInterface
     /**
      * Magento version
      */
-    const VERSION = '2.0.0.0-dev64';
-
+    const VERSION = '2.0.0.0-dev65';
 
     /**
      * Application run code
@@ -91,7 +87,7 @@ class App implements \Magento\AppInterface
     /**
      * Application location object
      *
-     * @var \Magento\Core\Model\LocaleInterface
+     * @var LocaleInterface
      */
     protected $_locale;
 
@@ -196,6 +192,7 @@ class App implements \Magento\AppInterface
     /**
      * Throw an exception, if the application has not been installed yet
      *
+     * @return void
      * @throws \Magento\Exception
      */
     public function requireInstalledInstance()
@@ -219,7 +216,7 @@ class App implements \Magento\AppInterface
      * Re-declare custom error handler
      *
      * @param   string $handler
-     * @return  \Magento\Core\Model\App
+     * @return  $this
      */
     public function setErrorHandler($handler)
     {
@@ -232,7 +229,7 @@ class App implements \Magento\AppInterface
      *
      * @param   string $area
      * @param   string $part
-     * @return  \Magento\Core\Model\App
+     * @return  $this
      */
     public function loadAreaPart($area, $part)
     {
@@ -270,7 +267,7 @@ class App implements \Magento\AppInterface
     /**
      * Retrieve application locale object
      *
-     * @return \Magento\Core\Model\LocaleInterface
+     * @return LocaleInterface
      */
     public function getLocale()
     {
@@ -344,7 +341,7 @@ class App implements \Magento\AppInterface
      * Loading cache data
      *
      * @param   string $cacheId
-     * @return  mixed
+     * @return  string
      */
     public function loadCache($cacheId)
     {
@@ -358,7 +355,7 @@ class App implements \Magento\AppInterface
      * @param string $cacheId
      * @param array $tags
      * @param bool $lifeTime
-     * @return \Magento\Core\Model\App
+     * @return $this
      */
     public function saveCache($data, $cacheId, $tags = array(), $lifeTime = false)
     {
@@ -370,7 +367,7 @@ class App implements \Magento\AppInterface
      * Remove cache
      *
      * @param   string $cacheId
-     * @return  \Magento\Core\Model\App
+     * @return  $this
      */
     public function removeCache($cacheId)
     {
@@ -382,7 +379,7 @@ class App implements \Magento\AppInterface
      * Cleaning cache
      *
      * @param   array $tags
-     * @return  \Magento\Core\Model\App
+     * @return  $this
      */
     public function cleanCache($tags = array())
     {
@@ -393,7 +390,7 @@ class App implements \Magento\AppInterface
     /**
      * Deletes all session files
      *
-     * @return \Magento\Core\Model\App
+     * @return $this
      */
     public function cleanAllSessions()
     {
@@ -425,7 +422,7 @@ class App implements \Magento\AppInterface
      * Request setter
      *
      * @param \Magento\App\RequestInterface $request
-     * @return \Magento\Core\Model\App
+     * @return $this
      */
     public function setRequest(\Magento\App\RequestInterface $request)
     {
@@ -451,7 +448,7 @@ class App implements \Magento\AppInterface
      * Response setter
      *
      * @param \Magento\App\ResponseInterface $response
-     * @return \Magento\Core\Model\App
+     * @return $this
      */
     public function setResponse(\Magento\App\ResponseInterface $response)
     {
@@ -484,6 +481,7 @@ class App implements \Magento\AppInterface
      * Set edition
      *
      * @param string $edition
+     * @return void
      */
     public function setEdition($edition)
     {
@@ -518,7 +516,7 @@ class App implements \Magento\AppInterface
             'revision'  => '0',
             'patch'     => '0',
             'stability' => 'dev',
-            'number'    => '64',
+            'number'    => '65',
         );
     }
 }
diff --git a/app/code/Magento/Core/Model/App/Area.php b/app/code/Magento/Core/Model/App/Area.php
index 4e7f005fc7a0ee201f7dae1b9ebe2975d328050b..3374b3a32f231cbec20899a9768b908598eab326 100644
--- a/app/code/Magento/Core/Model/App/Area.php
+++ b/app/code/Magento/Core/Model/App/Area.php
@@ -106,7 +106,6 @@ class Area
     protected $_logger;
 
     /**
-     * @param \Magento\Logger $logger
      * Core design
      *
      * @var \Magento\Core\Model\Design
@@ -158,7 +157,7 @@ class Area
      * Load area data
      *
      * @param   string|null $part
-     * @return  \Magento\Core\Model\App\Area
+     * @return  $this
      */
     public function load($part=null)
     {
@@ -176,6 +175,7 @@ class Area
      * Detect and apply design for the area
      *
      * @param \Magento\App\RequestInterface $request
+     * @return void
      */
     public function detectDesign($request = null)
     {
@@ -231,7 +231,7 @@ class Area
      * Loading part of area
      *
      * @param   string $part
-     * @return  \Magento\Core\Model\App\Area
+     * @return  $this
      */
     protected function _loadPart($part)
     {
@@ -258,6 +258,8 @@ class Area
 
     /**
      * Load area configuration
+     *
+     * @return void
      */
     protected function _initConfig()
     {
@@ -267,7 +269,7 @@ class Area
     /**
      * Initialize translate object.
      *
-     * @return \Magento\Core\Model\App\Area
+     * @return $this
      */
     protected function _initTranslate()
     {
@@ -286,6 +288,9 @@ class Area
         return $this;
     }
 
+    /**
+     * @return void
+     */
     protected function _initDesign()
     {
         $this->_getDesign()->setArea($this->_code)->setDefaultDesignTheme();
diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Core/Model/App/Emulation.php
index 5af97ec89c611071f2d4eadd4319d9655ac23c18..e6892c03653f500c5866830f75318da10151aebb 100644
--- a/app/code/Magento/Core/Model/App/Emulation.php
+++ b/app/code/Magento/Core/Model/App/Emulation.php
@@ -121,7 +121,6 @@ class Emulation extends \Magento\Object
      * @param integer $storeId
      * @param string $area
      * @param bool $emulateStoreInlineTranslation emulate inline translation of the specified store or just disable it
-     *
      * @return \Magento\Object information about environment of the initial store
      */
     public function startEnvironmentEmulation($storeId, $area = \Magento\Core\Model\App\Area::AREA_FRONTEND,
@@ -152,7 +151,6 @@ class Emulation extends \Magento\Object
      * Function restores initial store environment
      *
      * @param \Magento\Object $initialEnvironmentInfo information about environment of the initial store
-     *
      * @return \Magento\Core\Model\App\Emulation
      */
     public function stopEnvironmentEmulation(\Magento\Object $initialEnvironmentInfo)
@@ -172,7 +170,6 @@ class Emulation extends \Magento\Object
      * Function disables inline translation if $storeId is null
      *
      * @param integer|null $storeId
-     *
      * @return boolean initial inline translation state
      */
     protected function _emulateInlineTranslation($storeId = null)
@@ -192,7 +189,6 @@ class Emulation extends \Magento\Object
      *
      * @param integer $storeId
      * @param string $area
-     *
      * @return array initial design parameters(package, store, area)
      */
     protected function _emulateDesign($storeId, $area = \Magento\Core\Model\App\Area::AREA_FRONTEND)
@@ -222,7 +218,6 @@ class Emulation extends \Magento\Object
      *
      * @param integer $storeId
      * @param string $area
-     *
      * @return string initial locale code
      */
     protected function _emulateLocale($storeId, $area = \Magento\Core\Model\App\Area::AREA_FRONTEND)
@@ -241,8 +236,7 @@ class Emulation extends \Magento\Object
      * Restore initial inline translation state
      *
      * @param bool $initialTranslate
-     *
-     * @return \Magento\Core\Model\App\Emulation
+     * @return $this
      */
     protected function _restoreInitialInlineTranslation($initialTranslate)
     {
@@ -254,8 +248,7 @@ class Emulation extends \Magento\Object
      * Restore design of the initial store
      *
      * @param array $initialDesign
-     *
-     * @return \Magento\Core\Model\App\Emulation
+     * @return $this
      */
     protected function _restoreInitialDesign(array $initialDesign)
     {
@@ -268,8 +261,7 @@ class Emulation extends \Magento\Object
      *
      * @param string $initialLocaleCode
      * @param string $initialArea
-     *
-     * @return \Magento\Core\Model\App\Emulation
+     * @return $this
      */
     protected function _restoreInitialLocale($initialLocaleCode, $initialArea = \Magento\Core\Model\App\Area::AREA_ADMIN)
     {
diff --git a/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php b/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php
index e7363b8f71e17813ea768869b1456665e3949f3b..99f9cf528f5d3bda8e94b2007a31b3cccb12cac2 100644
--- a/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php
+++ b/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php
@@ -53,6 +53,7 @@ class CleanMergedJsCss
      *
      * @param array $arguments
      * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @return void
      */
     public function aroundCleanMergedJsCss(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
     {
diff --git a/app/code/Magento/Core/Model/Calculator.php b/app/code/Magento/Core/Model/Calculator.php
index 6f7def75bdd4eb7c06e12eed7148cba253a56248..b3082090cf2e980fce8550cf4713adfe5f4aedd4 100644
--- a/app/code/Magento/Core/Model/Calculator.php
+++ b/app/code/Magento/Core/Model/Calculator.php
@@ -46,17 +46,17 @@ class Calculator
     /**
      * Store instance
      *
-     * @var \Magento\Core\Model\Store|null
+     * @var Store|null
      */
     protected $_store = null;
 
     /**
      * Initialize calculator
      *
-     * @param \Magento\Core\Model\Store|int $store
-     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param Store|int $store
+     * @param StoreManagerInterface $storeManager
      */
-    public function __construct($store, \Magento\Core\Model\StoreManagerInterface $storeManager)
+    public function __construct($store, StoreManagerInterface $storeManager)
     {
         if (!($store instanceof \Magento\Core\Model\Store)) {
             $store = $storeManager->getStore($store);
diff --git a/app/code/Magento/Core/Model/Config/Base.php b/app/code/Magento/Core/Model/Config/Base.php
index 811fa8b2ee6c796cd7ca56e30abd0619c28de794..a454800d32b7cba1eb4c0d42db58d1e66b143285 100644
--- a/app/code/Magento/Core/Model/Config/Base.php
+++ b/app/code/Magento/Core/Model/Config/Base.php
@@ -33,7 +33,7 @@ class Base extends \Magento\Simplexml\Config
     /**
      * List of instances
      *
-     * @var array
+     * @var Base[]
      */
     public static $instances = array();
 
@@ -49,6 +49,8 @@ class Base extends \Magento\Simplexml\Config
 
     /**
      * Cleanup objects because of simplexml memory leak
+     *
+     * @return void
      */
     public static function destroy()
     {
diff --git a/app/code/Magento/Core/Model/Config/Cache.php b/app/code/Magento/Core/Model/Config/Cache.php
index e93addc966aa3f46cb0ce00e7d3f0dcbd2c35eea..51f51f4b52db76e7860a0e42d59fb2ea9b8b65bb 100644
--- a/app/code/Magento/Core/Model/Config/Cache.php
+++ b/app/code/Magento/Core/Model/Config/Cache.php
@@ -75,6 +75,7 @@ class Cache
      * Set cache lifetime
      *
      * @param int $lifetime
+     * @return void
      */
     public function setCacheLifetime($lifetime)
     {
@@ -109,6 +110,7 @@ class Cache
      * Save config cache
      *
      * @param \Magento\Core\Model\Config\Base $config
+     * @return void
      */
     public function save(\Magento\Core\Model\Config\Base $config)
     {
diff --git a/app/code/Magento/Core/Model/Config/FileResolver.php b/app/code/Magento/Core/Model/Config/FileResolver.php
index f2568be5d4186603b0c57cb9e8db812f88351679..5c97f1c35075dc99a4004cc151e50c78cbf9a3d7 100644
--- a/app/code/Magento/Core/Model/Config/FileResolver.php
+++ b/app/code/Magento/Core/Model/Config/FileResolver.php
@@ -57,7 +57,7 @@ class FileResolver implements \Magento\Config\FileResolverInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function get($filename, $scope)
     {
diff --git a/app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php b/app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php
index e1e06eec00172d90a6744ea7d97832b474805686..28ddcb37d2828db5b3da4c8e045d61455782f59a 100644
--- a/app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php
+++ b/app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php
@@ -57,8 +57,9 @@ class Placeholder
     /**
      * Process array data recursively
      *
-     * @param array $data
+     * @param array &$data
      * @param string $path
+     * @return void
      */
     protected function _processData(&$data, $path)
     {
@@ -129,7 +130,7 @@ class Placeholder
      *
      * @param string $path
      * @param array $data
-     * @return mixed
+     * @return array|null
      */
     protected function _getValue($path, array $data)
     {
@@ -147,9 +148,10 @@ class Placeholder
     /**
      * Set array value by path
      *
-     * @param array $container
+     * @param array &$container
      * @param string $path
      * @param string $value
+     * @return void
      */
     protected function _setValue(array &$container, $path, $value)
     {
diff --git a/app/code/Magento/Core/Model/Config/Storage/Db.php b/app/code/Magento/Core/Model/Config/Storage/Db.php
index c6b9c6f86efc481fdf103393685b1e79d70e9198..aee79c7305e19a9c30c2db34cab4a9666a8af316 100644
--- a/app/code/Magento/Core/Model/Config/Storage/Db.php
+++ b/app/code/Magento/Core/Model/Config/Storage/Db.php
@@ -48,6 +48,7 @@ class Db implements \Magento\App\Config\Storage\WriterInterface
      * @param   string $path
      * @param   string $scope
      * @param   int $scopeId
+     * @return  void
      */
     public function delete($path, $scope = \Magento\Core\Model\Store::DEFAULT_CODE, $scopeId = 0)
     {
@@ -61,6 +62,7 @@ class Db implements \Magento\App\Config\Storage\WriterInterface
      * @param string $value
      * @param string $scope
      * @param int $scopeId
+     * @return void
      */
     public function save($path, $value, $scope = \Magento\Core\Model\Store::DEFAULT_CODE, $scopeId = 0)
     {
diff --git a/app/code/Magento/Core/Model/Config/Value.php b/app/code/Magento/Core/Model/Config/Value.php
index 48c82758c41f5f81e3c98301ecb22e497e9b8067..306f0683e6a505832fd116d51fa2cdf47b3272ee 100644
--- a/app/code/Magento/Core/Model/Config/Value.php
+++ b/app/code/Magento/Core/Model/Config/Value.php
@@ -95,6 +95,8 @@ class Value extends \Magento\Core\Model\AbstractModel implements \Magento\App\Co
 
     /**
      * Magento model constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -103,6 +105,8 @@ class Value extends \Magento\Core\Model\AbstractModel implements \Magento\App\Co
 
     /**
      * Add availability call after load as public
+     *
+     * @return void
      */
     public function afterLoad()
     {
diff --git a/app/code/Magento/Core/Model/Date.php b/app/code/Magento/Core/Model/Date.php
index 2150db108040f199ace00f652abb90ef7c4d5ace..8f03e11353280495ac952d4b1151aa7526628e41 100644
--- a/app/code/Magento/Core/Model/Date.php
+++ b/app/code/Magento/Core/Model/Date.php
@@ -40,14 +40,14 @@ class Date
     private $_offset = 0;
 
     /**
-     * @var \Magento\Core\Model\LocaleInterface
+     * @var LocaleInterface
      */
     protected $_locale;
 
     /**
      * @param LocaleInterface $locale
      */
-    public function __construct(\Magento\Core\Model\LocaleInterface $locale)
+    public function __construct(LocaleInterface $locale)
     {
         $this->_locale = $locale;
         $this->_offset = $this->calculateOffset($locale->getConfigTimezone());
@@ -56,7 +56,7 @@ class Date
     /**
      * Calculates timezone offset
      *
-     * @param  string $timezone
+     * @param  string|null $timezone
      * @return int offset between timezone and gmt
      */
     public function calculateOffset($timezone = null)
diff --git a/app/code/Magento/Core/Model/Design.php b/app/code/Magento/Core/Model/Design.php
index 0d7f47744054de56de1ef482c192bdcea1845071..bef938c6dace90e3150f0c95cf97e0a77b21fbd9 100644
--- a/app/code/Magento/Core/Model/Design.php
+++ b/app/code/Magento/Core/Model/Design.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model;
 
+use Magento\Core\Model\Resource\AbstractResource;
+
 /**
  * Design settings change model
  *
@@ -40,7 +41,7 @@ namespace Magento\Core\Model;
  * @method string getDateTo()
  * @method \Magento\Core\Model\Design setDateTo(string $value)
  */
-class Design extends \Magento\Core\Model\AbstractModel
+class Design extends AbstractModel
 {
     /**
      * Cache tag
@@ -64,7 +65,7 @@ class Design extends \Magento\Core\Model\AbstractModel
     protected $_cacheTag = self::CACHE_TAG;
 
     /**
-     * @var \Magento\Core\Model\LocaleInterface
+     * @var LocaleInterface
      */
     protected $_locale;
 
@@ -78,16 +79,16 @@ class Design extends \Magento\Core\Model\AbstractModel
      * @param Registry $registry
      * @param LocaleInterface $locale
      * @param \Magento\Stdlib\DateTime $dateTime
-     * @param Resource\AbstractResource $resource
+     * @param AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
      */
     public function __construct(
-        \Magento\Core\Model\Context $context,
-        \Magento\Core\Model\Registry $registry,
-        \Magento\Core\Model\LocaleInterface $locale,
+        Context $context,
+        Registry $registry,
+        LocaleInterface $locale,
         \Magento\Stdlib\DateTime $dateTime,
-        \Magento\Core\Model\Resource\AbstractResource $resource = null,
+        AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
         array $data = array()
     ) {
@@ -98,6 +99,8 @@ class Design extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initialize resource model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -109,7 +112,7 @@ class Design extends \Magento\Core\Model\AbstractModel
      *
      * @param string $storeId
      * @param string|null $date
-     * @return \Magento\Core\Model\Design
+     * @return $this
      */
     public function loadChange($storeId, $date = null)
     {
@@ -140,7 +143,7 @@ class Design extends \Magento\Core\Model\AbstractModel
      * Apply design change from self data into specified design package instance
      *
      * @param \Magento\View\DesignInterface $packageInto
-     * @return \Magento\Core\Model\Design
+     * @return $this
      */
     public function changeDesign(\Magento\View\DesignInterface $packageInto)
     {
diff --git a/app/code/Magento/Core/Model/Design/Backend/Exceptions.php b/app/code/Magento/Core/Model/Design/Backend/Exceptions.php
index 492d8d3ea714a4d13e8f69630e2e3c6e37f109a0..ae880801ba1a4c4d19c262ec601a4d6c7d0cc4ff 100644
--- a/app/code/Magento/Core/Model/Design/Backend/Exceptions.php
+++ b/app/code/Magento/Core/Model/Design/Backend/Exceptions.php
@@ -62,6 +62,7 @@ class Exceptions extends \Magento\Backend\Model\Config\Backend\Serialized\ArrayS
     /**
      * Validate value
      *
+     * @return $this
      * @throws \Magento\Core\Exception
      * if there is no field value, search value is empty or regular expression is not valid
      */
diff --git a/app/code/Magento/Core/Model/Design/Backend/Theme.php b/app/code/Magento/Core/Model/Design/Backend/Theme.php
index f94fe88bc44c044d3ca25ef6859fcd96fab939af..6ea657a59a63d3dd07aafa28db24d107f8f31315 100644
--- a/app/code/Magento/Core/Model/Design/Backend/Theme.php
+++ b/app/code/Magento/Core/Model/Design/Backend/Theme.php
@@ -61,6 +61,8 @@ class Theme extends \Magento\Core\Model\Config\Value
 
     /**
      * Validate specified value against frontend area
+     *
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Core/Model/EntityFactory.php b/app/code/Magento/Core/Model/EntityFactory.php
index 6f2966a45921c5c902935f0867849a9b1e739dab..18a93d802e280e7721cec4aef6856afbb62ae68b 100644
--- a/app/code/Magento/Core/Model/EntityFactory.php
+++ b/app/code/Magento/Core/Model/EntityFactory.php
@@ -17,11 +17,10 @@
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
- *   
+ *
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model;
 
 class EntityFactory implements \Magento\Data\Collection\EntityFactoryInterface
@@ -46,7 +45,7 @@ class EntityFactory implements \Magento\Data\Collection\EntityFactoryInterface
     /**
      * Create class instance with specified parameters
      *
-     * @param $className
+     * @param string $className
      * @param array $data
      * @throws \LogicException
      * @return \Magento\Object
diff --git a/app/code/Magento/Core/Model/Factory.php b/app/code/Magento/Core/Model/Factory.php
index 0cc09866f9d4c910d685ffd1fe2b3d6e86069df0..028b62ed452c147946acb55bbd81104d359effd9 100644
--- a/app/code/Magento/Core/Model/Factory.php
+++ b/app/code/Magento/Core/Model/Factory.php
@@ -50,7 +50,7 @@ class Factory
      * @param string $model
      * @param array $data
      * @throws \InvalidArgumentException
-     * @return \Magento\Core\Model\AbstractModel
+     * @return AbstractModel
      */
     public function create($model, array $data = array())
     {
diff --git a/app/code/Magento/Core/Model/File/Storage.php b/app/code/Magento/Core/Model/File/Storage.php
index d0bed5f4155051bdc0064c2bcac7b1020e63140b..e33e561b8a68c4bd7b300de4bb6d556b5cc79e56 100644
--- a/app/code/Magento/Core/Model/File/Storage.php
+++ b/app/code/Magento/Core/Model/File/Storage.php
@@ -26,12 +26,13 @@
 
 namespace Magento\Core\Model\File;
 
-use \Magento\App\Filesystem;
+use Magento\App\Filesystem;
+use Magento\Core\Model\AbstractModel;
 
 /**
  * Class Storage
  */
-class Storage extends \Magento\Core\Model\AbstractModel
+class Storage extends AbstractModel
 {
     /**
      * Storage systems ids
@@ -141,11 +142,12 @@ class Storage extends \Magento\Core\Model\AbstractModel
     /**
      * Show if there were errors while synchronize process
      *
-     * @param $sourceModel
-     * @param $destinationModel
+     * @param AbstractModel $sourceModel
+     * @param AbstractModel $destinationModel
      * @return bool
      */
-    protected function _synchronizeHasErrors($sourceModel, $destinationModel) {
+    protected function _synchronizeHasErrors($sourceModel, $destinationModel)
+    {
         if (!$sourceModel || !$destinationModel) {
             return true;
         }
@@ -174,7 +176,7 @@ class Storage extends \Magento\Core\Model\AbstractModel
      *
      * @param  int|null $storage
      * @param  array $params
-     * @return \Magento\Core\Model\AbstractModel|bool
+     * @return AbstractModel|bool
      */
     public function getStorageModel($storage = null, $params = array())
     {
@@ -209,7 +211,7 @@ class Storage extends \Magento\Core\Model\AbstractModel
      * )
      *
      * @param  array $storage
-     * @return \Magento\Core\Model\File\Storage
+     * @return $this
      */
     public function synchronize($storage)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Config.php b/app/code/Magento/Core/Model/File/Storage/Config.php
index 319f86bc8dd85bb4e6c444a1c66a61baec9284b2..31ff131fc8ac1879ee6da43366d9d592c9dbd7a8 100644
--- a/app/code/Magento/Core/Model/File/Storage/Config.php
+++ b/app/code/Magento/Core/Model/File/Storage/Config.php
@@ -87,6 +87,8 @@ class Config
 
     /**
      * Save config in cache file
+     *
+     * @return void
      */
     public function save()
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Database.php b/app/code/Magento/Core/Model/File/Storage/Database.php
index 92e2a0a118aec64bc59325604ff5567113d33ba2..0d143fb025e8908d7f3e09b2e206c195f5f3f177 100644
--- a/app/code/Magento/Core/Model/File/Storage/Database.php
+++ b/app/code/Magento/Core/Model/File/Storage/Database.php
@@ -48,7 +48,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
     /**
      * Collect errors during sync process
      *
-     * @var array
+     * @var string[]
      */
     protected $_errors = array();
 
@@ -121,7 +121,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
     /**
      * Create tables for file and directory storages
      *
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function init()
     {
@@ -145,7 +145,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Load object data by filename
      *
      * @param  string $filePath
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function loadByFilename($filePath)
     {
@@ -168,7 +168,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
     /**
      * Clear files and directories in storage
      *
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function clear()
     {
@@ -184,7 +184,8 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * @param  int $count
      * @return bool|array
      */
-    public function exportDirectories($offset = 0, $count = 100) {
+    public function exportDirectories($offset = 0, $count = 100)
+    {
         return $this->getDirectoryModel()->exportDirectories($offset, $count);
     }
 
@@ -194,7 +195,8 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * @param  array $dirs
      * @return \Magento\Core\Model\File\Storage\Directory\Database
      */
-    public function importDirectories($dirs) {
+    public function importDirectories($dirs)
+    {
         return $this->getDirectoryModel()->importDirectories($dirs);
     }
 
@@ -222,7 +224,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Import files list
      *
      * @param  array $files
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function importFiles($files)
     {
@@ -257,7 +259,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Store file into database
      *
      * @param  string $filename
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function saveFile($filename)
     {
@@ -292,7 +294,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      *
      * @param  string $oldFilePath
      * @param  string $newFilePath
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function copyFile($oldFilePath, $newFilePath)
     {
@@ -311,7 +313,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      *
      * @param  string $oldFilePath
      * @param  string $newFilePath
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function renameFile($oldFilePath, $newFilePath)
     {
@@ -341,7 +343,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Return directory listing
      *
      * @param string $directory
-     * @return mixed
+     * @return array
      */
     public function getDirectoryFiles($directory)
     {
@@ -353,7 +355,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Delete file from database
      *
      * @param string $path
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function deleteFile($path)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php b/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php
index 0f518acb4289e0bfdab69f4c74843ed94824bc35..34bb514b1c18e5d318f562792222512467340f31 100644
--- a/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php
+++ b/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php
@@ -120,7 +120,7 @@ abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel
     /**
      * Prepare data storage
      *
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @return $this
      */
     public function prepareStorage()
     {
@@ -132,8 +132,8 @@ abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel
     /**
      * Specify connection name
      *
-     * @param  $connectionName
-     * @return \Magento\Core\Model\File\Storage\Database
+     * @param  string $connectionName
+     * @return $this
      */
     public function setConnectionName($connectionName)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Directory/Database.php b/app/code/Magento/Core/Model/File/Storage/Directory/Database.php
index 8f7b5960504e12cd806a652e0e4953625832dca4..a039265521e0053c585ce6715270bd398f5dff1b 100644
--- a/app/code/Magento/Core/Model/File/Storage/Directory/Database.php
+++ b/app/code/Magento/Core/Model/File/Storage/Directory/Database.php
@@ -41,7 +41,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
     /**
      * Collect errors during sync process
      *
-     * @var array
+     * @var string[]
      */
     protected $_errors = array();
 
@@ -93,7 +93,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Load object data by path
      *
      * @param  string $path
-     * @return \Magento\Core\Model\File\Storage\Directory\Database
+     * @return $this
      */
     public function loadByPath($path)
     {
@@ -148,7 +148,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Create directories recursively
      *
      * @param  string $path
-     * @return \Magento\Core\Model\File\Storage\Directory\Database
+     * @return $this
      */
     public function createRecursive($path)
     {
@@ -201,7 +201,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      *
      * @param  array $dirs
      * @throws \Magento\Core\Exception
-     * @return \Magento\Core\Model\File\Storage\Directory\Database
+     * @return $this
      */
     public function importDirectories($dirs)
     {
@@ -239,7 +239,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
     /**
      * Clean directories at storage
      *
-     * @return \Magento\Core\Model\File\Storage\Directory\Database
+     * @return $this
      */
     public function clearDirectories()
     {
@@ -251,7 +251,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Return subdirectories
      *
      * @param string $directory
-     * @return mixed
+     * @return array
      */
     public function getSubdirectories($directory)
     {
@@ -264,7 +264,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas
      * Delete directory from database
      *
      * @param string $dirPath
-     * @return \Magento\Core\Model\File\Storage\Directory\Database
+     * @return $this
      */
     public function deleteDirectory($dirPath)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/File.php b/app/code/Magento/Core/Model/File/Storage/File.php
index 8b7cc1e71a3d0ddc4a553f2ef7962cfc2ad2e557..a2170de7675193ad4b123850ddd0dfe9beca839a 100644
--- a/app/code/Magento/Core/Model/File/Storage/File.php
+++ b/app/code/Magento/Core/Model/File/Storage/File.php
@@ -67,7 +67,7 @@ class File
     /**
      * Collect errors during sync process
      *
-     * @var array
+     * @var string[]
      */
     protected $_errors = array();
 
@@ -97,7 +97,7 @@ class File
     /**
      * Initialization
      *
-     * @return \Magento\Core\Model\File\Storage\File
+     * @return $this
      */
     public function init()
     {
@@ -137,7 +137,7 @@ class File
     /**
      * Clear files and directories in storage
      *
-     * @return \Magento\Core\Model\File\Storage\File
+     * @return $this
      */
     public function clear()
     {
@@ -230,7 +230,7 @@ class File
      *
      * @param  array $data
      * @param  string $callback
-     * @return \Magento\Core\Model\File\Storage\File
+     * @return $this
      */
     public function import($data, $callback)
     {
@@ -254,7 +254,7 @@ class File
      * Import directories to storage
      *
      * @param  array $dirs
-     * @return \Magento\Core\Model\File\Storage\File
+     * @return $this
      */
     public function importDirectories($dirs)
     {
@@ -265,7 +265,7 @@ class File
      * Import files list
      *
      * @param  array $files
-     * @return \Magento\Core\Model\File\Storage\File
+     * @return $this
      */
     public function importFiles($files)
     {
@@ -286,10 +286,10 @@ class File
     /**
      * Save file to storage
      *
-     * @param  array|\Magento\Core\Model\File\Storage\Database $file
+     * @param  array $file
      * @param  bool $overwrite
      * @throws \Magento\Core\Exception
-     * @return bool|int
+     * @return bool
      */
     public function saveFile($file, $overwrite = true)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Flag.php b/app/code/Magento/Core/Model/File/Storage/Flag.php
index e85965941e07cc84c2c2ca52f09fe0256a9c4fe0..090b520701d19d8084d89c1ccefe1d5ef3f85211 100644
--- a/app/code/Magento/Core/Model/File/Storage/Flag.php
+++ b/app/code/Magento/Core/Model/File/Storage/Flag.php
@@ -69,7 +69,7 @@ class Flag extends \Magento\Core\Model\Flag
      * Pass error to flag
      *
      * @param \Exception $e
-     * @return \Magento\Core\Model\File\Storage\Flag
+     * @return $this
      */
     public function passError(\Exception $e)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Response.php b/app/code/Magento/Core/Model/File/Storage/Response.php
index 77dcf25ae4f23137608e09f5f13c50e54dc67717..9350014a2d15adb9c9507618cf801bae7354894a 100644
--- a/app/code/Magento/Core/Model/File/Storage/Response.php
+++ b/app/code/Magento/Core/Model/File/Storage/Response.php
@@ -49,6 +49,8 @@ class Response extends Http
 
     /**
      * Send response
+     *
+     * @return void
      */
     public function sendResponse()
     {
@@ -61,6 +63,7 @@ class Response extends Http
 
     /**
      * @param string $path
+     * @return void
      */
     public function setFilePath($path)
     {
diff --git a/app/code/Magento/Core/Model/File/Storage/Synchronization.php b/app/code/Magento/Core/Model/File/Storage/Synchronization.php
index 0da6710e83871f4550277883d8a442fe3484391a..d0dc414a59677dc6e1841f5b7d19cf49b40068c4 100644
--- a/app/code/Magento/Core/Model/File/Storage/Synchronization.php
+++ b/app/code/Magento/Core/Model/File/Storage/Synchronization.php
@@ -64,6 +64,7 @@ class Synchronization
      *
      * @param string $relativeFileName
      * @param string $filePath
+     * @return void
      * @throws \LogicException
      */
     public function synchronize($relativeFileName, $filePath)
diff --git a/app/code/Magento/Core/Model/File/Uploader.php b/app/code/Magento/Core/Model/File/Uploader.php
index ac2fc7f05fa040bf879e482b7e2dfd35f277aac0..a24655193bd291f0b73e0f25f8d726900859c8d2 100644
--- a/app/code/Magento/Core/Model/File/Uploader.php
+++ b/app/code/Magento/Core/Model/File/Uploader.php
@@ -84,7 +84,7 @@ class Uploader extends \Magento\File\Uploader
      * Save file to storage
      *
      * @param  array $result
-     * @return \Magento\Core\Model\File\Uploader
+     * @return $this
      */
     protected function _afterSave($result)
     {
diff --git a/app/code/Magento/Core/Model/File/Validator/AvailablePath.php b/app/code/Magento/Core/Model/File/Validator/AvailablePath.php
index fbd9db2ed2796b30e5e1b8169ddc3349bcdd2acd..104429563340cc5d3e585b711e050e46eaf17e1b 100644
--- a/app/code/Magento/Core/Model/File/Validator/AvailablePath.php
+++ b/app/code/Magento/Core/Model/File/Validator/AvailablePath.php
@@ -65,14 +65,14 @@ class AvailablePath extends \Zend_Validate_Abstract
     /**
      * Protected paths
      *
-     * @var array
+     * @var string[]
      */
     protected $_protectedPaths = array();
 
     /**
      * Available paths
      *
-     * @var array
+     * @var string[]
      */
     protected $_availablePaths = array();
 
@@ -94,7 +94,7 @@ class AvailablePath extends \Zend_Validate_Abstract
     /**
      * Initialize message templates with translating
      *
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @return $this
      */
     protected function _initMessageTemplates()
     {
@@ -116,7 +116,7 @@ class AvailablePath extends \Zend_Validate_Abstract
      *
      * @param array $paths  All paths masks types.
      *                      E.g.: array('available' => array(...), 'protected' => array(...))
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @return $this
      */
     public function setPaths(array $paths)
     {
@@ -133,7 +133,7 @@ class AvailablePath extends \Zend_Validate_Abstract
      * Set protected paths masks
      *
      * @param array $paths
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @return $this
      */
     public function setProtectedPaths(array $paths)
     {
@@ -144,8 +144,8 @@ class AvailablePath extends \Zend_Validate_Abstract
     /**
      * Add protected paths masks
      *
-     * @param string|array $path
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @param string|string[] $path
+     * @return $this
      */
     public function addProtectedPath($path)
     {
@@ -160,7 +160,7 @@ class AvailablePath extends \Zend_Validate_Abstract
     /**
      * Get protected paths masks
      *
-     * @return array
+     * @return string[]
      */
     public function getProtectedPaths()
     {
@@ -171,7 +171,7 @@ class AvailablePath extends \Zend_Validate_Abstract
      * Set available paths masks
      *
      * @param array $paths
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @return $this
      */
     public function setAvailablePaths(array $paths)
     {
@@ -182,8 +182,8 @@ class AvailablePath extends \Zend_Validate_Abstract
     /**
      * Add available paths mask
      *
-     * @param string|array $path
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @param string|string[] $path
+     * @return $this
      */
     public function addAvailablePath($path)
     {
@@ -198,7 +198,7 @@ class AvailablePath extends \Zend_Validate_Abstract
     /**
      * Get available paths masks
      *
-     * @return array
+     * @return string[]
      */
     public function getAvailablePaths()
     {
@@ -213,9 +213,9 @@ class AvailablePath extends \Zend_Validate_Abstract
      * getMessages() will return an array of messages that explain why the
      * validation failed.
      *
-     * @throws \Exception        Throw exception on empty both paths masks types
      * @param string $value     File/dir path
      * @return bool
+     * @throws \Exception       Throw exception on empty both paths masks types
      */
     public function isValid($value)
     {
@@ -254,7 +254,7 @@ class AvailablePath extends \Zend_Validate_Abstract
      * Validate value by path masks
      *
      * @param array $valuePathInfo  Path info from value path
-     * @param array $paths          Protected/available paths masks
+     * @param string[] $paths          Protected/available paths masks
      * @param bool $protected       Paths masks is protected?
      * @return bool
      */
diff --git a/app/code/Magento/Core/Model/File/Validator/NotProtectedExtension.php b/app/code/Magento/Core/Model/File/Validator/NotProtectedExtension.php
index df4dcbfe1d06dc43eb3cf11ea89d8e2096b51f33..78ac889c14a77470d95d7e24c861a3a2d1090d64 100644
--- a/app/code/Magento/Core/Model/File/Validator/NotProtectedExtension.php
+++ b/app/code/Magento/Core/Model/File/Validator/NotProtectedExtension.php
@@ -51,7 +51,7 @@ class NotProtectedExtension extends \Zend_Validate_Abstract
     /**
      * Protected file types
      *
-     * @var array
+     * @var string[]
      */
     protected $_protectedFileExtensions = array();
 
@@ -77,7 +77,7 @@ class NotProtectedExtension extends \Zend_Validate_Abstract
     /**
      * Initialize message templates with translating
      *
-     * @return \Magento\Core\Model\File\Validator\NotProtectedExtension
+     * @return $this
      */
     protected function _initMessageTemplates()
     {
@@ -92,7 +92,7 @@ class NotProtectedExtension extends \Zend_Validate_Abstract
     /**
      * Initialize protected file extensions
      *
-     * @return \Magento\Core\Model\File\Validator\NotProtectedExtension
+     * @return $this
      */
     protected function _initProtectedFileExtensions()
     {
@@ -113,7 +113,7 @@ class NotProtectedExtension extends \Zend_Validate_Abstract
      * Return list with protected file extensions
      *
      * @param \Magento\Core\Model\Store|string|int $store
-     * @return array
+     * @return string|string[]
      */
     public function getProtectedFileExtensions($store = null)
     {
diff --git a/app/code/Magento/Core/Model/Flag.php b/app/code/Magento/Core/Model/Flag.php
index f0cde391fc253364871df5b3ee48839dd45c616a..52672980b0305a8d2024d1b06416009e37c43579 100644
--- a/app/code/Magento/Core/Model/Flag.php
+++ b/app/code/Magento/Core/Model/Flag.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model;
 
 /**
  * Core Flag model
@@ -41,9 +41,7 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model;
-
-class Flag extends \Magento\Core\Model\AbstractModel
+class Flag extends AbstractModel
 {
     /**
      * Flag code
@@ -56,6 +54,7 @@ class Flag extends \Magento\Core\Model\AbstractModel
      * Init resource model
      * Set flag_code if it is specified in arguments
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -69,7 +68,7 @@ class Flag extends \Magento\Core\Model\AbstractModel
      * Processing object before save data
      *
      * @throws \Magento\Core\Exception
-     * @return \Magento\Core\Model\Flag
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -101,7 +100,7 @@ class Flag extends \Magento\Core\Model\AbstractModel
      * Set flag data
      *
      * @param mixed $value
-     * @return \Magento\Core\Model\Flag
+     * @return $this
      */
     public function setFlagData($value)
     {
@@ -112,7 +111,7 @@ class Flag extends \Magento\Core\Model\AbstractModel
      * load self (load by flag code)
      *
      * @throws \Magento\Core\Exception
-     * @return \Magento\Core\Model\Flag
+     * @return $this
      */
     public function loadSelf()
     {
diff --git a/app/code/Magento/Core/Model/Image/Adapter/Config.php b/app/code/Magento/Core/Model/Image/Adapter/Config.php
index b19d4d696a096f14e9f370d1f13b5d61e1a44133..de696532eb4fde4f8987575b84628609a929a0b8 100644
--- a/app/code/Magento/Core/Model/Image/Adapter/Config.php
+++ b/app/code/Magento/Core/Model/Image/Adapter/Config.php
@@ -43,6 +43,8 @@ class Config implements \Magento\Image\Adapter\ConfigInterface
 
     /**
      * {@inherit}
+     *
+     * @return string
      */
     public function getAdapterAlias()
     {
@@ -51,6 +53,8 @@ class Config implements \Magento\Image\Adapter\ConfigInterface
 
     /**
      * {@inherit}
+     *
+     * @return mixed
      */
     public function getAdapters()
     {
diff --git a/app/code/Magento/Core/Model/Input/Filter.php b/app/code/Magento/Core/Model/Input/Filter.php
index 6f7ab7ace7b24d358e15ddaa1200b291312e0521..12398b75af76e9543a780385fc0a0e312b0687af 100644
--- a/app/code/Magento/Core/Model/Input/Filter.php
+++ b/app/code/Magento/Core/Model/Input/Filter.php
@@ -126,7 +126,7 @@ class Filter implements \Zend_Filter_Interface
      * @param string $name
      * @param array|\Zend_Filter_Interface $filter
      * @param string $placement
-     * @return \Magento\Core\Model\Input\Filter
+     * @return $this
      */
     public function addFilter($name, $filter, $placement = \Zend_Filter::CHAIN_APPEND)
     {
@@ -142,7 +142,7 @@ class Filter implements \Zend_Filter_Interface
      * Add a filter to the end of the chain
      *
      * @param  array|\Zend_Filter_Interface $filter
-     * @return \Magento\Core\Model\Input\Filter
+     * @return $this
      */
     public function appendFilter(\Zend_Filter_Interface $filter)
     {
@@ -153,7 +153,7 @@ class Filter implements \Zend_Filter_Interface
      * Add a filter to the start of the chain
      *
      * @param  array|\Zend_Filter_Interface $filter
-     * @return \Magento\Core\Model\Input\Filter
+     * @return $this
      */
     public function prependFilter($filter)
     {
@@ -171,7 +171,7 @@ class Filter implements \Zend_Filter_Interface
      *      )
      *
      * @param array $filters
-     * @return \Magento\Core\Model\Input\Filter
+     * @return $this
      */
     public function addFilters(array $filters)
     {
@@ -183,7 +183,7 @@ class Filter implements \Zend_Filter_Interface
      * Set filters
      *
      * @param array $filters
-     * @return \Magento\Core\Model\Input\Filter
+     * @return $this
      */
     public function setFilters(array $filters)
     {
@@ -194,8 +194,8 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Get filters
      *
-     * @param string|null $name     Get filter for selected name
-     * @return array
+     * @param string|null $name Get filter for selected name
+     * @return array|\Zend_Filter_Interface
      */
     public function getFilters($name = null)
     {
@@ -210,7 +210,7 @@ class Filter implements \Zend_Filter_Interface
      * Filter data
      *
      * @param array $data
-     * @return array    Return filtered data
+     * @return array Return filtered data
      */
     public function filter($data)
     {
@@ -264,6 +264,7 @@ class Filter implements \Zend_Filter_Interface
      * @param \Magento\App\Helper\AbstractHelper $helper
      * @param array $filterData
      * @return mixed
+     * @throws \Exception
      */
     protected function _applyFiltrationWithHelper($value, \Magento\App\Helper\AbstractHelper $helper, array $filterData)
     {
@@ -282,8 +283,8 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Try to create Magento helper for filtration based on $filterData. Return false on failure
      *
-     * @param $filterData
-     * @return bool|\Magento\App\Helper\AbstractHelper
+     * @param \Zend_Filter_Interface|array $filterData
+     * @return false|\Magento\App\Helper\AbstractHelper
      * @throws \Exception
      */
     protected function _getFiltrationHelper($filterData)
@@ -303,8 +304,8 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Try to create Zend filter based on $filterData. Return false on failure
      *
-     * @param $filterData
-     * @return bool|\Zend_Filter_Interface
+     * @param \Zend_Filter_Interface|array $filterData
+     * @return false|\Zend_Filter_Interface
      */
     protected function _getZendFilter($filterData)
     {
@@ -323,7 +324,7 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Get Magento filters
      *
-     * @param $filterData
+     * @param array $filterData
      * @return \Zend_Filter_Interface
      * @throws \Exception
      */
@@ -348,7 +349,7 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Get native \Zend_Filter
      *
-     * @param $filterData
+     * @param array $filterData
      * @return \Zend_Filter_Interface
      * @throws \Exception
      */
diff --git a/app/code/Magento/Core/Model/Input/Filter/MaliciousCode.php b/app/code/Magento/Core/Model/Input/Filter/MaliciousCode.php
index e362f6619d42fcfa3b6002ef1c1ba4cec834bf05..eab05a3bc0c190ff9ac3cf0c5b7a9248a4536acc 100644
--- a/app/code/Magento/Core/Model/Input/Filter/MaliciousCode.php
+++ b/app/code/Magento/Core/Model/Input/Filter/MaliciousCode.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Core\Model\Input\Filter;
 
 class MaliciousCode implements \Zend_Filter_Interface
@@ -32,7 +30,7 @@ class MaliciousCode implements \Zend_Filter_Interface
     /**
      * Regular expressions for cutting malicious code
      *
-     * @var array
+     * @var string[]
      */
     protected $_expressions = array(
         //comments, must be first
@@ -57,7 +55,7 @@ class MaliciousCode implements \Zend_Filter_Interface
      * Filter value
      *
      * @param string|array $value
-     * @return string|array         Filtered value
+     * @return string|array Filtered value
      */
     public function filter($value)
     {
@@ -68,7 +66,7 @@ class MaliciousCode implements \Zend_Filter_Interface
      * Add expression
      *
      * @param string $expression
-     * @return \Magento\Core\Model\Input\Filter\MaliciousCode
+     * @return $this
      */
     public function addExpression($expression)
     {
@@ -82,7 +80,7 @@ class MaliciousCode implements \Zend_Filter_Interface
      * Set expressions
      *
      * @param array $expressions
-     * @return \Magento\Core\Model\Input\Filter\MaliciousCode
+     * @return $this
      */
     public function setExpressions(array $expressions)
     {
diff --git a/app/code/Magento/Core/Model/Layout.php b/app/code/Magento/Core/Model/Layout.php
index 84b73b7f1587a16b13e1b5c438c3c06e4dca82a1..3c75f5b11106320d489181b5e1657d2b8bf0fa12 100644
--- a/app/code/Magento/Core/Model/Layout.php
+++ b/app/code/Magento/Core/Model/Layout.php
@@ -23,10 +23,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model;
 
-use Magento\View\Element\BlockFactory;
 use Magento\View\Layout\Element;
 
 /**
@@ -181,7 +179,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * @var \Magento\Core\Model\Store\Config
      */
     protected $_coreStoreConfig;
-    
+
     /**
      * @var \Magento\Logger $logger
      */
@@ -214,16 +212,16 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
 
     /**
      * @param \Magento\View\Layout\ProcessorFactory $processorFactory
-     * @param Resource\Theme\CollectionFactory $themeFactory
+     * @param \Magento\Core\Model\Resource\Theme\CollectionFactory $themeFactory
      * @param \Magento\Logger $logger
      * @param \Magento\Event\ManagerInterface $eventManager
      * @param \Magento\Core\Helper\Data $coreData
      * @param \Magento\View\DesignInterface $design
-     * @param BlockFactory $blockFactory
+     * @param \Magento\View\Element\BlockFactory $blockFactory
      * @param \Magento\Data\Structure $structure
-     * @param Layout\Argument\Processor $argumentProcessor
-     * @param Layout\ScheduledStructure $scheduledStructure
-     * @param Store\Config $coreStoreConfig
+     * @param \Magento\Core\Model\Layout\Argument\Processor $argumentProcessor
+     * @param \Magento\Core\Model\Layout\ScheduledStructure $scheduledStructure
+     * @param \Magento\Core\Model\Store\Config $coreStoreConfig
      * @param \Magento\App\State $appState
      * @param \Magento\Message\ManagerInterface $messageManager
      * @param string $area
@@ -297,7 +295,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Retrieve instance of a theme currently used in an area
      *
      * @param string $area
-     * @return \Magento\Core\Model\Theme
+     * @return Theme
      */
     protected function _getThemeInstance($area)
     {
@@ -329,8 +327,9 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     /**
      * Set area code
      *
-     * @deprecated
      * @param string $areaCode
+     * @return void
+     * @deprecated
      */
     public function setArea($areaCode)
     {
@@ -340,7 +339,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     /**
      * Layout xml generation
      *
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function generateXml()
     {
@@ -352,6 +351,8 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
 
     /**
      * Create structure of elements from the loaded XML configuration
+     *
+     * @return void
      * @SuppressWarnings(PHPMD.UnusedLocalVariable)
      */
     public function generateElements()
@@ -403,7 +404,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param string $elementName
      * @param bool $isChild
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     protected function _removeElement($elementName, $isChild = false)
     {
@@ -425,7 +426,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Move element in scheduled structure
      *
      * @param string $element
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     protected function _moveElementInStructure($element)
     {
@@ -442,6 +443,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Traverse through all elements of specified XML-node and schedule structural elements of it
      *
      * @param \Magento\View\Layout\Element $parent
+     * @return void
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      */
     protected function _readStructure($parent)
@@ -503,6 +505,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Merge Container attributes
      *
      * @param \Magento\View\Layout\Element $node
+     * @return void
      */
     protected function _mergeContainerAttributes(\Magento\View\Layout\Element $node)
     {
@@ -580,7 +583,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param \Magento\View\Layout\Element $node
      * @throws \Magento\Exception
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     protected function _scheduleMove($node)
     {
@@ -604,6 +607,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param \Magento\View\Layout\Element $node
      * @param \Magento\View\Layout\Element $parent
+     * @return void
      * @see _scheduleElement() where the _scheduledStructure is used
      */
     protected function _scheduleStructure($node, $parent)
@@ -681,6 +685,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param string $name
      * @param string $path
+     * @return void
      */
     protected function _overrideElementWorkaround($name, $path)
     {
@@ -701,9 +706,10 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Since layout updates could come in arbitrary order, a case is possible where an element is declared in reference,
      * while referenced element itself is not declared yet.
      *
+     * @param string $key in _scheduledStructure represent element name
+     * @return void
      * @SuppressWarnings(PHPMD.NPathComplexity)
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
-     * @param string $key in _scheduledStructure represent element name
      */
     protected function _scheduleElement($key)
     {
@@ -804,7 +810,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Creates block object based on xml node data and add it to the layout
      *
      * @param string $elementName
-     * @return \Magento\View\Element\AbstractBlock
+     * @return \Magento\View\Element\AbstractBlock|void
      * @throws \Magento\Exception
      */
     protected function _generateBlock($elementName)
@@ -856,7 +862,8 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * @param string $name
      * @param string $label
      * @param array $options
-     * @throws \Magento\Exception if any of arguments are invalid
+     * @return void
+     * @throws \Magento\Exception If any of arguments are invalid
      */
     protected function _generateContainer($name, $label, array $options)
     {
@@ -888,6 +895,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param \Magento\View\Layout\Element $node
      * @param \Magento\View\Layout\Element $parent
+     * @return void
      */
     protected function _generateAction($node, $parent)
     {
@@ -937,7 +945,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * @param string $parentName
      * @param string $elementName
      * @param string $alias
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function setChild($parentName, $elementName, $alias)
     {
@@ -956,6 +964,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * @param string $childName
      * @param string|int|null $offsetOrSibling
      * @param bool $after
+     * @return void
      */
     public function reorderChild($parentName, $childName, $offsetOrSibling, $after = true)
     {
@@ -1008,7 +1017,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param string $parentName
      * @param string $alias
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function unsetChild($parentName, $alias)
     {
@@ -1224,7 +1233,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      *
      * @param string $name
      * @param \Magento\View\Element\AbstractBlock $block
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function setBlock($name, $block)
     {
@@ -1236,7 +1245,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Remove block from registry
      *
      * @param string $name
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function unsetElement($name)
     {
@@ -1319,6 +1328,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * @param array $options
      * @param string $parent
      * @param string $alias
+     * @return void
      */
     public function addContainer($name, $label, array $options = array(), $parent = '', $alias = '')
     {
@@ -1360,8 +1370,10 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     protected function _getBlockInstance($block, array $attributes = array())
     {
         if ($block && is_string($block)) {
-            if (class_exists($block)) {
+            try {
                 $block = $this->_blockFactory->createBlock($block, $attributes);
+            } catch (\ReflectionException $e) {
+                // incorrect class name
             }
         }
         if (!$block instanceof \Magento\View\Element\AbstractBlock) {
@@ -1370,7 +1382,6 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
         return $block;
     }
 
-
     /**
      * Retrieve all blocks from registry as array
      *
@@ -1425,7 +1436,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Add an element to output
      *
      * @param string $name
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function addOutputElement($name)
     {
@@ -1437,7 +1448,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
      * Remove an element from output
      *
      * @param string $name
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function removeOutputElement($name)
     {
@@ -1512,11 +1523,11 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     }
 
     /**
-     * @param $namespace
-     * @param $staticType
-     * @param $dynamicType
-     * @param $type
-     * @param $template
+     * @param string $namespace
+     * @param string $staticType
+     * @param string $dynamicType
+     * @param string $type
+     * @param string $template
      * @param array $data
      * @return $this
      */
@@ -1538,10 +1549,10 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     }
 
     /**
-     * @param $namespace
-     * @param $staticType
-     * @param $dynamicType
-     * @return null
+     * @param string $namespace
+     * @param string $staticType
+     * @param string $dynamicType
+     * @return array|null
      */
     public function getRendererOptions($namespace, $staticType, $dynamicType)
     {
@@ -1558,10 +1569,11 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     }
 
     /**
-     * @param $namespace
-     * @param $staticType
-     * @param $dynamicType
-     * @param $data
+     * @param string $namespace
+     * @param string $staticType
+     * @param string $dynamicType
+     * @param array $data
+     * @return void
      */
     public function executeRenderer($namespace, $staticType, $dynamicType, $data = array())
     {
@@ -1581,8 +1593,9 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn
     /**
      * Init messages by message storage(s), loading and adding messages to layout messages block
      *
-     * @throws \UnexpectedValueException
      * @param string|array $messageGroups
+     * @return void
+     * @throws \UnexpectedValueException
      */
     public function initMessages($messageGroups = array())
     {
diff --git a/app/code/Magento/Core/Model/Layout/Argument/AbstractHandler.php b/app/code/Magento/Core/Model/Layout/Argument/AbstractHandler.php
index 21155e843d327b6340e922bc3ef9b48e9ede9cde..2250c718bc8302ac313c02e6f1e98e5c23e9e2e0 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/AbstractHandler.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/AbstractHandler.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Argument;
 
 /**
  * Layout object abstract argument
@@ -31,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Argument;
 
 abstract class AbstractHandler implements \Magento\View\Layout\Argument\HandlerInterface
 {
@@ -44,7 +44,7 @@ abstract class AbstractHandler implements \Magento\View\Layout\Argument\HandlerI
      * Retrieve value from argument
      *
      * @param \Magento\View\Layout\Element $argument
-     * @return mixed|null
+     * @return string|null
      */
     protected function _getArgumentValue(\Magento\View\Layout\Element $argument)
     {
@@ -63,7 +63,7 @@ abstract class AbstractHandler implements \Magento\View\Layout\Argument\HandlerI
      * Check whether updater used and value not overwritten
      *
      * @param \Magento\View\Layout\Element $argument
-     * @return string
+     * @return bool
      */
     protected function _isUpdater(\Magento\View\Layout\Element $argument)
     {
@@ -114,6 +114,7 @@ abstract class AbstractHandler implements \Magento\View\Layout\Argument\HandlerI
      * Validate parsed argument before processing
      *
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/ArrayHandler.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/ArrayHandler.php
index a926309e843ef692762588fc07f3582af0fa85d5..b2cb67d4035e4f8138769c70bea4e9ea6bbd7c96 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/ArrayHandler.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/ArrayHandler.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Argument\Handler;
 
 /**
  * Layout argument. Type Array
@@ -31,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Argument\Handler;
 
 class ArrayHandler extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 {
@@ -70,6 +70,7 @@ class ArrayHandler extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/Boolean.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/Boolean.php
index 45a7e6b115194529733eeef27da514ace40bb42f..e913ca8b8d7dff2bfca5dc38f0dcfaa866effc81 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/Boolean.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/Boolean.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Argument\Handler;
 
 /**
  * Layout argument. Type boolean.
@@ -31,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Argument\Handler;
 
 class Boolean extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 {
@@ -50,6 +50,7 @@ class Boolean extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/Helper.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/Helper.php
index 10b0c47f9e83a2479021fe7b911205f4abbef63b..ade6fb9c60f8f56d0f697b6486056eacd90fe27e 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/Helper.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/Helper.php
@@ -66,6 +66,7 @@ class Helper extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/Number.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/Number.php
index 23260e33fd63f6fbf7093b34f48ba166af135f19..1c0d8050c2bf5bc20e612494733409f805b1cdac 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/Number.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/Number.php
@@ -51,6 +51,7 @@ class Number extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/Object.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/Object.php
index aa230f0393661fd085c118c8917a187101a6b83f..b6dca35fc95ad716f644472610ac27f659db318e 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/Object.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/Object.php
@@ -65,7 +65,9 @@ class Object extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * Validate argument
-     * @param $argument
+     *
+     * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/Options.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/Options.php
index 747509c4ea763d2da62e55e8e284b76d4be87be8..b91fc541ce9f232568d965fd9bb6864d5956f16b 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/Options.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/Options.php
@@ -52,7 +52,7 @@ class Options extends \Magento\Core\Model\Layout\Argument\AbstractHandler
      * Process Option argument
      *
      * @param array $argument
-     * @return string
+     * @return array
      * @throws \InvalidArgumentException
      */
     public function process(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/String.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/String.php
index 67fb17775ccc1e03322c3289e2545d08fb9406be..aa3f5e67ac77ada1e1540fc7e84169cc78144f47 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/String.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/String.php
@@ -56,6 +56,7 @@ class String extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Handler/Url.php b/app/code/Magento/Core/Model/Layout/Argument/Handler/Url.php
index d06bf53da462f505facd1b2ce83c7e8181ce9080..850313f1d1e09a2e2c70a924b75b7709c67354e5 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Handler/Url.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Handler/Url.php
@@ -41,7 +41,6 @@ class Url extends \Magento\Core\Model\Layout\Argument\AbstractHandler
     protected $_urlModel;
 
     /**
-     * @param \Magento\ObjectManager $objectManager
      * @param \Magento\UrlInterface $urlModel
      */
     public function __construct(\Magento\UrlInterface  $urlModel)
@@ -66,6 +65,7 @@ class Url extends \Magento\Core\Model\Layout\Argument\AbstractHandler
 
     /**
      * @param array $argument
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validate(array $argument)
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Processor.php b/app/code/Magento/Core/Model/Layout/Argument/Processor.php
index fc33c3311bad5da0fd6409c0d46deea4211d0ec8..63d65f3c19bc3bd81105863149abea8d3acf17a4 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Processor.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Processor.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Argument;
 
 /**
  * Layout argument processor
@@ -31,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Argument;
 
 class Processor
 {
diff --git a/app/code/Magento/Core/Model/Layout/Argument/Updater.php b/app/code/Magento/Core/Model/Layout/Argument/Updater.php
index e6f0796bac80bf1aaa8b669b57f886554867ded2..4893cb098f8817b7a0515056a1661e7da3594c03 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/Updater.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/Updater.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Argument;
 
 /**
  * Layout argument updater processor
@@ -31,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Argument;
 
 class Updater
 {
diff --git a/app/code/Magento/Core/Model/Layout/Argument/UpdaterInterface.php b/app/code/Magento/Core/Model/Layout/Argument/UpdaterInterface.php
index 24ab155575e3c07dfb8e2c4e213495e8beca04e9..940c0c2313594032005dcad5090ef3ee05cc80a5 100644
--- a/app/code/Magento/Core/Model/Layout/Argument/UpdaterInterface.php
+++ b/app/code/Magento/Core/Model/Layout/Argument/UpdaterInterface.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Argument;
 
 /**
  * Layout object argument updater interface
@@ -31,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Argument;
 
 interface UpdaterInterface
 {
diff --git a/app/code/Magento/Core/Model/Layout/Factory.php b/app/code/Magento/Core/Model/Layout/Factory.php
index 36ec255910fd8d789cc70ec1efae116dfc02ae6a..14d706ca382969e056b72ca545680b3e43445e87 100644
--- a/app/code/Magento/Core/Model/Layout/Factory.php
+++ b/app/code/Magento/Core/Model/Layout/Factory.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Layout;
 
 class Factory
@@ -49,7 +48,7 @@ class Factory
     /**
      * @param array $arguments
      * @param string $className
-     * @return \Magento\Core\Model\Layout
+     * @return $this
      */
     public function createLayout(array $arguments = array(), $className = self::CLASS_NAME)
     {
diff --git a/app/code/Magento/Core/Model/Layout/Filter/Acl.php b/app/code/Magento/Core/Model/Layout/Filter/Acl.php
index 0554eb40fbfb44eefeb0692813bb5c9d2e90b417..bc9f68d53fc5f69e6e4b2f3be563b84720e5dc37 100644
--- a/app/code/Magento/Core/Model/Layout/Filter/Acl.php
+++ b/app/code/Magento/Core/Model/Layout/Filter/Acl.php
@@ -47,6 +47,7 @@ class Acl
      * In any case, the "acl" attribute will be unset
      *
      * @param \Magento\Simplexml\Element $xml
+     * @return void
      */
     public function filterAclNodes(\Magento\Simplexml\Element $xml)
     {
diff --git a/app/code/Magento/Core/Model/Layout/Link.php b/app/code/Magento/Core/Model/Layout/Link.php
index 8904d5d7c4b95f6c18cc59ea0b443602eb486096..d8858d18f8a5e0ef5f3a19a309e8aa85d89f4a9a 100644
--- a/app/code/Magento/Core/Model/Layout/Link.php
+++ b/app/code/Magento/Core/Model/Layout/Link.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout;
 
 /**
  * Layout Link model class
@@ -34,7 +35,6 @@
  * @method \Magento\Core\Model\Layout\Link setThemeId($id)
  * @method \Magento\Core\Model\Layout\Link setLayoutUpdateId($id)
  */
-namespace Magento\Core\Model\Layout;
 
 class Link extends \Magento\Core\Model\AbstractModel
 {
diff --git a/app/code/Magento/Core/Model/Layout/Merge.php b/app/code/Magento/Core/Model/Layout/Merge.php
index 8a2288d086ff836c8c6b0a073e8b6f7d6a6a93f9..56761d4d6a34e189c84d89b43bda42425017fc7b 100644
--- a/app/code/Magento/Core/Model/Layout/Merge.php
+++ b/app/code/Magento/Core/Model/Layout/Merge.php
@@ -23,11 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout;
 
 /**
  * Layout merge model
  */
-namespace Magento\Core\Model\Layout;
 
 class Merge implements \Magento\View\Layout\ProcessorInterface
 {
@@ -133,7 +133,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      *
      * @param \Magento\View\DesignInterface $design
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\View\Layout\File\SourceInterface $fileSource,
+     * @param \Magento\View\Layout\File\SourceInterface $fileSource
      * @param \Magento\Core\Model\Resource\Layout\Update $resource
      * @param \Magento\App\State $appState
      * @param \Magento\Cache\FrontendInterface $cache
@@ -169,7 +169,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * Add XML update instruction
      *
      * @param string $update
-     * @return \Magento\Core\Model\Layout\Merge
+     * @return $this
      */
     public function addUpdate($update)
     {
@@ -201,7 +201,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * Add handle(s) to update
      *
      * @param array|string $handleName
-     * @return \Magento\Core\Model\Layout\Merge
+     * @return $this
      */
     public function addHandle($handleName)
     {
@@ -219,7 +219,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * Remove handle from update
      *
      * @param string $handleName
-     * @return \Magento\Core\Model\Layout\Merge
+     * @return $this
      */
     public function removeHandle($handleName)
     {
@@ -241,7 +241,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * Add the first existing (declared in layout updates) page handle along with all parents to the update.
      * Return whether any page handles have been added or not.
      *
-     * @param array $handlesToTry
+     * @param string[] $handlesToTry
      * @return bool
      */
     public function addPageHandles(array $handlesToTry)
@@ -354,7 +354,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      *
      * @param array|string $handles
      * @throws \Magento\Exception
-     * @return \Magento\Core\Model\Layout\Merge
+     * @return $this
      */
     public function load($handles = array())
     {
@@ -425,7 +425,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * Merge layout update by handle
      *
      * @param string $handle
-     * @return \Magento\Core\Model\Layout\Merge
+     * @return $this
      */
     protected function _merge($handle)
     {
@@ -520,7 +520,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * Add handles declared as '<update handle="handle_name"/>' directives
      *
      * @param \SimpleXMLElement $updateXml
-     * @return \Magento\Core\Model\Layout\Merge
+     * @return $this
      */
     protected function _fetchRecursiveUpdates($updateXml)
     {
@@ -584,6 +584,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      * @param string $data
      * @param string $cacheId
      * @param array $cacheTags
+     * @return void
      */
     protected function _saveCache($data, $cacheId, array $cacheTags = array())
     {
@@ -593,8 +594,8 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
     /**
      * Collect and merge layout updates from files
      *
-     * @throws \Magento\Exception
      * @return \Magento\View\Layout\Element
+     * @throws \Magento\Exception
      */
     protected function _loadFileLayoutUpdatesXml()
     {
@@ -636,6 +637,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface
      *
      * @param string $fileName
      * @param array $libXmlErrors
+     * @return void
      */
     protected function _logXmlErrors($fileName, $libXmlErrors)
     {
diff --git a/app/code/Magento/Core/Model/Layout/ScheduledStructure.php b/app/code/Magento/Core/Model/Layout/ScheduledStructure.php
index 06eda2d72549c8aca5c6b3c9491f5dc0a78afc05..d1e2d1ab4fe3461855345d418741bed203124b5a 100644
--- a/app/code/Magento/Core/Model/Layout/ScheduledStructure.php
+++ b/app/code/Magento/Core/Model/Layout/ScheduledStructure.php
@@ -23,11 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout;
 
 /**
  * Layout structure model
  */
-namespace Magento\Core\Model\Layout;
 
 class ScheduledStructure
 {
@@ -114,7 +114,7 @@ class ScheduledStructure
      *
      * @param string $elementName
      * @param array $default
-     * @return mixed
+     * @return bool|array
      */
     public function getElement($elementName, $default = array())
     {
@@ -134,8 +134,9 @@ class ScheduledStructure
     /**
      * Add element to scheduled elements list
      *
-     * @param  string $elementName
+     * @param string $elementName
      * @param array $data
+     * @return void
      */
     public function setElement($elementName, array $data)
     {
@@ -157,6 +158,7 @@ class ScheduledStructure
      * Unset specified element from scheduled elements list
      *
      * @param $elementName
+     * @return void
      */
     public function unsetElement($elementName)
     {
@@ -180,6 +182,7 @@ class ScheduledStructure
      *
      * @param string $elementName
      * @param array $data
+     * @return void
      */
     public function setElementToMove($elementName, array $data)
     {
@@ -190,6 +193,7 @@ class ScheduledStructure
      * Unset removed element by name
      *
      * @param string $elementName
+     * @return void
      */
     public function unsetElementFromListToRemove($elementName)
     {
@@ -200,6 +204,7 @@ class ScheduledStructure
      * Set removed element value
      *
      * @param string $elementName
+     * @return void
      */
     public function setElementToRemoveList($elementName)
     {
@@ -254,6 +259,7 @@ class ScheduledStructure
      *
      * @param  string $elementName
      * @param array $data
+     * @return void
      */
     public function setStructureElement($elementName, array $data)
     {
@@ -264,6 +270,7 @@ class ScheduledStructure
      * Unset scheduled structure element by name
      *
      * @param string $elementName
+     * @return void
      */
     public function unsetStructureElement($elementName)
     {
@@ -308,6 +315,7 @@ class ScheduledStructure
      *
      * @param string $elementName
      * @param string $data
+     * @return void
      */
     public function setPathElement($elementName, $data)
     {
@@ -318,6 +326,7 @@ class ScheduledStructure
      * Unset scheduled paths element by name
      *
      * @param string $elementName
+     * @return void
      */
     public function unsetPathElement($elementName)
     {
@@ -326,6 +335,8 @@ class ScheduledStructure
 
     /**
      * Flush scheduled paths list
+     *
+     * @return void
      */
     public function flushPaths()
     {
@@ -334,6 +345,8 @@ class ScheduledStructure
 
     /**
      * Flush scheduled structure list
+     *
+     * @return void
      */
     public function flushScheduledStructure()
     {
diff --git a/app/code/Magento/Core/Model/Layout/Translator.php b/app/code/Magento/Core/Model/Layout/Translator.php
index 24a1b8d007139f7984041f498d9b766421145cf1..d85d2cac0346196ed44c45fa26e770831452efd4 100644
--- a/app/code/Magento/Core/Model/Layout/Translator.php
+++ b/app/code/Magento/Core/Model/Layout/Translator.php
@@ -23,18 +23,20 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Layout;
 
+use Magento\Simplexml\Element;
+
 class Translator
 {
     /**
      * Translate layout node
      *
-     * @param \Magento\Simplexml\Element $node
+     * @param Element $node
      * @param array $args
+     * @return void
      **/
-    public function translateActionParameters(\Magento\Simplexml\Element $node, &$args)
+    public function translateActionParameters(Element $node, &$args)
     {
         if (false === $this->_isNodeTranslatable($node)) {
             return;
@@ -74,10 +76,10 @@ class Translator
     /**
      * Translate argument value
      *
-     * @param \Magento\Simplexml\Element $node
+     * @param Element $node
      * @return string
      */
-    public function translateArgument(\Magento\Simplexml\Element $node)
+    public function translateArgument(Element $node)
     {
         $value = $this->_getNodeValue($node);
 
@@ -95,10 +97,10 @@ class Translator
     /**
      * Get node names that have to be translated
      *
-     * @param $node
+     * @param Element $node
      * @return array
      */
-    protected function _getNodeNamesToTranslate(\Magento\Simplexml\Element $node)
+    protected function _getNodeNamesToTranslate(Element $node)
     {
         return explode(' ', (string)$node['translate']);
     }
@@ -106,10 +108,10 @@ class Translator
     /**
      * Check if node has to be translated
      *
-     * @param \Magento\Simplexml\Element $node
+     * @param Element $node
      * @return bool
      */
-    protected function _isNodeTranslatable(\Magento\Simplexml\Element $node)
+    protected function _isNodeTranslatable(Element $node)
     {
         return isset($node['translate']);
     }
@@ -117,10 +119,10 @@ class Translator
     /**
      * Check if node has to translate own value
      *
-     * @param \Magento\Simplexml\Element $node
+     * @param Element $node
      * @return bool
      */
-    protected function _isSelfTranslatable(\Magento\Simplexml\Element $node)
+    protected function _isSelfTranslatable(Element $node)
     {
         return $this->_isNodeTranslatable($node) && 'true' == (string)$node['translate'];
     }
@@ -128,10 +130,10 @@ class Translator
     /**
      * Get node value
      *
-     * @param \Magento\Simplexml\Element $node
+     * @param Element $node
      * @return string
      */
-    protected function _getNodeValue(\Magento\Simplexml\Element $node)
+    protected function _getNodeValue(Element $node)
     {
         return trim((string)$node);
     }
diff --git a/app/code/Magento/Core/Model/Layout/Update.php b/app/code/Magento/Core/Model/Layout/Update.php
index 20ad745302cc4a7a0a2c4226e840f16fb328066c..f13caa89174358c6abf6bedf8ca98546ae143e41 100644
--- a/app/code/Magento/Core/Model/Layout/Update.php
+++ b/app/code/Magento/Core/Model/Layout/Update.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Layout;
 
 /**
diff --git a/app/code/Magento/Core/Model/Layout/Update/Validator.php b/app/code/Magento/Core/Model/Layout/Update/Validator.php
index 9f6e4a9b6281320553eacbd9ca521d37c69c7d0e..8eb1343a7b386a0bf506b9f2d6ced51bd3a665e4 100644
--- a/app/code/Magento/Core/Model/Layout/Update/Validator.php
+++ b/app/code/Magento/Core/Model/Layout/Update/Validator.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Layout\Update;
 
 
 /**
@@ -34,7 +35,6 @@
  * @package    Magento_Core
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Layout\Update;
 
 class Validator extends \Zend_Validate_Abstract
 {
@@ -103,7 +103,7 @@ class Validator extends \Zend_Validate_Abstract
     /**
      * Initialize messages templates with translating
      *
-     * @return \Magento\Core\Model\Layout\Update\Validator
+     * @return $this
      */
     protected function _initMessageTemplates()
     {
@@ -128,7 +128,7 @@ class Validator extends \Zend_Validate_Abstract
      *
      * @param string $value
      * @param string $schema
-     * @param boolean $isSecurityCheck
+     * @param bool $isSecurityCheck
      * @return bool
      */
     public function isValid($value, $schema = self::LAYOUT_SCHEMA_SINGLE_HANDLE, $isSecurityCheck = true)
diff --git a/app/code/Magento/Core/Model/Locale.php b/app/code/Magento/Core/Model/Locale.php
index 57fc7c2f8f1f312262a45a99d82fa86e6c275f98..88a65c51ae6fd611626db2ef01dedb50f9ad690f 100644
--- a/app/code/Magento/Core/Model/Locale.php
+++ b/app/code/Magento/Core/Model/Locale.php
@@ -29,7 +29,7 @@ namespace Magento\Core\Model;
 /**
  * Locale model
  */
-class Locale implements \Magento\Core\Model\LocaleInterface
+class Locale implements LocaleInterface
 {
     /**
      * Default locale code
@@ -89,7 +89,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     protected $_appState;
 
     /**
-     * @var \Magento\Core\Model\StoreManagerInterface
+     * @var StoreManagerInterface
      */
     protected $_storeManager;
 
@@ -99,7 +99,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     protected $_config;
 
     /**
-     * @var \Magento\Core\Model\App
+     * @var App
      */
     protected $_app;
 
@@ -109,12 +109,12 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     protected $dateTime;
 
     /**
-     * @var \Magento\Core\Model\Date
+     * @var Date
      */
     protected $_dateModel;
 
     /**
-     * @var array
+     * @var string[]
      */
     protected $_allowedFormats = array(
         \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_FULL,
@@ -163,7 +163,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      * Set default locale code
      *
      * @param   string $locale
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  $this
      */
     public function setDefaultLocale($locale)
     {
@@ -192,7 +192,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      * Set locale
      *
      * @param   string $locale
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  $this
      */
     public function setLocale($locale = null)
     {
@@ -268,7 +268,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      * Specify current locale code
      *
      * @param   string $code
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  LocaleInterface
      */
     public function setLocaleCode($code)
     {
@@ -361,7 +361,6 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      *
      * @param bool $preserveCodes
      * @param bool $ucFirstCode
-     *
      * @return array
      */
     public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false)
@@ -535,10 +534,10 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     /**
      * Create \Zend_Date object for current locale
      *
-     * @param mixed              $date
-     * @param string             $part
+     * @param mixed               $date
+     * @param string              $part
      * @param string|\Zend_Locale $locale
-     * @param bool               $useTimezone
+     * @param bool                $useTimezone
      * @return \Zend_Date
      */
     public function date($date = null, $part = null, $locale = null, $useTimezone = true)
@@ -566,8 +565,8 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     /**
      * Create \Zend_Date object with date converted to store timezone and store Locale
      *
-     * @param   mixed $store Information about store
-     * @param   string|integer|Zend_Date|array|null $date date in UTC
+     * @param   null|string|bool|int|Store $store Information about store
+     * @param   string|integer|\Zend_Date|array|null $date date in UTC
      * @param   boolean $includeTime flag for including time to date
      * @return  \Zend_Date
      */
@@ -588,9 +587,9 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     /**
      * Format date using current locale options and time zone.
      *
-     * @param   date|Zend_Date|null $date
-     * @param   string              $format   See \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_* constants
-     * @param   bool                $showTime Whether to include time
+     * @param   date|\Zend_Date|null $date
+     * @param   string               $format   See \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_* constants
+     * @param   bool                 $showTime Whether to include time
      * @return  string
      */
     public function formatDate(
@@ -624,9 +623,9 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     /**
      * Format time using current locale options
      *
-     * @param   date|Zend_Date|null $time
-     * @param   string              $format
-     * @param   bool                $showDate
+     * @param   date|\Zend_Date|null $time
+     * @param   string               $format
+     * @param   bool                 $showDate
      * @return  string
      */
     public function formatTime(
@@ -658,7 +657,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      * to UTC time zone. Date can be passed in format of store's locale
      * or in format which was passed as parameter.
      *
-     * @param mixed $store Information about store
+     * @param null|string|bool|int|Store $store Information about store
      * @param string|integer|\Zend_Date|array|null $date date in store's timezone
      * @param boolean $includeTime flag for including time to date
      * @param null|string $format
@@ -676,7 +675,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      * Get store timestamp
      * Timestamp will be built with store timezone settings
      *
-     * @param   mixed $store
+     * @param   null|string|bool|int|Store $store
      * @return  int
      */
     public function storeTimeStamp($store=null)
@@ -782,7 +781,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
         $symbols = \Zend_Locale_Data::getList($this->getLocaleCode(), 'symbols');
 
         $pos = strpos($format, ';');
-        if ($pos !== false){
+        if ($pos !== false) {
             $format = substr($format, 0, $pos);
         }
         $format = preg_replace("/[^0\#\.,]/", "", $format);
@@ -796,7 +795,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
         $requiredPrecision = $totalPrecision;
         $t = substr($format, $decimalPoint);
         $pos = strpos($t, '#');
-        if ($pos !== false){
+        if ($pos !== false) {
             $requiredPrecision = strlen($t) - $pos - $totalPrecision;
         }
 
@@ -825,6 +824,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
      * Event is not dispatched.
      *
      * @param int $storeId
+     * @return void
      */
     public function emulate($storeId)
     {
@@ -844,6 +844,8 @@ class Locale implements \Magento\Core\Model\LocaleInterface
 
     /**
      * Get last locale, used before last emulation
+     *
+     * @return void
      */
     public function revert()
     {
@@ -886,8 +888,8 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     /**
      * Returns the localized country name
      *
-     * @param  $value string Name to get detailed information about
-     * @return array
+     * @param  string $value Name to get detailed information about
+     * @return string|false
      */
     public function getCountryTranslation($value)
     {
@@ -907,7 +909,7 @@ class Locale implements \Magento\Core\Model\LocaleInterface
     /**
      * Checks if current date of the given store (in the store timezone) is within the range
      *
-     * @param int|string|\Magento\Core\Model\Store $store
+     * @param int|string|Store $store
      * @param string|null $dateFrom
      * @param string|null $dateTo
      * @return bool
diff --git a/app/code/Magento/Core/Model/Locale/Validator.php b/app/code/Magento/Core/Model/Locale/Validator.php
index 20ccf48db0982461d6e723975d1227e4b4ed888e..5c562032ad8eae8aac8739e3f8e1d4ff18ea183b 100644
--- a/app/code/Magento/Core/Model/Locale/Validator.php
+++ b/app/code/Magento/Core/Model/Locale/Validator.php
@@ -54,7 +54,7 @@ class Validator
      * Validate locale code
      *
      * @param string $localeCode
-     * @return boolean
+     * @return bool
      */
     public function isValid($localeCode)
     {
diff --git a/app/code/Magento/Core/Model/LocaleInterface.php b/app/code/Magento/Core/Model/LocaleInterface.php
index c0cd6a6d463fc92871720bb401509307146bbbc0..d56761f6052a80ee83a5728ce4ba3b928a04aafb 100644
--- a/app/code/Magento/Core/Model/LocaleInterface.php
+++ b/app/code/Magento/Core/Model/LocaleInterface.php
@@ -59,7 +59,7 @@ interface LocaleInterface
      * Set default locale code
      *
      * @param   string $locale
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  $this
      */
     public function setDefaultLocale($locale);
 
@@ -74,7 +74,7 @@ interface LocaleInterface
      * Set locale
      *
      * @param   string $locale
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  $this
      */
     public function setLocale($locale = null);
 
@@ -110,7 +110,7 @@ interface LocaleInterface
      * Specify current locale code
      *
      * @param   string $code
-     * @return  \Magento\Core\Model\LocaleInterface
+     * @return  $this
      */
     public function setLocaleCode($code);
 
@@ -154,14 +154,14 @@ interface LocaleInterface
     /**
      * Retrieve currency option list
      *
-     * @return unknown
+     * @return array
      */
     public function getOptionCurrencies();
 
     /**
      * Retrieve all currency option list
      *
-     * @return unknown
+     * @return array
      */
     public function getOptionAllCurrencies();
 
@@ -175,7 +175,7 @@ interface LocaleInterface
     /**
      * Retrieve array of allowed currencies
      *
-     * @return unknown
+     * @return array
      */
     public function getAllowCurrencies();
 
@@ -213,10 +213,10 @@ interface LocaleInterface
     /**
      * Create \Zend_Date object for current locale
      *
-     * @param mixed              $date
-     * @param string             $part
-     * @param string|Zend_Locale $locale
-     * @param bool               $useTimezone
+     * @param string|integer|\Zend_Date|array|null $date
+     * @param string $part
+     * @param string|\Zend_Locale $locale
+     * @param bool $useTimezone
      * @return \Zend_Date
      */
     public function date($date = null, $part = null, $locale = null, $useTimezone = true);
@@ -224,8 +224,8 @@ interface LocaleInterface
     /**
      * Create \Zend_Date object with date converted to store timezone and store Locale
      *
-     * @param   mixed $store Information about store
-     * @param   string|integer|Zend_Date|array|null $date date in UTC
+     * @param   null|string|bool|int|Store $store Information about store
+     * @param   string|integer|\Zend_Date|array|null $date date in UTC
      * @param   boolean $includeTime flag for including time to date
      * @return  \Zend_Date
      */
@@ -236,8 +236,8 @@ interface LocaleInterface
      * to UTC time zone. Date can be passed in format of store's locale
      * or in format which was passed as parameter.
      *
-     * @param mixed $store Information about store
-     * @param string|integer|Zend_Date|array|null $date date in store's timezone
+     * @param null|string|bool|int|Store $store Information about store
+     * @param string|integer|\Zend_Date|array|null $date date in store's timezone
      * @param boolean $includeTime flag for including time to date
      * @param null|string $format
      * @return \Zend_Date
@@ -248,7 +248,7 @@ interface LocaleInterface
      * Get store timestamp
      * Timestamp will be built with store timezone settings
      *
-     * @param   mixed $store
+     * @param   null|string|bool|int|Store $store
      * @return  int
      */
     public function storeTimeStamp($store=null);
@@ -293,12 +293,14 @@ interface LocaleInterface
      * Event is not dispatched.
      *
      * @param int $storeId
+     * @return void
      */
     public function emulate($storeId);
 
     /**
      * Get last locale, used before last emulation
      *
+     * @return void
      */
     public function revert();
 
@@ -327,7 +329,7 @@ interface LocaleInterface
      * Returns the localized country name
      *
      * @param  string             $value  Name to get detailed information about
-     * @return array
+     * @return string|false
      */
     public function getCountryTranslation($value);
 
@@ -341,7 +343,7 @@ interface LocaleInterface
     /**
      * Checks if current date of the given store (in the store timezone) is within the range
      *
-     * @param int|string|\Magento\Core\Model\Store $store
+     * @param int|string|Store $store
      * @param string|null $dateFrom
      * @param string|null $dateTo
      * @return bool
@@ -351,7 +353,7 @@ interface LocaleInterface
     /**
      * Format date using current locale options and time zone.
      *
-     * @param Zend_Date|null $date
+     * @param \Zend_Date|null $date
      * @param string $format
      * @param bool $showTime
      * @return string
@@ -363,7 +365,7 @@ interface LocaleInterface
     /**
      * Format time using current locale options
      *
-     * @param Zend_Date|null $time
+     * @param \Zend_Date|null $time
      * @param string $format
      * @param bool $showDate
      * @return string
diff --git a/app/code/Magento/Core/Model/Log/Adapter.php b/app/code/Magento/Core/Model/Log/Adapter.php
index e87b7aaa4ddb3c08e07ffd76d75d13fd5076b0a7..e6ed6be0331198069adc0fc58d3e9ec306a99278 100644
--- a/app/code/Magento/Core/Model/Log/Adapter.php
+++ b/app/code/Magento/Core/Model/Log/Adapter.php
@@ -35,8 +35,7 @@ namespace Magento\Core\Model\Log;
 
 class Adapter
 {
-
-    /**
+ /**
      * Store log file name
      *
      * @var string
@@ -78,7 +77,7 @@ class Adapter
      * Perform forced log data to file
      *
      * @param mixed $data
-     * @return \Magento\Core\Model\Log\Adapter
+     * @return $this
      */
     public function log($data = null)
     {
@@ -101,7 +100,7 @@ class Adapter
      *
      * @param string|array $key
      * @param mixed $value
-     * @return \Magento\Core\Model\Log\Adapter
+     * @return $this
      * @todo replace whole data
      */
     public function setData($key, $value = null)
@@ -119,7 +118,7 @@ class Adapter
      * Setter for private data keys, that should be replaced in debug data with '***'
      *
      * @param array $keys
-     * @return \Magento\Core\Model\Log\Adapter
+     * @return $this
      */
     public function setFilterDataKeys($keys)
     {
@@ -134,7 +133,7 @@ class Adapter
      * Recursive filter data by private conventions
      *
      * @param mixed $debugData
-     * @return mixed
+     * @return string|array
      */
     protected function _filterDebugData($debugData)
     {
diff --git a/app/code/Magento/Core/Model/Mview/View/State.php b/app/code/Magento/Core/Model/Mview/View/State.php
index 30fdf76b67d403c10f42493c05920b1f2272620b..6fbe79dd4c55ce882c45d4783180a5f79975be2a 100644
--- a/app/code/Magento/Core/Model/Mview/View/State.php
+++ b/app/code/Magento/Core/Model/Mview/View/State.php
@@ -70,7 +70,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\
      * Fill object with state data by view ID
      *
      * @param string $viewId
-     * @return \Magento\Mview\View\StateInterface
+     * @return void
      */
     public function loadByView($viewId)
     {
@@ -83,7 +83,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\
     /**
      * Processing object before save data
      *
-     * @return \Magento\Core\Model\Mview\View\State
+     * @return void
      */
     protected function _beforeSave()
     {
@@ -115,7 +115,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\
      * Set state mode
      *
      * @param string $mode
-     * @return \Magento\Mview\View\StateInterface
+     * @return $this
      */
     public function setMode($mode)
     {
@@ -137,7 +137,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\
      * Set state status
      *
      * @param string $status
-     * @return \Magento\Mview\View\StateInterface
+     * @return $this
      */
     public function setStatus($status)
     {
@@ -159,7 +159,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\
      * Set state updated time
      *
      * @param string|int|\Zend_Date $updated
-     * @return \Magento\Mview\View\StateInterface
+     * @return $this
      */
     public function setUpdated($updated)
     {
@@ -181,7 +181,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\
      * Set state version ID
      *
      * @param int $versionId
-     * @return \Magento\Mview\View\StateInterface
+     * @return $this
      */
     public function setVersionId($versionId)
     {
diff --git a/app/code/Magento/Core/Model/Observer.php b/app/code/Magento/Core/Model/Observer.php
index cb9d4fd37911346a52c71105cef52729409d4d56..71e4bda57cefbeb1c418b079478b2d2ac0d55157 100644
--- a/app/code/Magento/Core/Model/Observer.php
+++ b/app/code/Magento/Core/Model/Observer.php
@@ -39,7 +39,7 @@ class Observer
     private $_cacheFrontendPool;
 
     /**
-     * @var \Magento\Core\Model\Theme
+     * @var Theme
      */
     private $_currentTheme;
 
@@ -99,6 +99,7 @@ class Observer
      * Cron job method to clean old cache resources
      *
      * @param \Magento\Cron\Model\Schedule $schedule
+     * @return void
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function cleanCache(\Magento\Cron\Model\Schedule $schedule)
@@ -114,7 +115,7 @@ class Observer
      * Theme registration
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Core\Model\Observer
+     * @return $this
      */
     public function themeRegistration(\Magento\Event\Observer $observer)
     {
@@ -131,6 +132,7 @@ class Observer
      * Apply customized static files to frontend
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function applyThemeCustomization(\Magento\Event\Observer $observer)
@@ -156,7 +158,7 @@ class Observer
      * Rebuild whole config and save to fast storage
      *
      * @param  \Magento\Event\Observer $observer
-     * @return \Magento\Core\Model\Observer
+     * @return $this
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function processReinitConfig(\Magento\Event\Observer $observer)
diff --git a/app/code/Magento/Core/Model/Option/ArrayInterface.php b/app/code/Magento/Core/Model/Option/ArrayInterface.php
index bc26a337c106b88d411c5cbf996524d2aadf97d2..fb24f45cefe8600b5236fbace34fccf9b443876f 100644
--- a/app/code/Magento/Core/Model/Option/ArrayInterface.php
+++ b/app/code/Magento/Core/Model/Option/ArrayInterface.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Option;
 
 /**
  * Option array interface
@@ -31,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Option;
-
 interface ArrayInterface
 {
     /**
diff --git a/app/code/Magento/Core/Model/Option/ArrayPool.php b/app/code/Magento/Core/Model/Option/ArrayPool.php
index 720b9285e1b0ebeeb6d6663d9406b0823e08ad18..60e52a1e1c8256702f995db6600e6aaf7155afe5 100644
--- a/app/code/Magento/Core/Model/Option/ArrayPool.php
+++ b/app/code/Magento/Core/Model/Option/ArrayPool.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Option;
 
 /**
  * Array optioned object factory
  */
-namespace Magento\Core\Model\Option;
-
 class ArrayPool
 {
     /**
diff --git a/app/code/Magento/Core/Model/Registry.php b/app/code/Magento/Core/Model/Registry.php
index b4d78f1286cd1d27858a736ead3c2a0fbae444d7..c81cbd3fb96a254679b13173832d8c32ba164fe9 100644
--- a/app/code/Magento/Core/Model/Registry.php
+++ b/app/code/Magento/Core/Model/Registry.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model;
 
 /**
  * Registry model. Used to manage values in registry
  */
-namespace Magento\Core\Model;
-
 class Registry
 {
     /**
@@ -58,6 +57,7 @@ class Registry
      * @param string $key
      * @param mixed $value
      * @param bool $graceful
+     * @return void
      * @throws \RuntimeException
      */
     public function register($key, $value, $graceful = false)
@@ -75,6 +75,7 @@ class Registry
      * Unregister a variable from register by key
      *
      * @param string $key
+     * @return void
      */
     public function unregister($key)
     {
diff --git a/app/code/Magento/Core/Model/Resource/AbstractResource.php b/app/code/Magento/Core/Model/Resource/AbstractResource.php
index de3f1b39e8c53df526dd75f5dce08d0b7db3d33b..ec28b5e2ebb18d838114f9f8bad3576259610482 100644
--- a/app/code/Magento/Core/Model/Resource/AbstractResource.php
+++ b/app/code/Magento/Core/Model/Resource/AbstractResource.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource;
 
 /**
  * Abstract resource model
@@ -31,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 abstract class AbstractResource
 {
     /**
@@ -65,18 +64,22 @@ abstract class AbstractResource
 
     /**
      * Retrieve connection for read data
+     *
+     * @return \Magento\DB\Adapter\AdapterInterface
      */
     abstract protected function _getReadAdapter();
 
     /**
      * Retrieve connection for write data
+     *
+     * @return \Magento\DB\Adapter\AdapterInterface
      */
     abstract protected function _getWriteAdapter();
 
     /**
      * Start resource transaction
      *
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @return $this
      */
     public function beginTransaction()
     {
@@ -87,8 +90,8 @@ abstract class AbstractResource
     /**
      * Subscribe some callback to transaction commit
      *
-     * @param callback $callback
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @param array $callback
+     * @return $this
      */
     public function addCommitCallback($callback)
     {
@@ -100,7 +103,7 @@ abstract class AbstractResource
     /**
      * Commit resource transaction
      *
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @return $this
      */
     public function commit()
     {
@@ -124,7 +127,7 @@ abstract class AbstractResource
     /**
      * Roll back resource transaction
      *
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @return $this
      */
     public function rollBack()
     {
@@ -139,7 +142,7 @@ abstract class AbstractResource
      * @param string $field
      * @param mixed $defaultValue
      * @param bool $unsetEmpty
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _serializeField(\Magento\Object $object, $field, $defaultValue = null, $unsetEmpty = false)
     {
@@ -166,6 +169,7 @@ abstract class AbstractResource
      * @param \Magento\Core\Model\AbstractModel $object
      * @param string $field
      * @param mixed $defaultValue
+     * @return void
      */
     protected function _unserializeField(\Magento\Object $object, $field, $defaultValue = null)
     {
@@ -226,7 +230,7 @@ abstract class AbstractResource
     /**
      * Template method to return validate rules to be executed before entity is saved
      *
-     * @return \Zend_Validate_Interface|null
+     * @return null
      */
     public function getValidationRulesBeforeSave()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Cache.php b/app/code/Magento/Core/Model/Resource/Cache.php
index 8b07112fc26194a4a8a57f5d9aab80751fe3f4fc..4fe010151fab12c97a8ad36add7cc3942715bc71 100644
--- a/app/code/Magento/Core/Model/Resource/Cache.php
+++ b/app/code/Magento/Core/Model/Resource/Cache.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Core Cache resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Cache extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magento\App\Cache\State\OptionsInterface
 {
     /**
@@ -48,7 +46,7 @@ class Cache extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magen
     /**
      * Get all cache options
      *
-     * @return array | false
+     * @return array|false
      */
     public function getAllOptions()
     {
@@ -70,7 +68,7 @@ class Cache extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magen
      * Save all options to option table
      *
      * @param array $options
-     * @return \Magento\Core\Model\Resource\Cache
+     * @return $this
      * @throws \Exception
      */
     public function saveAllOptions($options)
diff --git a/app/code/Magento/Core/Model/Resource/Config.php b/app/code/Magento/Core/Model/Resource/Config.php
index 09a4074336f2ceacb3f840b322dad53b004fb741..4bbf18015814953ed4a6e4ecac7ef5ea786a3ed8 100644
--- a/app/code/Magento/Core/Model/Resource/Config.php
+++ b/app/code/Magento/Core/Model/Resource/Config.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Core Resource Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Config extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -52,7 +50,7 @@ class Config extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param string $value
      * @param string $scope
      * @param int $scopeId
-     * @return \Magento\Core\Model\Resource\Config
+     * @return $this
      */
     public function saveConfig($path, $value, $scope, $scopeId)
     {
@@ -86,7 +84,7 @@ class Config extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param string $path
      * @param string $scope
      * @param int $scopeId
-     * @return \Magento\Core\Model\Resource\Config
+     * @return $this
      */
     public function deleteConfig($path, $scope, $scopeId)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Config/Data.php b/app/code/Magento/Core/Model/Resource/Config/Data.php
index 1e2a2073648cef8380bb82a487a345c8d89086d5..e07f37283b93f764f5fb28c1c066836fbc5f7f0c 100644
--- a/app/code/Magento/Core/Model/Resource/Config/Data.php
+++ b/app/code/Magento/Core/Model/Resource/Config/Data.php
@@ -23,6 +23,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Config;
+use Magento\Core\Model\Website;
 
 
 /**
@@ -32,8 +34,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Config;
-
 class Data extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -49,7 +49,7 @@ class Data extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Convert array to comma separated value
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Config\Data
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -68,7 +68,7 @@ class Data extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Set id to object if exists configuration instead of throw exception
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Config\Data
+     * @return $this
      */
     protected function _checkUnique(\Magento\Core\Model\AbstractModel $object)
     {
@@ -94,9 +94,10 @@ class Data extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Clear website data
      *
-     * @param $website
+     * @param Website $website
+     * @return void
      */
-    public function clearWebsiteData(\Magento\Core\Model\Website $website)
+    public function clearWebsiteData(Website $website)
     {
         $this->_getWriteAdapter()->delete(
             $this->getMainTable(), array('scope = ?' => 'websites', 'scope_id' => $website->getId())
@@ -108,6 +109,7 @@ class Data extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Clear store data
      *
      * @param array $storeIds
+     * @return void
      */
     public function clearStoreData(array $storeIds)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php b/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php
index 5e26a56cae059696437a493f7ee14bd85cd9d044..da7ce565f7547e2e89c80e711f531d1ce99dd076 100644
--- a/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Config/Data/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Config\Data;
 
 /**
  * Config data collection
@@ -32,13 +32,10 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Config\Data;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Define resource model
-     *
      */
     protected function _construct()
     {
@@ -51,7 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * @param string $scope
      * @param int $scopeId
      * @param string $section
-     * @return \Magento\Core\Model\Resource\Config\Data\Collection
+     * @return $this
      */
     public function addScopeFilter($scope, $scopeId, $section)
     {
@@ -65,7 +62,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *  Add path filter
      *
      * @param string $section
-     * @return \Magento\Core\Model\Resource\Config\Data\Collection
+     * @return $this
      */
     public function addPathFilter($section)
     {
@@ -77,7 +74,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add value filter
      *
      * @param int|string $value
-     * @return \Magento\Core\Model\Resource\Config\Data\Collection
+     * @return $this
      */
     public function addValueFilter($value)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php b/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php
index 51f4ecc90fb06aee76f7248ca03e1d4de7eb9a51..5ce7680f111ab299abdf1d1c709fd4f121ddc40b 100644
--- a/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php
+++ b/app/code/Magento/Core/Model/Resource/Config/Value/Collection/Scoped.php
@@ -69,7 +69,7 @@ class Scoped extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollecti
     /**
      * Initialize select
      *
-     * @return $this|\Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Db/AbstractDb.php b/app/code/Magento/Core/Model/Resource/Db/AbstractDb.php
index 3097b09885cedd50270bb98f415380168a8f52c7..6a9883a3610718bfb463c8bf11fcbe71f9be1b26 100644
--- a/app/code/Magento/Core/Model/Resource/Db/AbstractDb.php
+++ b/app/code/Magento/Core/Model/Resource/Db/AbstractDb.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Db;
 
 /**
  * Abstract resource model class
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Db;
-
 abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
 {
     /**
@@ -95,7 +93,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Use is object new method for save of object
      *
-     * @var boolean
+     * @var bool
      */
     protected $_useIsObjectNew       = false;
 
@@ -162,6 +160,8 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
 
     /**
      * Restore global dependencies
+     *
+     * @return void
      */
     public function __wakeup()
     {
@@ -173,7 +173,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      *
      * @param string $mainTable
      * @param string $idFieldName
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @return void
      */
     protected function _init($mainTable, $idFieldName)
     {
@@ -187,7 +187,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      *
      * @param string|array $connections
      * @param string|array|null $tables
-     * @return \Magento\Core\Model\Resource\AbstractResource
+     * @return $this
      */
     protected function _setResource($connections, $tables = null)
     {
@@ -217,7 +217,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      *
      * @param string $mainTable
      * @param string|null $idFieldName
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     protected function _setMainTable($mainTable, $idFieldName = null)
     {
@@ -289,7 +289,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * Get connection by resource name
      *
      * @param string $resourceName
-     * @return \Magento\DB\Adapter\AdapterInterface|bool
+     * @return \Magento\DB\Adapter\AdapterInterface|false
      */
     protected function _getConnection($resourceName)
     {
@@ -308,7 +308,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Retrieve connection for read data
      *
-     * @return \Magento\DB\Adapter\AdapterInterface
+     * @return \Magento\DB\Adapter\AdapterInterface|false
      */
     protected function _getReadAdapter()
     {
@@ -323,7 +323,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Retrieve connection for write data
      *
-     * @return \Magento\DB\Adapter\AdapterInterface
+     * @return \Magento\DB\Adapter\AdapterInterface|false
      */
     protected function _getWriteAdapter()
     {
@@ -333,7 +333,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Temporary resolving collection compatibility
      *
-     * @return \Magento\DB\Adapter\AdapterInterface
+     * @return \Magento\DB\Adapter\AdapterInterface|false
      */
     public function getReadConnection()
     {
@@ -346,7 +346,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * @param \Magento\Core\Model\AbstractModel $object
      * @param mixed $value
      * @param string $field field to load by (defaults to model id)
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null)
     {
@@ -391,7 +391,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * Save object object data
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     public function save(\Magento\Core\Model\AbstractModel $object)
     {
@@ -449,7 +449,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * Delete the object
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     public function delete(\Magento\Core\Model\AbstractModel $object)
     {
@@ -466,7 +466,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * Add unique field restriction
      *
      * @param array|string $field
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     public function addUniqueField($field)
     {
@@ -482,18 +482,19 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Reset unique fields restrictions
      *
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     public function resetUniqueField()
     {
         $this->_uniqueFields = array();
-         return $this;
+        return $this;
     }
 
     /**
      * Unserialize serializeable object fields
      *
      * @param \Magento\Core\Model\AbstractModel $object
+     * @return void
      */
     public function unserializeFields(\Magento\Core\Model\AbstractModel $object)
     {
@@ -506,7 +507,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Initialize unique fields
      *
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     protected function _initUniqueFields()
     {
@@ -543,7 +544,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * has really changed comparing with origData
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return boolean
+     * @return bool
      */
     public function hasDataChanged($object)
     {
@@ -577,7 +578,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * Check for unique values existence
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _checkUnique(\Magento\Core\Model\AbstractModel $object)
@@ -634,6 +635,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * After load
      *
      * @param \Magento\Core\Model\AbstractModel $object
+     * @return void
      */
     public function afterLoad(\Magento\Core\Model\AbstractModel $object)
     {
@@ -643,8 +645,8 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Perform actions after object load
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object
+     * @return $this
      */
     protected function _afterLoad(\Magento\Core\Model\AbstractModel $object)
     {
@@ -654,8 +656,8 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Perform actions before object save
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -665,8 +667,8 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Perform actions after object save
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -676,8 +678,8 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Perform actions before object delete
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object
+     * @return $this
      */
     protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object)
     {
@@ -687,8 +689,8 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     /**
      * Perform actions after object delete
      *
-     * @param \Magento\Object $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @param \Magento\Core\Model\AbstractModel|\Magento\Object $object
+     * @return $this
      */
     protected function _afterDelete(\Magento\Core\Model\AbstractModel $object)
     {
@@ -696,9 +698,10 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
     }
 
     /**
-     * Serialize serializeable fields of the object
+     * Serialize serializable fields of the object
      *
      * @param \Magento\Core\Model\AbstractModel $object
+     * @return void
      */
     protected function _serializeFields(\Magento\Core\Model\AbstractModel $object)
     {
@@ -712,7 +715,7 @@ abstract class AbstractDb extends \Magento\Core\Model\Resource\AbstractResource
      * Retrieve table checksum
      *
      * @param string|array $table
-     * @return int|array
+     * @return int|array|false
      */
     public function getChecksum($table)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php b/app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php
index 14a45b4864019928161b39657e4722eea7dff9a6..73d6bf32c2506ccc86a5e0e63329730a74852e36 100644
--- a/app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php
+++ b/app/code/Magento/Core/Model/Resource/Db/Collection/AbstractCollection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Db\Collection;
 
 /**
  * Abstract Core Resource Collection
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Db\Collection;
-
 abstract class AbstractCollection extends \Magento\Data\Collection\Db
 {
     /**
@@ -125,7 +123,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param \Magento\Logger $logger
      * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
      * @param \Magento\Event\ManagerInterface $eventManager
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
      */
     public function __construct(
@@ -147,10 +145,10 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Initialization here
      *
+     * @return void
      */
     protected function _construct()
     {
-
     }
 
     /**
@@ -171,7 +169,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Set main collection table
      *
      * @param string $table
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function setMainTable($table)
     {
@@ -191,7 +189,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Init collection select
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -216,7 +214,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Init fields for select
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _initSelectFields()
     {
@@ -288,7 +286,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Initialize initial fields to select like id field
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _initInitialFieldsToSelect()
     {
@@ -304,7 +302,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *
      * @param string|array $field
      * @param string|null $alias
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function addFieldToSelect($field, $alias = null)
     {
@@ -350,7 +348,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param string $alias
      * @param string $expression
      * @param array|string $fields
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function addExpressionFieldToSelect($alias, $expression, $fields)
     {
@@ -373,8 +371,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Removes field from select
      *
      * @param string|null $field
-     * @param boolean $isAlias Alias identifier
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @param bool $isAlias Alias identifier
+     * @return $this
      */
     public function removeFieldFromSelect($field, $isAlias = false)
     {
@@ -398,7 +396,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Removes all fields from select
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function removeAllFieldsFromSelect()
     {
@@ -412,7 +410,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *
      * @param string $model
      * @param string $resourceModel
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _init($model, $resourceModel)
     {
@@ -425,7 +423,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Set model name for collection items
      *
      * @param string $model
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function setModel($model)
     {
@@ -440,7 +438,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Get model instance
      *
      * @param array $args
-     * @return \Magento\Object
+     * @return string
      */
     public function getModelName($args = array())
     {
@@ -451,6 +449,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Set resource model name for collection items
      *
      * @param string $model
+     * @return void
      */
     public function setResourceModel($model)
     {
@@ -514,7 +513,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param string $table
      * @param string $cond
      * @param string $cols
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function join($table, $cond, $cols = '*')
     {
@@ -542,7 +541,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Redeclare before load method for adding event
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _beforeLoad()
     {
@@ -559,8 +558,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Set reset items data changed flag
      *
-     * @param boolean $flag
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @param bool $flag
+     * @return $this
      */
     public function setResetItemsDataChanged($flag)
     {
@@ -571,7 +570,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Set flag data has changed to all collection items
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function resetItemsDataChanged()
     {
@@ -585,7 +584,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Redeclare after load method for specifying collection items original data
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -608,7 +607,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Save all the entities in the collection
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     public function save()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Design.php b/app/code/Magento/Core/Model/Resource/Design.php
index eae00675d5d76195ce46d3ac6c74850f7eedc7b1..4266e3fe6121d1aa80005ad6454ffa2a14f98200 100644
--- a/app/code/Magento/Core/Model/Resource/Design.php
+++ b/app/code/Magento/Core/Model/Resource/Design.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource;
 
+use Magento\Stdlib\DateTime;
 
 /**
  * Core Design Resource Model
@@ -32,20 +34,18 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Design extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
-     * @var \Magento\Stdlib\DateTime
+     * @var DateTime
      */
     protected $dateTime;
 
     /**
      * @param \Magento\App\Resource $resource
-     * @param \Magento\Stdlib\DateTime $dateTime
+     * @param DateTime $dateTime
      */
-    public function __construct(\Magento\App\Resource $resource, \Magento\Stdlib\DateTime $dateTime)
+    public function __construct(\Magento\App\Resource $resource, DateTime $dateTime)
     {
         $this->dateTime = $dateTime;
         parent::__construct($resource);
@@ -53,7 +53,6 @@ class Design extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Define main table and primary key
-     *
      */
     protected function _construct()
     {
@@ -64,7 +63,7 @@ class Design extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Perform actions before object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function _beforeSave(\Magento\Core\Model\AbstractModel $object)
@@ -115,10 +114,10 @@ class Design extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Check intersections
      *
      * @param int $storeId
-     * @param date $dateFrom
-     * @param date $dateTo
+     * @param string $dateFrom
+     * @param string $dateTo
      * @param int $currentId
-     * @return Array
+     * @return string
      */
     protected function _checkIntersection($storeId, $dateFrom, $dateTo, $currentId)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Design/Collection.php b/app/code/Magento/Core/Model/Resource/Design/Collection.php
index 5690383da6c7ab1b6103eb60ff5193f371917c92..81a1352f82205457c9b4df7a5fc0225931e4c6f9 100644
--- a/app/code/Magento/Core/Model/Resource/Design/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Design/Collection.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Design;
 
 /**
@@ -60,6 +59,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Core Design resource collection
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -83,8 +84,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add date filter to collection
      *
-     * @param null|int|string|Zend_Date $date
-     * @return \Magento\Core\Model\Resource\Design\Collection
+     * @param null|int|string|\Zend_Date $date
+     * @return $this
      */
     public function addDateFilter($date = null)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php b/app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php
index 5987ec05feabe83efc9850afb0e1bb2e42d77be6..188c0fdcebfddc673c068fb1d81536f452138d4f 100644
--- a/app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php
+++ b/app/code/Magento/Core/Model/Resource/Entity/AbstractEntity.php
@@ -23,12 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Entity;
 
 abstract class AbstractEntity
 {
+    /**
+     * @var string
+     */
     protected $_name = null;
+
     /**
      * Configuration object
      *
@@ -50,7 +53,7 @@ abstract class AbstractEntity
      * Get config by key
      *
      * @param string $key
-     * @return string|boolean
+     * @return \Magento\Simplexml\Config|string|false
      */
     public function getConfig($key = '')
     {
diff --git a/app/code/Magento/Core/Model/Resource/Entity/Table.php b/app/code/Magento/Core/Model/Resource/Entity/Table.php
index cf89cd2053545673909ff079e1e837f63bfaad99..71f491bf36a3e4c6eb516b59cf51b13336f9eae6 100644
--- a/app/code/Magento/Core/Model/Resource/Entity/Table.php
+++ b/app/code/Magento/Core/Model/Resource/Entity/Table.php
@@ -23,14 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Entity;
 
 
 /**
  * Class describing db table resource entity
  *
  */
-namespace Magento\Core\Model\Resource\Entity;
-
 class Table extends \Magento\Core\Model\Resource\Entity\AbstractEntity
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php b/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php
index aefba80dfe9e56a619a62cd8c2dc7d84860ff1a1..43bad76577e9d0d228c29a8ed0b9efd2bc768b65 100644
--- a/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php
+++ b/app/code/Magento/Core/Model/Resource/File/Storage/AbstractStorage.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\File\Storage;
 
 /**
@@ -42,7 +41,7 @@ abstract class AbstractStorage extends \Magento\Core\Model\Resource\Db\AbstractD
      * Sets name of connection the resource will use
      *
      * @param string $name
-     * @return \Magento\Core\Model\Resource\File\Storage\AbstractStorage
+     * @return $this
      */
     public function setConnectionName($name)
     {
diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/Database.php b/app/code/Magento/Core/Model/Resource/File/Storage/Database.php
index c150ce18c81acf6a3a039b3c271ee402093c94a6..98c9bf6449e185bd523aa022c1e9e00c6eaf1918 100644
--- a/app/code/Magento/Core/Model/Resource/File/Storage/Database.php
+++ b/app/code/Magento/Core/Model/Resource/File/Storage/Database.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\File\Storage;
 
 /**
@@ -60,7 +59,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
     /**
      * Create database scheme for storing files
      *
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function createDatabaseScheme()
     {
@@ -141,7 +140,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      * @param  \Magento\Core\Model\File\Storage\Database $object
      * @param  string $filename
      * @param  string $path
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function loadByFilename(\Magento\Core\Model\File\Storage\Database $object, $filename, $path)
     {
@@ -165,7 +164,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
     /**
      * Clear files in storage
      *
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function clearFiles()
     {
@@ -201,8 +200,8 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
     /**
      * Save file to storage
      *
-     * @param  \Magento\Core\Model\File\Storage\Database|array $object
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @param  array $file
+     * @return $this
      */
     public function saveFile($file)
     {
@@ -230,7 +229,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      * @param  string $oldPath
      * @param  string $newFilename
      * @param  string $newPath
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function renameFile($oldFilename, $oldPath, $newFilename, $newPath)
     {
@@ -252,7 +251,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      * @param  string $oldPath
      * @param  string $newFilename
      * @param  string $newPath
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function copyFile($oldFilename, $oldPath, $newFilename, $newPath)
     {
@@ -305,6 +304,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      * Delete files that starts with given $folderName
      *
      * @param string $folderName
+     * @return void
      */
     public function deleteFolder($folderName = '')
     {
@@ -323,6 +323,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      *
      * @param string $filename
      * @param string $directory
+     * @return void
      */
     public function deleteFile($filename, $directory)
     {
@@ -338,7 +339,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      * Return directory file listing
      *
      * @param string $directory
-     * @return mixed
+     * @return array
      */
     public function getDirectoryFiles($directory)
     {
diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/Directory/Database.php b/app/code/Magento/Core/Model/Resource/File/Storage/Directory/Database.php
index 60303a1594b2047441f08f765747c8f08f3cfe9e..04dfc565f98656761f96d70960caa0582a5c395c 100644
--- a/app/code/Magento/Core/Model/Resource/File/Storage/Directory/Database.php
+++ b/app/code/Magento/Core/Model/Resource/File/Storage/Directory/Database.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\File\Storage\Directory;
 
 /**
@@ -42,7 +41,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
     /**
      * Create database scheme for storing files
      *
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function createDatabaseScheme()
     {
@@ -91,7 +90,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      *
      * @param  \Magento\Core\Model\File\Storage\Directory\Database $object
      * @param  string $path
-     * @return \Magento\Core\Model\Resource\File\Storage\Directory\Database
+     * @return $this
      */
     public function loadByPath(\Magento\Core\Model\File\Storage\Directory\Database $object, $path)
     {
@@ -147,7 +146,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
     /**
      * Delete all directories from storage
      *
-     * @return \Magento\Core\Model\Resource\File\Storage\Database
+     * @return $this
      */
     public function clearDirectories()
     {
@@ -162,7 +161,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      *
      * @param int $offset
      * @param int $count
-     * @return mixed
+     * @return array
      */
     public function exportDirectories($offset, $count = 100)
     {
@@ -183,7 +182,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      * Return directory file listing
      *
      * @param string $directory
-     * @return mixed
+     * @return array
      */
     public function getSubdirectories($directory)
     {
@@ -206,6 +205,7 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
      *
      * @param string $name
      * @param string $path
+     * @return void
      */
     public function deleteDirectory($name, $path)
     {
diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/File.php b/app/code/Magento/Core/Model/Resource/File/Storage/File.php
index 7bbfe64ddde68022685fd0d14e639b1510cacb89..2c9f8d5c0023332bdcb927bddf09c7f3ad70f527 100644
--- a/app/code/Magento/Core/Model/Resource/File/Storage/File.php
+++ b/app/code/Magento/Core/Model/Resource/File/Storage/File.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\File\Storage;
 
 /**
@@ -88,7 +87,7 @@ class File
      * Clear files and directories in storage
      *
      * @param string $dir
-     * @return \Magento\Core\Model\Resource\File\Storage\File
+     * @return $this
      */
     public function clear($dir = '')
     {
diff --git a/app/code/Magento/Core/Model/Resource/Flag.php b/app/code/Magento/Core/Model/Resource/Flag.php
index d1d55254b6152b6753309716c6fcf8e8332fbb84..21f091ecbb4eead7349973ea763ae356c33707b0 100644
--- a/app/code/Magento/Core/Model/Resource/Flag.php
+++ b/app/code/Magento/Core/Model/Resource/Flag.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Flag model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Flag extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/Helper.php b/app/code/Magento/Core/Model/Resource/Helper.php
index fcc35e97e6576b12dccd9b2c3cd0d11566133d75..3b2e9121bc6b4e989ed2eedcc4ec0b6f9021aa96 100644
--- a/app/code/Magento/Core/Model/Resource/Helper.php
+++ b/app/code/Magento/Core/Model/Resource/Helper.php
@@ -212,7 +212,7 @@ class Helper extends \Magento\Core\Model\Resource\Helper\AbstractHelper
      *
      * @param \Magento\DB\Select $select
      * @param string|null $groupByCondition OPTIONAL
-     * @return array
+     * @return mixed|array
      * @throws \Zend_Db_Exception
      */
     public function prepareColumnsList(\Magento\DB\Select $select, $groupByCondition = null)
diff --git a/app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php b/app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php
index b166b149d6ea8c6d147dd1838f6cc7f80ec90661..211eaec34e3bae8a9b6780836e2578801b4ea6ac 100644
--- a/app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php
+++ b/app/code/Magento/Core/Model/Resource/Helper/AbstractHelper.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Helper;
 
 /**
  * Abstract resource helper class
  */
-namespace Magento\Core\Model\Resource\Helper;
-
 abstract class AbstractHelper
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/Layout/Link.php b/app/code/Magento/Core/Model/Resource/Layout/Link.php
index f1fed3c963787701fc371cac9aa53809cac96540..49581a658071f5cdbeb90f919f6c3b11c8e05571 100644
--- a/app/code/Magento/Core/Model/Resource/Layout/Link.php
+++ b/app/code/Magento/Core/Model/Resource/Layout/Link.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Layout;
 
 /**
  * Layout Link resource model
  */
-namespace Magento\Core\Model\Resource\Layout;
-
 class Link extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php b/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php
index 739a020130661468b28538050e08ec972ae5ea31..a32d88c48b6550c5ac4c0cf66afe208fe429b524 100644
--- a/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Layout/Link/Collection.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Layout\Link;
 
 /**
@@ -83,7 +82,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Join with layout update table
      *
      * @param array $fields
-     * @return \Magento\Core\Model\Resource\Layout\Link\Collection
+     * @return $this
      */
     protected function _joinWithUpdate($fields = array())
     {
@@ -105,7 +104,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter by temporary flag
      *
      * @param bool $isTemporary
-     * @return \Magento\Core\Model\Resource\Layout\Link\Collection
+     * @return $this
      */
     public function addTemporaryFilter($isTemporary)
     {
@@ -114,10 +113,10 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     * Get links for layouts that are older then specified number of days
+     * Get links for layouts that are older than specified number of days
      *
-     * @param $days
-     * @return \Magento\Core\Model\Resource\Layout\Link\Collection
+     * @param string $days
+     * @return $this
      */
     public function addUpdatedDaysBeforeFilter($days)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Layout/Update.php b/app/code/Magento/Core/Model/Resource/Layout/Update.php
index 6eb33137637cc2b996fd063db4caba50e5e8a94d..6f369d8d4b81ef120b841ed14a74289533ab0409 100644
--- a/app/code/Magento/Core/Model/Resource/Layout/Update.php
+++ b/app/code/Magento/Core/Model/Resource/Layout/Update.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Layout;
 
 /**
  * Layout update resource model
  */
-namespace Magento\Core\Model\Resource\Layout;
-
 class Update extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -88,7 +87,7 @@ class Update extends \Magento\Core\Model\Resource\Db\AbstractDb
      */
     protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false)
     {
-        //TODO Why it also loads layout updates for store_id=0, isn't it Admin Store View?
+        //@todo Why it also loads layout updates for store_id=0, isn't it Admin Store View?
         //If 0 means 'all stores' why it then refers by foreign key to Admin in `core_store` and not to something named
         // 'All Stores'?
 
@@ -112,7 +111,7 @@ class Update extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Update a "layout update link" if relevant data is provided
      *
      * @param \Magento\Core\Model\Layout\Update|\Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Layout\Update
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php b/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php
index a8e1bf702b0cb58f8aa4f431e2aee81455e5e438..26349f46b47703872f15991dadb4c6cee2ae37bf 100644
--- a/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Layout/Update/Collection.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Layout\Update;
 
 /**
  * Layout update collection model
  */
-namespace Magento\Core\Model\Resource\Layout\Update;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -85,7 +84,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by theme id
      *
      * @param int $themeId
-     * @return \Magento\Core\Model\Resource\Layout\Update\Collection
+     * @return $this
      */
     public function addThemeFilter($themeId)
     {
@@ -100,7 +99,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by store id
      *
      * @param int $storeId
-     * @return \Magento\Core\Model\Resource\Layout\Update\Collection
+     * @return $this
      */
     public function addStoreFilter($storeId)
     {
@@ -114,7 +113,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Join with layout link table
      *
-     * @return \Magento\Core\Model\Resource\Layout\Update\Collection
+     * @return $this
      */
     protected function _joinWithLink()
     {
@@ -137,7 +136,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Left Join with layout link table
      *
      * @param array $fields
-     * @return \Magento\Core\Model\Resource\Layout\Update\Collection
+     * @return $this
      */
     protected function _joinLeftWithLink($fields = array())
     {
@@ -158,8 +157,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Get layouts that are older then specified number of days
      *
-     * @param $days
-     * @return \Magento\Core\Model\Resource\Layout\Update\Collection
+     * @param string $days
+     * @return $this
      */
     public function addUpdatedDaysBeforeFilter($days)
     {
@@ -177,7 +176,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Get layouts without links
      *
-     * @return \Magento\Core\Model\Resource\Layout\Update\Collection
+     * @return $this
      */
     public function addNoLinksFilter()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Mview/View/State.php b/app/code/Magento/Core/Model/Resource/Mview/View/State.php
index 77d374c66a17017bdb6682cf7e06fde870169d2d..fb2ca70edf354f18f33cdd2400402db30fb0598b 100644
--- a/app/code/Magento/Core/Model/Resource/Mview/View/State.php
+++ b/app/code/Magento/Core/Model/Resource/Mview/View/State.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Mview\View;
 
 class State extends \Magento\Core\Model\Resource\Db\AbstractDb
diff --git a/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php b/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php
index e949b1c116cc8783c51344314a34a764d97f944e..7de8810454340b27fc0268d96bd8249c7b55d308 100644
--- a/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Mview\View\State;
 
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
diff --git a/app/code/Magento/Core/Model/Resource/Resource.php b/app/code/Magento/Core/Model/Resource/Resource.php
index c5de880c7ce95eb1e1f53877fbdccea9acba0b35..3c1972bcaa33084f571c015b6226957a856f3ec5 100644
--- a/app/code/Magento/Core/Model/Resource/Resource.php
+++ b/app/code/Magento/Core/Model/Resource/Resource.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Core Resource Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Resource extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -67,7 +65,7 @@ class Resource extends \Magento\Core\Model\Resource\Db\AbstractDb
      * reissuing new sql just to get 'db' version of module.
      *
      * @param string $needType Can be 'db' or 'data'
-     * @return \Magento\Core\Model\Resource\Resource
+     * @return $this
      */
     protected function _loadVersionData($needType)
     {
@@ -100,7 +98,7 @@ class Resource extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Get Module version from DB
      *
      * @param string $resName
-     * @return bool|string
+     * @return false|string
      */
     public function getDbVersion($resName)
     {
@@ -158,7 +156,7 @@ class Resource extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param string $resName
      * @param string $version
-     * @return \Magento\Core\Model\Resource\Resource
+     * @return $this
      */
     public function setDataVersion($resName, $version)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Setup.php b/app/code/Magento/Core/Model/Resource/Setup.php
index 3b10fba864d2b0c5fa542dac86614738548cb6ee..836f02c0f64ec233b70679f6c1ece59879b84267 100644
--- a/app/code/Magento/Core/Model/Resource/Setup.php
+++ b/app/code/Magento/Core/Model/Resource/Setup.php
@@ -53,6 +53,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * @var \Magento\DB\Adapter\Pdo\Mysql
      */
     protected $_connection = null;
+
     /**
      * Tables cache array
      *
@@ -131,8 +132,8 @@ class Setup implements \Magento\Module\Updater\SetupInterface
 
     /**
      * @param \Magento\Core\Model\Resource\Setup\Context $context
-     * @param $resourceName
-     * @param $moduleName
+     * @param string $resourceName
+     * @param string $moduleName
      * @param string $connectionName
      */
     public function __construct(
@@ -174,7 +175,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      *
      * @param string $tableName
      * @param string $realTableName
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function setTable($tableName, $realTableName)
     {
@@ -215,7 +216,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
     /**
      * Apply data updates to the system after upgrading.
      *
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function applyDataUpdates()
     {
@@ -235,7 +236,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
     /**
      * Apply module resource install, upgrade and data scripts
      *
-     * @return \Magento\Core\Model\Resource\Setup|bool
+     * @return $this|true
      */
     public function applyUpdates()
     {
@@ -267,7 +268,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * Run data install scripts
      *
      * @param string $newVersion
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _installData($newVersion)
     {
@@ -283,7 +284,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      *
      * @param string $oldVersion
      * @param string $newVersion
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _upgradeData($oldVersion, $newVersion)
     {
@@ -297,7 +298,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * Run resource installation file
      *
      * @param string $newVersion
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _installResourceDb($newVersion)
     {
@@ -313,7 +314,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      *
      * @param string $oldVersion
      * @param string $newVersion
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _upgradeResourceDb($oldVersion, $newVersion)
     {
@@ -328,7 +329,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      *
      * @param string $newVersion
      * @param string $oldVersion
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _rollbackResourceDb($newVersion, $oldVersion)
     {
@@ -340,7 +341,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * Uninstall resource
      *
      * @param string $version existing resource version
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _uninstallResourceDb($version)
     {
@@ -427,7 +428,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      *
      * @param string $actionType
      * @param string $version
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     protected function _setResourceVersion($actionType, $version)
     {
@@ -452,7 +453,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * @param string $actionType
      * @param string $fromVersion
      * @param string $toVersion
-     * @return bool|string
+     * @return false|string
      * @throws \Magento\Exception
      */
     protected function _modifyResourceDb($actionType, $fromVersion, $toVersion)
@@ -593,10 +594,10 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * @param string $table
      * @param string $idField
      * @param string|integer $rowId
-     * @param string $field
-     * @param string $parentField
+     * @param string|null $field
+     * @param string|null $parentField
      * @param string|integer $parentId
-     * @return mixed|boolean
+     * @return mixed
      */
     public function getTableRow($table, $idField, $rowId, $field = null, $parentField = null, $parentId = 0)
     {
@@ -631,7 +632,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * @param string|int $rowId
      * @param null|string $parentField
      * @param int|string $parentId
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function deleteTableRow($table, $idField, $rowId, $parentField = null, $parentId = 0)
     {
@@ -661,7 +662,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * @param mixed|null $value
      * @param string $parentField
      * @param string|integer $parentId
-     * @return \Magento\Eav\Model\Entity\Setup
+     * @return $this
      */
     public function updateTableRow($table, $idField, $rowId, $field, $value = null, $parentField = null, $parentId = 0)
     {
@@ -709,7 +710,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * @param string $value
      * @param int|string $scope
      * @param int $scopeId
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function setConfigData($path, $value, $scope = \Magento\Core\Model\Store::DEFAULT_CODE, $scopeId = 0)
     {
@@ -732,7 +733,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      *
      * @param string $path
      * @param string $scope (default|stores|websites|config)
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function deleteConfigData($path, $scope = null)
     {
@@ -748,7 +749,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * Run plain SQL query(ies)
      *
      * @param string $sql
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function run($sql)
     {
@@ -759,7 +760,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
     /**
      * Prepare database before install/upgrade
      *
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function startSetup()
     {
@@ -770,7 +771,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
     /**
      * Prepare database after install/upgrade
      *
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function endSetup()
     {
@@ -808,7 +809,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
     /**
      * Check call afterApplyAllUpdates method for setup class
      *
-     * @return boolean
+     * @return bool
      */
     public function getCallAfterApplyAllUpdates()
     {
@@ -819,7 +820,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface
      * Run each time after applying of all updates,
      * if setup model setted $_callAfterApplyAllUpdates flag to true
      *
-     * @return \Magento\Core\Model\Resource\Setup
+     * @return $this
      */
     public function afterApplyAllUpdates()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Setup/Generic.php b/app/code/Magento/Core/Model/Resource/Setup/Generic.php
index b2c65b676aa00b6924467865081d874f23ef5f2a..ebbb5728eabbd4a7686f1911402d283b6386bca0 100644
--- a/app/code/Magento/Core/Model/Resource/Setup/Generic.php
+++ b/app/code/Magento/Core/Model/Resource/Setup/Generic.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Setup;
 
 class Generic extends \Magento\Core\Model\Resource\Setup
diff --git a/app/code/Magento/Core/Model/Resource/Setup/Migration.php b/app/code/Magento/Core/Model/Resource/Setup/Migration.php
index ec4c74e28e18d50e2a010fc47096eb8203db6af1..2285abfd895aeab5b07a467d4d70257ecec48d8a 100644
--- a/app/code/Magento/Core/Model/Resource/Setup/Migration.php
+++ b/app/code/Magento/Core/Model/Resource/Setup/Migration.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Setup;
 
 /**
@@ -194,6 +193,8 @@ class Migration extends \Magento\Core\Model\Resource\Setup
 
     /**
      * Start process of replacing aliases with class names using rules
+     *
+     * @return void
      */
     public function doUpdateClassAliases()
     {
@@ -207,6 +208,7 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      *
      * @param string $tableName name of table to replace aliases in
      * @param array $tableRules replacing rules for table
+     * @return void
      */
     protected function _updateClassAliasesInTable($tableName, array $tableRules)
     {
@@ -227,7 +229,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * @param string $tableName name of table to replace aliases in
      * @param string $fieldName name of table column to replace aliases in
      * @param string $additionalWhere additional where condition
-     *
      * @return int
      */
     protected function _getRowsCount($tableName, $fieldName, $additionalWhere = '')
@@ -252,6 +253,7 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * @param string $fieldName name of table column to replace aliases in
      * @param array $fieldRule
      * @param int $currentPage
+     * @return void
      */
     protected function _applyFieldRule($tableName, $fieldName, array $fieldRule, $currentPage = 0)
     {
@@ -293,6 +295,7 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * @param string $tableName
      * @param string $fieldName
      * @param array $fieldReplacements
+     * @return void
      */
     protected function _updateRowsData($tableName, $fieldName, array $fieldReplacements)
     {
@@ -321,7 +324,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * @param array $fieldsToSelect array of fields to select
      * @param string $additionalWhere additional where condition
      * @param int $currPage
-     *
      * @return array
      */
     protected function _getTableData($tableName, $fieldName, array $fieldsToSelect, $additionalWhere = '',
@@ -350,7 +352,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * @param string $data
      * @param string $contentType type of data (field content)
      * @param string $entityType entity type of alias
-     *
      * @return string
      */
     protected function _getReplacement($data, $contentType, $entityType = '')
@@ -378,7 +379,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      *
      * @param string $alias
      * @param string $entityType entity type of alias
-     *
      * @return string
      */
     protected function _getCorrespondingClassName($alias, $entityType = '')
@@ -479,7 +479,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * @param string $module
      * @param string $type
      * @param string $name
-     *
      * @return string
      */
     protected function _getClassName($module, $type, $name = null)
@@ -497,7 +496,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * Whether the given class name is a factory name
      *
      * @param string $factoryName
-     *
      * @return bool
      */
     protected function _isFactoryName($factoryName)
@@ -509,7 +507,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * Transform factory name into a pair of module and name
      *
      * @param string $factoryName
-     *
      * @return array
      */
     protected function _getModuleName($factoryName)
@@ -532,8 +529,7 @@ class Migration extends \Magento\Core\Model\Resource\Setup
     /**
      * Get composite module name by module alias
      *
-     * @param $moduleAlias
-     *
+     * @param string $moduleAlias
      * @return string|null
      */
     protected function _getCompositeModuleName($moduleAlias)
@@ -552,7 +548,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      *
      * @param string $alias
      * @param string $entityType
-     *
      * @return string
      */
     protected function _getAliasFromMap($alias, $entityType = '')
@@ -581,9 +576,10 @@ class Migration extends \Magento\Core\Model\Resource\Setup
     /**
      * Store already generated class name for alias
      *
-     * @param $entityType
-     * @param $alias
-     * @param $className
+     * @param string $entityType
+     * @param string $alias
+     * @param string $className
+     * @return void
      */
     protected function _pushToMap($entityType, $alias, $className)
     {
@@ -623,7 +619,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup
      * Load aliases to classes map from file
      *
      * @param string $pathToMapFile
-     *
      * @return string
      */
     protected function _loadMap($pathToMapFile)
@@ -638,7 +633,7 @@ class Migration extends \Magento\Core\Model\Resource\Setup
     /**
      * @param string $data
      * @param string $entityType
-     * @return mixed
+     * @return string
      */
     protected function _getAliasInSerializedStringReplacement($data, $entityType = '')
     {
@@ -660,7 +655,7 @@ class Migration extends \Magento\Core\Model\Resource\Setup
     /**
      * Parse class aliases from serialized string
      *
-     * @param $string
+     * @param string $string
      * @return array
      */
     protected function _parseSerializedString($string)
diff --git a/app/code/Magento/Core/Model/Resource/Store.php b/app/code/Magento/Core/Model/Resource/Store.php
index 8f4e1cf0d771190cd83f41b74f1075684d88b36a..7281e767e3cd788f7a91ba24f2b56ba0c3e997f4 100644
--- a/app/code/Magento/Core/Model/Resource/Store.php
+++ b/app/code/Magento/Core/Model/Resource/Store.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Core Store Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -66,7 +64,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize unique fields
      *
-     * @return \Magento\Core\Model\Resource\Store
+     * @return $this
      */
     protected function _initUniqueFields()
     {
@@ -81,7 +79,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Update Store Group data after save store
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Store
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -96,7 +94,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Remove core configuration data after delete store
      *
      * @param \Magento\Core\Model\AbstractModel $model
-     * @return \Magento\Core\Model\Resource\Store
+     * @return $this
      */
     protected function _afterDelete(\Magento\Core\Model\AbstractModel $model)
     {
@@ -117,7 +115,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $groupId
      * @param int $storeId
-     * @return \Magento\Core\Model\Resource\Store
+     * @return $this
      */
     protected function _updateGroupDefaultStore($groupId, $storeId)
     {
@@ -142,7 +140,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Change store group for store
      *
      * @param \Magento\Core\Model\AbstractModel $model
-     * @return \Magento\Core\Model\Resource\Store
+     * @return $this
      */
     protected function _changeGroup(\Magento\Core\Model\AbstractModel $model)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Store/Collection.php b/app/code/Magento/Core/Model/Resource/Store/Collection.php
index c954bd35c2e8e2c793da057a53a9dfb5fa3e8406..9a6afa85c5cce4d9e18ba25834f6c7e10a5b2bb0 100644
--- a/app/code/Magento/Core/Model/Resource/Store/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Store/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Store;
 
 /**
  * Stores collection
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Store;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -63,8 +61,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Set flag for load default (admin) store
      *
-     * @param boolean $loadDefault
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @param bool $loadDefault
+     * @return $this
      */
     public function setLoadDefault($loadDefault)
     {
@@ -75,7 +73,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Is load default (admin) store
      *
-     * @return boolean
+     * @return bool
      */
     public function getLoadDefault()
     {
@@ -85,7 +83,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add disable default store filter to collection
      *
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function setWithoutDefaultFilter()
     {
@@ -98,7 +96,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Group id can be passed as one single value or array of values.
      *
      * @param int|array $groupId
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function addGroupFilter($groupId)
     {
@@ -109,7 +107,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add store id(s) filter to collection
      *
      * @param int|array $store
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function addIdFilter($store)
     {
@@ -120,7 +118,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by website to collection
      *
      * @param int|array $website
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function addWebsiteFilter($website)
     {
@@ -131,7 +129,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add root category id filter to store collection
      *
      * @param int|array $category
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function addCategoryFilter($category)
     {
@@ -164,9 +162,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Load collection data
      *
-     * @param boolean $printQuery
-     * @param boolean $logQuery
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @param bool $printQuery
+     * @param bool $logQuery
+     * @return $this
      */
     public function load($printQuery = false, $logQuery = false)
     {
@@ -186,7 +184,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add root category id filter to store collection
      *
      * @param array $categories
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function loadByCategoryIds(array $categories)
     {
@@ -199,7 +197,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add store root category data to collection
      *
-     * @return \Magento\Core\Model\Resource\Store\Collection
+     * @return $this
      */
     public function addRootCategoryIdAttribute()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Store/Group.php b/app/code/Magento/Core/Model/Resource/Store/Group.php
index 4ec62f7cde249637ae7352c881fab7b4bf5b107f..6e9c2067b7a344a316f53f4b8cba6e87d4a13913 100644
--- a/app/code/Magento/Core/Model/Resource/Store/Group.php
+++ b/app/code/Magento/Core/Model/Resource/Store/Group.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Store;
 
 /**
  * Store group resource model
@@ -32,13 +32,10 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Store;
-
 class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Define main table
-     *
      */
     protected function _construct()
     {
@@ -49,7 +46,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Update default store group for website
      *
      * @param \Magento\Core\Model\AbstractModel $model
-     * @return \Magento\Core\Model\Resource\Store\Group
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $model)
     {
@@ -65,7 +62,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $websiteId
      * @param int $groupId
-     * @return \Magento\Core\Model\Resource\Store\Group
+     * @return $this
      */
     protected function _updateWebsiteDefaultGroup($websiteId, $groupId)
     {
@@ -86,7 +83,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Change store group website
      *
      * @param \Magento\Core\Model\AbstractModel $model
-     * @return \Magento\Core\Model\Resource\Store\Group
+     * @return $this
      */
     protected function _changeWebsite(\Magento\Core\Model\AbstractModel $model)
     {
@@ -110,7 +107,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $groupId
      * @param int $websiteId
-     * @return \Magento\Core\Model\Resource\Store\Group
+     * @return $this
      */
     protected function _updateStoreWebsite($groupId, $websiteId)
     {
@@ -125,7 +122,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $groupId
      * @param int $storeId
-     * @return \Magento\Core\Model\Resource\Store\Group
+     * @return $this
      */
     protected function _saveDefaultStore($groupId, $storeId)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php b/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php
index cf0692f66f912bd413e2fe7e22f7c8ab805363ef..d8ab0fd943700ac08d9bf81be31b1ab74774c679 100644
--- a/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Store/Group/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Store\Group;
 
 /**
  * Store group collection
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Store\Group;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -50,8 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set flag for load default (admin) store
      *
      * @param boolean $loadDefault
-     *
-     * @return \Magento\Core\Model\Resource\Store\Group\Collection
+     * @return $this
      */
     public function setLoadDefault($loadDefault)
     {
@@ -71,7 +68,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add disable default store group filter to collection
      *
-     * @return \Magento\Core\Model\Resource\Store\Group\Collection
+     * @return $this
      */
     public function setWithoutDefaultFilter()
     {
@@ -81,7 +78,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Filter to discard stores without views
      *
-     * @return \Magento\Core\Model\Resource\Store\Group\Collection
+     * @return $this
      */
     public function setWithoutStoreViewFilter()
     {
@@ -91,7 +88,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Load collection data
      *
-     * @return \Magento\Core\Model\Resource\Store\Group\Collection
+     * @return $this
      */
     public function _beforeLoad()
     {
@@ -116,8 +113,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by website to collection
      *
      * @param int|array $website
-     *
-     * @return \Magento\Core\Model\Resource\Store\Group\Collection
+     * @return $this
      */
     public function addWebsiteFilter($website)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Theme.php b/app/code/Magento/Core/Model/Resource/Theme.php
index 45018e078dc4ad7685f1c92287ea0c6ef993e663..fd3452373ace5fb14d46c4e4a622206ca289f2ff 100644
--- a/app/code/Magento/Core/Model/Resource/Theme.php
+++ b/app/code/Magento/Core/Model/Resource/Theme.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource;
 
 /**
  * Theme resource model
  */
-namespace Magento\Core\Model\Resource;
-
 class Theme extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/Theme/Collection.php b/app/code/Magento/Core/Model/Resource/Theme/Collection.php
index dcbfc0f99b933517ee9146825a0a39de78fd6a43..26ed41a1c727b3a872a1cbb6ded812ccd4522c88 100644
--- a/app/code/Magento/Core/Model/Resource/Theme/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Theme/Collection.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Theme;
 
 /**
  * Theme collection
  */
-namespace Magento\Core\Model\Resource\Theme;
-
 class Collection
     extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
     implements \Magento\View\Design\Theme\Label\ListInterface, \Magento\View\Design\Theme\ListInterface
@@ -49,7 +48,7 @@ class Collection
     /**
      * Add title for parent themes
      *
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function addParentTitle()
     {
@@ -65,7 +64,7 @@ class Collection
      * Add area filter
      *
      * @param string $area
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function addAreaFilter($area = \Magento\Core\Model\App\Area::AREA_FRONTEND)
     {
@@ -78,7 +77,7 @@ class Collection
      *
      * @param int $typeParent
      * @param int $typeChild
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function addTypeRelationFilter($typeParent, $typeChild)
     {
@@ -94,7 +93,7 @@ class Collection
      * Add type filter
      *
      * @param string|array $type
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function addTypeFilter($type)
     {
@@ -105,7 +104,7 @@ class Collection
     /**
      * Filter visible themes in backend (physical and virtual only)
      *
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function filterVisibleThemes()
     {
@@ -209,7 +208,7 @@ class Collection
      *
      * @param string $area
      * @param int $type
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function filterThemeCustomizations(
         $area = \Magento\Core\Model\App\Area::AREA_FRONTEND,
diff --git a/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php b/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php
index 941da970b9b3ae22861b25f8d4b2745938e3feeb..afc8ef68c888c37ac1e1443b0b0fd8fb89cada98 100644
--- a/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php
+++ b/app/code/Magento/Core/Model/Resource/Theme/Customization/Update.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Theme\Customization;
 
 /**
  * Theme customization link resource model
  */
-namespace Magento\Core\Model\Resource\Theme\Customization;
-
 class Update extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/Theme/File.php b/app/code/Magento/Core/Model/Resource/Theme/File.php
index fecab4c37eabdc61501e9cf7e427cfe9231f9955..174e7b5b4fc5f8b24cd90385aa5dd81085dcf11b 100644
--- a/app/code/Magento/Core/Model/Resource/Theme/File.php
+++ b/app/code/Magento/Core/Model/Resource/Theme/File.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Theme;
 
 /**
  * Theme files resource model
  */
-namespace Magento\Core\Model\Resource\Theme;
-
 class File extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
diff --git a/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php b/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php
index 62805541b1f1751cec1c4db146bbef49184da1b9..d458c50b17b4d09bc28b82ae359e9e77ca29a8af 100644
--- a/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Theme/File/Collection.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Theme\File;
 
 /**
  * Theme files collection
  */
-namespace Magento\Core\Model\Resource\Theme\File;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
     implements \Magento\View\Design\Theme\File\CollectionInterface
 {
@@ -43,11 +42,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add select order
      *
-     * $field is properly quoted, lately it was treated field "order" as special SQL word and was not working
+     * The $field parameter is properly quoted, lately it was treated field "order" as special SQL
+     * word and was not working
      *
      * @param string $field
      * @param string $direction
-     * @return \Magento\Core\Model\Resource\Theme\File\Collection|\Magento\Data\Collection|\Magento\Data\Collection\Db
+     * @return $this
      */
     public function setOrder($field, $direction = self::SORT_ORDER_DESC)
     {
@@ -58,7 +58,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set default order
      *
      * @param string $direction
-     * @return \Magento\Core\Model\Resource\Theme\File\Collection
+     * @return $this
      */
     public function setDefaultOrder($direction = self::SORT_ORDER_ASC)
     {
@@ -69,7 +69,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter out files that do not belong to a theme
      *
      * @param \Magento\View\Design\ThemeInterface $theme
-     * @return \Magento\Core\Model\Resource\Theme\File\Collection
+     * @return $this
      */
     public function addThemeFilter(\Magento\View\Design\ThemeInterface $theme)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Theme/Grid/Collection.php b/app/code/Magento/Core/Model/Resource/Theme/Grid/Collection.php
index b0ca784efc4f9c700f68d42e365b568e32910b5a..f6e64bbc4f861efcf254910feae182cb8ecdb724 100644
--- a/app/code/Magento/Core/Model/Resource/Theme/Grid/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Theme/Grid/Collection.php
@@ -23,19 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Theme\Grid;
 
 /**
  * Theme grid collection
  */
-namespace Magento\Core\Model\Resource\Theme\Grid;
-
 class Collection extends \Magento\Core\Model\Resource\Theme\Collection
 {
     /**
      * Add area filter
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection|
-     *  \Magento\Core\Model\Resource\Theme\Grid\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Transaction.php b/app/code/Magento/Core/Model/Resource/Transaction.php
index ecf3e2dea54235098a960d0c529da84fd7cba7eb..f82a98e7739fc8eb5eb22e9c5d298500fc259274 100644
--- a/app/code/Magento/Core/Model/Resource/Transaction.php
+++ b/app/code/Magento/Core/Model/Resource/Transaction.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Resource transaction model
@@ -33,8 +33,6 @@
  * @package    Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Transaction
 {
     /**
@@ -57,10 +55,11 @@ class Transaction
      * @var array
      */
     protected $_beforeCommitCallbacks = array();
+
     /**
      * Begin transaction for all involved object resources
      *
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      */
     protected function _startTransaction()
     {
@@ -73,7 +72,7 @@ class Transaction
     /**
      * Commit transaction for all resources
      *
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      */
     protected function _commitTransaction()
     {
@@ -86,7 +85,7 @@ class Transaction
     /**
      * Rollback transaction
      *
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      */
     protected function _rollbackTransaction()
     {
@@ -99,7 +98,7 @@ class Transaction
     /**
      * Run all configured object callbacks
      *
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      */
     protected function _runCallbacks()
     {
@@ -114,7 +113,7 @@ class Transaction
      *
      * @param \Magento\Core\Model\AbstractModel $object
      * @param string $alias
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      */
     public function addObject(\Magento\Core\Model\AbstractModel $object, $alias='')
     {
@@ -129,7 +128,7 @@ class Transaction
      * Add callback function which will be called before commit transactions
      *
      * @param callback $callback
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      */
     public function addCommitCallback($callback)
     {
@@ -140,7 +139,7 @@ class Transaction
     /**
      * Initialize objects save transaction
      *
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      * @throws \Exception
      */
     public function save()
@@ -177,7 +176,7 @@ class Transaction
     /**
      * Initialize objects delete transaction
      *
-     * @return \Magento\Core\Model\Resource\Transaction
+     * @return $this
      * @throws \Exception
      */
     public function delete()
diff --git a/app/code/Magento/Core/Model/Resource/Translate.php b/app/code/Magento/Core/Model/Resource/Translate.php
index 4d400fb80fc6988c11889a786a9ecfad89091755..006652ce546b0ec1279d85ebaa1b7ae93ff74add 100644
--- a/app/code/Magento/Core/Model/Resource/Translate.php
+++ b/app/code/Magento/Core/Model/Resource/Translate.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Translation resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magento\Translate\ResourceInterface
 {
     /**
@@ -64,7 +62,6 @@ class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb implements \M
 
     /**
      * Define main table
-     *
      */
     protected function _construct()
     {
@@ -111,7 +108,7 @@ class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb implements \M
      * Retrieve translations array by strings
      *
      * @param array $strings
-     * @param int_type $storeId
+     * @param int|null $storeId
      * @return array
      */
     public function getTranslationArrayByStrings(array $strings, $storeId = null)
diff --git a/app/code/Magento/Core/Model/Resource/Translate/String.php b/app/code/Magento/Core/Model/Resource/Translate/String.php
index 080fd314747680357bd5be11f0f00d7088a3058c..ffb641a792adfb2bf9d823527b575e2cb4380cc1 100644
--- a/app/code/Magento/Core/Model/Resource/Translate/String.php
+++ b/app/code/Magento/Core/Model/Resource/Translate/String.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Translate;
 
 /**
  * String translate resource model
@@ -32,7 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Translate;
 
 class String extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
@@ -76,7 +75,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\Core\Model\AbstractModel $object
      * @param String $value
      * @param String $field
-     * @return array
+     * @return array|$this
      */
     public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null)
     {
@@ -112,7 +111,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb
      * After translation loading
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Db\AbstractDb
+     * @return $this
      */
     public function _afterLoad(\Magento\Core\Model\AbstractModel $object)
     {
@@ -129,7 +128,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Before save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Translate\String
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -152,7 +151,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb
      * After save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Translate\String
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -199,7 +198,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param string $string
      * @param string $locale
      * @param int|null $storeId
-     * @return \Magento\Core\Model\Resource\Translate\String
+     * @return $this
      */
     public function deleteTranslate($string, $locale = null, $storeId = null)
     {
@@ -230,7 +229,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param String $translate
      * @param String $locale
      * @param int|null $storeId
-     * @return \Magento\Core\Model\Resource\Translate\String
+     * @return $this
      */
     public function saveTranslate($string, $translate, $locale = null, $storeId = null)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Type/AbstractType.php b/app/code/Magento/Core/Model/Resource/Type/AbstractType.php
index 3cbe30ac1a6ee0aeab3d75e87da14166852b765b..095b349949f81f1de769a49a6ed416541a8fd538 100644
--- a/app/code/Magento/Core/Model/Resource/Type/AbstractType.php
+++ b/app/code/Magento/Core/Model/Resource/Type/AbstractType.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Core\Model\Resource\Type;
 
 abstract class AbstractType
@@ -57,6 +55,7 @@ abstract class AbstractType
      * Set name
      *
      * @param String $name
+     * @return void
      */
     public function setName($name)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Type/Db.php b/app/code/Magento/Core/Model/Resource/Type/Db.php
index a679727fbb0c5c70785caf82923dcb1fb694ac35..68df0a5500cfb4a95f8d1267712dd1f44c09c382 100644
--- a/app/code/Magento/Core/Model/Resource/Type/Db.php
+++ b/app/code/Magento/Core/Model/Resource/Type/Db.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Resource\Type;
 
 abstract class Db extends \Magento\Core\Model\Resource\Type\AbstractType
diff --git a/app/code/Magento/Core/Model/Resource/Url/Rewrite.php b/app/code/Magento/Core/Model/Resource/Url/Rewrite.php
index 42ca088ed76d998be67bad50bec0fe87969a480f..6d63a85779ba26835389c743f8e880dd831bc85e 100644
--- a/app/code/Magento/Core/Model/Resource/Url/Rewrite.php
+++ b/app/code/Magento/Core/Model/Resource/Url/Rewrite.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Url;
 
 /**
  * Url rewrite resource model class
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Url;
-
 class Rewrite extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -48,7 +46,7 @@ class Rewrite extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize array fields
      *
-     * @return \Magento\Core\Model\Resource\Url\Rewrite
+     * @return $this
      */
     protected function _initUniqueFields()
     {
@@ -92,7 +90,7 @@ class Rewrite extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param string $idPath
      * @param int|\Magento\Core\Model\Store $store
-     * @return string|false
+     * @return string
      */
     public function getRequestPathByIdPath($idPath, $store)
     {
@@ -123,7 +121,7 @@ class Rewrite extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param   \Magento\Core\Model\Url\Rewrite $object
      * @param   array|string $path
-     * @return  \Magento\Core\Model\Resource\Url\Rewrite
+     * @return  $this
      */
     public function loadByRequestPath(\Magento\Core\Model\Url\Rewrite $object, $path)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php b/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php
index 9dc3059a53c91b931db5ff4154b49ae930c64efa..a77c38725ed9ce192fa91c163e8f68fad9962736 100644
--- a/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php
@@ -79,7 +79,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param mixed $store
      * @param bool $withAdmin
-     * @return \Magento\Core\Model\Resource\Url\Rewrite\Collection
+     * @return $this
      */
     public function addStoreFilter($store, $withAdmin = true)
     {
@@ -99,7 +99,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *  Add filter by catalog product Id
      *
      * @param int $productId
-     * @return \Magento\Core\Model\Resource\Url\Rewrite\Collection
+     * @return $this
      */
     public function filterAllByProductId($productId)
     {
@@ -113,7 +113,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add filter by all catalog category
      *
-     * @return \Magento\Core\Model\Resource\Url\Rewrite\Collection
+     * @return $this
      */
     public function filterAllByCategory()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Variable.php b/app/code/Magento/Core/Model/Resource/Variable.php
index 4594b36a64e827c810cc654f56a8aa08cbeb9cb2..c2d7070bad6508d14cde3541a7743c42fb958abf 100644
--- a/app/code/Magento/Core/Model/Resource/Variable.php
+++ b/app/code/Magento/Core/Model/Resource/Variable.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Custom variable resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Variable extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -50,7 +48,7 @@ class Variable extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Core\Model\Variable $object
      * @param string $code
-     * @return \Magento\Core\Model\Resource\Variable
+     * @return $this
      */
     public function loadByCode(\Magento\Core\Model\Variable $object, $code)
     {
@@ -64,7 +62,7 @@ class Variable extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve variable data by code
      *
      * @param string $code
-     * @param boolean $withValue
+     * @param bool $withValue
      * @param integer $storeId
      * @return array
      */
@@ -83,7 +81,7 @@ class Variable extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Perform actions after object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Variable
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -120,7 +118,7 @@ class Variable extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param string $field
      * @param mixed $value
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Zend_Db_Select
+     * @return $this
      */
     protected function _getLoadSelect($field, $value, $object)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Variable/Collection.php b/app/code/Magento/Core/Model/Resource/Variable/Collection.php
index 42f6fa96f8ccd33564613017268708062b0d71a0..c7b49779a53ca0dbe1e4cf826dced31b50f6a419 100644
--- a/app/code/Magento/Core/Model/Resource/Variable/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Variable/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Variable;
 
 /**
  * Custom variable collection
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Variable;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -57,7 +55,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Setter
      *
      * @param integer $storeId
-     * @return \Magento\Core\Model\Resource\Variable\Collection
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -78,7 +76,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add store values to result
      *
-     * @return \Magento\Core\Model\Resource\Variable\Collection
+     * @return $this
      */
     public function addValuesToResult()
     {
diff --git a/app/code/Magento/Core/Model/Resource/Website.php b/app/code/Magento/Core/Model/Resource/Website.php
index 36ee0d6f63002914d1c0038e552cd9eb612ef64b..a167e15dfbd762bd050f385422bdb63398370c56 100644
--- a/app/code/Magento/Core/Model/Resource/Website.php
+++ b/app/code/Magento/Core/Model/Resource/Website.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource;
 
 /**
  * Core Website Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource;
-
 class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -48,7 +46,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize unique fields
      *
-     * @return \Magento\Core\Model\Resource\Website
+     * @return $this
      */
     protected function _initUniqueFields()
     {
@@ -63,8 +61,8 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Validate website code before object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
+     * @return $this
      * @throws \Magento\Core\Exception
-     * @return \Magento\Core\Model\Resource\Website
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -79,7 +77,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Perform actions after object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Core\Model\Resource\Website
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
@@ -95,7 +93,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Remove core configuration data after delete website
      *
      * @param \Magento\Core\Model\AbstractModel $model
-     * @return \Magento\Core\Model\Resource\Website
+     * @return $this
      */
     protected function _afterDelete(\Magento\Core\Model\AbstractModel $model)
     {
@@ -114,7 +112,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve default stores select object
      * Select fields website_id, store_id
      *
-     * @param boolean $includeDefault include/exclude default admin website
+     * @param bool $includeDefault include/exclude default admin website
      * @return \Magento\DB\Select
      */
     public function getDefaultStoresSelect($includeDefault = false)
diff --git a/app/code/Magento/Core/Model/Resource/Website/Collection.php b/app/code/Magento/Core/Model/Resource/Website/Collection.php
index 358d50da33bc19c694acec2e46bd1bcaada362cb..f3d38639889191e9cfef0252d11dcd8c63f5779d 100644
--- a/app/code/Magento/Core/Model/Resource/Website/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Website/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\Resource\Website;
 
 /**
  * Websites collection
@@ -32,8 +32,6 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Website;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -55,6 +53,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Apply custom filtering
+     *
+     * @return void
      */
     protected function _renderFiltersBefore()
     {
@@ -67,8 +67,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Set flag for load default (admin) website
      *
-     * @param boolean $loadDefault
-     * @return \Magento\Core\Model\Resource\Website\Collection
+     * @param bool $loadDefault
+     * @return $this
      */
     public function setLoadDefault($loadDefault)
     {
@@ -79,7 +79,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Is load default (admin) website
      *
-     * @return boolean
+     * @return bool
      */
     public function getLoadDefault()
     {
@@ -89,7 +89,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Convert items array to array for select options
      *
-     * @return Array
+     * @return array
      */
     public function toOptionArray()
     {
@@ -99,7 +99,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Convert items array to hash for select options
      *
-     * @return Array
+     * @return array
      */
     public function toOptionHash()
     {
@@ -111,7 +111,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add website filter to collection
      *
      * @param int $ids|array
-     * @return \Magento\Core\Model\Resource\Website\Collection
+     * @return $this
      */
     public function addIdFilter($ids)
     {
@@ -132,7 +132,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param boolean $printQuery
      * @param boolean $logQuery
-     * @return \Magento\Core\Model\Resource\Website\Collection
+     * @return $this
      */
     public function load($printQuery = false, $logQuery = false)
     {
@@ -149,7 +149,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Sets extra combined ordering by group's name, defined
      * sort ordering and store's name.
      *
-     * @return \Magento\Core\Model\Resource\Website\Collection
+     * @return $this
      */
     public function joinGroupAndStore()
     {
@@ -179,7 +179,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * tables with appropriate information were joined before.
      *
      * @param int|array $groupIds
-     * @return \Magento\Core\Model\Resource\Website\Collection
+     * @return $this
      */
     public function addFilterByGroupIds($groupIds)
     {
diff --git a/app/code/Magento/Core/Model/Resource/Website/Grid/Collection.php b/app/code/Magento/Core/Model/Resource/Website/Grid/Collection.php
index fbbcdaecfda39c2cf7bb9302b887bd63cc3241e8..fe9b581fdc18f38c7db1ca9925c2c3d5152a52ea 100644
--- a/app/code/Magento/Core/Model/Resource/Website/Grid/Collection.php
+++ b/app/code/Magento/Core/Model/Resource/Website/Grid/Collection.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Resource\Website\Grid;
 
 /**
  * Grid collection
@@ -31,14 +32,12 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\Resource\Website\Grid;
-
 class Collection extends \Magento\Core\Model\Resource\Website\Collection
 {
     /**
      * Join website and store names
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection|\Magento\Core\Model\Resource\Website\Grid\Collection
+     * @return $this
      */
     protected function  _initSelect()
     {
diff --git a/app/code/Magento/Core/Model/Session/Config.php b/app/code/Magento/Core/Model/Session/Config.php
index a385cc6a1e828f46bd39853933cd16be1f3b58de..3a1530217df60a4ca233b1f3eb641ed0d980080c 100644
--- a/app/code/Magento/Core/Model/Session/Config.php
+++ b/app/code/Magento/Core/Model/Session/Config.php
@@ -25,12 +25,14 @@
  */
 namespace Magento\Core\Model\Session;
 
+use Magento\Session\Config\ConfigInterface;
+
 /**
  * Magento session configuration
  *
  * @method Config setSaveHandler()
  */
-class Config implements \Magento\Session\Config\ConfigInterface
+class Config implements ConfigInterface
 {
     /**
      * Configuration path for session save method
@@ -102,7 +104,7 @@ class Config implements \Magento\Session\Config\ConfigInterface
     /**
      * List of boolean options
      *
-     * @var array
+     * @var string[]
      */
     protected $booleanOptions = array(
         'session.use_cookies',
@@ -504,7 +506,7 @@ class Config implements \Magento\Session\Config\ConfigInterface
      * Set storage option in backend configuration store
      *
      * @param string $option
-     * @param mixed $value
+     * @param string $value
      * @return $this
      * @throws \InvalidArgumentException
      */
@@ -522,7 +524,7 @@ class Config implements \Magento\Session\Config\ConfigInterface
      * Retrieve a storage option from a backend configuration store
      *
      * @param string $option
-     * @return mixed
+     * @return string|bool
      */
     protected function getStorageOption($option)
     {
@@ -567,7 +569,7 @@ class Config implements \Magento\Session\Config\ConfigInterface
      * @param  string $method
      * @param  array $args
      * @return mixed
-     * @throws \BadMethodCallException on non-getter/setter method
+     * @throws \BadMethodCallException On non-getter/setter method
      */
     public function __call($method, $args)
     {
diff --git a/app/code/Magento/Core/Model/Session/Pool.php b/app/code/Magento/Core/Model/Session/Pool.php
index f7c09b0c94541558cf151c7cfa8938a1c7838fa2..cfb27bbcc7d18a99e7044ae9d477333dbdd61da7 100644
--- a/app/code/Magento/Core/Model/Session/Pool.php
+++ b/app/code/Magento/Core/Model/Session/Pool.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Core\Model\Session;
 
+use Magento\Session\SessionManagerInterface;
+
 class Pool
 {
     /**
@@ -47,12 +49,12 @@ class Pool
      * @param string $instanceName
      * @param array $data
      * @throws \LogicException
-     * @return \Magento\Session\SessionManagerInterface
+     * @return SessionManagerInterface
      */
     public function get($instanceName, $data = array())
     {
         $object = $this->_objectManager->get($instanceName, array('data' => $data));
-        if (!$object instanceof \Magento\Session\SessionManagerInterface) {
+        if (!$object instanceof SessionManagerInterface) {
             throw new \LogicException($instanceName . ' doesn\'t implement \Magento\Session\SessionManagerInterface');
         }
 
diff --git a/app/code/Magento/Core/Model/Session/SidResolver.php b/app/code/Magento/Core/Model/Session/SidResolver.php
index 63050bee61787f841b61845102cbbd19202b6d1d..591851e32f2536ea2dfa8f5f5f571ffc3afe51b5 100644
--- a/app/code/Magento/Core/Model/Session/SidResolver.php
+++ b/app/code/Magento/Core/Model/Session/SidResolver.php
@@ -27,7 +27,10 @@
  */
 namespace Magento\Core\Model\Session;
 
-class SidResolver implements \Magento\Session\SidResolverInterface
+use Magento\Session\SessionManagerInterface;
+use Magento\Session\SidResolverInterface;
+
+class SidResolver implements SidResolverInterface
 {
     /**
      * Config path for flag whether use SID on frontend
@@ -64,8 +67,8 @@ class SidResolver implements \Magento\Session\SidResolverInterface
     /**
      * Use session in URL flag
      *
-     * @see \Magento\UrlInterface
      * @var bool
+     * @see \Magento\UrlInterface
      */
     protected $_useSessionInUrl = true;
 
@@ -88,10 +91,10 @@ class SidResolver implements \Magento\Session\SidResolverInterface
     }
 
     /**
-     * @param \Magento\Session\SessionManagerInterface $session
+     * @param SessionManagerInterface $session
      * @return string
      */
-    public function getSid(\Magento\Session\SessionManagerInterface $session)
+    public function getSid(SessionManagerInterface $session)
     {
         $sidKey = null;
         if ($this->coreStoreConfig->getConfig(self::XML_PATH_USE_FRONTEND_SID)
@@ -106,10 +109,10 @@ class SidResolver implements \Magento\Session\SidResolverInterface
     /**
      * Get session id query param
      *
-     * @param \Magento\Session\SessionManagerInterface $session
+     * @param SessionManagerInterface $session
      * @return string
      */
-    public function getSessionIdQueryParam(\Magento\Session\SessionManagerInterface $session)
+    public function getSessionIdQueryParam(SessionManagerInterface $session)
     {
         $sessionName = $session->getName();
         if ($sessionName && isset($this->sidNameMap[$sessionName])) {
@@ -122,7 +125,7 @@ class SidResolver implements \Magento\Session\SidResolverInterface
      * Set use session var instead of SID for URL
      *
      * @param bool $var
-     * @return \Magento\Session\SidResolverInterface
+     * @return $this
      */
     public function setUseSessionVar($var)
     {
@@ -144,7 +147,7 @@ class SidResolver implements \Magento\Session\SidResolverInterface
      * Set Use session in URL flag
      *
      * @param bool $flag
-     * @return \Magento\Session\SidResolverInterface
+     * @return $this
      */
     public function setUseSessionInUrl($flag = true)
     {
diff --git a/app/code/Magento/Core/Model/Session/Validator.php b/app/code/Magento/Core/Model/Session/Validator.php
index 75d791f5391993b6d33c12db5965bc081072fa07..ed05fce63d95cc922a7d7a99ca14550bb1370efc 100644
--- a/app/code/Magento/Core/Model/Session/Validator.php
+++ b/app/code/Magento/Core/Model/Session/Validator.php
@@ -23,10 +23,14 @@
  */
 namespace Magento\Core\Model\Session;
 
+use Magento\Session\Exception;
+use Magento\Session\SessionManagerInterface;
+use Magento\Session\ValidatorInterface;
+
 /**
  * Session Validator
  */
-class Validator implements \Magento\Session\ValidatorInterface
+class Validator implements ValidatorInterface
 {
     const VALIDATOR_KEY                         = '_session_validator_data';
     const VALIDATOR_HTTP_USER_AGENT_KEY         = 'http_user_agent';
@@ -72,10 +76,11 @@ class Validator implements \Magento\Session\ValidatorInterface
     /**
      * Validate session
      *
-     * @param \Magento\Session\SessionManagerInterface $session
-     * @throws \Magento\Session\Exception
+     * @param SessionManagerInterface $session
+     * @return void
+     * @throws Exception
      */
-    public function validate(\Magento\Session\SessionManagerInterface $session)
+    public function validate(SessionManagerInterface $session)
     {
         if (!isset($_SESSION[self::VALIDATOR_KEY])) {
             $_SESSION[self::VALIDATOR_KEY] = $this->_getSessionEnvironment();
@@ -83,7 +88,7 @@ class Validator implements \Magento\Session\ValidatorInterface
             if (!$this->_validate()) {
                 $session->destroy(array('clear_storage' => false));
                 // throw core session exception
-                throw new \Magento\Session\Exception('');
+                throw new Exception('');
             }
         }
     }
diff --git a/app/code/Magento/Core/Model/Source/Urlrewrite/Options.php b/app/code/Magento/Core/Model/Source/Urlrewrite/Options.php
index 0d5370a8fd3e7fc2a8d2d1a1ae3e41b716d9587d..f6e176072901521af5a65e5d520e0a3f39da0e3e 100644
--- a/app/code/Magento/Core/Model/Source/Urlrewrite/Options.php
+++ b/app/code/Magento/Core/Model/Source/Urlrewrite/Options.php
@@ -33,7 +33,9 @@
  */
 namespace Magento\Core\Model\Source\Urlrewrite;
 
-class Options implements \Magento\Core\Model\Option\ArrayInterface
+use Magento\Core\Model\Option\ArrayInterface;
+
+class Options implements ArrayInterface
 {
     const TEMPORARY = 'R';
     const PERMANENT = 'RP';
@@ -63,7 +65,7 @@ class Options implements \Magento\Core\Model\Option\ArrayInterface
     /**
      * Get options list (redirects only)
      *
-     * @return array
+     * @return string[]
      */
     public function getRedirectOptions()
     {
diff --git a/app/code/Magento/Core/Model/Store.php b/app/code/Magento/Core/Model/Store.php
index 61db3a5e753dd1572e7fed8e5ebb872d274bddda..edaf96666af1847fd812d24869d1826ce1466276 100644
--- a/app/code/Magento/Core/Model/Store.php
+++ b/app/code/Magento/Core/Model/Store.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model;
 
+use Magento\Directory\Model\Currency\Filter;
+
 /**
  * Store model
  *
@@ -357,6 +358,9 @@ class Store extends AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return string[]
+     */
     public function __sleep()
     {
         $properties = parent::__sleep();
@@ -370,6 +374,8 @@ class Store extends AbstractModel
 
     /**
      * Init not serializable fields
+     *
+     * @return void
      */
     public function __wakeup()
     {
@@ -386,6 +392,8 @@ class Store extends AbstractModel
 
     /**
      * Initialize object
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -414,7 +422,7 @@ class Store extends AbstractModel
      */
     protected function _getValidationRulesBeforeSave()
     {
-        $validator = new \Magento\Validator\Composite\VarienObject();
+        $validator = new \Magento\Validator\Object();
 
         $storeLabelRule = new \Zend_Validate_NotEmpty();
         $storeLabelRule->setMessage(
@@ -438,7 +446,7 @@ class Store extends AbstractModel
      *
      * @param   mixed $key
      * @param   string $field
-     * @return  \Magento\Core\Model\Store
+     * @return  $this
      */
     public function load($key, $field = null)
     {
@@ -481,7 +489,7 @@ class Store extends AbstractModel
      *
      * @param string $path
      * @param mixed $value
-     * @return \Magento\Core\Model\Store
+     * @return $this
      */
     public function setConfig($path, $value)
     {
@@ -492,9 +500,10 @@ class Store extends AbstractModel
     /**
      * Set relation to the website
      *
-     * @param \Magento\Core\Model\Website $website
+     * @param Website $website
+     * @return void
      */
-    public function setWebsite(\Magento\Core\Model\Website $website)
+    public function setWebsite(Website $website)
     {
         $this->setWebsiteId($website->getId());
     }
@@ -502,7 +511,7 @@ class Store extends AbstractModel
     /**
      * Retrieve store website
      *
-     * @return \Magento\Core\Model\Website|bool
+     * @return Website|bool
      */
     public function getWebsite()
     {
@@ -959,10 +968,10 @@ class Store extends AbstractModel
     /**
      * Convert price from default currency to current currency
      *
-     * @param   double $price
-     * @param   boolean $format             Format price to currency format
-     * @param   boolean $includeContainer   Enclose into <span class="price"><span>
-     * @return  double
+     * @param   float $price
+     * @param   bool $format             Format price to currency format
+     * @param   bool $includeContainer   Enclose into <span class="price"><span>
+     * @return  float
      */
     public function convertPrice($price, $format = false, $includeContainer = true)
     {
@@ -981,8 +990,8 @@ class Store extends AbstractModel
     /**
      * Round price
      *
-     * @param mixed $price
-     * @return double
+     * @param float $price
+     * @return float
      */
     public function roundPrice($price)
     {
@@ -992,7 +1001,7 @@ class Store extends AbstractModel
     /**
      * Format price with currency filter (taking rate into consideration)
      *
-     * @param   double $price
+     * @param   float $price
      * @param   bool $includeContainer
      * @return  string
      */
@@ -1007,7 +1016,7 @@ class Store extends AbstractModel
     /**
      * Get store price filter
      *
-     * @return \Magento\Filter\Sprintf
+     * @return Filter|\Magento\Filter\Sprintf
      */
     public function getPriceFilter()
     {
@@ -1041,6 +1050,7 @@ class Store extends AbstractModel
      * Set group model for store
      *
      * @param \Magento\Core\Model\Store\Group $group
+     * @return void
      */
     public function setGroup($group)
     {
@@ -1181,7 +1191,7 @@ class Store extends AbstractModel
      *
      * Register indexing event before delete store
      *
-     * @return \Magento\Core\Model\Store
+     * @return $this
      */
     protected function _beforeDelete()
     {
@@ -1193,9 +1203,9 @@ class Store extends AbstractModel
     }
 
     /**
-     * rewrite in order to clear configuration cache
+     * Rewrite in order to clear configuration cache
      *
-     * @return \Magento\Core\Model\Store
+     * @return $this
      */
     protected function _afterDelete()
     {
@@ -1207,7 +1217,7 @@ class Store extends AbstractModel
     /**
      * Init indexing process after store delete commit
      *
-     * @return \Magento\Core\Model\Store
+     * @return $this
      */
     protected function _afterDeleteCommit()
     {
@@ -1220,7 +1230,7 @@ class Store extends AbstractModel
     /**
      * Reinit and reset Config Data
      *
-     * @return \Magento\Core\Model\Store
+     * @return $this
      */
     public function resetConfig()
     {
@@ -1264,7 +1274,7 @@ class Store extends AbstractModel
      * Set url model for current store
      *
      * @param \Magento\UrlInterface $urlModel
-     * @return \Magento\Core\Model\Store
+     * @return $this
      */
     public function setUrlModel($urlModel)
     {
diff --git a/app/code/Magento/Core/Model/Store/Config.php b/app/code/Magento/Core/Model/Store/Config.php
index 454921305060c519fad63b9d0f007c93f75844f4..6739e7d6100930c4ec6a7982d59b44356c6f6c13 100644
--- a/app/code/Magento/Core/Model/Store/Config.php
+++ b/app/code/Magento/Core/Model/Store/Config.php
@@ -67,8 +67,8 @@ class Config implements \Magento\Core\Model\Store\ConfigInterface
      * Retrieve store config value
      *
      * @param string $path
-     * @param mixed $store
-     * @return mixed
+     * @param null|string|bool|int|\Magento\Core\Model\Store $store
+     * @return string|null
      */
     public function getConfig($path, $store = null)
     {
@@ -79,7 +79,7 @@ class Config implements \Magento\Core\Model\Store\ConfigInterface
      * Retrieve store config flag
      *
      * @param string $path
-     * @param mixed $store
+     * @param null|string|bool|int|\Magento\Core\Model\Store $store
      * @return bool
      */
     public function getConfigFlag($path, $store = null)
@@ -91,7 +91,7 @@ class Config implements \Magento\Core\Model\Store\ConfigInterface
     /**
      * Retrieve store Ids for $path with checking
      *
-     * if empty $allowValues then retrieve all stores values
+     * If empty $allowValues then retrieve all stores values
      *
      * return array($storeId => $pathValue)
      *
diff --git a/app/code/Magento/Core/Model/Store/Group.php b/app/code/Magento/Core/Model/Store/Group.php
index 76eface06c5c3b7f6642d2d5ff5e76ee391771f2..a72706db903255e4469d1ae19b311aa5fd1470c1 100644
--- a/app/code/Magento/Core/Model/Store/Group.php
+++ b/app/code/Magento/Core/Model/Store/Group.php
@@ -38,11 +38,16 @@
  */
 namespace Magento\Core\Model\Store;
 
+use Magento\Core\Model\Website;
+
 class Group extends \Magento\Core\Model\AbstractModel
 {
     const ENTITY         = 'store_group';
     const CACHE_TAG      = 'store_group';
 
+    /**
+     * @var bool
+     */
     protected $_cacheTag = true;
 
     /**
@@ -58,21 +63,21 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Group Store collection array
      *
-     * @var array
+     * @var \Magento\Core\Model\Resource\Store\Collection[]
      */
     protected $_stores;
 
     /**
      * Group store ids array
      *
-     * @var array
+     * @var int[]
      */
     protected $_storeIds = array();
 
     /**
      * Group store codes array
      *
-     * @var array
+     * @var string[]
      */
     protected $_storeCodes = array();
 
@@ -138,8 +143,9 @@ class Group extends \Magento\Core\Model\AbstractModel
 
 
     /**
-     * init model
+     * Init model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -149,6 +155,7 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Load store collection and set internal data
      *
+     * @return void
      */
     protected function _loadStores()
     {
@@ -168,7 +175,8 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Set website stores
      *
-     * @param array $stores
+     * @param \Magento\Core\Model\Store[] $stores
+     * @return void
      */
     public function setStores($stores)
     {
@@ -200,7 +208,7 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve website store objects
      *
-     * @return array
+     * @return \Magento\Core\Model\Resource\Store\Collection[]
      */
     public function getStores()
     {
@@ -213,7 +221,7 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve website store ids
      *
-     * @return array
+     * @return int[]
      */
     public function getStoreIds()
     {
@@ -236,6 +244,9 @@ class Group extends \Magento\Core\Model\AbstractModel
         return $this->_storeCodes;
     }
 
+    /**
+     * @return int
+     */
     public function getStoresCount()
     {
         if (is_null($this->_stores)) {
@@ -285,8 +296,8 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve list of stores with given locale
      *
-     * @param $locale
-     * @return array
+     * @param string $locale
+     * @return \Magento\Core\Model\Store[]
      */
     public function getStoresByLocale($locale)
     {
@@ -303,9 +314,10 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Set relation to the website
      *
-     * @param \Magento\Core\Model\Website $website
+     * @param Website $website
+     * @return void
      */
-    public function setWebsite(\Magento\Core\Model\Website $website)
+    public function setWebsite(Website $website)
     {
         $this->setWebsiteId($website->getId());
     }
@@ -313,7 +325,7 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve website model
      *
-     * @return \Magento\Core\Model\Website|bool
+     * @return Website|bool
      */
     public function getWebsite()
     {
@@ -337,21 +349,33 @@ class Group extends \Magento\Core\Model\AbstractModel
         return $this->getWebsite()->getDefaultGroupId() != $this->getId();
     }
 
+    /**
+     * @return mixed
+     */
     public function getDefaultStoreId()
     {
         return $this->_getData('default_store_id');
     }
 
+    /**
+     * @return mixed
+     */
     public function getRootCategoryId()
     {
         return $this->_getData('root_category_id');
     }
 
+    /**
+     * @return mixed
+     */
     public function getWebsiteId()
     {
         return $this->_getData('website_id');
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeDelete()
     {
         $this->_protectFromNonAdmin();
diff --git a/app/code/Magento/Core/Model/Store/Storage/Db.php b/app/code/Magento/Core/Model/Store/Storage/Db.php
index eb1a26c4f8de4c43d1c6538dfa1abc33e11b67e8..c163ed0122b16a3c80dbbfd1963298550a2f3d55 100644
--- a/app/code/Magento/Core/Model/Store/Storage/Db.php
+++ b/app/code/Magento/Core/Model/Store/Storage/Db.php
@@ -30,10 +30,12 @@ use Magento\App\State;
 use Magento\Core\Model\Store;
 use Magento\Core\Model\Store\StorageInterface;
 use Magento\Core\Model\Store\Group;
+use Magento\Core\Model\Store\Group\Factory;
 use Magento\Core\Model\Store\Exception as StoreException;
 use Magento\Core\Model\StoreFactory;
 use Magento\Core\Model\StoreManagerInterface;
 use Magento\Core\Model\Website;
+use Magento\Core\Model\Website\Factory as WebsiteFactory;
 use Magento\Profiler;
 
 class Db implements StorageInterface
@@ -125,14 +127,14 @@ class Db implements StorageInterface
     /**
      * Website factory
      *
-     * @var Website\Factory
+     * @var WebsiteFactory
      */
     protected $_websiteFactory;
 
     /**
      * Group factory
      *
-     * @var Group\Factory
+     * @var Factory
      */
     protected $_groupFactory;
 
@@ -160,13 +162,27 @@ class Db implements StorageInterface
      */
     protected $response;
 
+    /**
+     * @param StoreFactory $storeFactory
+     * @param WebsiteFactory $websiteFactory
+     * @param Factory $groupFactory
+     * @param \Magento\App\ConfigInterface $config
+     * @param \Magento\Stdlib\Cookie $cookie
+     * @param State $appState
+     * @param \Magento\Backend\Model\UrlInterface $url
+     * @param \Magento\App\ResponseInterface $response
+     * @param bool $isSingleStoreAllowed
+     * @param string $scopeCode
+     * @param string $scopeType
+     * @param null $currentStore
+     */
     public function __construct(
-        \Magento\Core\Model\StoreFactory $storeFactory,
-        \Magento\Core\Model\Website\Factory $websiteFactory,
-        \Magento\Core\Model\Store\Group\Factory $groupFactory,
+        StoreFactory $storeFactory,
+        WebsiteFactory $websiteFactory,
+        Factory $groupFactory,
         \Magento\App\ConfigInterface $config,
         \Magento\Stdlib\Cookie $cookie,
-        \Magento\App\State $appState,
+        State $appState,
         \Magento\Backend\Model\UrlInterface $url,
         \Magento\App\ResponseInterface $response,
         $isSingleStoreAllowed,
@@ -208,6 +224,7 @@ class Db implements StorageInterface
     /**
      * Initialize currently ran store
      *
+     * @return void
      * @throws StoreException
      */
     public function initCurrentStore()
@@ -244,6 +261,7 @@ class Db implements StorageInterface
      * Check get store
      *
      * @param string $type
+     * @return void
      */
     protected function _checkGetStore($type)
     {
@@ -294,6 +312,7 @@ class Db implements StorageInterface
      * Check cookie store
      *
      * @param string $type
+     * @return void
      */
     protected function _checkCookieStore($type)
     {
@@ -358,6 +377,8 @@ class Db implements StorageInterface
 
     /**
      * Init store, group and website collections
+     *
+     * @return void
      */
     protected function _initStores()
     {
@@ -445,6 +466,7 @@ class Db implements StorageInterface
      * Allow or disallow single store mode
      *
      * @param bool $value
+     * @return void
      */
     public function setIsSingleStoreModeAllowed($value)
     {
@@ -641,6 +663,8 @@ class Db implements StorageInterface
 
     /**
      * Reinitialize store list
+     *
+     * @return void
      */
     public function reinitStores()
     {
@@ -650,7 +674,7 @@ class Db implements StorageInterface
     /**
      * Retrieve default store for default group and website
      *
-     * @return Store
+     * @return Store|null
      */
     public function getDefaultStoreView()
     {
@@ -670,6 +694,7 @@ class Db implements StorageInterface
      *  Unset website by id from app cache
      *
      * @param null|bool|int|string|Website $websiteId
+     * @return void
      */
     public function clearWebsiteCache($websiteId = null)
     {
@@ -711,6 +736,7 @@ class Db implements StorageInterface
      * Set current default store
      *
      * @param string $store
+     * @return void
      */
     public function setCurrentStore($store)
     {
@@ -718,6 +744,7 @@ class Db implements StorageInterface
     }
 
     /**
+     * @return void
      * @throws StoreException
      */
     public function throwStoreException()
diff --git a/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php b/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php
index 42aa7e06c52e6eb93550746f702e8a8bc82f1fea..01e7554a2e859e1d8dcc64d1b3694741e3114bd7 100644
--- a/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php
+++ b/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php
@@ -68,6 +68,8 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
 
     /**
      * Initialize current application store
+     *
+     * @return void
      */
     public function initCurrentStore()
     {
@@ -78,6 +80,7 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
      * Allow or disallow single store mode
      *
      * @param bool $value
+     * @return void
      */
     public function setIsSingleStoreModeAllowed($value)
     {
@@ -190,6 +193,8 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
 
     /**
      * Reinitialize store list
+     *
+     * @return void
      */
     public function reinitStores()
     {
@@ -199,17 +204,18 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
     /**
      * Retrieve default store for default group and website
      *
-     * @return \Magento\Core\Model\Store
+     * @return \Magento\Core\Model\Store|null
      */
     public function getDefaultStoreView()
     {
-       return null;
+        return null;
     }
 
     /**
      *  Unset website by id from app cache
      *
      * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId
+     * @return void
      */
     public function clearWebsiteCache($websiteId = null)
     {
@@ -219,7 +225,7 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
     /**
      * Get either default or any store view
      *
-     * @return \Magento\Core\Model\Store
+     * @return \Magento\Core\Model\Store|null
      */
     public function getAnyStoreView()
     {
@@ -230,6 +236,7 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
      * Set current default store
      *
      * @param string $store
+     * @return void
      */
     public function setCurrentStore($store)
     {
@@ -237,6 +244,7 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface
     }
 
     /**
+     * @return void
      * @throws \Magento\Core\Model\Store\Exception
      */
     public function throwStoreException()
diff --git a/app/code/Magento/Core/Model/StoreFactory.php b/app/code/Magento/Core/Model/StoreFactory.php
index dfb4fe7437ec320b179084416969472eba7bf38b..73e937f8d85015103181918aed8b77017d1f857e 100644
--- a/app/code/Magento/Core/Model/StoreFactory.php
+++ b/app/code/Magento/Core/Model/StoreFactory.php
@@ -45,7 +45,7 @@ class StoreFactory
      * Create store instance
      *
      * @param array $arguments
-     * @return \Magento\Core\Model\Store
+     * @return Store
      */
     public function create(array $arguments = array())
     {
diff --git a/app/code/Magento/Core/Model/StoreManager.php b/app/code/Magento/Core/Model/StoreManager.php
index cb93128d9117eb59b4f03ae840330d53a91c8c60..4586e2dc99caeba69cfd4c603cd98ac4a61f282f 100644
--- a/app/code/Magento/Core/Model/StoreManager.php
+++ b/app/code/Magento/Core/Model/StoreManager.php
@@ -80,7 +80,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     protected $_helper;
 
     /**
-     * @param Store\StorageFactory $factory
+     * @param \Magento\Core\Model\Store\StorageFactory $factory
      * @param \Magento\App\RequestInterface $request
      * @param \Magento\Core\Helper\Data $helper
      * @param string $scopeCode
@@ -119,9 +119,9 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     /**
      * Retrieve application store object without Store_Exception
      *
-     * @param string|int|\Magento\Core\Model\Store $storeId
+     * @param string|int|Store $storeId
      * @throws \Magento\Core\Exception
-     * @return \Magento\Core\Model\Store
+     * @return Store
      */
     public function getSafeStore($storeId = null)
     {
@@ -141,6 +141,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
      * Set current default store
      *
      * @param string $store
+     * @return void
      */
     public function setCurrentStore($store)
     {
@@ -149,6 +150,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     }
 
     /**
+     * @return void
      * @throws \Magento\Core\Model\Store\Exception
      */
     public function throwStoreException()
@@ -160,6 +162,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
      * Allow or disallow single store mode
      *
      * @param bool $value
+     * @return void
      */
     public function setIsSingleStoreModeAllowed($value)
     {
@@ -190,8 +193,8 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     /**
      * Retrieve application store object
      *
-     * @param null|string|bool|int|\Magento\Core\Model\Store $storeId
-     * @return \Magento\Core\Model\Store
+     * @param null|string|bool|int|Store $storeId
+     * @return Store
      * @throws \Magento\Core\Model\Store\Exception
      */
     public function getStore($storeId = null)
@@ -204,7 +207,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
      *
      * @param bool $withDefault
      * @param bool $codeKey
-     * @return \Magento\Core\Model\Store[]
+     * @return Store[]
      */
     public function getStores($withDefault = false, $codeKey = false)
     {
@@ -214,8 +217,8 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     /**
      * Retrieve application website object
      *
-     * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId
-     * @return \Magento\Core\Model\Website
+     * @param null|bool|int|string|Website $websiteId
+     * @return Website
      * @throws \Magento\Core\Exception
      */
     public function getWebsite($websiteId = null)
@@ -228,7 +231,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
      *
      * @param bool $withDefault
      * @param bool|string $codeKey
-     * @return \Magento\Core\Model\Website[]
+     * @return Website[]
      */
     public function getWebsites($withDefault = false, $codeKey = false)
     {
@@ -237,6 +240,8 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
 
     /**
      * Reinitialize store list
+     *
+     * @return void
      */
     public function reinitStores()
     {
@@ -246,7 +251,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     /**
      * Retrieve default store for default group and website
      *
-     * @return \Magento\Core\Model\Store
+     * @return Store
      */
     public function getDefaultStoreView()
     {
@@ -282,7 +287,8 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     /**
      *  Unset website by id from app cache
      *
-     * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId
+     * @param null|bool|int|string|Website $websiteId
+     * @return void
      */
     public function clearWebsiteCache($websiteId = null)
     {
@@ -292,7 +298,7 @@ class StoreManager implements \Magento\Core\Model\StoreManagerInterface
     /**
      * Get either default or any store view
      *
-     * @return \Magento\Core\Model\Store|null
+     * @return Store|null
      */
     public function getAnyStoreView()
     {
diff --git a/app/code/Magento/Core/Model/StoreManagerInterface.php b/app/code/Magento/Core/Model/StoreManagerInterface.php
index bfabb4c4d961a487f54634758b641fcec6b2fa6a..fc99b6257252f9deb06035433e3bdd61bd50456e 100644
--- a/app/code/Magento/Core/Model/StoreManagerInterface.php
+++ b/app/code/Magento/Core/Model/StoreManagerInterface.php
@@ -37,8 +37,8 @@ interface StoreManagerInterface extends \Magento\Core\Model\Store\ListInterface
     /**
      * Retrieve application store object without Store_Exception
      *
-     * @param string|int|\Magento\Core\Model\Store $storeId
-     * @return \Magento\Core\Model\Store
+     * @param string|int|Store $storeId
+     * @return Store
      */
     public function getSafeStore($storeId = null);
 
diff --git a/app/code/Magento/Core/Model/System/Store.php b/app/code/Magento/Core/Model/System/Store.php
index bbe5752577fa6f9af633a3874f614df04bfbcde7..79f785c77381ef8e32bedfabb02efad6e5cd2107 100644
--- a/app/code/Magento/Core/Model/System/Store.php
+++ b/app/code/Magento/Core/Model/System/Store.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model\System;
 
 /**
  * Core System Store Model
@@ -32,8 +32,6 @@
  * @package    Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model\System;
-
 class Store extends \Magento\Object
 {
 
@@ -76,7 +74,6 @@ class Store extends \Magento\Object
      * Load Website, Group and Store collections
      *
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @return \Magento\Core\Model\System\Store
      */
     public function __construct(\Magento\Core\Model\StoreManagerInterface $storeManager)
     {
@@ -87,7 +84,7 @@ class Store extends \Magento\Object
     /**
      * Load/Reload Website collection
      *
-     * @return array
+     * @return $this
      */
     protected function _loadWebsiteCollection()
     {
@@ -98,7 +95,7 @@ class Store extends \Magento\Object
     /**
      * Load/Reload Group collection
      *
-     * @return array
+     * @return $this
      */
     protected function _loadGroupCollection()
     {
@@ -114,7 +111,7 @@ class Store extends \Magento\Object
     /**
      * Load/Reload Store collection
      *
-     * @return array
+     * @return $this
      */
     protected function _loadStoreCollection()
     {
@@ -332,8 +329,8 @@ class Store extends \Magento\Object
     /**
      * Retrieve Website name by Id
      *
-     * @param int websiteId
-     * @return string
+     * @param int $websiteId
+     * @return string|null
      */
     public function getWebsiteName($websiteId)
     {
@@ -348,8 +345,8 @@ class Store extends \Magento\Object
     /**
      * Retrieve Group name by Id
      *
-     * @param int groupId
-     * @return string
+     * @param int $groupId
+     * @return string|null
      */
     public function getGroupName($groupId)
     {
@@ -365,7 +362,7 @@ class Store extends \Magento\Object
      * Retrieve Store name by Id
      *
      * @param int $storeId
-     * @return string
+     * @return string|null
      */
     public function getStoreName($storeId)
     {
@@ -379,8 +376,8 @@ class Store extends \Magento\Object
      * Retrieve store name with website and website store
      *
      * @param  int $storeId
-     * @return \Magento\Core\Model\Store
-     **/
+     * @return \Magento\Core\Model\Store|null
+     */
     public function getStoreData($storeId)
     {
         if (isset($this->_storeCollection[$storeId])) {
@@ -394,7 +391,7 @@ class Store extends \Magento\Object
      *
      * @param  int $storeId
      * @return string
-     **/
+     */
     public function getStoreNameWithWebsite($storeId)
     {
         $name = '';
@@ -451,7 +448,7 @@ class Store extends \Magento\Object
      * Allowed types: website, group, store or null for all
      *
      * @param string $type
-     * @return \Magento\Core\Model\System\Store
+     * @return $this
      */
     public function reload($type = null)
     {
@@ -483,7 +480,7 @@ class Store extends \Magento\Object
      *
      * @param  int $storeId
      * @return string
-     **/
+     */
     public function getStoreNamePath($storeId)
     {
         $name = '';
@@ -508,7 +505,7 @@ class Store extends \Magento\Object
      * Specify whether to show admin-scope options
      *
      * @param bool $value
-     * @return \Magento\Core\Model\System\Store
+     * @return $this
      */
     public function setIsAdminScopeAllowed($value)
     {
diff --git a/app/code/Magento/Core/Model/Template.php b/app/code/Magento/Core/Model/Template.php
index 26e54c5405031598b8cd5c5decf992e0037e6d33..289dc8d982d789d9a8529d55a5cc34bdc9f51d6f 100644
--- a/app/code/Magento/Core/Model/Template.php
+++ b/app/code/Magento/Core/Model/Template.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Core\Model;
 
 /**
  * Template model class
@@ -32,9 +32,7 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model;
-
-abstract class Template extends \Magento\Core\Model\AbstractModel
+abstract class Template extends AbstractModel
 {
     /**
      * Types of template
@@ -64,9 +62,9 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initial environment information
-     * @see self::_applyDesignConfig()
      *
      * @var \Magento\Object|null
+     * @see self::_applyDesignConfig()
      */
     protected $_initialEnvironmentInfo = null;
 
@@ -97,7 +95,7 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
     protected $_appEmulation;
 
     /**
-     * @var \Magento\Core\Model\StoreManagerInterface
+     * @var StoreManagerInterface
      */
     protected $_storeManager;
 
@@ -128,7 +126,7 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
     /**
      * Applying of design config
      *
-     * @return \Magento\Core\Model\Template
+     * @return $this
      */
     protected function _applyDesignConfig()
     {
@@ -145,7 +143,7 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
     /**
      * Revert design settings to previous
      *
-     * @return \Magento\Core\Model\Template
+     * @return $this
      */
     protected function _cancelDesignConfig()
     {
@@ -182,7 +180,7 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
      * Initialize design information for template processing
      *
      * @param array $config
-     * @return \Magento\Core\Model\Template
+     * @return $this
      * @throws \Magento\Exception
      */
     public function setDesignConfig(array $config)
@@ -200,6 +198,7 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
      *
      * @param int|string $storeId
      * @param string $area
+     * @return void
      */
     public function emulateDesign($storeId, $area=self::DEFAULT_DESIGN_AREA)
     {
@@ -218,6 +217,7 @@ abstract class Template extends \Magento\Core\Model\AbstractModel
     /**
      * Revert to last design config, used before emulation
      *
+     * @return void
      */
     public function revertDesign()
     {
diff --git a/app/code/Magento/Core/Model/Theme.php b/app/code/Magento/Core/Model/Theme.php
index e8344b9fca66b0ff19d6f23801f4f5557ae85ec6..92b2df84e0971bd408a39c8c5a3fff73dba19fcc 100644
--- a/app/code/Magento/Core/Model/Theme.php
+++ b/app/code/Magento/Core/Model/Theme.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model;
 
 use Magento\View\Design\ThemeInterface;
@@ -54,7 +53,7 @@ use Magento\View\Design\ThemeInterface;
  *
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
-class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
+class Theme extends AbstractModel implements ThemeInterface
 {
     /**
      * Filename of view configuration
@@ -120,15 +119,15 @@ class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
      * @param \Magento\View\Design\Theme\ImageFactory $imageFactory
      * @param \Magento\View\Design\Theme\Validator $validator
      * @param \Magento\View\Design\Theme\CustomizationFactory $customizationFactory
-     * @param Resource\Theme $resource
-     * @param Resource\Theme\Collection $resourceCollection
+     * @param \Magento\Core\Model\Resource\Theme $resource
+     * @param \Magento\Core\Model\Resource\Theme\Collection $resourceCollection
      * @param array $data
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
-        \Magento\Core\Model\Context $context,
-        \Magento\Core\Model\Registry $registry,
+        Context $context,
+        Registry $registry,
         \Magento\View\Design\Theme\FlyweightFactory $themeFactory,
         \Magento\View\Design\Theme\Domain\Factory $domainFactory,
         \Magento\View\Design\Theme\ImageFactory $imageFactory,
@@ -150,6 +149,8 @@ class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
 
     /**
      * Init resource model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -243,7 +244,7 @@ class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
     /**
      * Retrieve theme instance representing the latest changes to a theme
      *
-     * @return \Magento\Core\Model\Theme|null
+     * @return Theme|null
      */
     public function getStagingVersion()
     {
@@ -339,7 +340,7 @@ class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
     /**
      * Validate theme data
      *
-     * @return \Magento\Core\Model\Theme
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _validate()
@@ -354,7 +355,7 @@ class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
     /**
      * Before theme save
      *
-     * @return \Magento\Core\Model\Theme
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -380,7 +381,7 @@ class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface
     /**
      * Return the full theme inheritance sequence, from the root theme till a specified one
      *
-     * @return ThemeInterface[] Format: array([<root_theme>, ..., <parent_theme>,] <current_theme>)
+     * @return ThemeInterface[]
      */
     public function getInheritedThemes()
     {
diff --git a/app/code/Magento/Core/Model/Theme/Collection.php b/app/code/Magento/Core/Model/Theme/Collection.php
index 2b0f5a089ba31762ab3e111c0dcc08397b4f2a6a..2a40e3a75846fde5af3b7fdce5630b60bc6da935 100644
--- a/app/code/Magento/Core/Model/Theme/Collection.php
+++ b/app/code/Magento/Core/Model/Theme/Collection.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Core\Model\Theme;
 
+use Magento\View\Design\ThemeInterface;
+
 /**
  * Theme filesystem collection
  */
@@ -66,7 +67,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
      * Add default pattern to themes configuration
      *
      * @param string $area
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     public function addDefaultPattern($area = \Magento\Core\Model\App\Area::AREA_FRONTEND)
     {
@@ -78,7 +79,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
      * Target directory setter. Adds directory to be scanned
      *
      * @param string $relativeTarget
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     public function addTargetPattern($relativeTarget)
     {
@@ -92,7 +93,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Clear target patterns
      *
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     public function clearTargetPatterns()
     {
@@ -117,11 +118,10 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Fill collection with theme model loaded from filesystem
      *
-     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
-     *
      * @param bool $printQuery
      * @param bool $logQuery
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function loadData($printQuery = false, $logQuery = false)
     {
@@ -150,16 +150,16 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Set all parent themes
      *
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     protected function _updateRelations()
     {
         $themeItems = $this->getItems();
-        /** @var $theme \Magento\Object|\Magento\View\Design\ThemeInterface */
+        /** @var $theme \Magento\Object|ThemeInterface */
         foreach ($themeItems as $theme) {
             $parentThemePath = $theme->getData('parent_theme_path');
             if ($parentThemePath) {
-                $themePath = $theme->getArea() . \Magento\View\Design\ThemeInterface::PATH_SEPARATOR . $parentThemePath;
+                $themePath = $theme->getArea() . ThemeInterface::PATH_SEPARATOR . $parentThemePath;
                 if (isset($themeItems[$themePath])) {
                     $theme->setParentTheme($themeItems[$themePath]);
                 }
@@ -172,7 +172,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
      * Load themes collection from file system by file list
      *
      * @param array $themeConfigPaths
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     protected function _loadFromFilesystem(array $themeConfigPaths)
     {
@@ -220,15 +220,15 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
             $parentPathPieces = array_merge($pathPieces, $parentPathPieces);
         }
 
-        $themePath = implode(\Magento\View\Design\ThemeInterface::PATH_SEPARATOR, $pathData['theme_path_pieces']);
-        $themeCode = implode(\Magento\View\Design\ThemeInterface::CODE_SEPARATOR, $pathData['theme_path_pieces']);
+        $themePath = implode(ThemeInterface::PATH_SEPARATOR, $pathData['theme_path_pieces']);
+        $themeCode = implode(ThemeInterface::CODE_SEPARATOR, $pathData['theme_path_pieces']);
         $parentPath = $parentPathPieces
-            ? implode(\Magento\View\Design\ThemeInterface::PATH_SEPARATOR, $parentPathPieces)
+            ? implode(ThemeInterface::PATH_SEPARATOR, $parentPathPieces)
             : null;
 
         return array(
             'parent_id'         => null,
-            'type'              => \Magento\View\Design\ThemeInterface::TYPE_PHYSICAL,
+            'type'              => ThemeInterface::TYPE_PHYSICAL,
             'area'              => $pathData['area'],
             'theme_path'        => $themePath,
             'code'              => $themeCode,
@@ -242,12 +242,12 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Apply set field filters
      *
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     protected function _renderFilters()
     {
         $filters = $this->getFilter(array());
-        /** @var $theme \Magento\View\Design\ThemeInterface */
+        /** @var $theme ThemeInterface */
         foreach ($this->getItems() as $itemKey => $theme) {
             $removeItem = false;
             foreach ($filters as $filter) {
@@ -265,7 +265,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Clear all added filters
      *
-     * @return \Magento\Core\Model\Theme\Collection
+     * @return $this
      */
     protected function _clearFilters()
     {
@@ -276,7 +276,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Return configuration model for themes
      *
-     * @param $configPath
+     * @param string $configPath
      * @return \Magento\Config\Theme
      */
     protected function _getConfigModel($configPath)
@@ -287,7 +287,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Retrieve item id
      *
-     * @param \Magento\View\Design\ThemeInterface|\Magento\Object $item
+     * @param \Magento\Object $item
      * @return string
      */
     protected function _getItemId(\Magento\Object $item)
@@ -310,10 +310,10 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
     /**
      * Checks that a theme present in filesystem collection
      *
-     * @param \Magento\View\Design\ThemeInterface $theme
+     * @param ThemeInterface $theme
      * @return bool
      */
-    public function hasTheme(\Magento\View\Design\ThemeInterface $theme)
+    public function hasTheme(ThemeInterface $theme)
     {
         $themeItems = $this->getItems();
         return $theme->getThemePath() && isset($themeItems[$theme->getFullPath()]);
@@ -323,7 +323,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig
      * Get theme from file system by area and theme_path
      *
      * @param string $fullPath
-     * @return \Magento\View\Design\ThemeInterface
+     * @return ThemeInterface
      */
     public function getThemeByFullPath($fullPath)
     {
diff --git a/app/code/Magento/Core/Model/Theme/File.php b/app/code/Magento/Core/Model/Theme/File.php
index cde80b1627c912d09b6d9b57a9aa5834383d896a..3e44984d9c65acb5d18994a46e7afa9423492c70 100644
--- a/app/code/Magento/Core/Model/Theme/File.php
+++ b/app/code/Magento/Core/Model/Theme/File.php
@@ -23,14 +23,16 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Theme;
+
+use Magento\Core\Model\AbstractModel;
+use Magento\View\Design\Theme\FileInterface;
+use \Magento\View\Design\Theme\Customization\FileInterface as CustomizationFileInterface;
 
 /**
  * Theme files model class
  */
-namespace Magento\Core\Model\Theme;
-
-class File extends \Magento\Core\Model\AbstractModel
-    implements \Magento\View\Design\Theme\FileInterface
+class File extends AbstractModel implements FileInterface
 {
     /**
      * {@inheritdoc}
@@ -57,7 +59,7 @@ class File extends \Magento\Core\Model\AbstractModel
     protected $_fileServiceFactory;
 
     /**
-     * @var \Magento\View\Design\Theme\Customization\FileInterface
+     * @var CustomizationFileInterface
      */
     protected $_fileService;
 
@@ -91,6 +93,8 @@ class File extends \Magento\Core\Model\AbstractModel
 
     /**
      * Theme files model initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -102,7 +106,7 @@ class File extends \Magento\Core\Model\AbstractModel
      *
      * @return $this
      */
-    public function setCustomizationService(\Magento\View\Design\Theme\Customization\FileInterface $fileService)
+    public function setCustomizationService(CustomizationFileInterface $fileService)
     {
         $this->_fileService = $fileService;
         return $this;
@@ -111,6 +115,7 @@ class File extends \Magento\Core\Model\AbstractModel
     /**
      * {@inheritdoc}
      *
+     * @return CustomizationFileInterface
      * @throws \UnexpectedValueException
      */
     public function getCustomizationService()
diff --git a/app/code/Magento/Core/Model/Theme/Observer.php b/app/code/Magento/Core/Model/Theme/Observer.php
index 23afff0af4bce83a92dc1c9fd4b9fdca07aac5ff..85e6677bc275c887c8d5ec5dbac0a636e1c45068 100644
--- a/app/code/Magento/Core/Model/Theme/Observer.php
+++ b/app/code/Magento/Core/Model/Theme/Observer.php
@@ -23,12 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model\Theme;
+
+use Magento\Core\Exception;
+use Magento\Event\Observer as EventObserver;
 
 /**
  * Theme Observer model
  */
-namespace Magento\Core\Model\Theme;
-
 class Observer
 {
     /**
@@ -72,10 +74,11 @@ class Observer
     /**
      * Clean related contents to a theme (before save)
      *
-     * @param \Magento\Event\Observer $observer
-     * @throws \Magento\Core\Exception
+     * @param EventObserver $observer
+     * @return void
+     * @throws Exception
      */
-    public function cleanThemeRelatedContent(\Magento\Event\Observer $observer)
+    public function cleanThemeRelatedContent(EventObserver $observer)
     {
         $theme = $observer->getEvent()->getData('theme');
         if ($theme instanceof \Magento\View\Design\ThemeInterface) {
@@ -83,7 +86,7 @@ class Observer
         }
         /** @var $theme \Magento\View\Design\ThemeInterface */
         if ($this->_themeConfig->isThemeAssignedToStore($theme)) {
-            throw new \Magento\Core\Exception(__('Theme isn\'t deletable.'));
+            throw new Exception(__('Theme isn\'t deletable.'));
         }
         $this->_themeImageFactory->create(array('theme' => $theme))->removePreviewImage();
         $this->_updateCollection->addThemeFilter($theme->getId())->delete();
@@ -92,9 +95,10 @@ class Observer
     /**
      * Check a theme, it's assigned to any of store
      *
-     * @param \Magento\Event\Observer $observer
+     * @param EventObserver $observer
+     * @return void
      */
-    public function checkThemeIsAssigned(\Magento\Event\Observer $observer)
+    public function checkThemeIsAssigned(EventObserver $observer)
     {
         $theme = $observer->getEvent()->getData('theme');
         if ($theme instanceof \Magento\View\Design\ThemeInterface) {
diff --git a/app/code/Magento/Core/Model/Theme/Registration.php b/app/code/Magento/Core/Model/Theme/Registration.php
index be58085e3b817fcd73d0b9c497700d0f36954a8d..e686deb725ea0a3c0e2e39bd2f58920547e0c1dd 100644
--- a/app/code/Magento/Core/Model/Theme/Registration.php
+++ b/app/code/Magento/Core/Model/Theme/Registration.php
@@ -23,14 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Theme registration model class
- */
 namespace Magento\Core\Model\Theme;
 
+use Magento\App\Filesystem;
+use Magento\Core\Exception;
 use \Magento\View\Design\ThemeInterface;
 
+/**
+ * Theme registration model class
+ */
 class Registration
 {
     /**
@@ -41,7 +42,7 @@ class Registration
     /**
      * Collection of themes in file-system
      *
-     * @var \Magento\Core\Model\Theme\Collection
+     * @var Collection
      */
     protected $_themeCollection;
 
@@ -75,23 +76,23 @@ class Registration
      *
      * @param \Magento\Core\Model\Resource\Theme\CollectionFactory $collectionFactory
      * @param Collection $filesystemCollection
-     * @param \Magento\App\Filesystem $filesystem
+     * @param Filesystem $filesystem
      */
     public function __construct(
-        \Magento\Core\Model\Resource\Theme\CollectionFactory    $collectionFactory,
-        \Magento\Core\Model\Theme\Collection                    $filesystemCollection,
-        \Magento\App\Filesystem                                     $filesystem
+        \Magento\Core\Model\Resource\Theme\CollectionFactory $collectionFactory,
+        Collection $filesystemCollection,
+        Filesystem $filesystem
     ) {
-        $this->_collectionFactory   = $collectionFactory;
-        $this->_themeCollection     = $filesystemCollection;
-        $this->directoryRead        = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MEDIA_DIR);
+        $this->_collectionFactory = $collectionFactory;
+        $this->_themeCollection = $filesystemCollection;
+        $this->directoryRead = $filesystem->getDirectoryRead(Filesystem::MEDIA_DIR);
     }
 
     /**
      * Theme registration
      *
      * @param string $pathPattern
-     * @return \Magento\View\Design\ThemeInterface
+     * @return $this
      */
     public function register($pathPattern = '')
     {
@@ -114,10 +115,10 @@ class Registration
      * Register theme and recursively all its ascendants
      * Second param is optional and is used to prevent circular references in inheritance chain
      *
-     * @param \Magento\View\Design\ThemeInterface $theme
+     * @param ThemeInterface &$theme
      * @param array $inheritanceChain
-     * @return \Magento\Core\Model\Theme\Collection
-     * @throws \Magento\Core\Exception
+     * @return $this
+     * @throws Exception
      */
     protected function _registerThemeRecursively(&$theme, $inheritanceChain = array())
     {
@@ -132,7 +133,7 @@ class Registration
 
         $tempId = $theme->getFullPath();
         if (in_array($tempId, $inheritanceChain)) {
-            throw new \Magento\Core\Exception(__('Circular-reference in theme inheritance detected for "%1"', $tempId));
+            throw new Exception(__('Circular-reference in theme inheritance detected for "%1"', $tempId));
         }
         $inheritanceChain[] = $tempId;
         $parentTheme = $theme->getParentTheme();
@@ -142,7 +143,7 @@ class Registration
         }
 
         $this->_savePreviewImage($theme);
-        $theme->setType(\Magento\View\Design\ThemeInterface::TYPE_PHYSICAL);
+        $theme->setType(ThemeInterface::TYPE_PHYSICAL);
         $theme->save();
 
         return $this;
@@ -151,7 +152,7 @@ class Registration
     /**
      * Save preview image for theme
      *
-     * @param \Magento\View\Design\ThemeInterface $theme
+     * @param ThemeInterface $theme
      * @return $this
      */
     protected function _savePreviewImage(ThemeInterface $theme)
@@ -171,7 +172,7 @@ class Registration
      * Get theme from DB by full path
      *
      * @param string $fullPath
-     * @return \Magento\View\Design\ThemeInterface
+     * @return ThemeInterface
      */
     public function getThemeFromDb($fullPath)
     {
@@ -181,12 +182,12 @@ class Registration
     /**
      * Checks all physical themes that they were not deleted
      *
-     * @return \Magento\Core\Model\Theme\Registration
+     * @return $this
      */
     public function checkPhysicalThemes()
     {
         $themes = $this->_collectionFactory->create()->addTypeFilter(ThemeInterface::TYPE_PHYSICAL);
-        /** @var $theme \Magento\View\Design\ThemeInterface */
+        /** @var $theme ThemeInterface */
         foreach ($themes as $theme) {
             if (!$this->_themeCollection->hasTheme($theme)) {
                 $theme->setType(ThemeInterface::TYPE_VIRTUAL)->save();
@@ -198,7 +199,7 @@ class Registration
     /**
      * Check whether all themes have correct parent theme by type
      *
-     * @return \Magento\Core\Model\Resource\Theme\Collection
+     * @return $this
      */
     public function checkAllowedThemeRelations()
     {
@@ -206,7 +207,7 @@ class Registration
             list($parentType, $childType) = $typesSequence;
             $collection = $this->_collectionFactory->create();
             $collection->addTypeRelationFilter($parentType, $childType);
-            /** @var $theme \Magento\View\Design\ThemeInterface */
+            /** @var $theme ThemeInterface */
             foreach ($collection as $theme) {
                 $parentId = $this->_getResetParentId($theme);
                 if ($theme->getParentId() != $parentId) {
@@ -220,10 +221,10 @@ class Registration
     /**
      * Reset parent themes by type
      *
-     * @param \Magento\View\Design\ThemeInterface $theme
+     * @param ThemeInterface $theme
      * @return int|null
      */
-    protected function _getResetParentId(\Magento\View\Design\ThemeInterface $theme)
+    protected function _getResetParentId(ThemeInterface $theme)
     {
         $parentTheme = $theme->getParentTheme();
         while ($parentTheme) {
diff --git a/app/code/Magento/Core/Model/Theme/Source/Theme.php b/app/code/Magento/Core/Model/Theme/Source/Theme.php
index 877209c739d6ff612d0f30193336b885f29b7076..ba3058904ce568be07d0e3c3881808245b523e2e 100644
--- a/app/code/Magento/Core/Model/Theme/Source/Theme.php
+++ b/app/code/Magento/Core/Model/Theme/Source/Theme.php
@@ -40,12 +40,12 @@ use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
 class Theme extends AbstractSource
 {
     /**
-     * @var \Magento\View\Design\Theme\Label
+     * @var Label
      */
     protected $themeLabel;
 
     /**
-     * @param \Magento\View\Design\Theme\Label $themeLabel
+     * @param Label $themeLabel
      */
     public function __construct(Label $themeLabel)
     {
@@ -56,7 +56,7 @@ class Theme extends AbstractSource
      * Retrieve All Design Theme Options
      *
      * @param bool $withEmpty add empty (please select) values to result
-     * @return array
+     * @return Label[]
      */
     public function getAllOptions($withEmpty = true)
     {
diff --git a/app/code/Magento/Core/Model/Translate/Inline/Parser.php b/app/code/Magento/Core/Model/Translate/Inline/Parser.php
index 452b7faa1aaacfe4cfa71c9d66b2af2d1bd60b96..ff5af24c3277be20aa611e314813152a2c106cc7 100644
--- a/app/code/Magento/Core/Model/Translate/Inline/Parser.php
+++ b/app/code/Magento/Core/Model/Translate/Inline/Parser.php
@@ -214,6 +214,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
      * Validate the structure of translation parameters
      *
      * @param array $translateParams
+     * @return void
      * @throws \InvalidArgumentException
      */
     protected function _validateTranslationParams(array $translateParams)
@@ -230,8 +231,9 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
     /**
      * Apply input filter to values of translation parameters
      *
-     * @param array $translateParams
+     * @param array &$translateParams
      * @param array $fieldNames Names of fields values of which are to be filtered
+     * @return void
      */
     protected function _filterTranslationParams(array &$translateParams, array $fieldNames)
     {
@@ -272,7 +274,8 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
     /**
      * Sets the body content that is being parsed passed upon the passed in string.
      *
-     * @param $content string
+     * @param string $content
+     * @return void
      */
     public function setContent($content)
     {
@@ -368,7 +371,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
      * Get translate data by regexp
      *
      * @param string $regexp
-     * @param string $text
+     * @param string &$text
      * @param string|array $locationCallback
      * @param array $options
      * @return array
@@ -393,6 +396,8 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
 
     /**
      * Prepare tags inline translates
+     *
+     * @return void
      */
     private function _tagAttributes()
     {
@@ -402,7 +407,8 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
     /**
      * Prepare tags inline translates for the content
      *
-     * @param string $content
+     * @param string &$content
+     * @return void
      */
     private function _prepareTagAttributesForContent(&$content)
     {
@@ -479,6 +485,8 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
 
     /**
      * Prepare special tags
+     *
+     * @return void
      */
     private function _specialTags()
     {
@@ -489,9 +497,10 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
     /**
      * Prepare simple tags
      *
-     * @param string $content
+     * @param string &$content
      * @param array $tagsList
      * @param string|array $formatCallback
+     * @return void
      */
     private function _translateTags(&$content, $tagsList, $formatCallback)
     {
@@ -572,6 +581,8 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
 
     /**
      * Prepare other text inline translates
+     *
+     * @return void
      */
     private function _otherText()
     {
@@ -614,7 +625,7 @@ class Parser implements \Magento\Translate\Inline\ParserInterface
     /**
      * Add an additional html attribute if needed.
      *
-     * @param mixed|string $tagName
+     * @param mixed $tagName
      * @return string
      */
     protected function _getAdditionalHtmlAttribute($tagName = null)
diff --git a/app/code/Magento/Core/Model/Translate/String.php b/app/code/Magento/Core/Model/Translate/String.php
index 8a1f18bc8e7f43338e43d59ee4c38406043fd989..6775f04bb940fdfc8a6c73a8895f929b2f469b78 100644
--- a/app/code/Magento/Core/Model/Translate/String.php
+++ b/app/code/Magento/Core/Model/Translate/String.php
@@ -44,11 +44,18 @@ namespace Magento\Core\Model\Translate;
 
 class String extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Core\Model\Resource\Translate\String');
     }
 
+    /**
+     * @param string $string
+     * @return $this
+     */
     public function setString($string)
     {
         $this->setData('string', $string);
diff --git a/app/code/Magento/Core/Model/Url/Rewrite.php b/app/code/Magento/Core/Model/Url/Rewrite.php
index 0ead5b3347ecb84485d482b983c0fdd8c7951329..13d3c638a4d8695627d89bc4a74014754c880c95 100644
--- a/app/code/Magento/Core/Model/Url/Rewrite.php
+++ b/app/code/Magento/Core/Model/Url/Rewrite.php
@@ -63,7 +63,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
     /**
      * Cache tag for clear cache in after save and after delete
      *
-     * @var mixed | array | string | boolean
+     * @var array|string|boolean
      */
     protected $_cacheTag = false;
 
@@ -118,6 +118,9 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Core\Model\Resource\Url\Rewrite');
@@ -126,7 +129,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
     /**
      * Clean cache for front-end menu
      *
-     * @return  \Magento\Core\Model\Url\Rewrite
+     * @return  $this
      */
     protected function _afterSave()
     {
@@ -144,7 +147,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
      * If $path is array - we must load possible records and choose one matching earlier record in array
      *
      * @param   mixed $path
-     * @return  \Magento\Core\Model\Url\Rewrite
+     * @return  $this
      */
     public function loadByRequestPath($path)
     {
@@ -156,12 +159,20 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param int $path
+     * @return $this
+     */
     public function loadByIdPath($path)
     {
         $this->setId(null)->load($path, 'id_path');
         return $this;
     }
 
+    /**
+     * @param mixed $tags
+     * @return $this
+     */
     public function loadByTags($tags)
     {
         $this->setId(null);
@@ -190,6 +201,10 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param mixed $key
+     * @return bool
+     */
     public function hasOption($key)
     {
         $optArr = explode(',', $this->getOptions());
@@ -197,6 +212,10 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         return array_search($key, $optArr) !== false;
     }
 
+    /**
+     * @param mixed $tags
+     * @return $this
+     */
     public function addTag($tags)
     {
         $curTags = $this->getTags();
@@ -217,6 +236,10 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param mixed $tags
+     * @return $this
+     */
     public function removeTag($tags)
     {
         $curTags = $this->getTags();
@@ -343,6 +366,9 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         return true;
     }
 
+    /**
+     * @return bool|string
+     */
     protected function _getQueryString()
     {
         if (!empty($_SERVER['QUERY_STRING'])) {
@@ -364,6 +390,9 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
         return false;
     }
 
+    /**
+     * @return mixed
+     */
     public function getStoreId()
     {
         return $this->_getData('store_id');
@@ -374,6 +403,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel
      *
      * @param string $url
      * @param bool $isPermanent
+     * @return void
      */
     protected function _sendRedirectHeaders($url, $isPermanent = false)
     {
diff --git a/app/code/Magento/Core/Model/Validator/Factory.php b/app/code/Magento/Core/Model/Validator/Factory.php
index c56a32a34f53784afe9599948b2d5cfa2bd36aee..d637298bb1d701d0174458e6ffd34f951eb55fe1 100644
--- a/app/code/Magento/Core/Model/Validator/Factory.php
+++ b/app/code/Magento/Core/Model/Validator/Factory.php
@@ -40,7 +40,7 @@ class Factory
     /**
      * Validator config files
      *
-     * @var array
+     * @var array|null
      */
     protected $_configFiles = null;
 
@@ -65,6 +65,8 @@ class Factory
 
     /**
      * Create and set default translator to \Magento\Validator\AbstractValidator.
+     *
+     * @return void
      */
     protected function _initializeDefaultTranslator()
     {
diff --git a/app/code/Magento/Core/Model/Variable.php b/app/code/Magento/Core/Model/Variable.php
index af8cc7b46bd8ae00aedfbd2e4796aa8d818356da..cf4852c26667ddcecd502e6f15a728e04f8793c5 100644
--- a/app/code/Magento/Core/Model/Variable.php
+++ b/app/code/Magento/Core/Model/Variable.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model;
 
 /**
  * Custom variable model
@@ -38,13 +39,14 @@
  * @package     Magento_Core
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Core\Model;
-
 class Variable extends \Magento\Core\Model\AbstractModel
 {
     const TYPE_TEXT = 'text';
     const TYPE_HTML = 'html';
 
+    /**
+     * @var int
+     */
     protected $_storeId = 0;
 
     /**
@@ -53,16 +55,16 @@ class Variable extends \Magento\Core\Model\AbstractModel
     protected $_escaper = null;
 
     /**
-     * @param \Magento\Core\Model\Context $context
-     * @param \Magento\Core\Model\Registry $registry
+     * @param Context $context
+     * @param Registry $registry
      * @param \Magento\Escaper $escaper
      * @param \Magento\Core\Model\Resource\Variable $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
      */
     public function __construct(
-        \Magento\Core\Model\Context $context,
-        \Magento\Core\Model\Registry $registry,
+        Context $context,
+        Registry $registry,
         \Magento\Escaper $escaper,
         \Magento\Core\Model\Resource\Variable $resource,
         \Magento\Data\Collection\Db $resourceCollection = null,
@@ -74,6 +76,8 @@ class Variable extends \Magento\Core\Model\AbstractModel
 
     /**
      * Internal Constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -85,7 +89,7 @@ class Variable extends \Magento\Core\Model\AbstractModel
      * Setter
      *
      * @param integer $storeId
-     * @return \Magento\Core\Model\Variable
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -107,7 +111,7 @@ class Variable extends \Magento\Core\Model\AbstractModel
      * Load variable by code
      *
      * @param string $code
-     * @return \Magento\Core\Model\Variable
+     * @return $this
      */
     public function loadByCode($code)
     {
@@ -140,7 +144,7 @@ class Variable extends \Magento\Core\Model\AbstractModel
     /**
      * Validation of object data. Checking for unique variable code
      *
-     * @return boolean | string
+     * @return bool|string
      */
     public function validate()
     {
@@ -157,7 +161,7 @@ class Variable extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve variables option array
      *
-     * @param boolean $withValues
+     * @param bool $withGroup
      * @return array
      */
     public function getVariablesOptionArray($withGroup = false)
diff --git a/app/code/Magento/Core/Model/View/Design.php b/app/code/Magento/Core/Model/View/Design.php
index be1d006551e124fee483f57d7dc813dd31c94dc4..a3a715e1a85677c908091252f5f1665c2f858b7a 100644
--- a/app/code/Magento/Core/Model/View/Design.php
+++ b/app/code/Magento/Core/Model/View/Design.php
@@ -123,9 +123,9 @@ class Design implements \Magento\View\DesignInterface
     /**
      * Set package area
      *
-     * @deprecated
      * @param string $area
-     * @return \Magento\Core\Model\View\Design
+     * @return $this
+     * @deprecated
      */
     public function setArea($area)
     {
@@ -149,7 +149,7 @@ class Design implements \Magento\View\DesignInterface
      *
      * @param \Magento\View\Design\ThemeInterface|string $theme
      * @param string $area
-     * @return \Magento\Core\Model\View\Design
+     * @return $this
      */
     public function setDesignTheme($theme, $area = null)
     {
@@ -173,7 +173,7 @@ class Design implements \Magento\View\DesignInterface
      *
      * Write default theme to core_config_data
      *
-     * @param string $area
+     * @param string|null $area
      * @param array $params
      * @return string|int
      */
@@ -213,7 +213,7 @@ class Design implements \Magento\View\DesignInterface
     /**
      * Set default design theme
      *
-     * @return \Magento\Core\Model\View\Design
+     * @return $this
      */
     public function setDefaultDesignTheme()
     {
diff --git a/app/code/Magento/Core/Model/Website.php b/app/code/Magento/Core/Model/Website.php
index cd404f36c567a9c1f6ce852121006da511741295..0147877fbbe322eb2b8853ab875ac8804e1dfa2d 100644
--- a/app/code/Magento/Core/Model/Website.php
+++ b/app/code/Magento/Core/Model/Website.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Core\Model;
 
 /**
  * Core Website model
@@ -44,12 +45,14 @@
  * @method int getIsDefault()
  * @method \Magento\Core\Model\Website setIsDefault(int $value)
  */
-namespace Magento\Core\Model;
-
 class Website extends \Magento\Core\Model\AbstractModel
 {
     const ENTITY    = 'core_website';
     const CACHE_TAG = 'website';
+
+    /**
+     * @var bool
+     */
     protected $_cacheTag = true;
 
     /**
@@ -72,7 +75,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * Website Group Collection array
      *
-     * @var array
+     * @var \Magento\Core\Model\Store\Group[]
      */
     protected $_groups;
 
@@ -128,7 +131,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * Website default store
      *
-     * @var \Magento\Core\Model\Store
+     * @var Store
      */
     protected $_defaultStore;
 
@@ -150,7 +153,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     protected $_configDataResource;
 
     /**
-     * @var \Magento\Core\Model\StoreFactory
+     * @var StoreFactory
      */
     protected $_storeFactory;
 
@@ -160,17 +163,17 @@ class Website extends \Magento\Core\Model\AbstractModel
     protected $_storeGroupFactory;
 
     /**
-     * @var \Magento\Core\Model\WebsiteFactory
+     * @var WebsiteFactory
      */
     protected $_websiteFactory;
 
     /**
-     * @var \Magento\Core\Model\StoreManagerInterface
+     * @var StoreManagerInterface
      */
     protected $_storeManager;
 
     /**
-     * @var \Magento\Core\Model\App
+     * @var App
      */
     protected $_app;
 
@@ -223,6 +226,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * init model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -234,7 +238,7 @@ class Website extends \Magento\Core\Model\AbstractModel
      *
      * @param int|string $id
      * @param string $field
-     * @return \Magento\Core\Model\Website
+     * @return $this
      */
     public function load($id, $field = null)
     {
@@ -267,6 +271,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * Load group collection and set internal data
      *
+     * @return void
      */
     protected function _loadGroups()
     {
@@ -286,7 +291,7 @@ class Website extends \Magento\Core\Model\AbstractModel
      * Set website groups
      *
      * @param array $groups
-     * @return \Magento\Core\Model\Website
+     * @return $this
      */
     public function setGroups($groups)
     {
@@ -373,6 +378,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * Load store collection and set internal data
      *
+     * @return void
      */
     protected function _loadStores()
     {
@@ -393,6 +399,7 @@ class Website extends \Magento\Core\Model\AbstractModel
      * Set website stores
      *
      * @param array $stores
+     * @return void
      */
     public function setStores($stores)
     {
@@ -474,7 +481,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * is can delete website
+     * Can delete website
      *
      * @return bool
      */
@@ -500,16 +507,25 @@ class Website extends \Magento\Core\Model\AbstractModel
         return join('-', array($this->getWebsiteId(), $this->getGroupId(), $this->getStoreId()));
     }
 
+    /**
+     * @return mixed
+     */
     public function getDefaultGroupId()
     {
         return $this->_getData('default_group_id');
     }
 
+    /**
+     * @return mixed
+     */
     public function getCode()
     {
         return $this->_getData('code');
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeDelete()
     {
         $this->_protectFromNonAdmin();
@@ -518,9 +534,9 @@ class Website extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * rewrite in order to clear configuration cache
+     * Rewrite in order to clear configuration cache
      *
-     * @return \Magento\Core\Model\Website
+     * @return $this
      */
     protected function _afterDelete()
     {
@@ -563,7 +579,7 @@ class Website extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve Default Website Store or null
      *
-     * @return \Magento\Core\Model\Store
+     * @return Store
      */
     public function getDefaultStore()
     {
diff --git a/app/code/Magento/Core/Model/Website/Factory.php b/app/code/Magento/Core/Model/Website/Factory.php
index d4a7d3147475eacfc99c737e70f17bddcae3b078..2459a6f5f60c2e4eec6e947277795b16aaa0cf95 100644
--- a/app/code/Magento/Core/Model/Website/Factory.php
+++ b/app/code/Magento/Core/Model/Website/Factory.php
@@ -38,6 +38,9 @@ class Factory
      */
     protected $_objectManager;
 
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     */
     public function __construct(\Magento\ObjectManager $objectManager)
     {
         $this->_objectManager = $objectManager;
diff --git a/app/code/Magento/Core/etc/crontab.xml b/app/code/Magento/Core/etc/crontab.xml
index f68f881e19624477339edc26d60bb171f73ac699..69db8ad2594d96a75c76cd4c46726c1bd8818eb9 100644
--- a/app/code/Magento/Core/etc/crontab.xml
+++ b/app/code/Magento/Core/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="core_clean_cache" instance="Magento\Core\Model\Observer" method="cleanCache">
-        <schedule>30 2 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="core_clean_cache" instance="Magento\Core\Model\Observer" method="cleanCache">
+            <schedule>30 2 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml
index 252e2c952dc7bc73e1b5839ff636c4c3bc03e593..0cc5c46fe96c4ee4bff30ebd127dc0e3fcc07507 100644
--- a/app/code/Magento/Core/etc/di.xml
+++ b/app/code/Magento/Core/etc/di.xml
@@ -76,6 +76,7 @@
     <preference for="Magento\Css\PreProcessor\AdapterInterface" type="Magento\Css\PreProcessor\Adapter\Oyejorge" />
     <preference for="Magento\Translate\ResourceInterface" type="Magento\Core\Model\Resource\Translate" />
     <preference for="Magento\BaseScopeResolverInterface" type="Magento\Core\Model\BaseScopeResolver" />
+    <preference for="Magento\Less\PreProcessor\ErrorHandlerInterface" type="Magento\Less\PreProcessor\ErrorHandler" />
     <type name="Magento\Translate\Inline">
         <param name="templateFileName">
             <value>Magento_Core::translate_inline.phtml</value>
@@ -356,10 +357,32 @@
         </param>
     </type>
     <type name="Magento\View\Publisher">
+        <param name="preProcessor">
+            <instance type="Magento\View\Asset\PreProcessor\Composite" />
+        </param>
         <param name="allowDuplication">
             <value type="bool">true</value>
         </param>
     </type>
+    <type name="Magento\View\Asset\PreProcessor\Composite">
+        <param name="preProcessorsConfig">
+            <array>
+                <item key="css_preprocessor">
+                    <array>
+                        <item key="class"><value>Magento\Css\PreProcessor\Composite</value></item>
+                        <item key="asset_type"><value>css</value></item>
+                    </array>
+                </item>
+            </array>
+        </param>
+    </type>
+    <type name="Magento\Css\PreProcessor\Composite">
+        <param name="preProcessors">
+            <array>
+                <item key="css_source_processor"><value>Magento\Css\PreProcessor\Less</value></item>
+            </array>
+        </param>
+    </type>
     <type name="Magento\Object\Copy\Config\Reader">
         <param name="fileName">
             <value>fieldset.xml</value>
@@ -459,7 +482,7 @@
             </array>
         </param>
     </type>
-    <type name="\Magento\Image">
+    <type name="Magento\Image">
         <param name="adapter">
             <instance type="Magento\Image\Adapter\Gd2"/>
         </param>
@@ -569,7 +592,11 @@
             <instance type="Magento\Less\File\Source\Theme" />
         </param>
     </type>
+    <type name="Magento\Css\PreProcessor\Less">
+        <plugin name="process_less" type="Magento\Css\PreProcessor\Cache\Plugin" sortOrder="10"/>
+    </type>
     <type name="Magento\Less\PreProcessor">
+        <plugin name="process_less_instructions" type="Magento\Css\PreProcessor\Cache\Plugin" sortOrder="10"/>
         <param name="preProcessors">
             <array>
                 <item key="import">
diff --git a/app/code/Magento/Core/view/adminhtml/translate_inline.phtml b/app/code/Magento/Core/view/adminhtml/translate_inline.phtml
index 8d6adfba0cdc5a906c5e536bec3be17141784f68..4b90609390360849f213b3a1f214edc682f00a5e 100644
--- a/app/code/Magento/Core/view/adminhtml/translate_inline.phtml
+++ b/app/code/Magento/Core/view/adminhtml/translate_inline.phtml
@@ -64,7 +64,7 @@
 </script>
 
 <div data-role="translate-dialog"
-     data-mage-init="{translateInline: {ajaxUrl:&quot;<?php echo $this->getAjaxUrl() ?>&quot;}, loader: {}}"></div>
+     data-mage-init='{"translateInline":{"ajaxUrl":"<?php echo $this->getAjaxUrl() ?>"},"loader":{}}'></div>
 <script type="text/javascript">
     (function($){
         $('body').editTrigger({img: '<?php echo $this->getViewFileUrl('Magento_Core::fam_book_open.png') ?>', alwaysShown:true, singleElement:false});
diff --git a/app/code/Magento/Core/view/frontend/translate_inline.phtml b/app/code/Magento/Core/view/frontend/translate_inline.phtml
index bd877026b144ef9a0701414926268cd53b5d759c..91831300a2d0aa08dd7bbf5f122aa0675ecb7f9b 100644
--- a/app/code/Magento/Core/view/frontend/translate_inline.phtml
+++ b/app/code/Magento/Core/view/frontend/translate_inline.phtml
@@ -60,7 +60,7 @@
     {{if message}}<p class="a-center accent">${message}</p>{{/if}}
 </script>
 
-<div data-role="translate-dialog" data-mage-init="{translateInline: {ajaxUrl:&quot;<?php echo $this->getAjaxUrl() ?>&quot;}, loader: {}}"></div>
+<div data-role="translate-dialog" data-mage-init='{"translateInline":{"ajaxUrl":"<?php echo $this->getAjaxUrl() ?>"}, "loader": {}}'></div>
 <script type="text/javascript">
     (function($){
         $('body').editTrigger({alwaysShown:true, singleElement:false}).addClass('trnslate-inline-area');
diff --git a/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php b/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php
new file mode 100644
index 0000000000000000000000000000000000000000..8fc8e91085c7d96a77fbfe560230667d92bfd807
--- /dev/null
+++ b/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Cron\Model\Backend\Config\Structure;
+
+class Converter
+{
+    /**
+     * @var \Magento\Cron\Model\Groups\Config\Data
+     */
+    protected $groupsConfig;
+
+    /**
+     * @param \Magento\Cron\Model\Groups\Config\Data $groupsConfig
+     */
+    public function __construct(\Magento\Cron\Model\Groups\Config\Data $groupsConfig)
+    {
+        $this->groupsConfig = $groupsConfig;
+    }
+
+    /**
+     * Modify system configuration for cron
+     *
+     * @param array $result
+     * @return array
+     */
+    public function afterConvert(array $result)
+    {
+        $groupIterator = 0;
+        if (!isset($result['config']['system']['sections']['system']['children']['cron']['children']['template'])) {
+            return $result;
+        }
+        foreach ($this->groupsConfig->get() as $group => $fields) {
+            $template = $result['config']['system']['sections']['system']['children']['cron']['children']['template'];
+            $template['id'] = $group;
+            $template['label'] .= $group;
+            $template['sortOrder'] += $groupIterator++;
+
+            $fieldIterator = 0;
+            foreach ($fields as $fieldName => $value) {
+                $template['children'][$fieldName]['path'] = 'system/cron/' . $group;
+                $template['children'][$fieldName]['sortOrder'] += $fieldIterator++;
+            }
+            $result['config']['system']['sections']['system']['children']['cron']['children'][$group] = $template;
+        }
+        unset($result['config']['system']['sections']['system']['children']['cron']['children']['template']);
+        return $result;
+    }
+}
diff --git a/app/code/Magento/Cron/Model/Config.php b/app/code/Magento/Cron/Model/Config.php
index 4c6dfbef12cabdebc3708535d984bcd2e333e2cc..281e6908334d22e023b9455d586dee5d0b7fade2 100644
--- a/app/code/Magento/Cron/Model/Config.php
+++ b/app/code/Magento/Cron/Model/Config.php
@@ -51,7 +51,7 @@ class Config implements \Magento\Cron\Model\ConfigInterface
     /**
      * Return cron full cron jobs
      *
-     * @return array|mixed
+     * @return array
      */
     public function getJobs()
     {
diff --git a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php
index e8388e13979dc7b3c6c48840082d05447c606831..54b071057125ae57ba66e0b6a0cc4f683b4709d7 100644
--- a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php
+++ b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php
@@ -38,12 +38,12 @@ class Alert extends \Magento\Core\Model\Config\Value
     /**
      * Cron string path
      */
-    const CRON_STRING_PATH = 'crontab/jobs/catalog_product_alert/schedule/cron_expr';
+    const CRON_STRING_PATH = 'crontab/default/jobs/catalog_product_alert/schedule/cron_expr';
 
     /**
      * Cron model path
      */
-    const CRON_MODEL_PATH  = 'crontab/jobs/catalog_product_alert/run/model';
+    const CRON_MODEL_PATH  = 'crontab/default/jobs/catalog_product_alert/run/model';
 
     /**
      * @var \Magento\Core\Model\Config\ValueFactory
@@ -83,7 +83,7 @@ class Alert extends \Magento\Core\Model\Config\Value
     }
 
     /**
-     * @return \Magento\Core\Model\AbstractModel|void
+     * @return void
      * @throws \Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php
index 29b43deeaa64e998fdb95154bb97f39922cc3d04..c01551eaa23fa51833af4e3c83fefc8e074dfa35 100644
--- a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php
+++ b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php
@@ -38,12 +38,12 @@ class Sitemap extends \Magento\Core\Model\Config\Value
     /**
      * Cron string path
      */
-    const CRON_STRING_PATH = 'crontab/jobs/sitemap_generate/schedule/cron_expr';
+    const CRON_STRING_PATH = 'crontab/default/jobs/sitemap_generate/schedule/cron_expr';
 
     /**
      * Cron mode path
      */
-    const CRON_MODEL_PATH  = 'crontab/jobs/sitemap_generate/run/model';
+    const CRON_MODEL_PATH  = 'crontab/default/jobs/sitemap_generate/run/model';
 
     /**
      * @var \Magento\Core\Model\Config\ValueFactory
@@ -83,7 +83,7 @@ class Sitemap extends \Magento\Core\Model\Config\Value
     }
 
     /**
-     * @return \Magento\Core\Model\AbstractModel
+     * @return void
      * @throws \Exception
      */
     protected function _afterSave()
diff --git a/app/code/Magento/Cron/Model/Config/Converter/Db.php b/app/code/Magento/Cron/Model/Config/Converter/Db.php
index d3fd9851a485687a6b19742f4bff1e29f3730c58..31772576e4cef1be143fbda81d1bfbcc785d772b 100644
--- a/app/code/Magento/Cron/Model/Config/Converter/Db.php
+++ b/app/code/Magento/Cron/Model/Config/Converter/Db.php
@@ -34,7 +34,7 @@ class Db implements \Magento\Config\ConverterInterface
     /**
      * Convert data
      *
-     * @param mixed $source
+     * @param array $source
      * @return array
      */
     public function convert($source)
@@ -75,6 +75,7 @@ class Db implements \Magento\Config\ConverterInterface
      * @param array  $jobConfig
      * @param string $jobName
      * @param array  $result
+     * @return void
      */
     protected function _processConfigParam(array $jobConfig, $jobName, array &$result)
     {
@@ -88,6 +89,7 @@ class Db implements \Magento\Config\ConverterInterface
      * @param array  $jobConfig
      * @param string $jobName
      * @param array  $result
+     * @return void
      */
     protected function _processScheduleParam(array $jobConfig, $jobName, array &$result)
     {
@@ -102,6 +104,7 @@ class Db implements \Magento\Config\ConverterInterface
      * @param array  $jobConfig
      * @param string $jobName
      * @param array  $result
+     * @return void
      */
     protected function _processRunModel(array $jobConfig, $jobName, array &$result)
     {
diff --git a/app/code/Magento/Cron/Model/Config/Converter/Xml.php b/app/code/Magento/Cron/Model/Config/Converter/Xml.php
index c85e05b98d76e37d5443a4215dab534b13d19a41..567291fabcf9f28c9d00a92f5f1ab5dc936bedf3 100644
--- a/app/code/Magento/Cron/Model/Config/Converter/Xml.php
+++ b/app/code/Magento/Cron/Model/Config/Converter/Xml.php
@@ -34,7 +34,7 @@ class Xml implements \Magento\Config\ConverterInterface
     /**
      * Converting data to array type
      *
-     * @param mixed $source
+     * @param \DOMDocument $source
      * @return array
      * @throws \InvalidArgumentException
      */
@@ -46,30 +46,29 @@ class Xml implements \Magento\Config\ConverterInterface
             return $output;
         }
 
-        /** @var \DOMNodeList $jobs */
-        $jobs = $source->getElementsByTagName('job');
-        /** @var \DOMElement $jobConfig */
-        foreach ($jobs as $jobConfig) {
-            $jobName = $jobConfig->getAttribute('name');
-
-            if (!$jobName) {
-                throw new \InvalidArgumentException('Attribute "name" does not exist');
+        $groups = $source->getElementsByTagName('group');
+        foreach ($groups as $group) {
+            /** @var $group \DOMElement */
+            if (!$group->hasAttribute('id')) {
+                throw new \InvalidArgumentException('Attribute "id" does not exist');
             }
-            $config = array();
-            $config['name'] = $jobName;
-            $config += $this->_convertCronConfig($jobConfig);
+            /** @var \DOMElement $jobConfig */
+            foreach ($group->childNodes as $jobConfig) {
+                if ($jobConfig->nodeName != 'job') {
+                    continue;
+                }
+                $jobName = $jobConfig->getAttribute('name');
 
-            /** @var \DOMText $schedules */
-            foreach ($jobConfig->childNodes as $schedules) {
-                if ($schedules->nodeName == 'schedule') {
-                    if (!empty($schedules->nodeValue)) {
-                        $config['schedule'] = $schedules->nodeValue;
-                        break;
-                    }
+                if (!$jobName) {
+                    throw new \InvalidArgumentException('Attribute "name" does not exist');
                 }
-                continue;
+                $config = array();
+                $config['name'] = $jobName;
+                $config += $this->convertCronConfig($jobConfig);
+                $config += $this->convertCronSchedule($jobConfig);
+
+                $output[$group->getAttribute('id')][$jobName] = $config;
             }
-            $output[$jobName] = $config;
         }
         return $output;
     }
@@ -81,7 +80,7 @@ class Xml implements \Magento\Config\ConverterInterface
      * @return array
      * @throws \InvalidArgumentException
      */
-    protected function _convertCronConfig($jobConfig)
+    protected function convertCronConfig(\DOMElement $jobConfig)
     {
         $instanceName = $jobConfig->getAttribute('instance');
         $methodName = $jobConfig->getAttribute('method');
@@ -92,6 +91,30 @@ class Xml implements \Magento\Config\ConverterInterface
         if (!isset($methodName)) {
             throw new \InvalidArgumentException('Attribute "method" does not exist');
         }
+
         return array('instance' => $instanceName, 'method' => $methodName);
     }
+
+    /**
+     * Convert schedule cron configurations
+     *
+     * @param $jobConfig
+     * @return array
+     */
+    protected function convertCronSchedule(\DOMElement $jobConfig)
+    {
+        $result = array();
+        /** @var \DOMText $schedules */
+        foreach ($jobConfig->childNodes as $schedules) {
+            if ($schedules->nodeName == 'schedule') {
+                if (!empty($schedules->nodeValue)) {
+                    $result['schedule'] = $schedules->nodeValue;
+                    break;
+                }
+            }
+            continue;
+        }
+
+        return $result;
+    }
 }
diff --git a/app/code/Magento/Cron/Model/Config/Reader/Xml.php b/app/code/Magento/Cron/Model/Config/Reader/Xml.php
index 00dc69ddd03955cf2cb9e01f96346385995c4aa8..d7c1ddb32c7ccdfef3a92a3ca36a8d67f10ad918 100644
--- a/app/code/Magento/Cron/Model/Config/Reader/Xml.php
+++ b/app/code/Magento/Cron/Model/Config/Reader/Xml.php
@@ -37,7 +37,8 @@ class Xml extends \Magento\Config\Reader\Filesystem
      * @var array
      */
     protected $_idAttributes = array(
-        '/config/job' => 'name'
+        '/config/group'     => 'id',
+        '/config/group/job' => 'name',
     );
 
     /**
diff --git a/app/code/Magento/Cron/Model/Config/Source/Frequency.php b/app/code/Magento/Cron/Model/Config/Source/Frequency.php
index 9f2e7a0c322759e400175d78d415ece9183ec7ed..33e90942e8e984c6f30e756eb4b95c4306932681 100644
--- a/app/code/Magento/Cron/Model/Config/Source/Frequency.php
+++ b/app/code/Magento/Cron/Model/Config/Source/Frequency.php
@@ -29,13 +29,18 @@ namespace Magento\Cron\Model\Config\Source;
 
 class Frequency implements \Magento\Core\Model\Option\ArrayInterface
 {
-
+    /**
+     * @var array
+     */
     protected static $_options;
 
     const CRON_DAILY    = 'D';
     const CRON_WEEKLY   = 'W';
     const CRON_MONTHLY  = 'M';
 
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         if (!self::$_options) {
@@ -56,5 +61,4 @@ class Frequency implements \Magento\Core\Model\Option\ArrayInterface
         }
         return self::$_options;
     }
-
 }
diff --git a/app/code/Magento/Cron/Model/Groups/Config/Converter/Xml.php b/app/code/Magento/Cron/Model/Groups/Config/Converter/Xml.php
new file mode 100644
index 0000000000000000000000000000000000000000..f463c1a03a0efa5da67e0c15fea3da222cc700a7
--- /dev/null
+++ b/app/code/Magento/Cron/Model/Groups/Config/Converter/Xml.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Cron\Model\Groups\Config\Converter;
+
+/**
+ * Converts cron parameters from XML files
+ */
+class Xml implements \Magento\Config\ConverterInterface
+{
+    /**
+     * Converting data to array type
+     *
+     * @param mixed $source
+     * @return array
+     * @throws \InvalidArgumentException
+     */
+    public function convert($source)
+    {
+        $output = array();
+
+        if (!$source instanceof \DOMDocument) {
+            return $output;
+        }
+
+        $groups = $source->getElementsByTagName('group');
+        foreach ($groups as $group) {
+            /** @var $group \DOMElement */
+            if (!$group->hasAttribute('id')) {
+                throw new \InvalidArgumentException('Attribute "id" does not exist');
+            }
+            foreach ($group->childNodes as $child) {
+                if (!($child instanceof \DOMElement)) {
+                    continue;
+                }
+                /** @var $group \DOMElement */
+                $output[$group->getAttribute('id')][$child->nodeName] = $child->nodeValue;
+            }
+        }
+        return $output;
+    }
+}
diff --git a/app/code/Magento/Cron/Model/Groups/Config/Data.php b/app/code/Magento/Cron/Model/Groups/Config/Data.php
new file mode 100644
index 0000000000000000000000000000000000000000..ea337a1121bdf8a5165f2cbe4e8ee803e0209b7d
--- /dev/null
+++ b/app/code/Magento/Cron/Model/Groups/Config/Data.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+/**
+ * Prepare cron jobs data
+ */
+namespace Magento\Cron\Model\Groups\Config;
+
+class Data extends \Magento\Config\Data
+{
+    /**
+     * @param \Magento\Cron\Model\Groups\Config\Reader\Xml $reader
+     * @param \Magento\Config\CacheInterface $cache
+     * @param string $cacheId
+     */
+    public function __construct(
+        \Magento\Cron\Model\Groups\Config\Reader\Xml $reader,
+        \Magento\Config\CacheInterface $cache,
+        $cacheId = 'cron_groups_config_cache'
+    ) {
+        parent::__construct($reader, $cache, $cacheId);
+    }
+
+    /**
+     * Return config by group id
+     *
+     * @param string $groupId
+     * @return array
+     */
+    public function getByGroupId($groupId)
+    {
+        return $this->get()[$groupId];
+    }
+}
diff --git a/app/code/Magento/Cron/Model/Groups/Config/Reader/Xml.php b/app/code/Magento/Cron/Model/Groups/Config/Reader/Xml.php
new file mode 100644
index 0000000000000000000000000000000000000000..eae4a4299dc962e22379548c0fb96709b8c93237
--- /dev/null
+++ b/app/code/Magento/Cron/Model/Groups/Config/Reader/Xml.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Cron\Model\Groups\Config\Reader;
+
+/**
+ * Reader for XML files
+ */
+class Xml extends \Magento\Config\Reader\Filesystem
+{
+    /**
+     * Mapping XML name nodes
+     *
+     * @var array
+     */
+    protected $_idAttributes = array(
+        '/config/group' => 'id'
+    );
+
+    /**
+     * @param \Magento\Config\FileResolverInterface $fileResolver
+     * @param \Magento\Cron\Model\Groups\Config\Converter\Xml $converter
+     * @param \Magento\Cron\Model\Groups\Config\SchemaLocator $schemaLocator
+     * @param \Magento\Config\ValidationStateInterface $validationState
+     * @param string $fileName
+     * @param array $idAttributes
+     * @param string $domDocumentClass
+     * @param string $defaultScope
+     */
+    public function __construct(
+        \Magento\Config\FileResolverInterface $fileResolver,
+        \Magento\Cron\Model\Groups\Config\Converter\Xml $converter,
+        \Magento\Cron\Model\Groups\Config\SchemaLocator $schemaLocator,
+        \Magento\Config\ValidationStateInterface $validationState,
+        $fileName = 'cron_groups.xml',
+        $idAttributes = array(),
+        $domDocumentClass = 'Magento\Config\Dom',
+        $defaultScope = 'global'
+    ) {
+        parent::__construct(
+            $fileResolver,
+            $converter,
+            $schemaLocator,
+            $validationState,
+            $fileName,
+            $idAttributes,
+            $domDocumentClass,
+            $defaultScope
+        );
+    }
+}
diff --git a/app/code/Magento/Cron/Model/Groups/Config/SchemaLocator.php b/app/code/Magento/Cron/Model/Groups/Config/SchemaLocator.php
new file mode 100644
index 0000000000000000000000000000000000000000..48380b2c84470edd01595b7bb81f738f431f68b4
--- /dev/null
+++ b/app/code/Magento/Cron/Model/Groups/Config/SchemaLocator.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Cron\Model\Groups\Config;
+
+/**
+ * Cron locator
+ */
+class SchemaLocator implements \Magento\Config\SchemaLocatorInterface
+{
+    /**
+     * Path to corresponding XSD file with validation rules for merged config
+     *
+     * @var string
+     */
+    protected $_schema;
+
+    /**
+     * Path to corresponding XSD file with validation rules for separate config files
+     *
+     * @var string
+     */
+    protected $_perFileSchema;
+
+    /**
+     * @param \Magento\Module\Dir\Reader $moduleReader
+     */
+    public function __construct(\Magento\Module\Dir\Reader $moduleReader)
+    {
+        $this->_schema = $moduleReader->getModuleDir('etc', 'Magento_Cron') . '/' . 'cron_groups.xsd';
+        $this->_perFileSchema = $this->_schema;
+    }
+
+    /**
+     * Get path to merged config schema
+     *
+     * @return string|null
+     */
+    public function getSchema()
+    {
+        return $this->_schema;
+    }
+
+    /**
+     * Get path to pre file validation schema
+     *
+     * @return string|null
+     */
+    public function getPerFileSchema()
+    {
+        return $this->_perFileSchema;
+    }
+}
diff --git a/app/code/Magento/Cron/Model/Observer.php b/app/code/Magento/Cron/Model/Observer.php
index ba2387890669672eeaa02aeade1bf3518639aa19..67beb5ba9bb8bc2178d86430f0a64a5ef631d9ae 100644
--- a/app/code/Magento/Cron/Model/Observer.php
+++ b/app/code/Magento/Cron/Model/Observer.php
@@ -41,12 +41,12 @@ class Observer
     /**#@+
      * List of configurable constants used to calculate and validate during handling cron jobs
      */
-    const XML_PATH_SCHEDULE_GENERATE_EVERY  = 'system/cron/schedule_generate_every';
-    const XML_PATH_SCHEDULE_AHEAD_FOR       = 'system/cron/schedule_ahead_for';
-    const XML_PATH_SCHEDULE_LIFETIME        = 'system/cron/schedule_lifetime';
-    const XML_PATH_HISTORY_CLEANUP_EVERY    = 'system/cron/history_cleanup_every';
-    const XML_PATH_HISTORY_SUCCESS          = 'system/cron/history_success_lifetime';
-    const XML_PATH_HISTORY_FAILURE          = 'system/cron/history_failure_lifetime';
+    const XML_PATH_SCHEDULE_GENERATE_EVERY  = 'schedule_generate_every';
+    const XML_PATH_SCHEDULE_AHEAD_FOR       = 'schedule_ahead_for';
+    const XML_PATH_SCHEDULE_LIFETIME        = 'schedule_lifetime';
+    const XML_PATH_HISTORY_CLEANUP_EVERY    = 'history_cleanup_every';
+    const XML_PATH_HISTORY_SUCCESS          = 'history_success_lifetime';
+    const XML_PATH_HISTORY_FAILURE          = 'history_failure_lifetime';
     /**#@-*/
 
     /**
@@ -54,10 +54,14 @@ class Observer
      */
     const SECONDS_IN_MINUTE = 60;
 
-    /** @var \Magento\Cron\Model\Resource\Schedule\Collection */
+    /**
+     * @var \Magento\Cron\Model\Resource\Schedule\Collection
+     */
     protected $_pendingSchedules;
 
-    /** @var \Magento\Cron\Model\ConfigInterface */
+    /**
+     * @var \Magento\Cron\Model\ConfigInterface
+     */
     protected $_config;
 
     /**
@@ -65,30 +69,56 @@ class Observer
      */
     protected $_objectManager;
 
-    /** @var \Magento\Core\Model\App */
+    /**
+     * @var \Magento\Core\Model\App
+     */
     protected $_app;
 
-    /** @var \Magento\Core\Model\Store\Config */
+    /**
+     * @var \Magento\Core\Model\Store\Config
+     */
     protected $_coreStoreConfig;
-    
+
     /**
-     * Initialize parameters
-     *
-     * @param \Magento\ObjectManager              $objectManager
-     * @param \Magento\AppInterface    $app
-     * @param \Magento\Cron\Model\ConfigInterface $config
-     * @param \Magento\Core\Model\Store\Config    $coreStoreConfig
+     * @var ScheduleFactory
+     */
+    protected $_scheduleFactory;
+
+    /**
+     * @var \Magento\App\Console\Request
+     */
+    protected $_request;
+
+    /**
+     * @var \Magento\Shell
+     */
+    protected $_shell;
+
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     * @param ScheduleFactory $scheduleFactory
+     * @param \Magento\AppInterface $app
+     * @param ConfigInterface $config
+     * @param \Magento\Core\Model\Store\Config $coreStoreConfig
+     * @param \Magento\App\Console\Request $request
+     * @param \Magento\Shell $shell
      */
     public function __construct(
         \Magento\ObjectManager $objectManager,
+        \Magento\Cron\Model\ScheduleFactory $scheduleFactory,
         \Magento\AppInterface $app,
         \Magento\Cron\Model\ConfigInterface $config,
-        \Magento\Core\Model\Store\Config $coreStoreConfig
+        \Magento\Core\Model\Store\Config $coreStoreConfig,
+        \Magento\App\Console\Request $request,
+        \Magento\Shell $shell
     ) {
         $this->_objectManager = $objectManager;
+        $this->_scheduleFactory = $scheduleFactory;
         $this->_app = $app;
         $this->_config = $config;
         $this->_coreStoreConfig = $coreStoreConfig;
+        $this->_request = $request;
+        $this->_shell = $shell;
     }
 
     /**
@@ -97,64 +127,88 @@ class Observer
      * Cleanup tasks schedule
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function dispatch($observer)
     {
         $pendingJobs = $this->_getPendingSchedules();
         $currentTime = time();
-        $jobsRoot = $this->_config->getJobs();
-
-        /** @var $schedule \Magento\Cron\Model\Schedule */
-        foreach ($pendingJobs as $schedule) {
-            $jobConfig = isset($jobsRoot[$schedule->getJobCode()]) ? $jobsRoot[$schedule->getJobCode()] : null;
-            if (!$jobConfig) {
+        $jobGroupsRoot = $this->_config->getJobs();
+
+        foreach ($jobGroupsRoot as $groupId => $jobsRoot) {
+            if (
+                $this->_request->getParam('group') === null
+                && $this->_coreStoreConfig->getConfig(
+                    'system/cron/' . $groupId . '/use_separate_process',
+                    'default'
+                ) == 1
+            ) {
+                $this->_shell->executeInBackground(
+                    '"' . PHP_BINARY . '" -f ' . BP . DIRECTORY_SEPARATOR
+                    . \Magento\App\Filesystem::PUB_DIR . DIRECTORY_SEPARATOR
+                    . 'cron.php -- --group=' . $groupId
+                );
                 continue;
             }
-
-            $scheduledTime = strtotime($schedule->getScheduledAt());
-            if ($scheduledTime > $currentTime || !$schedule->tryLockJob()) {
+            if ($this->_request->getParam('group') !== null && $this->_request->getParam('group') != $groupId) {
                 continue;
             }
 
-            try {
-                $this->_runJob($scheduledTime, $currentTime, $jobConfig, $schedule);
-            } catch (\Exception $e) {
-                $schedule->setMessages($e->getMessage());
+            foreach ($pendingJobs as $schedule) {
+                $jobConfig = isset($jobsRoot[$schedule->getJobCode()]) ? $jobsRoot[$schedule->getJobCode()] : null;
+                if (!$jobConfig) {
+                    continue;
+                }
+
+                $scheduledTime = strtotime($schedule->getScheduledAt());
+                if ($scheduledTime > $currentTime || !$schedule->tryLockJob()) {
+                    continue;
+                }
+
+                try {
+                    $this->_runJob($scheduledTime, $currentTime, $jobConfig, $schedule, $groupId);
+                } catch (\Exception $e) {
+                    $schedule->setMessages($e->getMessage());
+                }
+                $schedule->save();
             }
-            $schedule->save();
-        }
 
-        $this->_generate();
-        $this->_cleanup();
+            $this->_generate($groupId);
+            $this->_cleanup($groupId);
+        }
     }
 
     /**
      * Execute job by calling specific class::method
      *
-     * @param $scheduledTime
-     * @param $currentTime
-     * @param $jobConfig
-     * @param \Magento\Cron\Model\Schedule $schedule
-     *
+     * @param int $scheduledTime
+     * @param int $currentTime
+     * @param string[] $jobConfig
+     * @param Schedule $schedule
+     * @param string $groupId
+     * @return void
      * @throws \Exception
      */
-    protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule)
+    protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule, $groupId)
     {
-        $scheduleLifetime = (int)$this->_coreStoreConfig->getConfig(self::XML_PATH_SCHEDULE_LIFETIME, 'default');
+        $scheduleLifetime = (int)$this->_coreStoreConfig->getConfig(
+            'system/cron/' . $groupId . '/' . self::XML_PATH_SCHEDULE_LIFETIME,
+            'default'
+        );
         $scheduleLifetime = $scheduleLifetime * self::SECONDS_IN_MINUTE;
         if ($scheduledTime < $currentTime - $scheduleLifetime) {
-            $schedule->setStatus(\Magento\Cron\Model\Schedule::STATUS_MISSED);
+            $schedule->setStatus(Schedule::STATUS_MISSED);
             throw new \Exception('Too late for the schedule');
         }
 
         if (!isset($jobConfig['instance'], $jobConfig['method'])) {
-            $schedule->setStatus(\Magento\Cron\Model\Schedule::STATUS_ERROR);
+            $schedule->setStatus(Schedule::STATUS_ERROR);
             throw new \Exception('No callbacks found');
         }
         $model = $this->_objectManager->create($jobConfig['instance']);
         $callback = array($model, $jobConfig['method']);
         if (!is_callable($callback)) {
-            $schedule->setStatus(\Magento\Cron\Model\Schedule::STATUS_ERROR);
+            $schedule->setStatus(Schedule::STATUS_ERROR);
             throw new \Exception(
                 sprintf('Invalid callback: %s::%s can\'t be called', $jobConfig['instance'], $jobConfig['method'])
             );
@@ -165,14 +219,14 @@ class Observer
          * was loaded with a pending status and will set it back to pending if we don't set it here
          */
         $schedule
-            ->setStatus(\Magento\Cron\Model\Schedule::STATUS_RUNNING)
+            ->setStatus(Schedule::STATUS_RUNNING)
             ->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', time()))
             ->save();
 
         call_user_func_array($callback, array($schedule));
 
         $schedule
-            ->setStatus(\Magento\Cron\Model\Schedule::STATUS_SUCCESS)
+            ->setStatus(Schedule::STATUS_SUCCESS)
             ->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()));
     }
 
@@ -184,8 +238,8 @@ class Observer
     protected function _getPendingSchedules()
     {
         if (!$this->_pendingSchedules) {
-            $this->_pendingSchedules = $this->_objectManager->create('Magento\Cron\Model\Schedule')->getCollection()
-                ->addFieldToFilter('status', \Magento\Cron\Model\Schedule::STATUS_PENDING)
+            $this->_pendingSchedules = $this->_scheduleFactory->create()->getCollection()
+                ->addFieldToFilter('status', Schedule::STATUS_PENDING)
                 ->load();
         }
         return $this->_pendingSchedules;
@@ -194,15 +248,19 @@ class Observer
     /**
      * Generate cron schedule
      *
-     * @return \Magento\Cron\Model\Observer
+     * @param string $groupId
+     * @return $this
      */
-    protected function _generate()
+    protected function _generate($groupId)
     {
         /**
          * check if schedule generation is needed
          */
         $lastRun = (int)$this->_app->loadCache(self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT);
-        $rawSchedulePeriod = (int)$this->_coreStoreConfig->getConfig(self::XML_PATH_SCHEDULE_GENERATE_EVERY, 'default');
+        $rawSchedulePeriod = (int)$this->_coreStoreConfig->getConfig(
+            'system/cron/' . $groupId . '/' . self::XML_PATH_SCHEDULE_GENERATE_EVERY,
+            'default'
+        );
         $schedulePeriod = $rawSchedulePeriod * self::SECONDS_IN_MINUTE;
         if ($lastRun > time() - $schedulePeriod) {
             return $this;
@@ -210,7 +268,7 @@ class Observer
 
         $schedules = $this->_getPendingSchedules();
         $exists = array();
-        /** @var \Magento\Cron\Model\Schedule $schedule */
+        /** @var Schedule $schedule */
         foreach ($schedules as $schedule) {
             $exists[$schedule->getJobCode() . '/' . $schedule->getScheduledAt()] = 1;
         }
@@ -219,7 +277,7 @@ class Observer
          * generate global crontab jobs
          */
         $jobs = $this->_config->getJobs();
-        $this->_generateJobs($jobs, $exists);
+        $this->_generateJobs($jobs[$groupId], $exists, $groupId);
 
         /**
          * save time schedules generation was ran with no expiration
@@ -232,16 +290,22 @@ class Observer
     /**
      * Generate jobs for config information
      *
-     * @param   $jobs
+     * @param   array $jobs
      * @param   array $exists
-     * @return  \Magento\Cron\Model\Observer
+     * @param   string $groupId
+     * @return  $this
      */
-    protected function _generateJobs($jobs, $exists)
+    protected function _generateJobs($jobs, $exists, $groupId)
     {
-        $scheduleAheadFor = (int)$this->_coreStoreConfig->getConfig(self::XML_PATH_SCHEDULE_AHEAD_FOR, 'default');
+        $scheduleAheadFor = (int)$this->_coreStoreConfig->getConfig(
+            'system/cron/' . $groupId . '/' . self::XML_PATH_SCHEDULE_AHEAD_FOR,
+            'default'
+        );
         $scheduleAheadFor = $scheduleAheadFor * self::SECONDS_IN_MINUTE;
-        /** @var \Magento\Cron\Model\Schedule $schedule */
-        $schedule = $this->_objectManager->create('Magento\Cron\Model\Schedule');
+        /**
+         * @var Schedule $schedule
+         */
+        $schedule = $this->_scheduleFactory->create();
 
         foreach ($jobs as $jobCode => $jobConfig) {
             $cronExpr = null;
@@ -259,7 +323,7 @@ class Observer
             $timeAhead = $currentTime + $scheduleAheadFor;
             $schedule->setJobCode($jobCode)
                 ->setCronExpr($cronExpr)
-                ->setStatus(\Magento\Cron\Model\Schedule::STATUS_PENDING);
+                ->setStatus(Schedule::STATUS_PENDING);
 
             for ($time = $currentTime; $time < $timeAhead; $time += self::SECONDS_IN_MINUTE) {
                 $ts = strftime('%Y-%m-%d %H:%M:00', $time);
@@ -280,35 +344,47 @@ class Observer
     /**
      * Clean existed jobs
      *
+     * @param string $groupId
      * @return $this
      */
-    protected function _cleanup()
+    protected function _cleanup($groupId)
     {
         // check if history cleanup is needed
         $lastCleanup = (int)$this->_app->loadCache(self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT);
-        $historyCleanUp = (int)$this->_coreStoreConfig->getConfig(self::XML_PATH_HISTORY_CLEANUP_EVERY, 'default');
+        $historyCleanUp = (int)$this->_coreStoreConfig->getConfig(
+            'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_CLEANUP_EVERY,
+            'default'
+        );
         if ($lastCleanup > time() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
             return $this;
         }
 
-        /** @var \Magento\Cron\Model\Resource\Schedule\Collection $history */
-        $history = $this->_objectManager->create('Magento\Cron\Model\Schedule')->getCollection()
+        /**
+         * @var \Magento\Cron\Model\Resource\Schedule\Collection $history
+         */
+        $history = $this->_scheduleFactory->create()->getCollection()
             ->addFieldToFilter('status', array('in' => array(
-                \Magento\Cron\Model\Schedule::STATUS_SUCCESS,
-                \Magento\Cron\Model\Schedule::STATUS_MISSED,
-                \Magento\Cron\Model\Schedule::STATUS_ERROR,
+                Schedule::STATUS_SUCCESS,
+                Schedule::STATUS_MISSED,
+                Schedule::STATUS_ERROR,
             )))->load();
 
-        $historySuccess = (int)$this->_coreStoreConfig->getConfig(self::XML_PATH_HISTORY_SUCCESS, 'default');
-        $historyFailure = (int)$this->_coreStoreConfig->getConfig(self::XML_PATH_HISTORY_FAILURE, 'default');
+        $historySuccess = (int)$this->_coreStoreConfig->getConfig(
+            'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_SUCCESS,
+            'default'
+        );
+        $historyFailure = (int)$this->_coreStoreConfig->getConfig(
+            'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_FAILURE,
+            'default'
+        );
         $historyLifetimes = array(
-            \Magento\Cron\Model\Schedule::STATUS_SUCCESS => $historySuccess * self::SECONDS_IN_MINUTE,
-            \Magento\Cron\Model\Schedule::STATUS_MISSED => $historyFailure * self::SECONDS_IN_MINUTE,
-            \Magento\Cron\Model\Schedule::STATUS_ERROR => $historyFailure * self::SECONDS_IN_MINUTE,
+            Schedule::STATUS_SUCCESS => $historySuccess * self::SECONDS_IN_MINUTE,
+            Schedule::STATUS_MISSED => $historyFailure * self::SECONDS_IN_MINUTE,
+            Schedule::STATUS_ERROR => $historyFailure * self::SECONDS_IN_MINUTE,
         );
 
         $now = time();
-        /** @var \Magento\Cron\Model\Schedule $record */
+        /** @var Schedule $record */
         foreach ($history as $record) {
             if (strtotime($record->getExecutedAt()) < $now - $historyLifetimes[$record->getStatus()]) {
                 $record->delete();
diff --git a/app/code/Magento/Cron/Model/Schedule.php b/app/code/Magento/Cron/Model/Schedule.php
index fe305d507aff44e7625807d4292eb9890f0c7a10..4d798b6de6fca7bfb42ad560695ffc96206baaef 100644
--- a/app/code/Magento/Cron/Model/Schedule.php
+++ b/app/code/Magento/Cron/Model/Schedule.php
@@ -50,6 +50,8 @@
  */
 namespace Magento\Cron\Model;
 
+use Magento\Cron\Exception;
+
 class Schedule extends \Magento\Core\Model\AbstractModel
 {
     const STATUS_PENDING = 'pending';
@@ -83,16 +85,24 @@ class Schedule extends \Magento\Core\Model\AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return void
+     */
     public function _construct()
     {
         $this->_init('Magento\Cron\Model\Resource\Schedule');
     }
 
+    /**
+     * @param string $expr
+     * @return $this
+     * @throws Exception
+     */
     public function setCronExpr($expr)
     {
         $e = preg_split('#\s+#', $expr, null, PREG_SPLIT_NO_EMPTY);
         if (sizeof($e) < 5 || sizeof($e) > 6) {
-            throw new \Magento\Cron\Exception('Invalid cron expression: ' . $expr);
+            throw new Exception('Invalid cron expression: ' . $expr);
         }
 
         $this->setCronExprArr($e);
@@ -104,8 +114,8 @@ class Schedule extends \Magento\Core\Model\AbstractModel
      *
      * Supports $this->setCronExpr('* 0-5,10-59/5 2-10,15-25 january-june/2 mon-fri')
      *
-     * @param \Magento\Event $event
-     * @return boolean
+     * @param int|string $time
+     * @return bool
      */
     public function trySchedule($time)
     {
@@ -132,6 +142,12 @@ class Schedule extends \Magento\Core\Model\AbstractModel
         return $match;
     }
 
+    /**
+     * @param string $expr
+     * @param int $num
+     * @return bool
+     * @throws Exception
+     */
     public function matchCronExpression($expr, $num)
     {
         // handle ALL match
@@ -153,12 +169,12 @@ class Schedule extends \Magento\Core\Model\AbstractModel
         if (strpos($expr, '/') !== false) {
             $e = explode('/', $expr);
             if (sizeof($e) !== 2) {
-                throw new \Magento\Cron\Exception(
+                throw new Exception(
                     "Invalid cron expression, expecting 'match/modulus': " . $expr
                 );
             }
             if (!is_numeric($e[1])) {
-                throw new \Magento\Cron\Exception(
+                throw new Exception(
                     "Invalid cron expression, expecting numeric modulus: " . $expr
                 );
             }
@@ -176,7 +192,7 @@ class Schedule extends \Magento\Core\Model\AbstractModel
         } elseif (strpos($expr, '-') !== false) {
             $e = explode('-', $expr);
             if (sizeof($e) !== 2) {
-                throw new \Magento\Cron\Exception(
+                throw new Exception(
                     "Invalid cron expression, expecting 'from-to' structure: " . $expr
                 );
             }
@@ -190,12 +206,16 @@ class Schedule extends \Magento\Core\Model\AbstractModel
         }
 
         if ($from === false || $to === false) {
-            throw new \Magento\Cron\Exception("Invalid cron expression: " . $expr);
+            throw new Exception("Invalid cron expression: " . $expr);
         }
 
         return ($num >= $from) && ($num <= $to) && ($num % $mod === 0);
     }
 
+    /**
+     * @param int|string $value
+     * @return bool|int|string
+     */
     public function getNumeric($value)
     {
         static $data = array(
diff --git a/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php b/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php
new file mode 100644
index 0000000000000000000000000000000000000000..1ad44b4447421e22aeb315b38bce25e53102040f
--- /dev/null
+++ b/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Cron\Model\System\Config\Initial;
+
+class Converter
+{
+    /**
+     * @var \Magento\Cron\Model\Groups\Config\Data
+     */
+    protected $groupsConfig;
+
+    /**
+     * @param \Magento\Cron\Model\Groups\Config\Data $groupsConfig
+     */
+    public function __construct(\Magento\Cron\Model\Groups\Config\Data $groupsConfig)
+    {
+        $this->groupsConfig = $groupsConfig;
+    }
+
+    /**
+     * Modify global configuration for cron
+     *
+     * @param array $result
+     * @return array
+     */
+    public function afterConvert(array $result)
+    {
+        if (isset($result['data']['default']['system'])) {
+            $result['data']['default']['system']['cron'] = $this->groupsConfig->get();
+        }
+        return $result;
+    }
+}
diff --git a/app/code/Magento/Cron/etc/adminhtml/system.xml b/app/code/Magento/Cron/etc/adminhtml/system.xml
index c4f66d0e356f59a7c76beda92cb220e2b4f24ba4..631feee53706bd93b3b5dab8c3fb0530cb14119c 100644
--- a/app/code/Magento/Cron/etc/adminhtml/system.xml
+++ b/app/code/Magento/Cron/etc/adminhtml/system.xml
@@ -31,24 +31,31 @@
             <group id="cron" translate="label comment" type="text" sortOrder="15" showInDefault="1" showInWebsite="0" showInStore="0">
                 <label>Cron (Scheduled Tasks) - all the times are in minutes</label>
                 <comment>For correct URLs generated during cron runs please make sure that Web &gt; Secure and Unsecure Base URLs are explicitly set.</comment>
-                <field id="schedule_generate_every" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Generate Schedules Every</label>
-                </field>
-                <field id="schedule_ahead_for" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Schedule Ahead for</label>
-                </field>
-                <field id="schedule_lifetime" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Missed if Not Run Within</label>
-                </field>
-                <field id="history_cleanup_every" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>History Cleanup Every</label>
-                </field>
-                <field id="history_success_lifetime" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Success History Lifetime</label>
-                </field>
-                <field id="history_failure_lifetime" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Failure History Lifetime</label>
-                </field>
+                <group id="template" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
+                    <label>Cron configuration options for group: </label>
+                    <field id="schedule_generate_every" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>Generate Schedules Every</label>
+                    </field>
+                    <field id="schedule_ahead_for" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>Schedule Ahead for</label>
+                    </field>
+                    <field id="schedule_lifetime" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>Missed if Not Run Within</label>
+                    </field>
+                    <field id="history_cleanup_every" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>History Cleanup Every</label>
+                    </field>
+                    <field id="history_success_lifetime" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>Success History Lifetime</label>
+                    </field>
+                    <field id="history_failure_lifetime" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>Failure History Lifetime</label>
+                    </field>
+                    <field id="use_separate_process" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
+                        <label>Use Separate Process</label>
+                        <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model>
+                    </field>
+                </group>
             </group>
         </section>
     </system>
diff --git a/app/code/Magento/Cron/etc/config.xml b/app/code/Magento/Cron/etc/cron_groups.xml
similarity index 66%
rename from app/code/Magento/Cron/etc/config.xml
rename to app/code/Magento/Cron/etc/cron_groups.xml
index fdb9e59f5396abad04f6191dec6d2f147a357aaa..08e72b8295e8c82f2cf2fa94f3ae8f224922919e 100644
--- a/app/code/Magento/Cron/etc/config.xml
+++ b/app/code/Magento/Cron/etc/cron_groups.xml
@@ -26,16 +26,13 @@
  */
 -->
 <config>
-    <default>
-        <system>
-            <cron>
-                <schedule_generate_every>15</schedule_generate_every>
-                <schedule_ahead_for>20</schedule_ahead_for>
-                <schedule_lifetime>15</schedule_lifetime>
-                <history_cleanup_every>10</history_cleanup_every>
-                <history_success_lifetime>60</history_success_lifetime>
-                <history_failure_lifetime>600</history_failure_lifetime>
-            </cron>
-        </system>
-    </default>
-</config>
+    <group id="default">
+        <schedule_generate_every>15</schedule_generate_every>
+        <schedule_ahead_for>20</schedule_ahead_for>
+        <schedule_lifetime>15</schedule_lifetime>
+        <history_cleanup_every>10</history_cleanup_every>
+        <history_success_lifetime>60</history_success_lifetime>
+        <history_failure_lifetime>600</history_failure_lifetime>
+        <use_separate_process>0</use_separate_process>
+    </group>
+</config>
\ No newline at end of file
diff --git a/app/code/Magento/Cron/etc/cron_groups.xsd b/app/code/Magento/Cron/etc/cron_groups.xsd
new file mode 100644
index 0000000000000000000000000000000000000000..22373e5dcc4d553b7ada06401a28f79fc2f8c5b6
--- /dev/null
+++ b/app/code/Magento/Cron/etc/cron_groups.xsd
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    <xs:element name="config">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="group" type="group" minOccurs="1" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+
+        <xs:unique name="uniqueGroupId">
+            <xs:annotation>
+                <xs:documentation>
+                    Group id must be unique.
+                </xs:documentation>
+            </xs:annotation>
+            <xs:selector xpath="group"/>
+            <xs:field xpath="@id"/>
+        </xs:unique>
+    </xs:element>
+
+    <xs:complexType name="group">
+        <xs:sequence>
+            <xs:element name="schedule_generate_every" type="xs:integer" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="schedule_ahead_for" type="xs:integer" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="schedule_lifetime" type="xs:integer" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="history_cleanup_every" type="xs:integer" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="history_success_lifetime" type="xs:integer" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="history_failure_lifetime" type="xs:integer" minOccurs="0" maxOccurs="1"/>
+            <xs:element name="use_separate_process" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
+        </xs:sequence>
+        <xs:attribute name="id" type="typeId" use="required" />
+    </xs:complexType>
+
+    <xs:simpleType name="typeId">
+        <xs:annotation>
+            <xs:documentation>
+                Item id attribute can has only [a-z0-9_].
+            </xs:documentation>
+        </xs:annotation>
+
+        <xs:restriction base="xs:string">
+            <xs:pattern value="[a-z0-9_]+" />
+        </xs:restriction>
+    </xs:simpleType>
+</xs:schema>
diff --git a/app/code/Magento/Cron/etc/crontab.xsd b/app/code/Magento/Cron/etc/crontab.xsd
index 674b30d1ca1e410b47bc74326e34a51e2f611fc2..b940e9df8090edc0a683ce178583c18bfcaa62ce 100644
--- a/app/code/Magento/Cron/etc/crontab.xsd
+++ b/app/code/Magento/Cron/etc/crontab.xsd
@@ -27,21 +27,37 @@
     <xs:element name="config">
         <xs:complexType>
             <xs:sequence>
-                <xs:element name="job" type="jobDeclaration" minOccurs="1" maxOccurs="unbounded"/>
+                <xs:element name="group" minOccurs="1" maxOccurs="unbounded">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="job" type="jobDeclaration" minOccurs="1" maxOccurs="unbounded"/>
+                        </xs:sequence>
+                        <xs:attribute name="id" type="xs:string" use="required"/>
+                    </xs:complexType>
+
+                    <xs:unique name="uniqueJobName">
+                        <xs:annotation>
+                            <xs:documentation>
+                                Job name must be unique.
+                            </xs:documentation>
+                        </xs:annotation>
+                        <xs:selector xpath="job"/>
+                        <xs:field xpath="@name"/>
+                    </xs:unique>
+                </xs:element>
             </xs:sequence>
         </xs:complexType>
-
-        <xs:unique name="uniqueJobName">
-            <xs:annotation>
-                <xs:documentation>
-                    Job name must be unique.
-                </xs:documentation>
-            </xs:annotation>
-            <xs:selector xpath="job"/>
-            <xs:field xpath="@name"/>
-        </xs:unique>
     </xs:element>
 
+    <xs:complexType name="groupDeclaration">
+        <xs:annotation>
+            <xs:documentation>
+                Group declaration.
+            </xs:documentation>
+        </xs:annotation>
+        <xs:attribute name="name" type="xs:string" use="required"/>
+    </xs:complexType>
+
     <xs:complexType name="jobDeclaration">
         <xs:annotation>
             <xs:documentation>
diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml
index cc1bc7452d03e8eaedff73ccd64969758a33e342..07ffb555717f70a8d8b8ffce260f5d840600474e 100644
--- a/app/code/Magento/Cron/etc/di.xml
+++ b/app/code/Magento/Cron/etc/di.xml
@@ -33,4 +33,10 @@
     <type name="Magento\App\Cron">
         <plugin name="application_initializer" type="Magento\Cron\App\Cron\Plugin\ApplicationInitializer" sortOrder="10"/>
     </type>
+    <type name="Magento\Backend\Model\Config\Structure\Converter">
+        <plugin name="cron_backend_config_structure_converter_plugin" type="Magento\Cron\Model\Backend\Config\Structure\Converter" />
+    </type>
+    <type name="Magento\App\Config\Initial\Converter">
+        <plugin name="cron_system_config_initial_converter_plugin" type="Magento\Cron\Model\System\Config\Initial\Converter" />
+    </type>
 </config>
diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Address.php b/app/code/Magento/Customer/Block/Account/Dashboard/Address.php
index f3078cf1854650f36b30a20849fd2c7a6091ce87..0aa939cd9f7e2331589ce5e1b9c6eefda318e5a8 100644
--- a/app/code/Magento/Customer/Block/Account/Dashboard/Address.php
+++ b/app/code/Magento/Customer/Block/Account/Dashboard/Address.php
@@ -1,5 +1,7 @@
 <?php
 /**
+ * Customer dashboard addresses section
+ *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -20,18 +22,11 @@
  *
  * @category    Magento
  * @package     Magento_Customer
+ * @author      Magento Core Team <core@magentocommerce.com>
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-/**
- * Customer dashboard addresses section
- *
- * @category   Magento
- * @package    Magento_Customer
- * @author      Magento Core Team <core@magentocommerce.com>
- */
-
 namespace Magento\Customer\Block\Account\Dashboard;
 
 class Address extends \Magento\View\Element\Template
@@ -41,43 +36,94 @@ class Address extends \Magento\View\Element\Template
      */
     protected $_customerSession;
 
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerServiceInterface
+     */
+    protected $_customerService;
+
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface
+     */
+    protected $_addressService;
+
+    /**
+     * @var \Magento\Customer\Model\Address\Config
+     */
+    protected $_addressConfig;
+    
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
+     * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+     * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
+     * @param \Magento\Customer\Model\Address\Config $addressConfig
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
         \Magento\Customer\Model\Session $customerSession,
+        \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+        \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
+        \Magento\Customer\Model\Address\Config $addressConfig,
         array $data = array()
     ) {
         $this->_customerSession = $customerSession;
+        $this->_customerService = $customerService;
+        $this->_addressService = $addressService;
+        $this->_addressConfig = $addressConfig;
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
     }
 
+    /**
+     * Get the logged in customer
+     *
+     * @return \Magento\Customer\Service\V1\Dto\Customer
+     */
     public function getCustomer()
     {
-        return $this->_customerSession->getCustomer();
+        try {
+            return $this->_customerService->getCustomer($this->_customerSession->getId());
+        } catch (\Magento\Exception\NoSuchEntityException $e) {
+            return null;
+        }
     }
 
+    /**
+     * HTML for Shipping Address
+     *
+     * @return string
+     */
     public function getPrimaryShippingAddressHtml()
     {
-        $address = $this->getCustomer()->getPrimaryShippingAddress();
+        try {
+            $address = $this->_addressService->getDefaultShippingAddress($this->_customerSession->getCustomerId());
+        } catch (\Magento\Exception\NoSuchEntityException $e) {
+            return __('You have not set a default shipping address.');
+        }
 
-        if( $address instanceof \Magento\Object ) {
-            return $address->format('html');
+        if ($address) {
+            return $this->_getAddressHtml($address);
         } else {
             return __('You have not set a default shipping address.');
         }
     }
 
+    /**
+     * HTML for Billing Address
+     *
+     * @return string
+     */
     public function getPrimaryBillingAddressHtml()
     {
-        $address = $this->getCustomer()->getPrimaryBillingAddress();
+        try {
+            $address = $this->_addressService->getDefaultBillingAddress($this->_customerSession->getCustomerId());
+        } catch (\Magento\Exception\NoSuchEntityException $e) {
+            return __('You have not set a default billing address.');
+        }
 
-        if( $address instanceof \Magento\Object ) {
-            return $address->format('html');
+        if ($address) {
+            return $this->_getAddressHtml($address);
         } else {
             return __('You have not set a default billing address.');
         }
@@ -85,16 +131,38 @@ class Address extends \Magento\View\Element\Template
 
     public function getPrimaryShippingAddressEditUrl()
     {
-        return $this->_urlBuilder->getUrl('customer/address/edit', array('id'=>$this->getCustomer()->getDefaultShipping()));
+        if (is_null($this->getCustomer())) {
+            return '';
+        } else {
+            return $this->_urlBuilder->getUrl('customer/address/edit', array('id'=>$this->getCustomer()->getDefaultShipping()));
+        }
     }
 
     public function getPrimaryBillingAddressEditUrl()
     {
-        return $this->_urlBuilder->getUrl('customer/address/edit', array('id'=>$this->getCustomer()->getDefaultBilling()));
+        if (is_null($this->getCustomer())) {
+            return '';
+        } else {
+            return $this->_urlBuilder->getUrl('customer/address/edit', array('id'=>$this->getCustomer()->getDefaultBilling()));
+        }
     }
 
     public function getAddressBookUrl()
     {
         return $this->getUrl('customer/address/');
     }
+
+    /**
+     * Render an address as HTML and return the result
+     *
+     * @param \Magento\Customer\Service\V1\Dto\Address $address
+     * @return string
+     */
+    protected function _getAddressHtml($address)
+    {
+        /** @var \Magento\Customer\Block\Address\Renderer\RendererInterface $renderer */
+        $renderer = $this->_addressConfig->getFormatByCode('html')->getRenderer();
+        return $renderer->renderArray($address->getAttributes());
+    }
 }
+
diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php
index 1bf2eb1b99e056ece3c59fe37fbfd353b3bd72d0..686dacd266f24a418af8eae339e0d58011174ee6 100644
--- a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php
+++ b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php
@@ -18,22 +18,18 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
+namespace Magento\Customer\Block\Account\Dashboard;
+
+use Magento\Customer\Service\V1\CustomerMetadataServiceInterface;
+use Magento\Exception\NoSuchEntityException;
+
 /**
  * Dashboard Customer Info
- *
- * @category   Magento
- * @package    Magento_Customer
- * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Customer\Block\Account\Dashboard;
-
 class Info extends \Magento\View\Element\Template
 {
     /**
@@ -53,28 +49,78 @@ class Info extends \Magento\View\Element\Template
      */
     protected $_subscriberFactory;
 
+    /**
+     * @var CustomerMetadataServiceInterface
+     */
+    protected $_metadataService;
+
+    /** @var  \Magento\Customer\Service\V1\CustomerServiceInterface */
+    protected $_customerService;
+
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
+     * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+     * @param CustomerMetadataServiceInterface $metadataService
      * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
         \Magento\Customer\Model\Session $customerSession,
+        \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+        CustomerMetadataServiceInterface $metadataService,
         \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
         array $data = array()
     ) {
         $this->_customerSession = $customerSession;
+        $this->_customerService = $customerService;
+        $this->_metadataService = $metadataService;
         $this->_subscriberFactory = $subscriberFactory;
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
     }
 
-
+    /**
+     * Returns the Magento Customer Model for this block
+     *
+     * @return \Magento\Customer\Service\V1\Dto\Customer
+     */
     public function getCustomer()
     {
-        return $this->_customerSession->getCustomer();
+        try {
+            return $this->_customerService->getCustomer($this->_customerSession->getId());
+        } catch (NoSuchEntityException $e) {
+            return null;
+        }
+    }
+
+    /**
+     * Get the full name of a customer
+     *
+     * @return string full name
+     */
+    public function getName()
+    {
+        $name = '';
+
+        $customer = $this->getCustomer();
+
+        if ($this->_metadataService->getCustomerAttributeMetadata('prefix')->isVisible()
+            && $customer->getPrefix()) {
+            $name .= $customer->getPrefix() . ' ';
+        }
+        $name .= $customer->getFirstname();
+        if ($this->_metadataService->getCustomerAttributeMetadata('middlename')->isVisible()
+            && $customer->getMiddlename()) {
+            $name .= ' ' . $customer->getMiddlename();
+        }
+        $name .=  ' ' . $customer->getLastname();
+        if ($this->_metadataService->getCustomerAttributeMetadata('suffix')->isVisible()
+            && $customer->getSuffix()) {
+            $name .= ' ' . $customer->getSuffix();
+        }
+        return $name;
     }
 
     public function getChangePasswordUrl()
@@ -91,7 +137,10 @@ class Info extends \Magento\View\Element\Template
     {
         if (!$this->_subscription) {
             $this->_subscription = $this->_createSubscriber();
-            $this->_subscription->loadByCustomer($this->_customerSession->getCustomer());
+            $customer = $this->getCustomer();
+            if ($customer) {
+                $this->_subscription->loadByEmail($customer->getEmail());
+            }
         }
         return $this->_subscription;
     }
diff --git a/app/code/Magento/Customer/Block/Address/Book.php b/app/code/Magento/Customer/Block/Address/Book.php
index 6fa2ae4f80f4d02abfc4308f67ebfde430b0d6a7..52bc220ec549028cb483f7fe069083b9b9ea406a 100644
--- a/app/code/Magento/Customer/Block/Address/Book.php
+++ b/app/code/Magento/Customer/Block/Address/Book.php
@@ -40,17 +40,41 @@ class Book extends \Magento\View\Element\Template
      */
     protected $_customerSession;
 
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerServiceInterface
+     */
+    protected $_customerService;
+
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface
+     */
+    protected $_addressService;
+
+    /**
+     * @var \Magento\Customer\Model\Address\Config
+     */
+    protected $_addressConfig;
+
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
+     * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+     * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
+     * @param \Magento\Customer\Model\Address\Config $addressConfig
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
         \Magento\Customer\Model\Session $customerSession,
+        \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+        \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
+        \Magento\Customer\Model\Address\Config $addressConfig,
         array $data = array()
     ) {
         $this->_customerSession = $customerSession;
+        $this->_customerService = $customerService;
+        $this->_addressService = $addressService;
+        $this->_addressConfig = $addressConfig;
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
     }
@@ -81,42 +105,70 @@ class Book extends \Magento\View\Element\Template
         return $this->getUrl('customer/address/delete');
     }
 
-    public function getAddressEditUrl($address)
-    {
-        return $this->getUrl('customer/address/edit', array('_secure'=>true, 'id'=>$address->getId()));
-    }
-
-    public function getPrimaryBillingAddress()
-    {
-        return $this->getCustomer()->getPrimaryBillingAddress();
-    }
-
-    public function getPrimaryShippingAddress()
+    /**
+     * @param int $addressId
+     * @return string
+     */
+    public function getAddressEditUrl($addressId)
     {
-        return $this->getCustomer()->getPrimaryShippingAddress();
+        return $this->getUrl('customer/address/edit', array('_secure'=>true, 'id' => $addressId));
     }
 
+    /**
+     * @return bool
+     */
     public function hasPrimaryAddress()
     {
-        return $this->getPrimaryBillingAddress() || $this->getPrimaryShippingAddress();
+        return $this->getDefaultBilling() || $this->getDefaultShipping();
     }
 
+    /**
+     * @return \Magento\Customer\Service\V1\Dto\Address[]|bool
+     */
     public function getAdditionalAddresses()
     {
-        $addresses = $this->getCustomer()->getAdditionalAddresses();
-        return empty($addresses) ? false : $addresses;
+        try {
+            $addresses = $this->_addressService->getAddresses($this->_customerSession->getCustomerId());
+        } catch (\Magento\Exception\NoSuchEntityException $e) {
+            return false;
+        }
+        $primaryAddressIds = [$this->getDefaultBilling(), $this->getDefaultShipping()];
+        foreach ($addresses as $address) {
+            if (!in_array($address->getId(), $primaryAddressIds)) {
+                $additional[] = $address;
+            }
+        }
+        return empty($additional) ? false : $additional;
     }
 
-    public function getAddressHtml($address)
+    /**
+     * Render an address as HTML and return the result
+     *
+     * @param \Magento\Customer\Service\V1\Dto\Address $address
+     * @return string
+     */
+    public function getAddressHtml(\Magento\Customer\Service\V1\Dto\Address $address = null)
     {
-        return $address->format('html');
+        if (!is_null($address)) {
+            /** @var \Magento\Customer\Block\Address\Renderer\RendererInterface $renderer */
+            $renderer = $this->_addressConfig->getFormatByCode('html')->getRenderer();
+            return $renderer->renderArray($address->getAttributes());
+        }
+        return '';
     }
 
+    /**
+     * @return \Magento\Customer\Service\V1\Dto\Customer|null
+     */
     public function getCustomer()
     {
         $customer = $this->getData('customer');
         if (is_null($customer)) {
-            $customer = $this->_customerSession->getCustomer();
+            try {
+                $customer = $this->_customerService->getCustomer($this->_customerSession->getCustomerId());
+            } catch (\Magento\Exception\NoSuchEntityException $e) {
+                return null;
+            }
             $this->setData('customer', $customer);
         }
         return $customer;
@@ -127,16 +179,25 @@ class Book extends \Magento\View\Element\Template
      */
     public function getDefaultBilling()
     {
-        return $this->_customerSession->getCustomer()->getDefaultBilling();
+        $customer = $this->getCustomer();
+        if (is_null($customer)) {
+            return null;
+        } else {
+            return $customer->getDefaultBilling();
+        }
     }
 
     /**
-     * @param int $address
-     * @return \Magento\Customer\Model\Address
+     * @param int $addressId
+     * @return \Magento\Customer\Service\V1\Dto\Address|null
      */
-    public function getAddressById($address)
+    public function getAddressById($addressId)
     {
-        return $this->_customerSession->getCustomer()->getAddressById($address);
+        try {
+            return $this->_addressService->getAddressById($addressId);
+        } catch (\Magento\Exception\NoSuchEntityException $e) {
+            return null;
+        }
     }
 
     /**
@@ -144,6 +205,11 @@ class Book extends \Magento\View\Element\Template
      */
     public function getDefaultShipping()
     {
-        return $this->_customerSession->getCustomer()->getDefaultShipping();
+        $customer = $this->getCustomer();
+        if (is_null($customer)) {
+            return null;
+        } else {
+            return $customer->getDefaultShipping();
+        }
     }
 }
diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php
index 9f3a14cc88ae7f286243318534b242b5ba887309..6ebadbf7139de4ea966f8b7f05a291a3d8792a07 100644
--- a/app/code/Magento/Customer/Block/Address/Edit.php
+++ b/app/code/Magento/Customer/Block/Address/Edit.php
@@ -29,9 +29,16 @@
  */
 namespace Magento\Customer\Block\Address;
 
+use Magento\Customer\Service\V1\Dto\Address;
+use Magento\Customer\Service\V1\Dto\Customer;
+use Magento\Exception\NoSuchEntityException;
+
 class Edit extends \Magento\Directory\Block\Data
 {
-    protected $_address;
+    /**
+     * @var Address
+     */
+    protected $_address = null;
     protected $_countryCollection;
     protected $_regionCollection;
 
@@ -46,20 +53,32 @@ class Edit extends \Magento\Directory\Block\Data
     protected $_customerSession;
 
     /**
-     * @var \Magento\Customer\Model\AddressFactory
+     * @var \Magento\Customer\Service\V1\CustomerServiceInterface
+     */
+    protected $_customerService;
+
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface
      */
-    protected $_addressFactory;
+    protected $_addressService;
+
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\AddressBuilder
+     */
+    private $_addressBuilder;
 
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Json\EncoderInterface $jsonEncoder
      * @param \Magento\Core\Helper\Data $coreData
+     * @param \Magento\Json\EncoderInterface $jsonEncoder
      * @param \Magento\App\Cache\Type\Config $configCacheType
      * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory
      * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory
      * @param \Magento\App\ConfigInterface $config
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Customer\Model\AddressFactory $addressFactory
+     * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+     * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
+     * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
      * @param array $data
      */
     public function __construct(
@@ -71,12 +90,16 @@ class Edit extends \Magento\Directory\Block\Data
         \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory,
         \Magento\App\ConfigInterface $config,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Customer\Model\AddressFactory $addressFactory,
+        \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+        \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
+        \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder,
         array $data = array()
     ) {
         $this->_config = $config;
         $this->_customerSession = $customerSession;
-        $this->_addressFactory = $addressFactory;
+        $this->_customerService = $customerService;
+        $this->_addressService = $addressService;
+        $this->_addressBuilder = $addressBuilder;
         parent::__construct(
             $context, $coreData, $jsonEncoder, $configCacheType, $regionCollectionFactory, $countryCollectionFactory, $data
         );
@@ -86,22 +109,23 @@ class Edit extends \Magento\Directory\Block\Data
     protected function _prepareLayout()
     {
         parent::_prepareLayout();
-        $this->_address = $this->_createAddress();
 
         // Init address object
-        if ($id = $this->getRequest()->getParam('id')) {
-            $this->_address->load($id);
-            if ($this->_address->getCustomerId() != $this->_customerSession->getCustomerId()) {
-                $this->_address->setData(array());
+        if ($addressId = $this->getRequest()->getParam('id')) {
+            try {
+                $this->_address = $this->_addressService->getAddressById($addressId);
+            } catch (NoSuchEntityException $e) {
+                // something went wrong, but we are ignore it for now
             }
         }
 
-        if (!$this->_address->getId()) {
-            $this->_address->setPrefix($this->getCustomer()->getPrefix())
+        if (is_null($this->_address) || !$this->_address->getId()) {
+            $this->_address = $this->_addressBuilder->setPrefix($this->getCustomer()->getPrefix())
                 ->setFirstname($this->getCustomer()->getFirstname())
                 ->setMiddlename($this->getCustomer()->getMiddlename())
                 ->setLastname($this->getCustomer()->getLastname())
-                ->setSuffix($this->getCustomer()->getSuffix());
+                ->setSuffix($this->getCustomer()->getSuffix())
+                ->create();
         }
 
         if ($headBlock = $this->getLayout()->getBlock('head')) {
@@ -109,7 +133,15 @@ class Edit extends \Magento\Directory\Block\Data
         }
 
         if ($postedData = $this->_customerSession->getAddressFormData(true)) {
-            $this->_address->addData($postedData);
+            if (!empty($postedData['region_id']) || !empty($postedData['region'])) {
+                $postedData['region'] = [
+                    'region_id' => $postedData['region_id'],
+                    'region' => $postedData['region'],
+                ];
+            }
+            $this->_address = $this->_addressBuilder
+                ->populateWithArray(array_merge($this->_address->__toArray(), $postedData))
+                ->create();
         }
     }
 
@@ -156,14 +188,30 @@ class Edit extends \Magento\Directory\Block\Data
 
     public function getSaveUrl()
     {
-        return $this->_urlBuilder->getUrl('customer/address/formPost', array('_secure'=>true, 'id'=>$this->getAddress()->getId()));
+        return $this->_urlBuilder->getUrl(
+            'customer/address/formPost',
+            array('_secure'=>true, 'id'=>$this->getAddress()->getId())
+        );
     }
 
+    /**
+     * @return Address
+     */
     public function getAddress()
     {
         return $this->_address;
     }
 
+    /**
+     * @param int $lineNumber
+     * @return string
+     */
+    public function getStreetLine($lineNumber)
+    {
+        $street = $this->_address->getStreet();
+        return isset($street[$lineNumber-1]) ? $street[$lineNumber-1] : '';
+    }
+
     public function getCountryId()
     {
         if ($countryId = $this->getAddress()->getCountryId()) {
@@ -172,9 +220,26 @@ class Edit extends \Magento\Directory\Block\Data
         return parent::getCountryId();
     }
 
+    /**
+     * Return the name of the region for the address being edited
+     *
+     * @return string region name
+     */
+    public function getRegion()
+    {
+        $region = $this->getAddress()->getRegion();
+        return is_null($region) ? '' : $region->getRegion();
+    }
+
+    /**
+     * Return the id of the region being edited
+     *
+     * @return int region id
+     */
     public function getRegionId()
     {
-        return $this->getAddress()->getRegionId();
+        $region = $this->getAddress()->getRegion();
+        return is_null($region) ? 0 : $region->getRegionId();
     }
 
     public function getCustomerAddressCount()
@@ -195,24 +260,25 @@ class Edit extends \Magento\Directory\Block\Data
         if (!$this->getAddress()->getId()) {
             return $this->getCustomerAddressCount();
         }
-        return !$this->isDefaultShipping();;
+        return !$this->isDefaultShipping();
     }
 
     public function isDefaultBilling()
     {
-        $defaultBilling = $this->_customerSession->getCustomer()->getDefaultBilling();
-        return $this->getAddress()->getId() && $this->getAddress()->getId() == $defaultBilling;
+        return (bool)$this->getAddress()->isDefaultBilling();
     }
 
     public function isDefaultShipping()
     {
-        $defaultShipping = $this->_customerSession->getCustomer()->getDefaultShipping();
-        return $this->getAddress()->getId() && $this->getAddress()->getId() == $defaultShipping;
+        return (bool)$this->getAddress()->isDefaultShipping();
     }
 
+    /**
+     * @return Customer
+     */
     public function getCustomer()
     {
-        return $this->_customerSession->getCustomer();
+        return $this->_customerService->getCustomer($this->_customerSession->getId());
     }
 
     public function getBackButtonUrl()
@@ -234,12 +300,4 @@ class Edit extends \Magento\Directory\Block\Data
     {
         return $this->_storeConfig->getConfig($path);
     }
-
-    /**
-     * @return \Magento\Customer\Model\Address
-     */
-    protected function _createAddress()
-    {
-        return $this->_addressFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php
index ddccada0e86f99ac59865c212d8455cde0664bc5..255f61767416202bffec1e92552f66fab0d45853 100644
--- a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php
+++ b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php
@@ -18,22 +18,17 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Customer\Block\Address\Renderer;
 
+use Magento\Eav\Model\AttributeDataFactory;
+use Magento\Customer\Model\Metadata\ElementFactory;
 
 /**
  * Address format renderer default
- *
- * @category   Magento
- * @package    Magento_Customer
- * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Customer\Block\Address\Renderer;
-
 class DefaultRenderer
     extends \Magento\View\Element\AbstractBlock
     implements \Magento\Customer\Block\Address\Renderer\RendererInterface
@@ -53,14 +48,9 @@ class DefaultRenderer
     protected $_customerAddress = null;
 
     /**
-     * @var \Magento\Eav\Model\AttributeDataFactory
+     * @var ElementFactory
      */
-    protected $_attrDataFactory;
-
-    /**
-     * @var \Magento\Customer\Model\Metadata\ElementFactory
-     */
-    protected $_attributeMetadataFactory;
+    protected $_elementFactory;
 
     /**
      * @var \Magento\Directory\Model\CountryFactory
@@ -70,30 +60,36 @@ class DefaultRenderer
     /**
      * @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
      */
-    protected $_customerMetadataService;
+    protected $_metadataService;
+
+    /**
+     * @var AttributeDataFactory
+     */
+    protected $_attrDataFactory;
 
     /**
      * @param \Magento\View\Element\Context $context
+     * @param \Magento\Customer\Model\Metadata\ElementFactory $elementFactory
+     * @param \Magento\Directory\Model\CountryFactory $countryFactory ,
      * @param \Magento\Customer\Helper\Address $customerAddress
-     * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory
-     * @param \Magento\Directory\Model\CountryFactory $countryFactory,
-     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService
+     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService
+     * @param AttributeDataFactory $attrDataFactory
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Context $context,
-        \Magento\Customer\Helper\Address $customerAddress,
-        \Magento\Eav\Model\AttributeDataFactory $attrDataFactory,
+        \Magento\Customer\Model\Metadata\ElementFactory $elementFactory,
         \Magento\Directory\Model\CountryFactory $countryFactory,
-        \Magento\Customer\Model\Metadata\ElementFactory $attributeMetadataFactory,
-        \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService,
+        \Magento\Customer\Helper\Address $customerAddress,
+        \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService,
+        AttributeDataFactory $attrDataFactory,
         array $data = array()
     ) {
+        $this->_elementFactory = $elementFactory;
         $this->_customerAddress = $customerAddress;
-        $this->_attrDataFactory = $attrDataFactory;
         $this->_countryFactory = $countryFactory;
-        $this->_attributeMetadataFactory = $attributeMetadataFactory;
-        $this->_customerMetadataService = $customerMetadataService;
+        $this->_metadataService = $metadataService;
+        $this->_attrDataFactory = $attrDataFactory;
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
     }
@@ -135,27 +131,22 @@ class DefaultRenderer
     }
 
     /**
-     * Render address
-     *
-     * @deprecated All new code should use renderArray based on Metadata service
-     * @param \Magento\Customer\Model\Address\AbstractAddress $address
-     * @param string|null $format
-     * @return string
+     * {@inheritdoc}
      */
     public function render(\Magento\Customer\Model\Address\AbstractAddress $address, $format = null)
     {
         switch ($this->getType()->getCode()) {
             case 'html':
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_HTML;
                 break;
             case 'pdf':
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_PDF;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_PDF;
                 break;
             case 'oneline':
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ONELINE;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_ONELINE;
                 break;
             default:
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_TEXT;
                 break;
         }
 
@@ -175,7 +166,7 @@ class DefaultRenderer
                 $dataModel = $this->_attrDataFactory->create($attribute, $address);
                 $value     = $dataModel->outputValue($dataFormat);
                 if ($attribute->getFrontendInput() == 'multiline') {
-                    $values    = $dataModel->outputValue(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY);
+                    $values    = $dataModel->outputValue(AttributeDataFactory::OUTPUT_FORMAT_ARRAY);
                     // explode lines
                     foreach ($values as $k => $v) {
                         $key = sprintf('%s%d', $attribute->getAttributeCode(), $k + 1);
@@ -197,10 +188,7 @@ class DefaultRenderer
     }
 
     /**
-     * Get a format object for a given address attributes, based on the type set earlier.
-     *
-     * @param null|array $addressAttributes
-     * @return string
+     * {@inheritdoc}
      */
     public function getFormatArray($addressAttributes = null)
     {
@@ -215,30 +203,26 @@ class DefaultRenderer
     }
 
     /**
-     * Render address  by attribute array
-     *
-     * @param array $addressAttributes
-     * @param \Magento\Directory\Model\Country\Format $format
-     * @return string
+     * {@inheritdoc}
      */
     public function renderArray($addressAttributes, $format = null)
     {
         switch ($this->getType()->getCode()) {
             case 'html':
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_HTML;
                 break;
             case 'pdf':
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_PDF;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_PDF;
                 break;
             case 'oneline':
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ONELINE;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_ONELINE;
                 break;
             default:
-                $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT;
+                $dataFormat = AttributeDataFactory::OUTPUT_FORMAT_TEXT;
                 break;
         }
 
-        $attributesMetadata = $this->_customerMetadataService->getAllAddressAttributeMetadata();
+        $attributesMetadata = $this->_metadataService->getAllAddressAttributeMetadata();
         $data = array();
         foreach ($attributesMetadata as $attributeMetadata) {
             if (!$attributeMetadata->isVisible()) {
@@ -246,15 +230,16 @@ class DefaultRenderer
             }
             $attributeCode = $attributeMetadata->getAttributeCode();
             if ($attributeCode == 'country_id' && isset($addressAttributes['country_id'])) {
-                $data['country'] = $this->_countryFactory->create(['id' => $addressAttributes['country_id']])->getName();
+                $data['country'] =
+                    $this->_countryFactory->create(['id' => $addressAttributes['country_id']])->getName();
             } elseif ($attributeCode == 'region' && isset($addressAttributes['region'])) {
                 $data['region'] = __($addressAttributes['region']['region']);
             } elseif (isset($addressAttributes[$attributeCode])) {
                 $value = $addressAttributes[$attributeCode];
-                $dataModel = $this->_attributeMetadataFactory->create($attributeMetadata, $value, 'customer_address');
-                $value     = $dataModel->outputValue($dataFormat);
+                $dataModel = $this->_elementFactory->create($attributeMetadata, $value, 'customer_address');
+                $value = $dataModel->outputValue($dataFormat);
                 if ($attributeMetadata->getFrontendInput() == 'multiline') {
-                    $values    = $dataModel->outputValue(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY);
+                    $values = $dataModel->outputValue(AttributeDataFactory::OUTPUT_FORMAT_ARRAY);
                     // explode lines
                     foreach ($values as $k => $v) {
                         $key = sprintf('%s%d', $attributeCode, $k + 1);
diff --git a/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php b/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php
index 532b0ab8ccd31fd48a6942332c5bccccc9c05eaa..e659aa9a8c5e38ecdf9123e110c476c254c36053 100644
--- a/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php
+++ b/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php
@@ -41,23 +41,24 @@ interface RendererInterface
      *
      * @param \Magento\Object $type
      */
-    function setType(\Magento\Object $type);
+    public function setType(\Magento\Object $type);
 
     /**
      * Retrieve format type object
      *
      * @return \Magento\Object
      */
-    function getType();
+    public function getType();
 
     /**
      * Render address
      *
      * @deprecated All new code should use renderArray based on Metadata service
      * @param \Magento\Customer\Model\Address\AbstractAddress $address
+     * @param string|null $format
      * @return mixed
      */
-    function render(\Magento\Customer\Model\Address\AbstractAddress $address);
+    public function render(\Magento\Customer\Model\Address\AbstractAddress $address, $format = null);
 
     /**
      * Get a format object for a given address attributes, based on the type set earlier.
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php
index b2d4c10f19efcfd37a498df3fd6fa990e91067b4..83198e812a2c9a4af55fd987131da4711cc663b8 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php
@@ -34,7 +34,7 @@ class View
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
     /**
-     * @var \Magento\Log\Model\Customer
+     * @var \Magento\Customer\Model\Customer
      */
     protected $_customer;
 
@@ -56,9 +56,9 @@ class View
     protected $_modelVisitor;
 
     /**
-     * @var \Magento\Customer\Model\GroupFactory
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
      */
-    protected $_groupFactory;
+    protected $_groupService;
 
     /**
      * @var \Magento\Log\Model\CustomerFactory
@@ -69,10 +69,10 @@ class View
      * @var \Magento\Stdlib\DateTime
      */
     protected $dateTime;
-
+    
     /**
      * @param \Magento\Backend\Block\Template\Context $context
-     * @param \Magento\Customer\Model\GroupFactory $groupFactory
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
      * @param \Magento\Log\Model\CustomerFactory $logFactory
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Log\Model\Visitor $modelVisitor
@@ -81,7 +81,7 @@ class View
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
-        \Magento\Customer\Model\GroupFactory $groupFactory,
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
         \Magento\Log\Model\CustomerFactory $logFactory,
         \Magento\Core\Model\Registry $registry,
         \Magento\Log\Model\Visitor $modelVisitor,
@@ -90,14 +90,14 @@ class View
     ) {
         $this->_coreRegistry = $registry;
         $this->_modelVisitor = $modelVisitor;
-        $this->_groupFactory = $groupFactory;
+        $this->_groupService = $groupService;
         $this->_logFactory = $logFactory;
         $this->dateTime = $dateTime;
         parent::__construct($context, $data);
     }
 
     /**
-     * @return \Magento\Log\Model\Customer
+     * @return \Magento\Customer\Model\Customer
      */
     public function getCustomer()
     {
@@ -108,16 +108,33 @@ class View
     }
 
     /**
-     * @return int
+     * @param int $groupId
+     * @return \Magento\Customer\Service\V1\Dto\CustomerGroup|null
+     */
+    private function getGroup($groupId)
+    {
+        try {
+            $group = $this->_groupService->getGroup($groupId);
+        } catch (\Magento\Exception\NoSuchEntityException $e) {
+            $group = null;
+        }
+        return $group;
+    }
+
+    /**
+     * @return string|null
      */
     public function getGroupName()
     {
-        $groupId = $this->getCustomer()->getGroupId();
-        if ($groupId) {
-            return $this->_groupFactory->create()
-                ->load($groupId)
-                ->getCustomerGroupCode();
+        $customer = $this->getCustomer();
+
+        if ($groupId = ($customer->getId() ? $customer->getGroupId() : null)) {
+            if ($group = $this->getGroup($groupId)) {
+                return $group->getCode();
+            }
         }
+
+        return null;
     }
 
     /**
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Grid.php b/app/code/Magento/Customer/Block/Adminhtml/Grid.php
index add8e677851188a3574d847a007b8a220d53b223..1816d81a3459720a0d5a9ecbfa059d2a94c3bc00 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Grid.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Grid.php
@@ -46,9 +46,14 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     protected $_customersFactory;
 
     /**
-     * @var \Magento\Customer\Model\Resource\Group\CollectionFactory
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
      */
-    protected $_groupsFactory;
+    protected $_groupService;
+    
+    /**
+     * @var \Magento\Convert\Object
+     */
+    protected $_converter;
 
     /**
      * @var \Magento\Customer\Helper\Data
@@ -60,8 +65,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
      * @param \Magento\Backend\Helper\Data $backendHelper
      * @param \Magento\Core\Model\System\Store $systemStore
      * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customersFactory
-     * @param \Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory
-     * @param \Magento\Customer\Helper\Data $customerHelper
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+     * @param \Magento\Convert\Object $converter
      * @param array $data
      */
     public function __construct(
@@ -69,14 +74,14 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         \Magento\Backend\Helper\Data $backendHelper,
         \Magento\Core\Model\System\Store $systemStore,
         \Magento\Customer\Model\Resource\Customer\CollectionFactory $customersFactory,
-        \Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory,
-        \Magento\Customer\Helper\Data $customerHelper,
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+        \Magento\Convert\Object $converter,
         array $data = array()
     ) {
-        $this->_customerHelper = $customerHelper;
         $this->_systemStore = $systemStore;
         $this->_customersFactory = $customersFactory;
-        $this->_groupsFactory = $groupsFactory;
+        $this->_groupService = $groupService;
+        $this->_converter = $converter;
         parent::__construct($context, $backendHelper, $data);
     }
 
@@ -133,10 +138,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
             'index'     => 'email'
         ));
 
-        $groups = $this->_groupsFactory->create()
-            ->addFieldToFilter('customer_group_id', array('gt'=> 0))
-            ->load()
-            ->toOptionHash();
+        $groups = $this->_groupService->getGroups(FALSE);
+        $groups = $this->_converter->toOptionHash($groups, 'id', 'code');
 
         $this->addColumn('group', array(
             'header'    =>  __('Group'),
@@ -235,7 +238,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
              'url'      => $this->getUrl('customer/*/massUnsubscribe')
         ));
 
-        $groups = $this->_customerHelper->getGroups()->toOptionArray();
+        $groups = $this->_converter->toOptionArray($this->_groupService->getGroups(), 'id', 'code');
 
         array_unshift($groups, array('label'=> '', 'value'=> ''));
         $this->getMassactionBlock()->addItem('assign_group', array(
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php
index aefb89dde22fb23ac35c19b94378baea166956fa..275b93ad43a7ea5b458029bcae0487de74059d4c 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php
@@ -38,17 +38,25 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
      */
     protected $_coreRegistry = null;
 
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
+     */
+    protected $_groupService = null;
+
     /**
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
         array $data = array()
     ) {
         $this->_coreRegistry = $registry;
+        $this->_groupService = $groupService;
         parent::__construct($context, $data);
     }
 
@@ -63,8 +71,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         $this->_updateButton('save', 'label', __('Save Customer Group'));
         $this->_updateButton('delete', 'label', __('Delete Customer Group'));
 
+        /** @var \Magento\Customer\Service\V1\Dto\CustomerGroup $group */
         $group = $this->_coreRegistry->registry('current_group');
-        if (!$group || !$group->getId() || $group->usesAsDefault()) {
+        if (!$group || !$group->getId() || !$this->_groupService->canDelete($group->getId())) {
             $this->_removeButton('delete');
         }
     }
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php
index 92e6edae0c1003e27f537c79420b9bc7303f3069..b61f3869d9ac2717a46842b812eceaab590aad0d 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php
@@ -68,25 +68,26 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
         /** @var \Magento\Data\Form $form */
         $form = $this->_formFactory->create();
 
+        /** @var \Magento\Customer\Service\V1\Dto\CustomerGroup $customerGroup */
         $customerGroup = $this->_coreRegistry->registry('current_group');
 
         $fieldset = $form->addFieldset('base_fieldset', array('legend'=>__('Group Information')));
 
         $validateClass = sprintf('required-entry validate-length maximum-length-%d',
-            \Magento\Customer\Model\Group::GROUP_CODE_MAX_LENGTH);
+            \Magento\Customer\Service\V1\CustomerGroupServiceInterface::GROUP_CODE_MAX_LENGTH);
         $name = $fieldset->addField('customer_group_code', 'text',
             array(
                 'name'  => 'code',
                 'label' => __('Group Name'),
                 'title' => __('Group Name'),
                 'note'  => __('Maximum length must be less then %1 symbols',
-                    \Magento\Customer\Model\Group::GROUP_CODE_MAX_LENGTH),
+                    \Magento\Customer\Service\V1\CustomerGroupServiceInterface::GROUP_CODE_MAX_LENGTH),
                 'class' => $validateClass,
                 'required' => true,
             )
         );
 
-        if ($customerGroup->getId()==0 && $customerGroup->getCustomerGroupCode() ) {
+        if ($customerGroup->getId()==0 && $customerGroup->getCode() ) {
             $name->setDisabled(true);
         }
 
@@ -115,7 +116,12 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
             $form->addValues($this->_backendSession->getCustomerGroupData());
             $this->_backendSession->setCustomerGroupData(null);
         } else {
-            $form->addValues($customerGroup->getData());
+            // TODO: need to figure out how the DTOs can work with forms
+            $form->addValues([
+                'id'                  => $customerGroup->getId(),
+                'customer_group_code' => $customerGroup->getCode(),
+                'tax_class_id'        => $customerGroup->getTaxClassId(),
+            ]);
         }
 
         $form->setUseContainer(true);
diff --git a/app/code/Magento/Customer/Block/Form/Register.php b/app/code/Magento/Customer/Block/Form/Register.php
index 48bdbaf3447bd54142ecb4b4a0fbed204a367bfb..b84f43bca0243b6a388dccc3eb622a1d73a98b74 100644
--- a/app/code/Magento/Customer/Block/Form/Register.php
+++ b/app/code/Magento/Customer/Block/Form/Register.php
@@ -31,13 +31,6 @@ namespace Magento\Customer\Block\Form;
 
 class Register extends \Magento\Directory\Block\Data
 {
-    /**
-     * Address instance with data
-     *
-     * @var \Magento\Customer\Model\Address
-     */
-    protected $_address;
-
     /**
      * @var \Magento\Customer\Model\Session
      */
@@ -62,7 +55,6 @@ class Register extends \Magento\Directory\Block\Data
      * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory
      * @param \Magento\Module\Manager $moduleManager
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Customer\Model\AddressFactory $addressFactory
      * @param \Magento\Customer\Helper\Data $customerHelper
      * @param array $data
      * 
@@ -77,14 +69,12 @@ class Register extends \Magento\Directory\Block\Data
         \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory,
         \Magento\Module\Manager $moduleManager,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Customer\Model\AddressFactory $addressFactory,
         \Magento\Customer\Helper\Data $customerHelper,
         array $data = array()
     ) {
         $this->_customerHelper = $customerHelper;
         $this->_moduleManager = $moduleManager;
         $this->_customerSession = $customerSession;
-        $this->_addressFactory = $addressFactory;
         parent::__construct(
             $context,
             $coreData,
@@ -178,13 +168,13 @@ class Register extends \Magento\Directory\Block\Data
     /**
      * Retrieve customer region identifier
      *
-     * @return int
+     * @return mixed
      */
     public function getRegion()
     {
-        if (false !== ($region = $this->getFormData()->getRegion())) {
+        if (null !== ($region = $this->getFormData()->getRegion())) {
             return $region;
-        } else if (false !== ($region = $this->getFormData()->getRegionId())) {
+        } else if (null !== ($region = $this->getFormData()->getRegionId())) {
             return $region;
         }
         return null;
@@ -200,29 +190,15 @@ class Register extends \Magento\Directory\Block\Data
         return $this->_moduleManager->isOutputEnabled('Magento_Newsletter');
     }
 
-    /**
-     * Return customer address instance
-     *
-     * @return \Magento\Customer\Model\Address
-     */
-    public function getAddress()
-    {
-        if (is_null($this->_address)) {
-            $this->_address = $this->_createAddress();
-        }
-
-        return $this->_address;
-    }
-
     /**
      * Restore entity data from session
      * Entity and form code must be defined for the form
      *
-     * @param \Magento\Customer\Model\Form $form
+     * @param \Magento\Customer\Model\Metadata\Form $form
      * @param null $scope
      * @return \Magento\Customer\Block\Form\Register
      */
-    public function restoreSessionData(\Magento\Customer\Model\Form $form, $scope = null)
+    public function restoreSessionData(\Magento\Customer\Model\Metadata\Form $form, $scope = null)
     {
         if ($this->getFormData()->getCustomerData()) {
             $request = $form->prepareRequest($this->getFormData()->getData());
@@ -232,12 +208,4 @@ class Register extends \Magento\Directory\Block\Data
 
         return $this;
     }
-
-    /**
-     * @return \Magento\Customer\Model\Address
-     */
-    protected function _createAddress()
-    {
-        return $this->_addressFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Block/Widget/AbstractWidget.php b/app/code/Magento/Customer/Block/Widget/AbstractWidget.php
index 7999b1613a08e6f0cfe0aeabb7d65e4a62c6ab67..a4174d634e2a2bd825dbff16f3a8c4b91533db28 100644
--- a/app/code/Magento/Customer/Block/Widget/AbstractWidget.php
+++ b/app/code/Magento/Customer/Block/Widget/AbstractWidget.php
@@ -29,9 +29,9 @@ namespace Magento\Customer\Block\Widget;
 class AbstractWidget extends \Magento\View\Element\Template
 {
     /**
-     * @var \Magento\Eav\Model\Config
+     * @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
      */
-    protected $_eavConfig;
+    protected $_attributeMetadata;
 
     /**
      * @var \Magento\Customer\Helper\Address
@@ -40,18 +40,18 @@ class AbstractWidget extends \Magento\View\Element\Template
 
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Eav\Model\Config $eavConfig
      * @param \Magento\Customer\Helper\Address $addressHelper
+     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
-        \Magento\Eav\Model\Config $eavConfig,
         \Magento\Customer\Helper\Address $addressHelper,
+        \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata,
         array $data = array()
     ) {
         $this->_addressHelper = $addressHelper;
-        $this->_eavConfig = $eavConfig;
+        $this->_attributeMetadata = $attributeMetadata;
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
     }
@@ -91,10 +91,10 @@ class AbstractWidget extends \Magento\View\Element\Template
      * Retrieve customer attribute instance
      *
      * @param string $attributeCode
-     * @return \Magento\Customer\Model\Attribute|false
+     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata
      */
     protected function _getAttribute($attributeCode)
     {
-        return $this->_eavConfig->getAttribute('customer', $attributeCode);
+        return $this->_attributeMetadata->getAttributeMetadata('customer', $attributeCode);
     }
 }
diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php
index aeeca73bbcb6573a2a13d5908bf0dee260f3e914..e6a47a60973b0db8b2dcd48180d34987df5f6f2a 100644
--- a/app/code/Magento/Customer/Block/Widget/Dob.php
+++ b/app/code/Magento/Customer/Block/Widget/Dob.php
@@ -41,22 +41,6 @@ class Dob extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     protected $_dateInputs = array();
 
-    /**
-     * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Eav\Model\Config $eavConfig
-     * @param \Magento\Customer\Helper\Address $addressHelper
-     * @param array $data
-     */
-    public function __construct(
-        \Magento\View\Element\Template\Context $context,
-        \Magento\Eav\Model\Config $eavConfig,
-        \Magento\Customer\Helper\Address $addressHelper,
-        array $data = array()
-    ) {
-        parent::__construct($context, $eavConfig, $addressHelper, $data);
-        $this->_isScopePrivate = true;
-    }
-
     public function _construct()
     {
         parent::_construct();
@@ -65,12 +49,12 @@ class Dob extends \Magento\Customer\Block\Widget\AbstractWidget
 
     public function isEnabled()
     {
-        return (bool)$this->_getAttribute('dob')->getIsVisible();
+        return (bool)$this->_getAttribute('dob')->isVisible();
     }
 
     public function isRequired()
     {
-        return (bool)$this->_getAttribute('dob')->getIsRequired();
+        return (bool)$this->_getAttribute('dob')->isRequired();
     }
 
     public function setDate($date)
@@ -148,7 +132,7 @@ class Dob extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function getMinDateRange()
     {
-        $rules = $this->_getAttribute('dob')->getValidateRules();
+        $rules = $this->_getAttribute('dob')->getValidationRules();
         return isset($rules[self::MIN_DATE_RANGE_KEY]) ? date("Y/m/d", $rules[self::MIN_DATE_RANGE_KEY]) : null;
     }
 
@@ -159,7 +143,7 @@ class Dob extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function getMaxDateRange()
     {
-        $rules = $this->_getAttribute('dob')->getValidateRules();
+        $rules = $this->_getAttribute('dob')->getValidationRules();
         return isset($rules[self::MAX_DATE_RANGE_KEY]) ? date("Y/m/d", $rules[self::MAX_DATE_RANGE_KEY]) : null;
     }
 }
diff --git a/app/code/Magento/Customer/Block/Widget/Gender.php b/app/code/Magento/Customer/Block/Widget/Gender.php
index 0ba5a1a62c4dc893905788f8233c193974df2bc5..7344c5525042b9d0bb778ff51d9d9f32234a3d19 100644
--- a/app/code/Magento/Customer/Block/Widget/Gender.php
+++ b/app/code/Magento/Customer/Block/Widget/Gender.php
@@ -47,23 +47,23 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget
 
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Eav\Model\Config $eavConfig
      * @param \Magento\Customer\Helper\Address $addressHelper
+     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata
      * @param \Magento\Customer\Model\Session $customerSession
      * @param \Magento\Customer\Model\Resource\Customer $customerResource
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
-        \Magento\Eav\Model\Config $eavConfig,
         \Magento\Customer\Helper\Address $addressHelper,
+        \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata,
         \Magento\Customer\Model\Session $customerSession,
         \Magento\Customer\Model\Resource\Customer $customerResource,
         array $data = array()
     ) {
         $this->_customerSession = $customerSession;
         $this->_customerResource = $customerResource;
-        parent::__construct($context, $eavConfig, $addressHelper, $data);
+        parent::__construct($context, $addressHelper,  $attributeMetadata, $data);
         $this->_isScopePrivate = true;
     }
 
@@ -83,7 +83,7 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function isEnabled()
     {
-        return (bool)$this->_getAttribute('gender')->getIsVisible();
+        return (bool)$this->_getAttribute('gender')->isVisible();
     }
 
     /**
@@ -93,7 +93,7 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function isRequired()
     {
-        return (bool)$this->_getAttribute('gender')->getIsRequired();
+        return (bool)$this->_getAttribute('gender')->isRequired();
     }
 
     /**
diff --git a/app/code/Magento/Customer/Block/Widget/Name.php b/app/code/Magento/Customer/Block/Widget/Name.php
index e2c3a00476580ec70ecef50c11e8fc8ca1b0c66f..2118dc9d47f9436dda9440a19dc436d2329a7d2c 100644
--- a/app/code/Magento/Customer/Block/Widget/Name.php
+++ b/app/code/Magento/Customer/Block/Widget/Name.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Customer\Block\Widget;
 
+use Magento\Customer\Service\V1\Dto\Customer;
+
 class Name extends \Magento\Customer\Block\Widget\AbstractWidget
 {
     /**
@@ -35,20 +37,20 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
 
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Eav\Model\Config $eavConfig
      * @param \Magento\Customer\Helper\Address $addressHelper
+     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata,
      * @param \Magento\Customer\Helper\Data $customerHelper
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
-        \Magento\Eav\Model\Config $eavConfig,
         \Magento\Customer\Helper\Address $addressHelper,
+        \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata,
         \Magento\Customer\Helper\Data $customerHelper,
         array $data = array()
     ) {
         $this->_customerHelper = $customerHelper;
-        parent::__construct($context, $eavConfig, $addressHelper, $data);
+        parent::__construct($context, $addressHelper, $attributeMetadata, $data);
         $this->_isScopePrivate = true;
     }
 
@@ -78,7 +80,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function showPrefix()
     {
-        return (bool)$this->_getAttribute('prefix')->getIsVisible();
+        return (bool)$this->_getAttribute('prefix')->isVisible();
     }
 
     /**
@@ -88,7 +90,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function isPrefixRequired()
     {
-        return (bool)$this->_getAttribute('prefix')->getIsRequired();
+        return (bool)$this->_getAttribute('prefix')->isRequired();
     }
 
     /**
@@ -114,7 +116,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function showMiddlename()
     {
-        return (bool)$this->_getAttribute('middlename')->getIsVisible();
+        return (bool)$this->_getAttribute('middlename')->isVisible();
     }
 
     /**
@@ -124,7 +126,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function isMiddlenameRequired()
     {
-        return (bool)$this->_getAttribute('middlename')->getIsRequired();
+        return (bool)$this->_getAttribute('middlename')->isRequired();
     }
 
     /**
@@ -134,7 +136,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function showSuffix()
     {
-        return (bool)$this->_getAttribute('suffix')->getIsVisible();
+        return (bool)$this->_getAttribute('suffix')->isVisible();
     }
 
     /**
@@ -144,7 +146,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      */
     public function isSuffixRequired()
     {
-        return (bool)$this->_getAttribute('suffix')->getIsRequired();
+        return (bool)$this->_getAttribute('suffix')->isRequired();
     }
 
     /**
@@ -193,19 +195,21 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget
      * Retrieve customer or customer address attribute instance
      *
      * @param string $attributeCode
-     * @return \Magento\Customer\Model\Attribute|false
+     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata
      */
     protected function _getAttribute($attributeCode)
     {
-        if ($this->getForceUseCustomerAttributes() || $this->getObject() instanceof \Magento\Customer\Model\Customer) {
+        if ($this->getForceUseCustomerAttributes()
+            || $this->getObject() instanceof \Magento\Customer\Model\Customer
+            || $this->getObject() instanceof Customer) {
             return parent::_getAttribute($attributeCode);
         }
 
-        $attribute = $this->_eavConfig->getAttribute('customer_address', $attributeCode);
+        $attribute = $this->_attributeMetadata->getAttributeMetadata('customer_address', $attributeCode);
 
-        if ($this->getForceUseCustomerRequiredAttributes() && $attribute && !$attribute->getIsRequired()) {
+        if ($this->getForceUseCustomerRequiredAttributes() && $attribute && !$attribute->isRequired()) {
             $customerAttribute = parent::_getAttribute($attributeCode);
-            if ($customerAttribute && $customerAttribute->getIsRequired()) {
+            if ($customerAttribute && $customerAttribute->isRequired()) {
                 $attribute = $customerAttribute;
             }
         }
diff --git a/app/code/Magento/Customer/Block/Widget/Taxvat.php b/app/code/Magento/Customer/Block/Widget/Taxvat.php
index d02353b86bf59790171e70ecf32d1b4248ec2d38..23092ae05bd43027653ee4c54f99520016eb5556 100644
--- a/app/code/Magento/Customer/Block/Widget/Taxvat.php
+++ b/app/code/Magento/Customer/Block/Widget/Taxvat.php
@@ -35,20 +35,20 @@ class Taxvat extends \Magento\Customer\Block\Widget\AbstractWidget
 
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Eav\Model\Config $eavConfig
      * @param \Magento\Customer\Helper\Address $addressHelper
+     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata
      * @param \Magento\Customer\Model\Session $customerSession
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
-        \Magento\Eav\Model\Config $eavConfig,
         \Magento\Customer\Helper\Address $addressHelper,
+        \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata,
         \Magento\Customer\Model\Session $customerSession,
         array $data = array()
     ) {
         $this->_customerSession = $customerSession;
-        parent::__construct($context, $eavConfig, $addressHelper, $data);
+        parent::__construct($context, $addressHelper, $attributeMetadata, $data);
         $this->_isScopePrivate = true;
     }
 
@@ -60,12 +60,12 @@ class Taxvat extends \Magento\Customer\Block\Widget\AbstractWidget
 
     public function isEnabled()
     {
-        return (bool)$this->_getAttribute('taxvat')->getIsVisible();
+        return (bool)$this->_getAttribute('taxvat')->isVisible();
     }
 
     public function isRequired()
     {
-        return (bool)$this->_getAttribute('taxvat')->getIsRequired();
+        return (bool)$this->_getAttribute('taxvat')->isRequired();
     }
 
     public function getCustomer()
diff --git a/app/code/Magento/Customer/Controller/Account.php b/app/code/Magento/Customer/Controller/Account.php
index b8c2ca4a35ac5ebb9550b6cc2eca431f86d3e697..e8c2f15923b1763cfbfa08641e1d95bf3d00441b 100644
--- a/app/code/Magento/Customer/Controller/Account.php
+++ b/app/code/Magento/Customer/Controller/Account.php
@@ -25,7 +25,15 @@
  */
 
 namespace Magento\Customer\Controller;
+
 use Magento\App\RequestInterface;
+use Magento\Customer\Service\V1\CustomerAccountServiceInterface;
+use Magento\Customer\Service\V1\CustomerGroupServiceInterface;
+use Magento\Customer\Service\V1\Dto\Customer;
+use Magento\Exception\AuthenticationException;
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+use Magento\Exception\StateException;
 
 /**
  * Customer account controller
@@ -62,7 +70,7 @@ class Account extends \Magento\App\Action\Action
     /**
      * @var \Magento\Customer\Model\Session
      */
-    protected $_customerSession;
+    protected $_session;
 
     /**
      * @var \Magento\UrlFactory
@@ -79,11 +87,6 @@ class Account extends \Magento\App\Action\Action
      */
     protected $_formFactory;
 
-    /**
-     * @var \Magento\Customer\Model\AddressFactory
-     */
-    protected $_addressFactory;
-
     /**
      * Magento string lib
      *
@@ -91,6 +94,12 @@ class Account extends \Magento\App\Action\Action
      */
     protected $string;
 
+    /** @var CustomerAccountServiceInterface  */
+    protected $_customerAccountService;
+
+    /** @var CustomerGroupV1Interface */
+    protected $_groupService;
+
     /**
      * @var \Magento\Core\App\Action\FormKeyValidator
      */
@@ -101,6 +110,26 @@ class Account extends \Magento\App\Action\Action
      */
     protected $escaper;
 
+    /**
+     * @var \Magento\Newsletter\Model\SubscriberFactory
+     */
+    protected $_subscriberFactory;
+
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\RegionBuilder
+     */
+    protected $_regionBuilder;
+
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\AddressBuilder
+     */
+    protected $_addressBuilder;
+
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder
+     */
+    protected $_customerBuilder;
+
     /**
      * @param \Magento\App\Action\Context $context
      * @param \Magento\Core\Model\Registry $coreRegistry
@@ -108,11 +137,16 @@ class Account extends \Magento\App\Action\Action
      * @param \Magento\UrlFactory $urlFactory
      * @param \Magento\Customer\Model\CustomerFactory $customerFactory
      * @param \Magento\Customer\Model\FormFactory $formFactory
-     * @param \Magento\Customer\Model\AddressFactory $addressFactory
      * @param \Magento\Stdlib\String $string
      * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator
+     * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Escaper $escaper
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService
+     * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService
+     * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
+     * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
+     * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder
      */
     public function __construct(
         \Magento\App\Action\Context $context,
@@ -121,22 +155,32 @@ class Account extends \Magento\App\Action\Action
         \Magento\UrlFactory $urlFactory,
         \Magento\Customer\Model\CustomerFactory $customerFactory,
         \Magento\Customer\Model\FormFactory $formFactory,
-        \Magento\Customer\Model\AddressFactory $addressFactory,
         \Magento\Stdlib\String $string,
         \Magento\Core\App\Action\FormKeyValidator $formKeyValidator,
+        \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Escaper $escaper
+        \Magento\Escaper $escaper,
+        CustomerGroupServiceInterface $customerGroupService,
+        CustomerAccountServiceInterface $customerAccountService,
+        \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder,
+        \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder,
+        \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder
     ) {
         $this->_storeManager = $storeManager;
         $this->_coreRegistry = $coreRegistry;
-        $this->_customerSession = $customerSession;
+        $this->_session = $customerSession;
         $this->_urlFactory = $urlFactory;
         $this->_customerFactory = $customerFactory;
         $this->_formFactory = $formFactory;
-        $this->_addressFactory = $addressFactory;
         $this->string = $string;
         $this->_formKeyValidator = $formKeyValidator;
+        $this->_customerAccountService = $customerAccountService;
+        $this->_groupService = $customerGroupService;
+        $this->_subscriberFactory = $subscriberFactory;
         $this->escaper = $escaper;
+        $this->_regionBuilder = $regionBuilder;
+        $this->_addressBuilder = $addressBuilder;
+        $this->_customerBuilder = $customerBuilder;
         parent::__construct($context);
     }
 
@@ -147,7 +191,7 @@ class Account extends \Magento\App\Action\Action
      */
     protected function _getSession()
     {
-        return $this->_customerSession;
+        return $this->_session;
     }
 
     /**
@@ -231,29 +275,31 @@ class Account extends \Magento\App\Action\Action
             $login = $this->getRequest()->getPost('login');
             if (!empty($login['username']) && !empty($login['password'])) {
                 try {
-                    $this->_getSession()->login($login['username'], $login['password']);
-                    if ($this->_getSession()->getCustomer()->getIsJustConfirmed()) {
-                        $this->_welcomeCustomer($this->_getSession()->getCustomer(), true);
-                    }
-                } catch (\Magento\Core\Exception $e) {
+                    $customer = $this->_customerAccountService->authenticate($login['username'], $login['password']);
+                    $this->_getSession()->setCustomerDtoAsLoggedIn($customer);
+                    $this->_getSession()->regenerateId();
+                } catch (AuthenticationException $e) {
                     switch ($e->getCode()) {
-                        case \Magento\Customer\Model\Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
+                        case AuthenticationException::EMAIL_NOT_CONFIRMED:
                             $value = $this->_objectManager->get('Magento\Customer\Helper\Data')
                                 ->getEmailConfirmationUrl($login['username']);
-                            $message = __('This account is not confirmed.'
-                                    . ' <a href="%1">Click here</a> to resend confirmation email.', $value);
-                            break;
-                        case \Magento\Customer\Model\Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
-                            $message = $e->getMessage();
+                            $message = __(
+                                'This account is not confirmed.'
+                                . ' <a href="%1">Click here</a> to resend confirmation email.',
+                                $value
+                            );
                             break;
+                        case AuthenticationException::INVALID_EMAIL_OR_PASSWORD:
                         default:
-                            $message = $e->getMessage();
+                            $message = __('Invalid login or password.');
                             break;
                     }
                     $this->messageManager->addError($message);
                     $this->_getSession()->setUsername($login['username']);
                 } catch (\Exception $e) {
-                    // $this->_objectManager->get('Magento\Logger')->logException($e); // PA DSS violation: this exception log can disclose customer password
+                    // PA DSS violation: this exception log can disclose customer password
+                    // $this->_objectManager->get('Magento\Logger')->logException($e);
+                    $this->messageManager->addError(__('There was an error validating the login and password.'));
                 }
             } else {
                 $this->messageManager->addError(__('Login and password are required.'));
@@ -364,24 +410,27 @@ class Account extends \Magento\App\Action\Action
 
         try {
             $customer = $this->_extractCustomer();
-            $address = $this->_extractAddress($customer);
-            $this->_validateCustomer($customer, $address);
+            $address = $this->_extractAddress();
+            $result = $this->_customerAccountService->createAccount(
+                $customer,
+                is_null($address) ? array() : array($address),
+                $this->getRequest()->getParam('password'),
+                $this->_getSession()->getBeforeAuthUrl(),
+                ''
+            );
+            $this->_customerBuilder->populate($customer);
+            $this->_customerBuilder->setCustomerId($result->getCustomerId());
+            $customer = $this->_customerBuilder->create();
+
+            if ($this->getRequest()->getParam('is_subscribed', false)) {
+                $this->_subscriberFactory->create()->updateSubscription($result->getCustomerId(), true);
+            }
 
-            $customer->save()->setOrigData();
             $this->_eventManager->dispatch('customer_register_success',
                 array('account_controller' => $this, 'customer' => $customer)
             );
 
-            $newLinkToken = $this->_objectManager->get('Magento\Customer\Helper\Data')
-                ->generateResetPasswordLinkToken();
-            $customer->changeResetPasswordLinkToken($newLinkToken);
-
-            if ($customer->isConfirmationRequired()) {
-                $customer->sendNewAccountEmail(
-                    'confirmation',
-                    $this->_getSession()->getBeforeAuthUrl(),
-                    $this->_storeManager->getStore()->getId()
-                );
+            if ($result->getStatus() == CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION) {
                 $email = $this->_objectManager->get('Magento\Customer\Helper\Data')->getEmailConfirmationUrl($customer->getEmail());
                 $this->messageManager->addSuccess(
                     __('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%1">click here</a>.', $email)
@@ -389,24 +438,19 @@ class Account extends \Magento\App\Action\Action
                 $url = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true));
                 $this->getResponse()->setRedirect($this->_redirect->success($url));
             } else {
-                $this->_getSession()->setCustomerAsLoggedIn($customer);
+                $this->_getSession()->setCustomerDtoAsLoggedIn($customer);
                 $url = $this->_welcomeCustomer($customer);
                 $this->getResponse()->setRedirect($this->_redirect->success($url));
             }
             return;
-        } catch (\Magento\Core\Exception $e) {
-            if ($e->getCode() === \Magento\Customer\Model\Customer::EXCEPTION_EMAIL_EXISTS) {
-                $url = $this->_createUrl()->getUrl('customer/account/forgotpassword');
-                $message = __('There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.', $url);
-            } else {
-                $message = $e->getMessage();
-            }
+        } catch (StateException $e) {
+            $url = $this->_createUrl()->getUrl('customer/account/forgotpassword');
+            $message = __('There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.', $url);
             $this->messageManager->addError($message);
-        } catch (\Magento\Validator\ValidatorException $e) {
-            foreach ($e->getMessages() as $messages) {
-                foreach ($messages as $message) {
-                    $this->messageManager->addError($this->escaper->escapeHtml($message));
-                }
+        } catch (InputException $e) {
+            foreach ($e->getErrors() as $error) {
+                $message = InputException::translateError($error);
+                $this->messageManager->addError($this->escaper->escapeHtml($message));
             }
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('Cannot save the customer.'));
@@ -417,130 +461,131 @@ class Account extends \Magento\App\Action\Action
         $this->getResponse()->setRedirect($this->_redirect->error($defaultUrl));
     }
 
-    /**
-     * Do validation of customer and its address using validate methods in models
-     *
-     * @param \Magento\Customer\Model\Customer $customer
-     * @param \Magento\Customer\Model\Address|null $address
-     * @throws \Magento\Validator\ValidatorException
-     */
-    protected function _validateCustomer($customer, $address = null)
-    {
-        $errors = array();
-        if ($address) {
-            $addressErrors = $address->validate();
-            if (is_array($addressErrors)) {
-                $errors = array_merge($errors, $addressErrors);
-            }
-        }
-        $customerErrors = $customer->validate();
-        if (is_array($customerErrors)) {
-            $errors = array_merge($errors, $customerErrors);
-        }
-        if (count($errors) > 0) {
-            throw new \Magento\Validator\ValidatorException(array($errors));
-        }
-        // Empty password confirmation data (it is needed only for validation purposes and is not meant to be stored)
-        $customer->setConfirmation(null);
-    }
-
     /**
      * Add address to customer during create account
      *
-     * @param \Magento\Customer\Model\Customer $customer
-     * @return \Magento\Customer\Model\Address|null
+     * @return \Magento\Customer\Service\V1\Dto\Address|null
      */
-    protected function _extractAddress($customer)
+    protected function _extractAddress()
     {
         if (!$this->getRequest()->getPost('create_address')) {
             return null;
         }
-        /* @var \Magento\Customer\Model\Address $address */
-        $address = $this->_createAddress();
-        /* @var \Magento\Customer\Model\Form $addressForm */
+
         $addressForm = $this->_createForm();
         $addressForm->setFormCode('customer_register_address')
-            ->setEntity($address);
-
-        $addressData = $addressForm->extractData($this->getRequest(), 'address', false);
-        $address->setId(null)
-            ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
-            ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
-        $addressForm->compactData($addressData);
-        $customer->addAddress($address);
-        return $address;
+            ->setEntityType('customer_address');
+        $allowedAttributes = $addressForm->getAllowedAttributes();
+
+        $addressData = [];
+
+        /** @var $attribute \Magento\Eav\Model\Attribute */
+        foreach ($allowedAttributes as $attribute) {
+            $attributeCode = $attribute->getAttributeCode();
+            $value = $this->getRequest()->getParam($attributeCode);
+            if (is_null($value)) {
+                continue;
+            }
+            switch ($attributeCode) {
+                case 'region_id':
+                    $this->_regionBuilder->setRegionId($value);
+                    break;
+                case 'region':
+                    $this->_regionBuilder->setRegion($value);
+                    break;
+                default:
+                    $addressData[$attributeCode] = $value;
+            }
+        }
+        $this->_addressBuilder->populateWithArray($addressData);
+        $this->_addressBuilder->setRegion($this->_regionBuilder->create());
+
+        $this->_addressBuilder->setDefaultBilling($this->getRequest()->getParam('default_billing', false))
+            ->setDefaultShipping($this->getRequest()->getParam('default_shipping', false));
+        return $this->_addressBuilder->create();
     }
 
     /**
      * Extract customer entity from request
      *
-     * @return \Magento\Customer\Model\Customer
+     * @return Customer
      */
     protected function _extractCustomer()
     {
-        /** @var \Magento\Customer\Model\Customer $customer */
-        $customer = $this->_coreRegistry->registry('current_customer');
-        if (!$customer) {
-            $customer = $this->_createCustomer()->setId(null);
-        }
-        /* @var \Magento\Customer\Model\Form $customerForm */
         $customerForm = $this->_createForm();
         $customerForm->setFormCode('customer_account_create')
-            ->setEntity($customer);
-
-        $customerData = $customerForm->extractData($this->getRequest());
-        // Initialize customer group id
-        $customer->getGroupId();
-        $customerForm->compactData($customerData);
-        $customer->setPassword($this->getRequest()->getPost('password'));
-        $customer->setConfirmation($this->getRequest()->getPost('confirmation'));
-        if ($this->getRequest()->getParam('is_subscribed', false)) {
-            $customer->setIsSubscribed(1);
+            ->setEntityType('customer');
+        $allowedAttributes = $customerForm->getAllowedAttributes();
+        $isGroupIdEmpty = true;
+        /** @var $attribute \Magento\Eav\Model\Attribute */
+        $customerData = [];
+        foreach ($allowedAttributes as $attribute) {
+            $attributeCode = $attribute->getAttributeCode();
+            if ($attributeCode == 'group_id') {
+                $isGroupIdEmpty = false;
+            }
+            $customerData[$attributeCode] = $this->getRequest()->getParam($attributeCode);
         }
-        return $customer;
+        $this->_customerBuilder->populateWithArray($customerData);
+        $storeId = $this->_storeManager->getStore()->getId();
+        if ($isGroupIdEmpty) {
+            $this->_customerBuilder->setGroupId($this->_groupService->getDefaultGroup($storeId)->getId());
+        }
+
+        $this->_customerBuilder->setConfirmation($this->getRequest()->getParam('confirmation'));
+
+        return $this->_customerBuilder->create();
     }
 
     /**
-     * Add welcome message and send new account email.
-     * Returns success URL
+     * Adds welcome message and returns success URL
      *
-     * @param \Magento\Customer\Model\Customer $customer
-     * @param bool $isJustConfirmed
      * @return string
      */
-    protected function _welcomeCustomer(\Magento\Customer\Model\Customer $customer, $isJustConfirmed = false)
+    protected function _welcomeCustomer()
+    {
+        $this->_addWelcomeMessage();
+
+        $successUrl = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true));
+        if (!$this->_objectManager->get('Magento\Core\Model\Store\Config')->getConfigFlag(
+                \Magento\Customer\Helper\Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD
+            )
+            && $this->_getSession()->getBeforeAuthUrl()
+        ) {
+            $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
+        }
+        return $successUrl;
+    }
+
+    /**
+     * Adds a welcome message to the session
+     */
+    protected function _addWelcomeMessage()
     {
         $this->messageManager->addSuccess(
             __('Thank you for registering with %1.', $this->_storeManager->getStore()->getFrontendName())
         );
         if ($this->_isVatValidationEnabled()) {
             // Show corresponding VAT message to customer
-            $configAddressType = $this->_objectManager->get('Magento\Customer\Helper\Address')->getTaxCalculationAddressType();
+            $configAddressType = $this->_objectManager->get('Magento\Customer\Helper\Address')
+                ->getTaxCalculationAddressType();
             $editAddersUrl = $this->_createUrl()->getUrl('customer/address/edit');
             switch ($configAddressType) {
                 case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING:
-                    $userPrompt = __('If you are a registered VAT customer, please click <a href="%1">here</a> to enter you shipping address for proper VAT calculation', $editAddersUrl);
+                    $userPrompt = __(
+                        'If you are a registered VAT customer, please click <a href="%1">here</a> to enter you shipping address for proper VAT calculation',
+                        $editAddersUrl
+                    );
                     break;
                 default:
-                    $userPrompt = __('If you are a registered VAT customer, please click <a href="%1">here</a> to enter you billing address for proper VAT calculation', $editAddersUrl);
+                    $userPrompt = __(
+                        'If you are a registered VAT customer, please click <a href="%1">here</a> to enter you billing address for proper VAT calculation',
+                        $editAddersUrl
+                    );
                     break;
             }
             $this->messageManager->addSuccess($userPrompt);
         }
-
-        $customer->sendNewAccountEmail(
-            $isJustConfirmed ? 'confirmed' : 'registered',
-            '',
-            $this->_storeManager->getStore()->getId()
-        );
-
-        $successUrl = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true));
-        if (!$this->_objectManager->get('Magento\Core\Model\Store\Config')->getConfigFlag(\Magento\Customer\Helper\Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD)
-            && $this->_getSession()->getBeforeAuthUrl()
-        ) {
-            $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
-        }
-        return $successUrl;
     }
 
     /**
@@ -578,32 +623,6 @@ class Account extends \Magento\App\Action\Action
         }
     }
 
-    /**
-     * @param \Magento\Customer\Model\Customer $customer
-     * @param mixed $key
-     * @return bool|null
-     * @throws \Exception
-     */
-    protected function _checkCustomerActive($customer, $key)
-    {
-        $backUrl = $this->getRequest()->getParam('back_url', false);
-
-        // check if it is inactive
-        if ($customer->getConfirmation()) {
-            if ($customer->getConfirmation() !== $key) {
-                throw new \Exception(__('Wrong confirmation key.'));
-            }
-            $this->_activateCustomer($customer);
-
-            // log in and send greeting email, then die happy
-            $this->_getSession()->setCustomerAsLoggedIn($customer);
-            $successUrl = $this->_welcomeCustomer($customer, true);
-            $url = $backUrl ? $backUrl : $successUrl;
-            $this->getResponse()->setRedirect($this->_redirect->success($url));
-            return true;
-        }
-    }
-
     /**
      * Confirm customer account by id and confirmation key
      */
@@ -616,26 +635,39 @@ class Account extends \Magento\App\Action\Action
         try {
             $customerId = $this->getRequest()->getParam('id', false);
             $key     = $this->getRequest()->getParam('key', false);
+            $backUrl = $this->getRequest()->getParam('back_url', false);
             if (empty($customerId) || empty($key)) {
                 throw new \Exception(__('Bad request.'));
             }
 
-            $customer = $this->_loadCustomerById($customerId);
-            if (true === $this->_checkCustomerActive($customer, $key)) {
-                return;
-            }
+            $customer = $this->_customerAccountService->activateAccount($customerId, $key);
 
-            // die happy
-            $url = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true));
-            $this->getResponse()->setRedirect($this->_redirect->success($url));
+            // log in and send greeting email, then die happy
+            $this->_getSession()->setCustomerDtoAsLoggedIn($customer);
+            $successUrl = $this->_welcomeCustomer();
+            $this->getResponse()->setRedirect($this->_redirect->success($backUrl ? $backUrl : $successUrl));
             return;
+        } catch (StateException $e) {
+            switch ($e->getCode()) {
+                case StateException::INVALID_STATE:
+                    return;
+                case StateException::INPUT_MISMATCH:
+                case StateException::EXPIRED:
+                    $this->messageManager->addException($e, __('This confirmation key is invalid or has expired.'));
+                    break;
+                default:
+                    $this->messageManager->addException($e, __('There was an error confirming the account.'));
+                    break;
+            }
+        } catch (NoSuchEntityException $e) {
+            $this->messageManager->addException($e, __('There was an error confirming the account.'));
         } catch (\Exception $e) {
-            // die unhappy
-            $this->messageManager->addError($e->getMessage());
-            $url = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true));
-            $this->getResponse()->setRedirect($this->_redirect->error($url));
-            return;
+            $this->messageManager->addException($e, __('There was an error confirming the account'));
         }
+        // die unhappy
+        $url = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true));
+        $this->getResponse()->setRedirect($this->_redirect->error($url));
+        return;
     }
 
     /**
@@ -670,7 +702,6 @@ class Account extends \Magento\App\Action\Action
      */
     public function confirmationAction()
     {
-        $customer = $this->_createCustomer();
         if ($this->_getSession()->isLoggedIn()) {
             $this->_redirect('*/*/');
             return;
@@ -679,7 +710,23 @@ class Account extends \Magento\App\Action\Action
         // try to confirm by email
         $email = $this->getRequest()->getPost('email');
         if ($email) {
-            $this->_confirmByEmail($customer, $email);
+            try {
+                $this->_customerAccountService->sendConfirmation($email);
+                $this->messageManager->addSuccess(__('Please, check your email for confirmation key.'));
+            } catch (StateException $e) {
+                $this->messageManager->addSuccess(__('This email does not require confirmation.'));
+            } catch (\Exception $e) {
+				$this->messageManager->addException($e, __('Wrong email.'));
+				$this->getResponse()->setRedirect(
+					$this->_createUrl()->getUrl(
+						'*/*/*',
+						array('email' => $email, '_secure' => true)
+					)
+				);
+				return;
+            }
+            $this->_getSession()->setUsername($email);
+            $this->getResponse()->setRedirect($this->_createUrl()->getUrl('*/*/index', array('_secure' => true)));
             return;
         }
 
@@ -723,22 +770,15 @@ class Account extends \Magento\App\Action\Action
                 return;
             }
 
-            /** @var $customer \Magento\Customer\Model\Customer */
-            $customer = $this->_createCustomer()
-                ->setWebsiteId($this->_storeManager->getStore()->getWebsiteId())
-                ->loadByEmail($email);
-
-            if ($customer->getId()) {
-                try {
-                    $newPasswordToken = $this->_objectManager->get('Magento\Customer\Helper\Data')
-                        ->generateResetPasswordLinkToken();
-                    $customer->changeResetPasswordLinkToken($newPasswordToken);
-                    $customer->sendPasswordResetConfirmationEmail();
-                } catch (\Exception $exception) {
-                    $this->messageManager->addError($exception->getMessage());
-                    $this->_redirect('*/*/forgotpassword');
-                    return;
-                }
+            try {
+                $this->_customerAccountService
+                    ->sendPasswordResetLink($email, $this->_storeManager->getStore()->getWebsiteId());
+            } catch (NoSuchEntityException $e) {
+                // Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
+            } catch (\Exception $exception) {
+                $this->messageManager->addException($exception, __('Unable to send password reset email.'));
+                $this->_redirect('*/*/forgotpassword');
+                return;
             }
             $email = $this->_objectManager->get('Magento\Escaper')->escapeHtml($email);
             $this->messageManager->addSuccess(
@@ -772,7 +812,7 @@ class Account extends \Magento\App\Action\Action
         $resetPasswordToken = (string)$this->getRequest()->getParam('token');
         $customerId = (int)$this->getRequest()->getParam('id');
         try {
-            $this->_validateResetPasswordLinkToken($customerId, $resetPasswordToken);
+            $this->_customerAccountService->validateResetPasswordLinkToken($customerId, $resetPasswordToken);
             $this->_view->loadLayout();
             // Pass received parameters to the reset forgotten password form
             $this->_view->getLayout()->getBlock('resetPassword')
@@ -780,9 +820,7 @@ class Account extends \Magento\App\Action\Action
                 ->setResetPasswordLinkToken($resetPasswordToken);
             $this->_view->renderLayout();
         } catch (\Exception $exception) {
-            $this->messageManager->addError(
-                __('Your password reset link has expired.')
-            );
+            $this->messageManager->addError(__('Your password reset link has expired.'));
             $this->_redirect('*/*/forgotpassword');
         }
     }
@@ -800,54 +838,32 @@ class Account extends \Magento\App\Action\Action
         $password = (string)$this->getRequest()->getPost('password');
         $passwordConfirmation = (string)$this->getRequest()->getPost('confirmation');
 
-        try {
-            $this->_validateResetPasswordLinkToken($customerId, $resetPasswordToken);
-        } catch (\Exception $exception) {
+        if ($password !== $passwordConfirmation) {
             $this->messageManager->addError(
-                __('Your password reset link has expired.')
+                __("New Password and Confirm New Password values didn't match.")
             );
-            $this->_redirect('*/*/');
             return;
         }
-
-        $errorMessages = array();
         if (iconv_strlen($password) <= 0) {
-            $errorMessages[] = __('New password field cannot be empty.');
-        }
-        /** @var $customer \Magento\Customer\Model\Customer */
-        $customer = $this->_createCustomer()->load($customerId);
-
-        $customer->setPassword($password);
-        $customer->setConfirmation($passwordConfirmation);
-        $validationErrors = $customer->validate();
-        if (is_array($validationErrors)) {
-            $errorMessages = array_merge($errorMessages, $validationErrors);
-        }
-
-        if (!empty($errorMessages)) {
-            $this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
-            foreach ($errorMessages as $errorMessage) {
-                $this->messageManager->addError($errorMessage);
-            }
+            $this->messageManager->addError(
+                __('New password field cannot be empty.')
+            );
             $this->_redirect('*/*/createpassword', array(
-                'id' => $customerId,
-                'token' => $resetPasswordToken
-            ));
+                    'id' => $customerId,
+                    'token' => $resetPasswordToken
+                ));
             return;
         }
 
         try {
-            // Empty current reset password token i.e. invalidate it
-            $customer->setRpToken(null);
-            $customer->setRpTokenCreatedAt(null);
-            $customer->setConfirmation(null);
-            $customer->save();
+            $this->_customerAccountService->resetPassword($customerId, $password, $resetPasswordToken);
             $this->messageManager->addSuccess(
                 __('Your password has been updated.')
             );
             $this->_redirect('*/*/login');
+            return;
         } catch (\Exception $exception) {
-            $this->messageManager->addException($exception, __('Cannot save a new password.'));
+            $this->messageManager->addError(__('There was an error saving the new password.'));
             $this->_redirect('*/*/createpassword', array(
                 'id' => $customerId,
                 'token' => $resetPasswordToken
@@ -856,36 +872,6 @@ class Account extends \Magento\App\Action\Action
         }
     }
 
-    /**
-     * Check if password reset token is valid
-     *
-     * @param int $customerId
-     * @param string $resetPasswordLinkToken
-     * @throws \Magento\Core\Exception
-     */
-    protected function _validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken)
-    {
-        if (!is_int($customerId)
-            || !is_string($resetPasswordLinkToken)
-            || empty($resetPasswordLinkToken)
-            || empty($customerId)
-            || $customerId < 0
-        ) {
-            throw new \Magento\Core\Exception(__('Invalid password reset token.'));
-        }
-
-        /** @var $customer \Magento\Customer\Model\Customer */
-        $customer = $this->_createCustomer()->load($customerId);
-        if (!$customer || !$customer->getId()) {
-            throw new \Magento\Core\Exception(__('Wrong customer account specified.'));
-        }
-
-        $customerToken = $customer->getRpToken();
-        if (strcmp($customerToken, $resetPasswordLinkToken) !== 0 || $customer->isResetPasswordLinkTokenExpired()) {
-            throw new \Magento\Core\Exception(__('Your password reset link has expired.'));
-        }
-    }
-
     /**
      * Forgot customer account information page
      */
@@ -984,7 +970,9 @@ class Account extends \Magento\App\Action\Action
                 $customer->setConfirmation(null);
                 $customer->save();
 
-                $customer->sendPasswordResetNotificationEmail('reset_frontend');
+                if ($this->getRequest()->getParam('change_password')) {
+                    $customer->sendPasswordResetNotificationEmail('reset_frontend');
+                }
 
                 $this->_getSession()->setCustomer($customer);
                 $this->messageManager->addSuccess(__('The account information has been saved.'));
@@ -1037,12 +1025,4 @@ class Account extends \Magento\App\Action\Action
     {
         return $this->_formFactory->create();
     }
-
-    /**
-     * @return \Magento\Customer\Model\Address
-     */
-    protected function _createAddress()
-    {
-        return $this->_addressFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Controller/Address.php b/app/code/Magento/Customer/Controller/Address.php
index 3e973df1acb1cc9e8e9cea68d07120d2c33e9167..cec5c6f414fcf0e901d7dddc9f1046d2bf8de91f 100644
--- a/app/code/Magento/Customer/Controller/Address.php
+++ b/app/code/Magento/Customer/Controller/Address.php
@@ -18,24 +18,17 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Customer address controller
- *
- * @category   Magento
- * @package    Magento_Customer
- * @author      Magento Core Team <core@magentocommerce.com>
- */
 namespace Magento\Customer\Controller;
 
-use Magento\App\Action\NotFoundException;
 use Magento\App\RequestInterface;
+use Magento\Exception\InputException;
 
+/**
+ * Customer address controller
+ */
 class Address extends \Magento\App\Action\Action
 {
     /**
@@ -44,48 +37,56 @@ class Address extends \Magento\App\Action\Action
     protected $_customerSession;
 
     /**
-     * @var \Magento\Customer\Model\AddressFactory
+     * @var \Magento\Core\App\Action\FormKeyValidator
      */
-    protected $_addressFactory;
+    protected $_formKeyValidator;
+
+
+    /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface */
+    protected $_addressService;
 
     /**
-     * @var \Magento\Customer\Model\Address\FormFactory
+     * @var \Magento\Customer\Model\Metadata\FormFactory
      */
-    protected $_addressFormFactory;
+    protected $_formFactory;
 
     /**
-     * Customer data
-     *
-     * @var \Magento\Customer\Helper\Data
+     * @var \Magento\Customer\Service\V1\Dto\RegionBuilder
      */
-    protected $_customerData;
+    protected $_regionBuilder;
 
     /**
-     * @var \Magento\Core\App\Action\FormKeyValidator
+     * @var \Magento\Customer\Service\V1\Dto\AddressBuilder
      */
-    protected $_formKeyValidator;
+    protected $_addressBuilder;
 
     /**
      * @param \Magento\App\Action\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Customer\Model\AddressFactory $addressFactory
-     * @param \Magento\Customer\Model\Address\FormFactory $addressFormFactory
-     * @param \Magento\Customer\Helper\Data $customerData
      * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator
+     * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
+     * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory
+     * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
+     * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
+     * @internal param \Magento\Customer\Helper\Data $customerData
+     * @internal param \Magento\Customer\Model\AddressFactory $addressFactory
+     * @internal param \Magento\Customer\Model\Address\FormFactory $addressFormFactory
      */
     public function __construct(
         \Magento\App\Action\Context $context,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Customer\Model\AddressFactory $addressFactory,
-        \Magento\Customer\Model\Address\FormFactory $addressFormFactory,
-        \Magento\Customer\Helper\Data $customerData,
-        \Magento\Core\App\Action\FormKeyValidator $formKeyValidator
+        \Magento\Core\App\Action\FormKeyValidator $formKeyValidator,
+        \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
+        \Magento\Customer\Model\Metadata\FormFactory $formFactory,
+        \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder,
+        \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
     ) {
         $this->_customerSession = $customerSession;
-        $this->_addressFactory = $addressFactory;
-        $this->_addressFormFactory = $addressFormFactory;
-        $this->_customerData = $customerData;
         $this->_formKeyValidator = $formKeyValidator;
+        $this->_addressService = $addressService;
+        $this->_formFactory = $formFactory;
+        $this->_regionBuilder = $regionBuilder;
+        $this->_addressBuilder = $addressBuilder;
         parent::__construct($context);
     }
 
@@ -118,7 +119,8 @@ class Address extends \Magento\App\Action\Action
      */
     public function indexAction()
     {
-        if (count($this->_getSession()->getCustomer()->getAddresses())) {
+        $addresses = $this->_addressService->getAddresses($this->_getSession()->getCustomerId());
+        if (count($addresses)) {
             $this->_view->loadLayout();
             $this->_view->getLayout()->initMessages();
 
@@ -158,11 +160,14 @@ class Address extends \Magento\App\Action\Action
 
     /**
      * Process address form save
+     *
+     * @return void
      */
     public function formPostAction()
     {
         if (!$this->_formKeyValidator->validate($this->getRequest())) {
-            return $this->_redirect('*/*/');
+            $this->_redirect('*/*/');
+            return;
         }
 
         if (!$this->getRequest()->isPost()) {
@@ -170,86 +175,62 @@ class Address extends \Magento\App\Action\Action
             $this->getResponse()->setRedirect($this->_redirect->error($this->_buildUrl('*/*/edit')));
             return;
         }
-
+        $customerId = $this->_getSession()->getCustomerId();
         try {
             $address = $this->_extractAddress();
-            $this->_validateAddress($address);
-            $address->save();
-
-            // set in VAT observer
-            if ($address->getVatValidationResult()) {
-                $validationMessage = $this->_customerData->getVatValidationUserMessage(
-                    $address,
-                    $this->_getSession()->getCustomer()->getDisableAutoGroupChange(),
-                    $address->getVatValidationResult()
-                );
-                $validationMessage->getIsError()
-                    ? $this->messageManager->addError($validationMessage->getMessage())
-                    : $this->messageManager->addSuccess($validationMessage->getMessage());
-            }
-
+            $this->_addressService->saveAddresses($customerId, [$address]);
             $this->messageManager->addSuccess(__('The address has been saved.'));
             $url = $this->_buildUrl('*/*/index', array('_secure'=>true));
             $this->getResponse()->setRedirect($this->_redirect->success($url));
             return;
-        } catch (\Magento\Core\Exception $e) {
-            $this->messageManager->addException($e, $e->getMessage());
-        } catch (\Magento\Validator\ValidatorException $e) {
-            foreach ($e->getMessages() as $messages) {
-                foreach ($messages as $message) {
-                    $this->messageManager->addError($message);
-                }
+        } catch (InputException $e) {
+            foreach ($e->getErrors() as $error) {
+                $message = InputException::translateError($error);
+                $this->messageManager->addError($message);
             }
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('Cannot save address.'));
         }
 
         $this->_getSession()->setAddressFormData($this->getRequest()->getPost());
-        $url = $this->_buildUrl('*/*/edit', array('id' => $address->getId()));
+        $url = $this->_buildUrl('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
         $this->getResponse()->setRedirect($this->_redirect->error($url));
     }
 
-    /**
-     * Do address validation using validate methods in models
-     *
-     * @param \Magento\Customer\Model\Address $address
-     * @throws \Magento\Validator\ValidatorException
-     */
-    protected function _validateAddress($address)
-    {
-        $addressErrors = $address->validate();
-        if (is_array($addressErrors) && count($addressErrors) > 0) {
-            throw new \Magento\Validator\ValidatorException(array($addressErrors));
-        }
-    }
-
     /**
      * Extract address from request
      *
-     * @return \Magento\Customer\Model\Address
+     * @return \Magento\Customer\Service\V1\Dto\Address
      */
     protected function _extractAddress()
     {
-        $customer = $this->_getSession()->getCustomer();
-        /* @var \Magento\Customer\Model\Address $address */
-        $address  = $this->_createAddress();
         $addressId = $this->getRequest()->getParam('id');
+        $existingAddressData = [];
         if ($addressId) {
-            $existsAddress = $customer->getAddressById($addressId);
-            if ($existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) {
-                $address->load($existsAddress->getId());
+            $existingAddress = $this->_addressService->getAddressById($addressId);
+            if ($existingAddress->getId()) {
+                $existingAddressData = $existingAddress->__toArray();
             }
         }
-        /* @var \Magento\Customer\Model\Form $addressForm */
-        $addressForm = $this->_createAddressForm();
-        $addressForm->setFormCode('customer_address_edit')
-            ->setEntity($address);
+
+        /** @var \Magento\Customer\Model\Metadata\Form $addressForm */
+        $addressForm = $this->_formFactory->create(
+            'customer_address',
+            'customer_address_edit',
+            $existingAddressData
+        );
         $addressData = $addressForm->extractData($this->getRequest());
-        $addressForm->compactData($addressData);
-        $address->setCustomerId($customer->getId())
-            ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
-            ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
-        return $address;
+        $attributeValues = $addressForm->compactData($addressData);
+        $region = [
+            'region_id' => $attributeValues['region_id'],
+            'region' => $attributeValues['region'],
+        ];
+        unset($attributeValues['region'], $attributeValues['region_id']);
+        $attributeValues['region'] = $region;
+        return $this->_addressBuilder->populateWithArray(array_merge($existingAddressData, $attributeValues))
+            ->setDefaultBilling($this->getRequest()->getParam('default_billing', false))
+            ->setDefaultShipping($this->getRequest()->getParam('default_shipping', false))
+            ->create();
     }
 
     public function deleteAction()
@@ -257,21 +238,16 @@ class Address extends \Magento\App\Action\Action
         $addressId = $this->getRequest()->getParam('id', false);
 
         if ($addressId) {
-            $address = $this->_createAddress();
-            $address->load($addressId);
-
-            // Validate address_id <=> customer_id
-            if ($address->getCustomerId() != $this->_getSession()->getCustomerId()) {
-                $this->messageManager->addError(__('The address does not belong to this customer.'));
-                $this->getResponse()->setRedirect($this->_buildUrl('*/*/index'));
-                return;
-            }
-
             try {
-                $address->delete();
-                $this->messageManager->addSuccess(__('The address has been deleted.'));
-            } catch (\Exception $e){
-                $this->messageManager->addException($e, __('An error occurred while deleting the address.'));
+                $address = $this->_addressService->getAddressById($addressId);
+                if ($address->getCustomerId() === $this->_getSession()->getCustomerId()) {
+                    $this->_addressService->deleteAddress($addressId);
+                    $this->messageManager->addSuccess(__('The address has been deleted.'));
+                } else {
+                    $this->messageManager->addError(__('An error occurred while deleting the address.'));
+                }
+            } catch (\Exception $other) {
+                $this->messageManager->addException($other, __('An error occurred while deleting the address.'));
             }
         }
         $this->getResponse()->setRedirect($this->_buildUrl('*/*/index'));
@@ -288,20 +264,4 @@ class Address extends \Magento\App\Action\Action
         $urlBuilder = $this->_objectManager->create('Magento\UrlInterface');
         return $urlBuilder->getUrl($route, $params);
     }
-
-    /**
-     * @return \Magento\Customer\Model\Address
-     */
-    protected function _createAddress()
-    {
-        return $this->_addressFactory->create();
-    }
-
-    /**
-     * @return \Magento\Customer\Model\Address\Form
-     */
-    protected function _createAddressForm()
-    {
-        return $this->_addressFormFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Group.php b/app/code/Magento/Customer/Controller/Adminhtml/Group.php
index edf0ab9279959682047c45ac483df1ef0497fac8..26cf4bd51ccf98f67ed11122dcadc13c5c5b40de 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Group.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Group.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Customer\Controller\Adminhtml;
 
+use Magento\Exception\NoSuchEntityException;
+
 /**
  * Customer groups controller
  */
@@ -36,16 +38,33 @@ class Group extends \Magento\Backend\App\Action
      *
      * @var \Magento\Core\Model\Registry
      */
-    protected $_coreRegistry = null;
+    protected $_coreRegistry;
+
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
+     */
+    protected $_groupService;
+    
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder
+     */
+    protected $_customerGroupBuilder;
+
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Core\Model\Registry $coreRegistry
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+     * @param \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $customerGroupBuilder
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Core\Model\Registry $coreRegistry
+        \Magento\Core\Model\Registry $coreRegistry,
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+        \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $customerGroupBuilder
     ) {
         $this->_coreRegistry = $coreRegistry;
+        $this->_groupService = $groupService;
+        $this->_customerGroupBuilder = $customerGroupBuilder;
         parent::__construct($context);
     }
 
@@ -53,12 +72,14 @@ class Group extends \Magento\Backend\App\Action
     {
         $this->_title->add(__('Customer Groups'));
 
-        $this->_coreRegistry->register('current_group', $this->_objectManager->create('Magento\Customer\Model\Group'));
+        $currentGroup = null;
         $groupId = $this->getRequest()->getParam('id');
         if (!is_null($groupId)) {
-            $this->_coreRegistry->registry('current_group')->load($groupId);
+            $currentGroup = $this->_groupService->getGroup($groupId);
+        } else {
+            $currentGroup = $this->_customerGroupBuilder->create();
         }
-
+        $this->_coreRegistry->register('current_group', $currentGroup);
     }
 
     /**
@@ -86,6 +107,7 @@ class Group extends \Magento\Backend\App\Action
         $this->_addBreadcrumb(__('Customers'), __('Customers'));
         $this->_addBreadcrumb(__('Customer Groups'), __('Customer Groups'), $this->getUrl('customer/group'));
 
+        /** @var \Magento\Customer\Service\V1\Dto\CustomerGroup $currentGroup */
         $currentGroup = $this->_coreRegistry->registry('current_group');
 
         if (!is_null($currentGroup->getId())) {
@@ -115,30 +137,33 @@ class Group extends \Magento\Backend\App\Action
      */
     public function saveAction()
     {
-        $customerGroup = $this->_objectManager->create('Magento\Customer\Model\Group');
-        $id = $this->getRequest()->getParam('id');
-        if (!is_null($id)) {
-            $customerGroup->load((int)$id);
-        }
-
         $taxClass = (int)$this->getRequest()->getParam('tax_class');
 
+        $customerGroup = null;
         if ($taxClass) {
+            $id = $this->getRequest()->getParam('id');
             try {
+                if (!is_null($id)) {
+                    $this->_customerGroupBuilder->populate($this->_groupService->getGroup((int)$id));
+                }
                 $customerGroupCode = (string)$this->getRequest()->getParam('code');
-
-                if (!empty($customerGroupCode)) {
-                    $customerGroup->setCode($customerGroupCode);
+                if (empty($customerGroupCode)) {
+                    $customerGroupCode = null;
                 }
+                $this->_customerGroupBuilder->setCode($customerGroupCode);
+                $this->_customerGroupBuilder->setTaxClassId($taxClass);
+                $customerGroup = $this->_customerGroupBuilder->create();
 
-                $customerGroup->setTaxClassId($taxClass)->save();
+                $this->_groupService->saveGroup($customerGroup);
                 $this->messageManager->addSuccess(__('The customer group has been saved.'));
                 $this->getResponse()->setRedirect($this->getUrl('customer/group'));
                 return;
             } catch (\Exception $e) {
                 $this->messageManager->addError($e->getMessage());
-                $this->_objectManager->get('Magento\Session\SessionManagerInterface')
-                    ->setCustomerGroupData($customerGroup->getData());
+                if ($customerGroup != null) {
+                    $this->_objectManager->get('Magento\Session\SessionManagerInterface')
+                        ->setCustomerGroupData($customerGroup->getData());
+                }
                 $this->getResponse()->setRedirect($this->getUrl('customer/group/edit', array('id' => $id)));
                 return;
             }
@@ -162,10 +187,15 @@ class Group extends \Magento\Backend\App\Action
                 return;
             }
             try {
-                $customerGroup->delete();
+                $this->_groupService->deleteGroup($id);
                 $this->messageManager->addSuccess(__('The customer group has been deleted.'));
                 $this->getResponse()->setRedirect($this->getUrl('customer/group'));
                 return;
+            } catch (NoSuchEntityException $e) {
+                $this->_objectManager->get('Magento\Adminhtml\Model\Session')
+                    ->addError(__('The customer group no longer exists.'));
+                $this->_redirect('adminhtml/*/');
+                return;
             } catch (\Exception $e) {
                 $this->messageManager->addError($e->getMessage());
                 $this->getResponse()->setRedirect($this->getUrl('customer/group/edit', array('id' => $id)));
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php
index 62f59c44d9811bf85033c211dd8a3d94eec6d1dd..163b217c047d67bf6bd14891752c11b38ff8c5c2 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php
@@ -284,6 +284,8 @@ class Index extends \Magento\Backend\App\Action
                 } else {
                     // create a new customer
                     $customer = $this->_customerFactory->create();
+                    // Need to set proper attribute id or future updates will cause data loss.
+                    $customer->setData('attribute_set_id', 1);
                     $this->_preparePasswordForSave($customer, $customerData);
                 }
 
@@ -463,9 +465,9 @@ class Index extends \Magento\Backend\App\Action
     private function _changePassword($customer, array $customerData)
     {
         if (!empty($customerData['password']) || $this->_isAutogeneratePassword($customerData)) {
-                $newPassword = $this->_getCustomerPassword($customer, $customerData);
-                $customer->changePassword($newPassword);
-                $customer->sendPasswordReminderEmail();
+            $newPassword = $this->_getCustomerPassword($customer, $customerData);
+            $customer->changePassword($newPassword);
+            $customer->sendPasswordReminderEmail();
         }
     }
 
diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php
index a445b418744bd00769bacf535842487410efe0cf..71f4afb9e5bb710c77f9ee27dd7ad23f79d9e8fe 100644
--- a/app/code/Magento/Customer/Helper/Address.php
+++ b/app/code/Magento/Customer/Helper/Address.php
@@ -189,7 +189,7 @@ class Address extends \Magento\App\Helper\AbstractHelper
     public function getFormat($code)
     {
         $format = $this->_addressConfig->getFormatByCode($code);
-        return $format->getRenderer() ? $format->getRenderer()->getFormat() : '';
+        return $format->getRenderer() ? $format->getRenderer()->getFormatArray() : '';
     }
 
     /**
diff --git a/app/code/Magento/Customer/Helper/Data.php b/app/code/Magento/Customer/Helper/Data.php
index 503acd501e82f4e65087a69d4cca06cf9634f543..7d305ab1194d72929a4719cb82f8294fca96cf33 100644
--- a/app/code/Magento/Customer/Helper/Data.php
+++ b/app/code/Magento/Customer/Helper/Data.php
@@ -98,13 +98,6 @@ class Data extends \Magento\App\Helper\AbstractHelper
     const VAT_CLASS_INVALID     = 'invalid';
     const VAT_CLASS_ERROR       = 'error';
 
-    /**
-     * Customer groups collection
-     *
-     * @var \Magento\Customer\Model\Resource\Group\Collection
-     */
-    protected $_groups;
-
     /**
      * Core data
      *
@@ -137,9 +130,9 @@ class Data extends \Magento\App\Helper\AbstractHelper
     protected $_customerSession;
 
     /**
-     * @var \Magento\Customer\Model\GroupFactory
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
      */
-    protected $_groupFactory;
+    protected $_groupService;
 
     /**
      * @var \Magento\Customer\Model\FormFactory
@@ -155,6 +148,11 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @var \Magento\Math\Random
      */
     protected $mathRandom;
+    
+    /**
+     * @var \Magento\Customer\Model\Converter
+     */
+    protected $_converter;
 
     /**
      * @param \Magento\App\Helper\Context $context
@@ -163,10 +161,11 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @param \Magento\Core\Model\Store\Config $coreStoreConfig
      * @param \Magento\App\ConfigInterface $coreConfig
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Customer\Model\GroupFactory $groupFactory
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
      * @param \Magento\Customer\Model\FormFactory $formFactory
      * @param \Magento\Escaper $escaper
      * @param \Magento\Math\Random $mathRandom
+     * @param \Magento\Customer\Model\Converter
      */
     public function __construct(
         \Magento\App\Helper\Context $context,
@@ -175,20 +174,22 @@ class Data extends \Magento\App\Helper\AbstractHelper
         \Magento\Core\Model\Store\Config $coreStoreConfig,
         \Magento\App\ConfigInterface $coreConfig,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Customer\Model\GroupFactory $groupFactory,
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
         \Magento\Customer\Model\FormFactory $formFactory,
         \Magento\Escaper $escaper,
-        \Magento\Math\Random $mathRandom
+        \Magento\Math\Random $mathRandom,
+        \Magento\Customer\Model\Converter $converter
     ) {
         $this->_customerAddress = $customerAddress;
         $this->_coreData = $coreData;
         $this->_coreStoreConfig = $coreStoreConfig;
         $this->_coreConfig = $coreConfig;
         $this->_customerSession = $customerSession;
-        $this->_groupFactory = $groupFactory;
+        $this->_groupService = $groupService;
         $this->_formFactory = $formFactory;
         $this->_escaper = $escaper;
         $this->mathRandom = $mathRandom;
+        $this->_converter = $converter;
         parent::__construct($context);
     }
 
@@ -250,21 +251,6 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return $this->_customer;
     }
 
-    /**
-     * Retrieve customer groups collection
-     *
-     * @return \Magento\Customer\Model\Resource\Group\Collection
-     */
-    public function getGroups()
-    {
-        if (empty($this->_groups)) {
-            $this->_groups = $this->_createGroup()->getResourceCollection()
-                ->setRealGroupsFilter()
-                ->load();
-        }
-        return $this->_groups;
-    }
-
     /**
      * Retrieve current (logged in) customer object
      *
@@ -539,7 +525,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      */
     public function getDefaultCustomerGroupId($store = null)
     {
-        return (int)$this->_coreStoreConfig->getConfig(\Magento\Customer\Model\Group::XML_PATH_DEFAULT_ID, $store);
+        return $this->_groupService->getDefaultGroup($store)->getId();
     }
 
     /**
@@ -700,7 +686,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
         $message = '';
         $isError = true;
         $customerVatClass = $this->getCustomerVatClass($customerAddress->getCountryId(), $validationResult);
-        $groupAutoAssignDisabled = $this->_coreStoreConfig->getConfigFlag(self::XML_PATH_CUSTOMER_VIV_GROUP_AUTO_ASSIGN);
+        $groupAutoAssignDisabled = $this->_coreStoreConfig->getConfigFlag(
+            self::XML_PATH_CUSTOMER_VIV_GROUP_AUTO_ASSIGN);
 
         $willChargeTaxMessage    = __('You will be charged tax.');
         $willNotChargeTaxMessage = __('You will not be charged tax.');
@@ -722,8 +709,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
             if (!$groupAutoAssignDisabled && !$customerGroupAutoAssignDisabled) {
                 $message .= $willChargeTaxMessage;
             }
-        }
-        else {
+        } else {
             $contactUsMessage = sprintf(__('If you believe this is an error, please contact us at %s'),
                 $this->_coreStoreConfig->getConfig(self::XML_PATH_SUPPORT_EMAIL));
 
@@ -793,18 +779,24 @@ class Data extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
-     * @return \Magento\Customer\Model\Group
+     * @return \Magento\Customer\Model\Form
      */
-    protected function _createGroup()
+    protected function _createForm()
     {
-        return $this->_groupFactory->create();
+        return $this->_formFactory->create();
     }
 
     /**
-     * @return \Magento\Customer\Model\Form
+     * Loads the values from a customer model.
+     * This is a wrapper for the converter object.
+     *
+     * TODO to be removed after service refactoring is done
+     *
+     * @param \Magento\Customer\Model\Customer $customerModel
+     * @return \Magento\Customer\Service\V1\Dto\Customer
      */
-    protected function _createForm()
+    public function createCustomerFromModel($customerModel)
     {
-        return $this->_formFactory->create();
+        return $this->_converter->createCustomerFromModel($customerModel);
     }
 }
diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php
index 55045c091d6b6582fe6a30e10ce55ae20326f468..c6e61d2d1c3a4ef163e8b394362c628f47ec36ce 100644
--- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php
+++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php
@@ -282,8 +282,8 @@ class AbstractAddress extends \Magento\Core\Model\AbstractModel
     public function explodeStreetAddress()
     {
         $streetLines = $this->getStreet();
-        foreach ($streetLines as $i=>$line) {
-            $this->setData('street'.($i+1), $line);
+        foreach ($streetLines as $i => $line) {
+            $this->setData('street' . ($i+1), $line);
         }
         return $this;
     }
@@ -299,8 +299,8 @@ class AbstractAddress extends \Magento\Core\Model\AbstractModel
         $region   = $this->getData('region');
 
         if ($regionId) {
-               if ($this->getRegionModel($regionId)->getCountryId() == $this->getCountryId()) {
-                   $region = $this->getRegionModel($regionId)->getName();
+            if ($this->getRegionModel($regionId)->getCountryId() == $this->getCountryId()) {
+                $region = $this->getRegionModel($regionId)->getName();
                 $this->setData('region', $region);
             }
         }
diff --git a/app/code/Magento/Customer/Model/Address/Config.php b/app/code/Magento/Customer/Model/Address/Config.php
index 7bda3a147b9ad8061cf8df0072e7b8df2f70421d..ec4d04154e4ba478e87686ab55f0781fa3b2abbd 100644
--- a/app/code/Magento/Customer/Model/Address/Config.php
+++ b/app/code/Magento/Customer/Model/Address/Config.php
@@ -168,20 +168,20 @@ class Config extends \Magento\Config\Data
     {
         $store = $this->getStore();
         $storeId = $store->getId();
-        if (!isset($this->_defaultType[$storeId])) {
-            $this->_defaultType[$storeId] = new \Magento\Object();
-            $this->_defaultType[$storeId]->setCode('default')
+        if (!isset($this->_defaultTypes[$storeId])) {
+            $this->_defaultTypes[$storeId] = new \Magento\Object();
+            $this->_defaultTypes[$storeId]->setCode('default')
                 ->setDefaultFormat('{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}'
                         . '{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, '
                         . '{{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}}');
 
-            $this->_defaultType[$storeId]->setRenderer(
+            $this->_defaultTypes[$storeId]->setRenderer(
                 $this->_addressHelper
                     ->getRenderer(self::DEFAULT_ADDRESS_RENDERER)
-                    ->setType($this->_defaultType[$storeId])
+                    ->setType($this->_defaultTypes[$storeId])
             );
         }
-        return $this->_defaultType[$storeId];
+        return $this->_defaultTypes[$storeId];
     }
 
     /**
diff --git a/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php b/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php
index 1c22613dca9c2df57882295e5cf74e5fab3136bf..7b111e71353f84742e2a581646417ec1ed1f4760 100644
--- a/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php
+++ b/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php
@@ -76,4 +76,4 @@ class Postcode extends \Magento\Eav\Model\Attribute\Data\Text
         }
         return true;
     }
-}
+}
\ No newline at end of file
diff --git a/app/code/Magento/Customer/Model/Config/Source/Group.php b/app/code/Magento/Customer/Model/Config/Source/Group.php
index f2e6bb967a7b7ff9ff845eb67b4ed67b0a95209c..f8eaeeb2bc126918dfa1c07c09ebc7184fbb1374 100644
--- a/app/code/Magento/Customer/Model/Config/Source/Group.php
+++ b/app/code/Magento/Customer/Model/Config/Source/Group.php
@@ -35,32 +35,34 @@ class Group implements \Magento\Core\Model\Option\ArrayInterface
     protected $_options;
 
     /**
-     * @var \Magento\Customer\Model\Resource\Group\CollectionFactory
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
      */
-    protected $_groupsFactory;
+    protected $_groupService;
 
     /**
-     * @param \Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory
+     * @var \Magento\Convert\Object
      */
-    public function __construct(\Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory)
-    {
-        $this->_groupsFactory = $groupsFactory;
+    protected $_converter;
+
+    /**
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+     * @param \Magento\Convert\Object $converter
+     */
+    public function __construct(
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+        \Magento\Convert\Object $converter
+    ) {
+        $this->_groupService = $groupService;
+        $this->_converter = $converter;
     }
 
     public function toOptionArray()
     {
         if (!$this->_options) {
-            $this->_options = $this->_getCustomerGroupsCollection()->setRealGroupsFilter()->loadData()->toOptionArray();
+            $groups = $this->_groupService->getGroups(FALSE);
+            $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
             array_unshift($this->_options, array('value'=> '', 'label'=> __('-- Please Select --')));
         }
         return $this->_options;
     }
-
-    /**
-     * @return \Magento\Customer\Model\Resource\Group\Collection
-     */
-    protected function _getCustomerGroupsCollection()
-    {
-        return $this->_groupsFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php b/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php
index fb89ca3262852b3d52c901202c36d930d75fbeec..a5fd1261d3a18f86bc798c85dcafe127033abb53 100644
--- a/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php
+++ b/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php
@@ -36,16 +36,25 @@ class Multiselect implements \Magento\Core\Model\Option\ArrayInterface
     protected $_options;
 
     /**
-     * @var \Magento\Customer\Model\Resource\Group\CollectionFactory
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
      */
-    protected $_groupsFactory;
+    protected $_groupService;
 
     /**
-     * @param \Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory
+     * @var \Magento\Convert\Object
      */
-    public function __construct(\Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory)
-    {
-        $this->_groupsFactory = $groupsFactory;
+    protected $_converter;
+
+    /**
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+     * @param \Magento\Convert\Object $converter
+     */
+    public function __construct(
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+        \Magento\Convert\Object $converter
+    ) {
+        $this->_groupService = $groupService;
+        $this->_converter = $converter;
     }
 
     /**
@@ -56,16 +65,9 @@ class Multiselect implements \Magento\Core\Model\Option\ArrayInterface
     public function toOptionArray()
     {
         if (!$this->_options) {
-            $this->_options = $this->_getCustomerGroupsCollection()->setRealGroupsFilter()->loadData()->toOptionArray();
+            $groups = $this->_groupService->getGroups(false);
+            $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
         }
         return $this->_options;
     }
-
-    /**
-     * @return \Magento\Customer\Model\Resource\Group\Collection
-     */
-    protected function _getCustomerGroupsCollection()
-    {
-        return $this->_groupsFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Model/Converter.php b/app/code/Magento/Customer/Model/Converter.php
index a3f039a7fc27c3f76d2412e73f3086e2ca9ca4aa..88c8efd75047a56a589fc1debb86bad32c6ea62b 100644
--- a/app/code/Magento/Customer/Model/Converter.php
+++ b/app/code/Magento/Customer/Model/Converter.php
@@ -1,6 +1,5 @@
 <?php
 /**
- *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -25,22 +24,20 @@
 
 namespace Magento\Customer\Model;
 
-use Magento\Customer\Service\Entity\V1\Exception;
 use Magento\Customer\Service\V1\CustomerMetadataServiceInterface;
+use Magento\Exception\NoSuchEntityException;
+use Magento\Customer\Service\V1\Dto\Customer as CustomerDto;
+use Magento\Customer\Service\V1\Dto\CustomerBuilder as CustomerDtoBuilder;
 
 /**
  * Customer Model converter.
  *
- * Converts a Customer Model to a DTO.
- *
- * TODO: Remove this class after service refactoring is done and the model
- * TODO: is no longer needed outside of service.  Then this function could
- * TODO: be moved to the service.
+ * Converts a Customer Model to a DTO or vice versa.
  */
 class Converter
 {
     /**
-     * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder
+     * @var CustomerDtoBuilder
      */
     protected $_customerBuilder;
 
@@ -51,12 +48,10 @@ class Converter
 
     /**
      * @param CustomerFactory $customerFactory
-     * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder
+     * @param CustomerDtoBuilder $customerBuilder
      */
-    public function __construct(
-        \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder,
-        \Magento\Customer\Model\CustomerFactory $customerFactory
-    ) {
+    public function __construct(CustomerDtoBuilder $customerBuilder, CustomerFactory $customerFactory)
+    {
         $this->_customerBuilder = $customerBuilder;
         $this->_customerFactory = $customerFactory;
     }
@@ -64,43 +59,32 @@ class Converter
     /**
      * Convert a customer model to a customer entity
      *
-     * @param \Magento\Customer\Model\Customer $customerModel
-     * @throws \InvalidArgumentException
-     * @return \Magento\Customer\Service\V1\Dto\Customer
+     * @param Customer $customerModel
+     * @return CustomerDto
      */
-    public function createCustomerFromModel($customerModel)
+    public function createCustomerFromModel(Customer $customerModel)
     {
-        if (!($customerModel instanceof \Magento\Customer\Model\Customer)) {
-            throw new \InvalidArgumentException('customer model is invalid');
-        }
-        $this->_convertAttributesFromModel($this->_customerBuilder, $customerModel);
-        $this->_customerBuilder->setCustomerId($customerModel->getId());
-        $this->_customerBuilder->setFirstname($customerModel->getFirstname());
-        $this->_customerBuilder->setLastname($customerModel->getLastname());
-        $this->_customerBuilder->setEmail($customerModel->getEmail());
-        return $this->_customerBuilder->create();
+        $customerBuilder = $this->_populateBuilderWithAttributes($customerModel);
+        $customerBuilder->setCustomerId($customerModel->getId());
+        $customerBuilder->setFirstname($customerModel->getFirstname());
+        $customerBuilder->setLastname($customerModel->getLastname());
+        $customerBuilder->setEmail($customerModel->getEmail());
+        return $customerBuilder->create();
     }
 
 
     /**
      * @param int $customerId
-     * @throws Exception If customerId is not found or other error occurs.
+     * @throws NoSuchEntityException If customer with customerId is not found.
      * @return Customer
      */
     public function getCustomerModel($customerId)
     {
-        try {
-            $customer = $this->_customerFactory->create()->load($customerId);
-        } catch (\Exception $e) {
-            throw new Exception($e->getMessage(), $e->getCode(), $e);
-        }
+        $customer = $this->_customerFactory->create()->load($customerId);
 
         if (!$customer->getId()) {
             // customer does not exist
-            throw new Exception(
-                'No customer with customerId ' . $customerId . ' exists.',
-                Exception::CODE_INVALID_CUSTOMER_ID
-            );
+            throw new NoSuchEntityException('customerId', $customerId);
         } else {
             return $customer;
         }
@@ -110,10 +94,10 @@ class Converter
     /**
      * Creates a customer model from a customer entity.
      *
-     * @param \Magento\Customer\Service\V1\Dto\Customer $customer
+     * @param CustomerDto $customer
      * @return Customer
      */
-    public function createCustomerModel(\Magento\Customer\Service\V1\Dto\Customer $customer)
+    public function createCustomerModel(CustomerDto $customer)
     {
         $customerModel = $this->_customerFactory->create();
 
@@ -144,10 +128,10 @@ class Converter
     /**
      * Loads the values from a customer model
      *
-     * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder
-     * @param \Magento\Customer\Model\Customer $customerModel
+     * @param Customer $customerModel
+     * @return CustomerDtoBuilder
      */
-    protected function _convertAttributesFromModel($customerBuilder, $customerModel)
+    protected function _populateBuilderWithAttributes(Customer $customerModel)
     {
         $attributes = [];
         foreach ($customerModel->getAttributes() as $attribute) {
@@ -159,7 +143,7 @@ class Converter
             $attributes[$attrCode] = $value;
         }
 
-        $customerBuilder->populateWithArray($attributes);
+        return $this->_customerBuilder->populateWithArray($attributes);
     }
 
 }
diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php
index 3ee15ab8d917837613f07565e43d95a830623c3a..24c9746daa62658b422e0e5ac9f89ae56720d2ba 100644
--- a/app/code/Magento/Customer/Model/Customer.php
+++ b/app/code/Magento/Customer/Model/Customer.php
@@ -119,13 +119,6 @@ class Customer extends \Magento\Core\Model\AbstractModel
      */
     protected $_isReadonly = false;
 
-    /**
-     * Confirmation requirement flag
-     *
-     * @var boolean
-     */
-    private static $_isConfirmationRequired;
-
     /** @var \Magento\Email\Model\Sender */
     protected $_sender;
 
@@ -716,12 +709,9 @@ class Customer extends \Magento\Core\Model\AbstractModel
         if ($this->canSkipConfirmation()) {
             return false;
         }
-        if (self::$_isConfirmationRequired === null) {
-            $storeId = $this->getStoreId() ? $this->getStoreId() : null;
-            self::$_isConfirmationRequired = (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_IS_CONFIRM, $storeId);
-        }
+        $storeId = $this->getStoreId() ? $this->getStoreId() : null;
 
-        return self::$_isConfirmationRequired;
+        return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_IS_CONFIRM, $storeId);
     }
 
     /**
diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php
index 70c52cd84b25de4af15cabc0fefc407e88f91a05..b0f80c52d59a7ce6c84879fb78b67083f575696e 100644
--- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php
+++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php
@@ -36,39 +36,40 @@ namespace Magento\Customer\Model\Customer\Attribute\Source;
 class Group extends \Magento\Eav\Model\Entity\Attribute\Source\Table
 {
     /**
-     * @var \Magento\Customer\Model\Resource\Group\CollectionFactory
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
      */
-    protected $_groupsFactory;
+    protected $_groupService;
+
+    /**
+     * @var \Magento\Convert\Object
+     */
+    protected $_converter;
 
     /**
      * @param \Magento\Core\Helper\Data $coreData
      * @param \Magento\Eav\Model\Resource\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
      * @param \Magento\Eav\Model\Resource\Entity\Attribute\OptionFactory $attrOptionFactory
-     * @param \Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+     * @param \Magento\Convert\Object $converter
      */
     public function __construct(
         \Magento\Core\Helper\Data $coreData,
         \Magento\Eav\Model\Resource\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
         \Magento\Eav\Model\Resource\Entity\Attribute\OptionFactory $attrOptionFactory,
-        \Magento\Customer\Model\Resource\Group\CollectionFactory $groupsFactory
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+        \Magento\Convert\Object $converter
     ) {
-        $this->_groupsFactory = $groupsFactory;
+        $this->_groupService = $groupService;
+        $this->_converter = $converter;
         parent::__construct($coreData, $attrOptionCollectionFactory, $attrOptionFactory);
     }
 
     public function getAllOptions()
     {
         if (!$this->_options) {
-            $this->_options = $this->_getCustomerGroupsCollection()->setRealGroupsFilter()->load()->toOptionArray();
+            $groups = $this->_groupService->getGroups(false);
+            $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
         }
         return $this->_options;
     }
-
-    /**
-     * @return \Magento\Customer\Model\Resource\Group\Collection
-     */
-    protected function _getCustomerGroupsCollection()
-    {
-        return $this->_groupsFactory->create();
-    }
 }
diff --git a/app/code/Magento/Customer/Model/Metadata/ElementFactory.php b/app/code/Magento/Customer/Model/Metadata/ElementFactory.php
index 6c7b83f39c7458bb04b72d770bb1ba28cc1bf052..7710469808206d2d8f1332c87ae74795694b8c76 100644
--- a/app/code/Magento/Customer/Model/Metadata/ElementFactory.php
+++ b/app/code/Magento/Customer/Model/Metadata/ElementFactory.php
@@ -30,6 +30,13 @@ namespace Magento\Customer\Model\Metadata;
 
 class ElementFactory
 {
+    const OUTPUT_FORMAT_JSON    = 'json';
+    const OUTPUT_FORMAT_TEXT    = 'text';
+    const OUTPUT_FORMAT_HTML    = 'html';
+    const OUTPUT_FORMAT_PDF     = 'pdf';
+    const OUTPUT_FORMAT_ONELINE = 'oneline';
+    const OUTPUT_FORMAT_ARRAY   = 'array'; // available only for multiply attributes
+
     /**
      * @var \Magento\ObjectManager
      */
diff --git a/app/code/Magento/Customer/Model/Metadata/Form.php b/app/code/Magento/Customer/Model/Metadata/Form.php
index 900372c0191a2f157346dc7b42286e649f4abb33..2c43148081f66155cc844defc3f847836fded217 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form.php
@@ -120,7 +120,7 @@ class Form
         $ignoreInvisible = true,
         $filterAttributes = [],
         $isAjax = false
-    ) {
+    )  {
         $this->_eavMetadataService = $eavMetadataService;
         $this->_elementFactory = $elementFactory;
         $this->_attributeValues = $attributeValues;
@@ -187,7 +187,7 @@ class Form
      */
     public function getAllowedAttributes()
     {
-        $attributes = $this->_eavMetadataService->getAttributes($this->_entityType, $this->_formCode);
+        $attributes = $this->getAttributes();
         foreach ($attributes as $attributeCode => $attribute) {
             if (
                 $this->_ignoreInvisible && !$attribute->isVisible()
@@ -210,7 +210,6 @@ class Form
     public function extractData(\Magento\App\RequestInterface $request, $scope = null, $scopeOnly = true)
     {
         $data = array();
-        /** @var $attribute \Magento\Eav\Model\Attribute */
         foreach ($this->getAllowedAttributes() as $attribute) {
             $dataModel = $this->_getAttributeDataModel($attribute);
             $dataModel->setRequestScope($scope);
@@ -247,7 +246,6 @@ class Form
      */
     public function restoreData(array $data)
     {
-        /** @var $attribute \Magento\Eav\Model\Attribute */
         foreach ($this->getAllowedAttributes() as $attribute) {
             $dataModel = $this->_getAttributeDataModel($attribute);
             $dataModel->setExtractedData($data);
@@ -262,7 +260,7 @@ class Form
     /**
      * Return attribute data model by attribute
      *
-     * @param \Magento\Eav\Model\Entity\Attribute $attribute
+     * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute
      * @return \Magento\Eav\Model\Attribute\Data\AbstractData
      */
     protected function _getAttributeDataModel($attribute)
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php
index 2dde4619fea813693240a4fbf61f125dc6a77a07..36aa6bdefec6a2cd94562b8059e6a7abbfa989aa 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php
@@ -20,8 +20,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -152,19 +150,6 @@ abstract class AbstractData
         return $this;
     }
 
-    /**
-     * Returns entity instance
-     *
-     * @return \Magento\Customer\Service\V1\Dto\Eav\EntityInterface
-     */
-    public function getEntity()
-    {
-        if (!$this->_entity) {
-            throw new \Magento\Core\Exception(__('Entity object is undefined'));
-        }
-        return $this->_entity;
-    }
-
     /**
      * Set array of full extracted data
      *
@@ -198,7 +183,7 @@ abstract class AbstractData
      * Apply attribute input filter to value
      *
      * @param string $value
-     * @return string
+     * @return string|bool
      */
     protected function _applyInputFilter($value)
     {
@@ -529,7 +514,7 @@ abstract class AbstractData
      *
      * @param array|string $value
      * @throws \Magento\Core\Exception
-     * @return boolean
+     * @return array|bool
      */
     abstract public function validateValue($value);
 
@@ -537,7 +522,7 @@ abstract class AbstractData
      * Export attribute value to entity model
      *
      * @param array|string $value
-     * @return string|bool
+     * @return array|string|bool
      */
     abstract public function compactValue($value);
 
@@ -545,7 +530,7 @@ abstract class AbstractData
      * Restore attribute value from SESSION to entity model
      *
      * @param array|string $value
-     * @return string|bool
+     * @return array|string|bool
      */
     abstract public function restoreValue($value);
 
@@ -555,5 +540,5 @@ abstract class AbstractData
      * @param string $format
      * @return string|array
      */
-    abstract public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT);
+    abstract public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT);
 }
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Boolean.php b/app/code/Magento/Customer/Model/Metadata/Form/Boolean.php
index 0893367eb47d02e2573180ad0cce8625aff6379f..cf79e2f9aa05352e611b7920752281a7fef68c4c 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Boolean.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Boolean.php
@@ -20,8 +20,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Date.php b/app/code/Magento/Customer/Model/Metadata/Form/Date.php
index 071c9d561c1fc2fd6c6ffe9018abab1b310a248a..c48798b290810294026754732e8ba1e58ad237d5 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Date.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Date.php
@@ -20,8 +20,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -31,10 +29,7 @@ namespace Magento\Customer\Model\Metadata\Form;
 class Date extends AbstractData
 {
     /**
-     * Extract data from request and return value
-     *
-     * @param \Magento\App\RequestInterface $request
-     * @return array|string
+     * {@inheritdoc}
      */
     public function extractValue(\Magento\App\RequestInterface $request)
     {
@@ -43,11 +38,7 @@ class Date extends AbstractData
     }
 
     /**
-     * Validate data
-     * Return true or array of errors
-     *
-     * @param array|string $value
-     * @return boolean|array
+     * {@inheritdoc}
      */
     public function validateValue($value)
     {
@@ -95,10 +86,7 @@ class Date extends AbstractData
     }
 
     /**
-     * Export attribute value to entity model
-     *
-     * @param array|string $value
-     * @return string
+     * {@inheritdoc}
      */
     public function compactValue($value)
     {
@@ -113,10 +101,7 @@ class Date extends AbstractData
 
 
     /**
-     * Restore attribute value from SESSION to entity model
-     *
-     * @param array|string $value
-     * @return \Magento\Eav\Model\Attribute\Data\Date
+     * {@inheritdoc}
      */
     public function restoreValue($value)
     {
@@ -124,19 +109,16 @@ class Date extends AbstractData
     }
 
     /**
-     * Return formated attribute value from entity model
-     *
-     * @param string $format
-     * @return string|array
+     * {@inheritdoc}
      */
-    public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
+    public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
     {
         $value = $this->_value;
         if ($value) {
             switch ($format) {
-                case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT:
-                case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML:
-                case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_PDF:
+                case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT:
+                case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_HTML:
+                case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_PDF:
                     $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM);
                     break;
             }
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php
index a3ee74acedb38c1045cbf1c7bcea3de62ad59b66..85f9f6f1d13343b19bd6282c7fdad39a0345698e 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/File.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php
@@ -20,8 +20,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -83,10 +81,7 @@ class File extends AbstractData
     }
 
     /**
-     * Extract data from request and return value
-     *
-     * @param \Magento\App\RequestInterface $request
-     * @return array|string
+     * {@inheritdoc}
      */
     public function extractValue(\Magento\App\RequestInterface $request)
     {
@@ -148,7 +143,7 @@ class File extends AbstractData
      */
     protected function _validateByRules($value)
     {
-        $label  = $this->getAttribute()->getStoreLabel();
+        $label  = $value['name'];
         $rules  = $this->getAttribute()->getValidationRules();
         $extension  = pathinfo($value['name'], PATHINFO_EXTENSION);
 
@@ -157,7 +152,7 @@ class File extends AbstractData
             $extensions = array_map('trim', $extensions);
             if (!in_array($extension, $extensions)) {
                 return array(
-                    __('"%1" is not a valid file extension.', $label)
+                    __('"%1" is not a valid file extension.', $extension)
                 );
             }
         }
@@ -169,7 +164,7 @@ class File extends AbstractData
             return $this->_fileValidator->getMessages();
         }
 
-        if (!is_uploaded_file($value['tmp_name'])) {
+        if (!$this->_isUploadedFile($value['tmp_name'])) {
             return array(
                 __('"%1" is not a valid file.', $label)
             );
@@ -188,11 +183,20 @@ class File extends AbstractData
     }
 
     /**
-     * Validate data
+     * Helper function that checks if the file was uploaded.
+     *
+     * This helper function is needed for testing.
      *
-     * @param array|string $value
-     * @throws \Magento\Core\Exception
-     * @return boolean
+     * @param string $filename
+     * @return bool
+     */
+    protected function _isUploadedFile($filename)
+    {
+        return is_uploaded_file($filename);
+    }
+
+    /**
+     * {@inheritdoc}
      */
     public function validateValue($value)
     {
@@ -231,11 +235,7 @@ class File extends AbstractData
     }
 
     /**
-     * Export attribute value to entity model
-     *
-     * @param \Magento\Core\Model\AbstractModel $entity
-     * @param array|string $value
-     * @return string
+     * {@inheritdoc}
      */
     public function compactValue($value)
     {
@@ -286,27 +286,22 @@ class File extends AbstractData
     }
 
     /**
-     * Restore attribute value from SESSION to entity model
-     *
-     * @param array|string $value
-     * @return \Magento\Customer\Model\Metadata\Form\File
+     * {@inheritdoc}
      */
     public function restoreValue($value)
     {
-        return $this;
+        return $this->_value;
     }
 
     /**
-     * Return formated attribute value from entity model
-     *
-     * @return string|array
+     * {@inheritdoc}
      */
-    public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
+    public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
     {
         $output = '';
         if ($this->_value) {
             switch ($format) {
-                case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON:
+                case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_JSON:
                     $output = array(
                         'value'     => $this->_value,
                         'url_key'   => $this->_coreData->urlEncode($this->_value)
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Image.php b/app/code/Magento/Customer/Model/Metadata/Form/Image.php
index f467a81220fbe93ce3ce640c7dc2edfb6fc03a7e..4541d6cc24ca20be111354bf1799211b43989361 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Image.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Image.php
@@ -20,8 +20,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -39,14 +37,14 @@ class Image extends File
      */
     protected function _validateByRules($value)
     {
-        $label  = __($this->getAttribute()->getStoreLabel());
+        $label  = $value['name'];
         $rules  = $this->getAttribute()->getValidationRules();
 
         $imageProp = @getimagesize($value['tmp_name']);
 
-        if (!is_uploaded_file($value['tmp_name']) || !$imageProp) {
+        if (!$this->_isUploadedFile($value['tmp_name']) || !$imageProp) {
             return array(
-                __('"%1" is not a valid file', $label)
+                __('"%1" is not a valid file.', $label)
             );
         }
 
@@ -58,7 +56,7 @@ class Image extends File
 
         if (!isset($allowImageTypes[$imageProp[2]])) {
             return array(
-                __('"%1" is not a valid image format', $label)
+                __('"%1" is not a valid image format.', $label)
             );
         }
 
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php
index 035b9d6a106dde1bc853d43f0c150342016b2220..99a336e3f1b7064b1eaa291d3fab02ba9eb3bbf1 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php
@@ -31,10 +31,7 @@ namespace Magento\Customer\Model\Metadata\Form;
 class Multiline extends Text
 {
     /**
-     * Extract data from request and return value
-     *
-     * @param \Magento\App\RequestInterface $request
-     * @return array|string
+     * {@inheritdoc}
      */
     public function extractValue(\Magento\App\RequestInterface $request)
     {
@@ -48,11 +45,7 @@ class Multiline extends Text
     }
 
     /**
-     * Validate data
-     * Return true or array of errors
-     *
-     * @param array|string $value
-     * @return boolean|array
+     * {@inheritdoc}
      */
     public function validateValue($value)
     {
@@ -97,10 +90,7 @@ class Multiline extends Text
     }
 
     /**
-     * Export attribute value to entity model
-     *
-     * @param array|string $value
-     * @return \Magento\Customer\Model\Metadata\Form\Multiline
+     * {@inheritdoc}
      */
     public function compactValue($value)
     {
@@ -111,10 +101,7 @@ class Multiline extends Text
     }
 
     /**
-     * Restore attribute value from SESSION to entity model
-     *
-     * @param array|string $value
-     * @return \Magento\Customer\Model\Metadata\Form\Multiline
+     * {@inheritdoc}
      */
     public function restoreValue($value)
     {
@@ -122,12 +109,9 @@ class Multiline extends Text
     }
 
     /**
-     * Return formated attribute value from entity model
-     *
-     * @param string $format
-     * @return array|string
+     * {@inheritdoc}
      */
-    public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
+    public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
     {
         $values = $this->_value;
         if (!is_array($values)) {
@@ -135,13 +119,13 @@ class Multiline extends Text
         }
         $values = array_map(array($this, '_applyOutputFilter'), $values);
         switch ($format) {
-            case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY:
+            case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_ARRAY:
                 $output = $values;
                 break;
-            case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML:
+            case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_HTML:
                 $output = implode("<br />", $values);
                 break;
-            case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ONELINE:
+            case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_ONELINE:
                 $output = implode(" ", $values);
                 break;
             default:
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php
index 586bedfbd7f111cce490332f00c8a9a7a90086da..a00e9e885920cb707e3aa776435a26501f2be4c5 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php
@@ -20,23 +20,21 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 namespace Magento\Customer\Model\Metadata\Form;
 
+use Magento\App\RequestInterface;
+use Magento\Customer\Model\Metadata\ElementFactory;
+
 class Multiselect extends Select
 {
     /**
-     * Extract data from request and return value
-     *
-     * @param \Magento\App\RequestInterface $request
-     * @return array|string
+     * {@inheritdoc}
      */
-    public function extractValue(\Magento\App\RequestInterface $request)
+    public function extractValue(RequestInterface $request)
     {
         $values = $this->_getRequestValue($request);
         if ($values !== false && !is_array($values)) {
@@ -46,54 +44,44 @@ class Multiselect extends Select
     }
 
     /**
-     * Export attribute value to entity model
-     *
-     * @param array|string $value
-     * @return \Magento\Customer\Model\Metadata\Form\Multiselect
+     * {@inheritdoc}
      */
     public function compactValue($value)
     {
         if (is_array($value)) {
+            foreach($value as $key => $val) {
+                $value[$key] = parent::compactValue($val);
+            }
+
             $value = implode(',', $value);
         }
         return parent::compactValue($value);
     }
 
     /**
-     * Return formated attribute value from entity model
-     *
-     * @param string $format
-     * @return array|string
+     * {@inheritdoc}
      */
-    public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
+    public function outputValue($format = ElementFactory::OUTPUT_FORMAT_TEXT)
     {
         $values = $this->_value;
         if (!is_array($values)) {
             $values = explode(',', $values);
         }
 
-        switch ($format) {
-            case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON:
-            case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY:
-                $output = $values;
-            default:
-                $output = array();
-                foreach ($values as $value) {
-                    if (!$value) {
-                        continue;
-                    }
-                    $optionText = false;
-                    foreach ($this->getAttribute()->getOptions() as $optionKey => $optionValue) {
-                        if ($optionValue == $value) {
-                            $optionText = $optionKey;
-                        }
-                    }
-                    $output[] = $optionText;
-                }
-                $output = implode(', ', $output);
-                break;
+        if (ElementFactory::OUTPUT_FORMAT_ARRAY === $format || ElementFactory::OUTPUT_FORMAT_JSON === $format) {
+            return $values;
         }
 
+        $output = [];
+        foreach ($values as $value) {
+            if (!$value) {
+                continue;
+            }
+            $output[] = $this->_getOptionText($value);
+        }
+
+        $output = implode(', ', $output);
+
         return $output;
     }
 }
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Select.php b/app/code/Magento/Customer/Model/Metadata/Form/Select.php
index 8ee81142130d23d07b745c18d10713ac745f103e..2221d86b97b723963dcdc5b070197767d0f4c20b 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Select.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Select.php
@@ -20,33 +20,27 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 namespace Magento\Customer\Model\Metadata\Form;
 
+use Magento\App\RequestInterface;
+use Magento\Customer\Model\Metadata\ElementFactory;
+
 class Select extends AbstractData
 {
     /**
-     * Extract data from request and return value
-     *
-     * @param \Magento\App\RequestInterface $request
-     * @return array|string
+     * {@inheritdoc}
      */
-    public function extractValue(\Magento\App\RequestInterface $request)
+    public function extractValue(RequestInterface $request)
     {
         return $this->_getRequestValue($request);
     }
 
     /**
-     * Validate data
-     * Return true or array of errors
-     *
-     * @param array|string $value
-     * @return boolean|array
+     * {@inheritdoc}
      */
     public function validateValue($value)
     {
@@ -59,7 +53,7 @@ class Select extends AbstractData
             $value = $this->_value;
         }
 
-        if ($attribute->isRequired() && empty($value) && $value != '0') {
+        if ($attribute->isRequired() && empty($value) && $value !== '0') {
             $errors[] = __('"%1" is a required value.', $label);
         }
 
@@ -75,24 +69,15 @@ class Select extends AbstractData
     }
 
     /**
-     * Export attribute value to entity model
-     *
-     * @param array|string $value
-     * @return string
+     * {@inheritdoc}
      */
     public function compactValue($value)
     {
-        if ($value !== false) {
-            $value;
-        }
-        return false;
+        return $value;
     }
 
     /**
-     * Restore attribute value from SESSION to entity model
-     *
-     * @param array|string $value
-     * @return string
+     * {@inheritdoc}
      */
     public function restoreValue($value)
     {
@@ -102,39 +87,34 @@ class Select extends AbstractData
     /**
      * Return a text for option value
      *
-     * @param int $value
+     * @param string|int $value
      * @return string
      */
     protected function _getOptionText($value)
     {
-        $optionText = false;
-        foreach ($this->getAttribute()->getOptions() as $optionKey => $optionValue) {
-            if ($optionValue == $value) {
-                $optionText = $optionKey;
+        foreach ($this->getAttribute()->getOptions() as $option) {
+            if ($option->getValue() == $value && !is_bool($value)) {
+                return $option->getLabel();
             }
         }
-        $output[] = $optionText;
+        return '';
     }
 
     /**
      * Return formated attribute value from entity model
      *
-     * @return string|array
+     * @param string $format
+     * @return string
      */
-    public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
+    public function outputValue($format = ElementFactory::OUTPUT_FORMAT_TEXT)
     {
         $value = $this->_value;
-        switch ($format) {
-            case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON:
-                $output = $value;
-                break;
-            default:
-                if ($value != '') {
-                    $output = $this->_getOptionText($value);
-                } else {
-                    $output = '';
-                }
-                break;
+        if ($format === ElementFactory::OUTPUT_FORMAT_JSON) {
+            $output = $value;
+        } elseif ($value != '') {
+            $output = $this->_getOptionText($value);
+        } else {
+            $output = '';
         }
 
         return $output;
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Text.php b/app/code/Magento/Customer/Model/Metadata/Form/Text.php
index 59bc406fce49103e08ed0d223b386d33693548f4..4322fbfb29d7f05f4ec16bbd931bb1b82c489028 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Text.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Text.php
@@ -20,20 +20,9 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
-/**
- * EAV Entity Attribute Text Data Model
- *
- * @category    Magento
- * @package     Magento_Eav
- * @author      Magento Core Team <core@magentocommerce.com>
- */
 namespace Magento\Customer\Model\Metadata\Form;
 
 class Text extends AbstractData
@@ -47,8 +36,8 @@ class Text extends AbstractData
      * @param \Magento\Core\Model\LocaleInterface $locale
      * @param \Magento\Logger $logger
      * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute
-     * @param null $value
-     * @param $entityTypeCode
+     * @param string $value
+     * @param string $entityTypeCode
      * @param bool $isAjax
      * @param \Magento\Stdlib\String $stringHelper
      */
@@ -56,7 +45,7 @@ class Text extends AbstractData
         \Magento\Core\Model\LocaleInterface $locale,
         \Magento\Logger $logger,
         \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute,
-        $value = null,
+        $value,
         $entityTypeCode,
         $isAjax = false,
         \Magento\Stdlib\String $stringHelper
@@ -66,23 +55,15 @@ class Text extends AbstractData
     }
 
     /**
-     * Extract data from request and return value
-     *
-     * @param \Magento\App\RequestInterface $request
-     * @return array|string
+     * {@inheritdoc}
      */
     public function extractValue(\Magento\App\RequestInterface $request)
     {
-        $value = $this->_getRequestValue($request);
-        return $this->_applyInputFilter($value);
+        return $this->_applyInputFilter($this->_getRequestValue($request));
     }
 
     /**
-     * Validate data
-     * Return true or array of errors
-     *
-     * @param array|string $value
-     * @return boolean|array
+     * {@inheritdoc}
      */
     public function validateValue($value)
     {
@@ -128,24 +109,15 @@ class Text extends AbstractData
     }
 
     /**
-     * Export attribute value to entity model
-     *
-     * @param array|string $value
-     * @return string|value
+     * {@inheritdoc}
      */
     public function compactValue($value)
     {
-        if ($value !== false) {
-            $value;
-        }
-        return false;
+        return $value;
     }
 
     /**
-     * Restore attribute value from SESSION to entity model
-     *
-     * @param array|string $value
-     * @return string|value
+     * {@inheritdoc}
      */
     public function restoreValue($value)
     {
@@ -153,16 +125,10 @@ class Text extends AbstractData
     }
 
     /**
-     * Return formated attribute value from entity model
-     *
-     * @param string $format
-     * @return string|array
+     * {@inheritdoc}
      */
-    public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
+    public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
     {
-        $value = $this->_value;
-        $value = $this->_applyOutputFilter($value);
-
-        return $value;
+        return $this->_applyOutputFilter($this->_value);
     }
 }
diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Textarea.php b/app/code/Magento/Customer/Model/Metadata/Form/Textarea.php
index eeb7bec0d8366e7a313bf4e1b53861612c177bf9..60e6c0266f2f0985485359047466a07242f651e4 100644
--- a/app/code/Magento/Customer/Model/Metadata/Form/Textarea.php
+++ b/app/code/Magento/Customer/Model/Metadata/Form/Textarea.php
@@ -20,14 +20,12 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Eav
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 namespace Magento\Customer\Model\Metadata\Form;
 
-class Textarea extends \Magento\Eav\Model\Attribute\Data\Text
+class Textarea extends Text
 {
 }
diff --git a/app/code/Magento/Customer/Model/Metadata/FormFactory.php b/app/code/Magento/Customer/Model/Metadata/FormFactory.php
index 7a4984c1cbfb8f1ebe7f517e77e6ba29819598cf..c720627859b616762471f7b58cf476f734434c71 100644
--- a/app/code/Magento/Customer/Model/Metadata/FormFactory.php
+++ b/app/code/Magento/Customer/Model/Metadata/FormFactory.php
@@ -20,8 +20,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -43,7 +41,6 @@ class FormFactory
         $this->_objectManager = $objectManager;
     }
 
-
     /**
      * Create Form
      *
@@ -67,4 +64,4 @@ class FormFactory
         ];
         return $this->_objectManager->create('Magento\Customer\Model\Metadata\Form', $params);
     }
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Customer/Model/Metadata/Validator.php b/app/code/Magento/Customer/Model/Metadata/Validator.php
index b727a6e85fb95ff3fd5073cc45675f3af244fe24..0fab0b4422e2320f1cda5c7f460a4a0e1bfa7adb 100644
--- a/app/code/Magento/Customer/Model/Metadata/Validator.php
+++ b/app/code/Magento/Customer/Model/Metadata/Validator.php
@@ -35,9 +35,9 @@ class Validator extends \Magento\Eav\Model\Validator\Attribute\Data
     protected $_entityType;
 
     /**
-     * @param \Magento\Customer\Model\Metadata\ElementFactory $attrDataFactory
+     * @param ElementFactory $attrDataFactory
      */
-    public function __construct(\Magento\Customer\Model\Metadata\ElementFactory $attrDataFactory)
+    public function __construct(ElementFactory $attrDataFactory)
     {
         $this->_attrDataFactory = $attrDataFactory;
     }
@@ -56,9 +56,15 @@ class Validator extends \Magento\Eav\Model\Validator\Attribute\Data
         } elseif ($entity instanceof \Magento\Object) {
             $data = $entity->getData();
         }
-        $this->validateData($data, $this->_attributes, $this->_entityType);
+        return $this->validateData($data, $this->_attributes, $this->_entityType);
     }
 
+    /**
+     * @param array                                                    $data
+     * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] $attributes
+     * @param string                                                   $entityType
+     * @return bool
+     */
     public function validateData($data, $attributes, $entityType)
     {
         foreach ($attributes as $attribute) {
@@ -85,7 +91,7 @@ class Validator extends \Magento\Eav\Model\Validator\Attribute\Data
      * Set type of the entity
      *
      * @param string $entityType
-     * @return null
+     * @return void
      */
     public function setEntityType($entityType)
     {
diff --git a/app/code/Magento/Customer/Model/Resource/Group/Grid/ServiceCollection.php b/app/code/Magento/Customer/Model/Resource/Group/Grid/ServiceCollection.php
new file mode 100644
index 0000000000000000000000000000000000000000..ec77a2d11fec151e700af7d0f4cf46bbc69b28f6
--- /dev/null
+++ b/app/code/Magento/Customer/Model/Resource/Group/Grid/ServiceCollection.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Customer group collection
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Resource\Group\Grid;
+
+use Magento\Customer\Service\V1\Dto\CustomerGroup;
+use Magento\Customer\Service\V1\Dto\Filter;
+use Magento\Customer\Service\V1\Dto\SearchCriteria;
+
+class ServiceCollection extends \Magento\Data\Collection
+{
+    /**
+     * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
+     */
+    protected $groupService;
+
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\FilterBuilder
+     */
+    protected $filterBuilder;
+
+    /**
+     * @var \Magento\Customer\Service\V1\Dto\SearchCriteriaBuilder
+     */
+    protected $searchCriteriaBuilder;
+
+    /**
+     * @param \Magento\Core\Model\EntityFactory $entityFactory
+     * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+     * @param \Magento\Customer\Service\V1\Dto\FilterBuilder $filterBuilder
+     * @param \Magento\Customer\Service\V1\Dto\SearchCriteriaBuilder $searchCriteriaBuilder
+     */
+    public function __construct(
+        \Magento\Core\Model\EntityFactory $entityFactory,
+        \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+        \Magento\Customer\Service\V1\Dto\FilterBuilder $filterBuilder,
+        \Magento\Customer\Service\V1\Dto\SearchCriteriaBuilder $searchCriteriaBuilder
+    ) {
+        parent::__construct($entityFactory);
+        $this->groupService = $groupService;
+        $this->filterBuilder = $filterBuilder;
+        $this->searchCriteriaBuilder = $searchCriteriaBuilder;
+    }
+
+    /**
+     * Load customer group collection data from service
+     *
+     * @param bool $printQuery
+     * @param bool $logQuery
+     * @return  \Magento\Data\Collection
+     */
+    public function loadData($printQuery = false, $logQuery = false)
+    {
+        if (!$this->isLoaded()) {
+            $searchCriteria = $this->getSearchCriteria();
+            $searchResults = $this->groupService->searchGroups($searchCriteria);
+            $this->_totalRecords = $searchResults->getTotalCount();
+            /** @var CustomerGroup[] $groups */
+            $groups = $searchResults->getItems();
+            foreach ($groups as $group) {
+                $groupItem = new \Magento\Object();
+                $groupItem->addData($group->__toArray());
+                $this->_addItem($groupItem);
+            }
+            $this->_setIsLoaded();
+        }
+        return $this;
+    }
+
+    public function addFieldToFilter($field, $condition)
+    {
+        // TODO this is broken until the Widget/Grid can be re-written not to have db logic in it
+        return $this;
+    }
+
+    protected function getSearchCriteria()
+    {
+        foreach ($this->_filters as $filter) {
+            $this->filerBuilder->setField($filter['field'])
+                ->setValue($filter['value'])
+                ->setConditionType($filter['type']);
+            $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
+        }
+        foreach ($this->_orders as $field => $direction) {
+            $this->searchCriteriaBuilder->addSortOrder(
+                $field, $direction == 'ASC' ? SearchCriteria::SORT_ASC : SearchCriteria::SORT_DESC);
+        }
+        $this->searchCriteriaBuilder->setCurrentPage($this->_curPage);
+        $this->searchCriteriaBuilder->setPageSize($this->_pageSize);
+        return $this->searchCriteriaBuilder->create();
+    }
+}
diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php
index 2c7c5ae8a91148953a8d216d33a341d4d983c0dd..c3ff8c4eca0fbbd2c477744f12a5165988593dd4 100644
--- a/app/code/Magento/Customer/Model/Session.php
+++ b/app/code/Magento/Customer/Model/Session.php
@@ -24,8 +24,11 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
+
 namespace Magento\Customer\Model;
 
+use Magento\Customer\Service\V1\Dto\Customer as CustomerDto;
+
 /**
  * Customer session model
  */
@@ -34,10 +37,17 @@ class Session extends \Magento\Session\SessionManager
     /**
      * Customer object
      *
-     * @var \Magento\Customer\Model\Customer
+     * @var CustomerDto
      */
     protected $_customer;
 
+    /**
+     * Customer model
+     *
+     * @var \Magento\Customer\Model\Customer
+     */
+    protected $_customerModel;
+
     /**
      * Flag with customer id validations result
      *
@@ -70,12 +80,14 @@ class Session extends \Magento\Session\SessionManager
     protected $_session;
 
     /**
-     * @var \Magento\Customer\Model\Resource\Customer
+     * @var \Magento\Customer\Service\V1\CustomerServiceInterface
      */
-    protected $_customerResource;
+    protected $_customerService;
 
+    /** @var  \Magento\Customer\Service\V1\CustomerAccountServiceInterface */
+    protected $_customerAccountService;
     /**
-     * @var \Magento\Customer\Model\CustomerFactory
+     * @var CustomerFactory
      */
     protected $_customerFactory;
 
@@ -114,6 +126,8 @@ class Session extends \Magento\Session\SessionManager
      * @param \Magento\Core\Model\Session $session
      * @param \Magento\Event\ManagerInterface $eventManager
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+     * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService
      * @param null $sessionName
      * @param array $data
      */
@@ -134,6 +148,8 @@ class Session extends \Magento\Session\SessionManager
         \Magento\Event\ManagerInterface $eventManager,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\App\ResponseInterface $response,
+        \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+        \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService,
         $sessionName = null,
         array $data = array()
     ) {
@@ -144,6 +160,8 @@ class Session extends \Magento\Session\SessionManager
         $this->_customerFactory = $customerFactory;
         $this->_urlFactory = $urlFactory;
         $this->_session = $session;
+        $this->_customerService = $customerService;
+        $this->_customerAccountService = $customerAccountService;
         $this->_eventManager = $eventManager;
         $this->_storeManager = $storeManager;
         $this->response = $response;
@@ -165,48 +183,79 @@ class Session extends \Magento\Session\SessionManager
     /**
      * Set customer object and setting customer id in session
      *
-     * @param   \Magento\Customer\Model\Customer $customer
+     * @param   CustomerDto $customer
      * @return  \Magento\Customer\Model\Session
      */
-    public function setCustomer(\Magento\Customer\Model\Customer $customer)
+    public function setCustomerDto(CustomerDto $customer)
     {
-        // check if customer is not confirmed
-        if ($customer->isConfirmationRequired()) {
-            if ($customer->getConfirmation()) {
-                return $this->_logout();
-            }
-        }
         $this->_customer = $customer;
-        $this->setId($customer->getId());
-        // save customer as confirmed, if it is not
-        if ((!$customer->isConfirmationRequired()) && $customer->getConfirmation()) {
-            $customer->setConfirmation(null)->save();
-            $customer->setIsJustConfirmed(true);
+        if ($customer === null) {
+            $this->setCustomerId(null);
+        } else {
+            $this->response->setVary('customer_group', $customer->getGroupId());
+            $this->setCustomerId($customer->getCustomerId());
         }
-        $this->response->setVary('customer_group', $this->_customer->getGroupId());
         return $this;
     }
 
     /**
      * Retrieve customer model object
      *
-     * @return \Magento\Customer\Model\Customer
+     * @deprecated
+     * @return CustomerDto
      */
-    public function getCustomer()
+    public function getCustomerDto()
     {
-        if ($this->_customer instanceof \Magento\Customer\Model\Customer) {
+        /*** XXX: shouldn't this be CustomerDto? ***/
+        if ($this->_customer instanceof Customer) {
             return $this->_customer;
         }
 
-        $customer = $this->_createCustomer()->setWebsiteId($this->_storeManager->getStore()->getWebsiteId());
-        if ($this->getId()) {
-            $customer->load($this->getId());
+        if ($this->getCustomerId()) {
+            $this->_customer = $this->_customerService->getCustomer($this->getCustomerId());
         }
 
-        $this->setCustomer($customer);
         return $this->_customer;
     }
 
+
+    /**
+     * Set customer model and the customer id in session
+     *
+     * @param   Customer $customerModel
+     * @return  \Magento\Customer\Model\Session
+     */
+    public function setCustomer(Customer $customerModel)
+    {
+        $this->_customerModel = $customerModel;
+        if ($customerModel === null) {
+            $this->setCustomerId(null);
+        } else {
+            $this->response->setVary('customer_group', $customerModel->getGroupId());
+            $this->setCustomerId($customerModel->getId());
+            if ((!$customerModel->isConfirmationRequired()) && $customerModel->getConfirmation()) {
+                $customerModel->setConfirmation(null)->save();
+            }
+        }
+        
+        return $this;
+    }
+
+    /**
+     * Retrieve customer model object
+     *
+     * @return Customer
+     * @deprecated use getCustomerId() instead
+     */
+    public function getCustomer()
+    {
+        if ($this->_customerModel === null) {
+            $this->_customerModel = $this->_customerFactory->create()->load($this->getCustomerId());
+        }
+
+        return $this->_customerModel;
+    }
+
     /**
      * Set customer id
      *
@@ -230,7 +279,17 @@ class Session extends \Magento\Session\SessionManager
         if ($this->storage->getData('customer_id')) {
             return $this->storage->getData('customer_id');
         }
-        return ($this->isLoggedIn()) ? $this->getId() : null;
+        return null;
+    }
+
+    public function getId()
+    {
+        return $this->getCustomerId();
+    }
+
+    public function setId($customerId)
+    {
+        return $this->setCustomerId($customerId);
     }
 
     /**
@@ -256,10 +315,11 @@ class Session extends \Magento\Session\SessionManager
         if ($this->storage->getData('customer_group_id')) {
             return $this->storage->getData('customer_group_id');
         }
-        if ($this->isLoggedIn() && $this->getCustomer()) {
-            return $this->getCustomer()->getGroupId();
+        if ($this->getCustomerDto()) {
+            $customerGroupId = $this->getCustomerDto()->getGroupId();
+            $this->setCustomerGroupId($customerGroupId);
+            return $customerGroupId;
         }
-
         return \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID;
     }
 
@@ -270,7 +330,7 @@ class Session extends \Magento\Session\SessionManager
      */
     public function isLoggedIn()
     {
-        return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId());
+        return (bool)$this->getCustomerId() && (bool)$this->checkCustomerId($this->getId());
     }
 
     /**
@@ -281,10 +341,17 @@ class Session extends \Magento\Session\SessionManager
      */
     public function checkCustomerId($customerId)
     {
-        if ($this->_isCustomerIdChecked === null) {
-            $this->_isCustomerIdChecked = $this->_customerResource->checkCustomerId($customerId);
+        if ($this->_isCustomerIdChecked === $customerId) {
+            return true;
+        }
+
+        try {
+            $this->_customerService->getCustomer($customerId);
+            $this->_isCustomerIdChecked = $customerId;
+            return true;
+        } catch (\Exception $e) {
+            return false;
         }
-        return $this->_isCustomerIdChecked;
     }
 
     /**
@@ -296,19 +363,18 @@ class Session extends \Magento\Session\SessionManager
      */
     public function login($username, $password)
     {
-        /** @var $customer \Magento\Customer\Model\Customer */
-        $customer = $this->_createCustomer()->setWebsiteId($this->_storeManager->getStore()->getWebsiteId());
-
-        if ($customer->authenticate($username, $password)) {
-            $this->setCustomerAsLoggedIn($customer);
+        try {
+            $customer = $this->_customerAccountService->authenticate($username, $password);
+            $this->setCustomerDtoAsLoggedIn($customer);
             return true;
+        } catch (\Exception $e) {
+            return false;
         }
-        return false;
     }
 
     /**
-     * @param \Magento\Customer\Model\Customer $customer
-     * @return $this
+     * @param Customer $customer
+     * @return \Magento\Customer\Model\Session
      */
     public function setCustomerAsLoggedIn($customer)
     {
@@ -318,6 +384,17 @@ class Session extends \Magento\Session\SessionManager
         return $this;
     }
 
+    /**
+     * @param CustomerDto $customer
+     * @return \Magento\Customer\Model\Session
+     */
+    public function setCustomerDtoAsLoggedIn($customer)
+    {
+        $this->setCustomerDto($customer);
+        $this->_eventManager->dispatch('customer_login', array('customer' => $this->getCustomer()));
+        return $this;
+    }
+
     /**
      * Authorization customer by identifier
      *
@@ -326,12 +403,13 @@ class Session extends \Magento\Session\SessionManager
      */
     public function loginById($customerId)
     {
-        $customer = $this->_createCustomer()->load($customerId);
-        if ($customer->getId()) {
-            $this->setCustomerAsLoggedIn($customer);
+        try {
+            $customer = $this->_customerService->getCustomer($customerId);
+            $this->setCustomerDtoAsLoggedIn($customer);
             return true;
+        } catch (\Exception $e) {
+            return false;
         }
-        return false;
     }
 
     /**
@@ -400,8 +478,10 @@ class Session extends \Magento\Session\SessionManager
      */
     protected function _logout()
     {
-        $this->setId(null);
-        $this->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID);
+        $this->_customer = null;
+        $this->_customerModel = null;
+        $this->setCustomerId(null);
+        $this->setCustomerGroupId(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID);
         $this->destroy(array('clear_storage' => false));
         return $this;
     }
@@ -441,14 +521,6 @@ class Session extends \Magento\Session\SessionManager
         return $this;
     }
 
-    /**
-     * @return \Magento\Customer\Model\Customer
-     */
-    protected function _createCustomer()
-    {
-        return $this->_customerFactory->create();
-    }
-
     /**
      * @return \Magento\UrlInterface
      */
diff --git a/app/code/Magento/Customer/Service/Entity/V1/Exception.php b/app/code/Magento/Customer/Service/Entity/V1/Exception.php
deleted file mode 100644
index 97596d6121a9e9666b0265fc8df6ea54494c903b..0000000000000000000000000000000000000000
--- a/app/code/Magento/Customer/Service/Entity/V1/Exception.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/**
- * Base service exception
- *
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-namespace Magento\Customer\Service\Entity\V1;
-
-class Exception extends \Exception
-{
-    /** Error codes */
-    const CODE_UNKNOWN                              = 0;
-    const CODE_ACCT_ALREADY_ACTIVE                  = 1;
-    const CODE_INVALID_RESET_TOKEN                  = 2;
-    const CODE_RESET_TOKEN_EXPIRED                  = 3;
-    const CODE_EMAIL_NOT_FOUND                      = 4;
-    const CODE_CONFIRMATION_NOT_NEEDED              = 5;
-    const CODE_CUSTOMER_ID_MISMATCH                 = 6;
-    const CODE_EMAIL_NOT_CONFIRMED                  = 7;
-    const CODE_INVALID_EMAIL_OR_PASSWORD            = 8;
-    const CODE_EMAIL_EXISTS                         = 9;
-    const CODE_INVALID_RESET_PASSWORD_LINK_TOKEN    = 10;
-    const CODE_ADDRESS_NOT_FOUND                    = 11;
-    const CODE_INVALID_ADDRESS_ID                   = 12;
-    const CODE_VALIDATION_FAILED                    = 13;
-    const CODE_INVALID_CUSTOMER_ID                  = 14;
-}
diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php
index bf3f4e52e5c929ed5a7a2ddd32b36d4fbba9e219..c813684461a48ebdbbc4e25edd01c23ed85ce0f5 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php
@@ -23,43 +23,56 @@
  */
 
 namespace Magento\Customer\Service\V1;
-use Magento\Customer\Service\Entity\V1\Exception;
+
+use Magento\Core\Model\StoreManagerInterface;
+use Magento\Customer\Model\Converter;
+use Magento\Customer\Model\Customer as CustomerModel;
+use Magento\Customer\Model\CustomerFactory;
+use Magento\Customer\Model\Metadata\Validator;
+use Magento\Event\ManagerInterface;
+use Magento\Exception\InputException;
+use Magento\Exception\AuthenticationException;
+use Magento\Exception\NoSuchEntityException;
+use Magento\Exception\StateException;
+use Magento\Math\Random;
 
 /**
- * Manipulate Customer Address Entities *
+ *  Handle various customer account actions
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class CustomerAccountService implements CustomerAccountServiceInterface
 {
-
-    /** @var \Magento\Customer\Model\CustomerFactory */
+    /** @var CustomerFactory */
     private $_customerFactory;
+
     /**
      * Core event manager proxy
      *
-     * @var \Magento\Event\ManagerInterface
+     * @var ManagerInterface
      */
-    private $_eventManager = null;
+    private $_eventManager;
 
-    /** @var \Magento\Core\Model\StoreManagerInterface */
+    /** @var StoreManagerInterface */
     private $_storeManager;
 
     /**
-     * @var \Magento\Math\Random
+     * @var Random
      */
     private $_mathRandom;
 
     /**
-     * @var \Magento\Customer\Model\Converter
+     * @var Converter
      */
     private $_converter;
 
     /**
-     * @var \Magento\Customer\Model\Metadata\Validator
+     * @var Validator
      */
     private $_validator;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\Response\CreateCustomerAccountResponseBuilder
+     * @var Dto\Response\CreateCustomerAccountResponseBuilder
      */
     private $_createCustomerAccountResponseBuilder;
 
@@ -76,25 +89,23 @@ class CustomerAccountService implements CustomerAccountServiceInterface
     /**
      * Constructor
      *
-     * @param \Magento\Customer\Model\CustomerFactory $customerFactory
-     * @param \Magento\Customer\Model\AddressFactory $addressFactory
-     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $eavMetadataService
-     * @param \Magento\Event\ManagerInterface $eventManager
-     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Math\Random $mathRandom
-     * @param \Magento\Customer\Model\Converter $converter
-     * @param \Magento\Customer\Model\Metadata\Validator $validator
-     * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
-     * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
-     * @param \Magento\Customer\Service\V1\Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder
+     * @param CustomerFactory $customerFactory
+     * @param ManagerInterface $eventManager
+     * @param StoreManagerInterface $storeManager
+     * @param Random $mathRandom
+     * @param Converter $converter
+     * @param Validator $validator
+     * @param Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder
+     * @param CustomerServiceInterface $customerService
+     * @param CustomerAddressServiceInterface $customerAddressService
      */
     public function __construct(
-        \Magento\Customer\Model\CustomerFactory $customerFactory,
-        \Magento\Event\ManagerInterface $eventManager,
-        \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Math\Random $mathRandom,
-        \Magento\Customer\Model\Converter $converter,
-        \Magento\Customer\Model\Metadata\Validator $validator,
+        CustomerFactory $customerFactory,
+        ManagerInterface $eventManager,
+        StoreManagerInterface $storeManager,
+        Random $mathRandom,
+        Converter $converter,
+        Validator $validator,
         Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder,
         CustomerServiceInterface $customerService,
         CustomerAddressServiceInterface $customerAddressService
@@ -112,28 +123,25 @@ class CustomerAccountService implements CustomerAccountServiceInterface
 
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function sendConfirmation($email)
     {
         $customer = $this->_customerFactory->create();
-        $customer->setWebsiteId($this->_storeManager->getStore()->getWebsiteId())->loadByEmail($email);
+        $websiteId = $this->_storeManager->getStore()->getWebsiteId();
+        $customer->setWebsiteId($websiteId)->loadByEmail($email);
         if (!$customer->getId()) {
-            throw new Exception('Wrong email.', Exception::CODE_EMAIL_NOT_FOUND);
+            throw (new NoSuchEntityException('email', $email))->addField('websiteId', $websiteId);
         }
         if ($customer->getConfirmation()) {
             $customer->sendNewAccountEmail('confirmation', '', $this->_storeManager->getStore()->getId());
         } else {
-            throw new Exception(
-                'This email does not require confirmation.',
-                Exception::CODE_CONFIRMATION_NOT_NEEDED
-            );
+            throw new StateException('No confirmation needed.', StateException::INVALID_STATE);
         }
     }
 
-
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function activateAccount($customerId, $key)
     {
@@ -143,29 +151,21 @@ class CustomerAccountService implements CustomerAccountServiceInterface
         // check if customer is inactive
         if ($customer->getConfirmation()) {
             if ($customer->getConfirmation() !== $key) {
-                throw new \Magento\Core\Exception('Wrong confirmation key.');
+                throw new StateException('Invalid confirmation token', StateException::INPUT_MISMATCH);
             }
-
             // activate customer
-            try {
-                $customer->setConfirmation(null);
-                $customer->save();
-            } catch (\Exception $e) {
-                throw new \Magento\Core\Exception('Failed to confirm customer account.');
-            }
+            $customer->setConfirmation(null);
+            $customer->save();
             $customer->sendNewAccountEmail('confirmed', '', $this->_storeManager->getStore()->getId());
         } else {
-            throw new Exception(
-                'Customer account is already active.',
-                Exception::CODE_ACCT_ALREADY_ACTIVE
-            );
+            throw new StateException('Account already active', StateException::INVALID_STATE);
         }
 
         return $this->_converter->createCustomerFromModel($customer);
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function authenticate($username, $password)
     {
@@ -175,16 +175,16 @@ class CustomerAccountService implements CustomerAccountServiceInterface
             $customerModel->authenticate($username, $password);
         } catch (\Magento\Core\Exception $e) {
             switch ($e->getCode()) {
-                case \Magento\Customer\Model\Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
-                    $code = Exception::CODE_EMAIL_NOT_CONFIRMED;
+                case CustomerModel::EXCEPTION_EMAIL_NOT_CONFIRMED:
+                    $code = AuthenticationException::EMAIL_NOT_CONFIRMED;
                     break;
-                case \Magento\Customer\Model\Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
-                    $code = Exception::CODE_INVALID_EMAIL_OR_PASSWORD;
+                case CustomerModel::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
+                    $code = AuthenticationException::INVALID_EMAIL_OR_PASSWORD;
                     break;
                 default:
-                    $code = Exception::CODE_UNKNOWN;
+                    $code = AuthenticationException::UNKNOWN;
             }
-            throw new Exception($e->getMessage(), $code, $e);
+            throw new AuthenticationException($e->getMessage(), $code, $e);
         }
 
         $this->_eventManager->dispatch('customer_login', array('customer'=>$customerModel));
@@ -193,7 +193,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken)
     {
@@ -201,7 +201,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function sendPasswordResetLink($email, $websiteId)
     {
@@ -210,20 +210,15 @@ class CustomerAccountService implements CustomerAccountServiceInterface
             ->loadByEmail($email);
 
         if (!$customer->getId()) {
-            throw new Exception(
-                'No customer found for the provided email and website ID.', Exception::CODE_EMAIL_NOT_FOUND);
-        }
-        try {
-            $newPasswordToken = $this->_mathRandom->getUniqueHash();
-            $customer->changeResetPasswordLinkToken($newPasswordToken);
-            $customer->sendPasswordResetConfirmationEmail();
-        } catch (\Exception $exception) {
-            throw new Exception($exception->getMessage(), Exception::CODE_UNKNOWN, $exception);
+            throw (new NoSuchEntityException('email', $email))->addField('websiteId', $websiteId);
         }
+        $newPasswordToken = $this->_mathRandom->getUniqueHash();
+        $customer->changeResetPasswordLinkToken($newPasswordToken);
+        $customer->sendPasswordResetConfirmationEmail();
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function resetPassword($customerId, $password, $resetToken)
     {
@@ -235,7 +230,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function createAccount(
         Dto\Customer $customer,
@@ -254,7 +249,15 @@ class CustomerAccountService implements CustomerAccountServiceInterface
                     ->create();
             }
         }
-        $customerId = $this->_customerService->saveCustomer($customer, $password);
+        try {
+            $customerId = $this->_customerService->saveCustomer($customer, $password);
+        } catch (\Magento\Customer\Exception $e) {
+            if ($e->getCode() === CustomerModel::EXCEPTION_EMAIL_EXISTS) {
+                throw new StateException('Provided email already exists.', StateException::INPUT_MISMATCH);
+            }
+            throw $e;
+        }
+
         $this->_customerAddressService->saveAddresses($customerId, $addresses);
 
         $customerModel = $this->_converter->getCustomerModel($customerId);
@@ -280,7 +283,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function validateCustomerData(Dto\Customer $customer, array $attributes)
     {
@@ -290,6 +293,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface
             'customer'
         );
 
+        // FIXME: $customerErrors is a boolean but we are treating it as an array here
         if ($customerErrors !== true) {
             return array(
                 'error'     => -1,
@@ -311,29 +315,39 @@ class CustomerAccountService implements CustomerAccountServiceInterface
 
 
     /**
+     * Validate the Reset Password Token for a customer.
+     *
      * @param $customerId
      * @param $resetPasswordLinkToken
-     * @return \Magento\Customer\Model\Customer
-     * @throws Exception
+     * @return CustomerModel
+     * @throws \Magento\Exception\StateException if token is expired or mismatched
+     * @throws \Magento\Exception\InputException if token or customer id is invalid
+     * @throws \Magento\Exception\NoSuchEntityException if customer doesn't exist
      */
     private function _validateResetPasswordToken($customerId, $resetPasswordLinkToken)
     {
-        if (!is_int($customerId)
-            || !is_string($resetPasswordLinkToken)
-            || empty($resetPasswordLinkToken)
-            || empty($customerId)
-            || $customerId < 0
-        ) {
-            throw new Exception('Invalid password reset token.', Exception::CODE_INVALID_RESET_TOKEN);
+        if (!is_int($customerId) || empty($customerId) || $customerId < 0) {
+            throw InputException::create(
+                InputException::INVALID_FIELD_VALUE,
+                'customerId',
+                $customerId
+            );
+        }
+        if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
+            throw InputException::create(
+                InputException::INVALID_FIELD_VALUE,
+                'resetPasswordLinkToken',
+                $resetPasswordLinkToken
+            );
         }
 
         $customerModel = $this->_converter->getCustomerModel($customerId);
 
         $customerToken = $customerModel->getRpToken();
-        if (strcmp($customerToken, $resetPasswordLinkToken) !== 0
-            || $customerModel->isResetPasswordLinkTokenExpired($customerId)
-        ) {
-            throw new Exception('Your password reset link has expired.', Exception::CODE_RESET_TOKEN_EXPIRED);
+        if (strcmp($customerToken, $resetPasswordLinkToken) !== 0) {
+            throw new StateException('Reset password token mismatch.', StateException::INPUT_MISMATCH);
+        } else if ($customerModel->isResetPasswordLinkTokenExpired($customerId)) {
+            throw new StateException('Reset password token expired.', StateException::EXPIRED);
         }
 
         return $customerModel;
diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php
index 510cb3a97423b1a09f491f18e7a763f8adb3b112..f20a4fd933999ae58ecc9d5c37f8fcb00bc35f86 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php
@@ -41,13 +41,16 @@ interface CustomerAccountServiceInterface
     /**
      * Create Customer Account
      *
-     * @param \Magento\Customer\Service\V1\Dto\Customer $customer
-     * @param \Magento\Customer\Service\V1\Dto\Address[] $addresses
+     * @param Dto\Customer $customer
+     * @param Dto\Address[] $addresses
      * @param string $password
      * @param string $confirmationBackUrl
      * @param string $registeredBackUrl
      * @param int $storeId
      * @return Dto\Response\CreateCustomerAccountResponse
+     * @throws \Exception If something goes wrong during save
+     * @throws \Magento\Exception\InputException If bad input is provided
+     * @throws \Magento\Exception\StateException If the provided email is already used
      */
     public function createAccount(
         Dto\Customer $customer,
@@ -63,9 +66,11 @@ interface CustomerAccountServiceInterface
      *
      * @param int $customerId
      * @param string $key
-     * @throws \Magento\Customer\Service\Entity\V1\Exception If customerId is invalid, does not exist, or customer account was already active
-     * @throws \Magento\Core\Exception If there is an issue with supplied $customerId or $key
-     * @return \Magento\Customer\Service\V1\Dto\Customer
+     * @return Dto\Customer
+     * @throws \Magento\Exception\NoSuchEntityException If customer doesn't exist
+     * @throws \Magento\Exception\StateException
+     *      StateException::INPUT_MISMATCH if key doesn't match expected.
+     *      StateException::INVALID_STATE_CHANGE if account already active.
      */
     public function activateAccount($customerId, $key);
 
@@ -74,8 +79,8 @@ interface CustomerAccountServiceInterface
      *
      * @param string $username username in plain-text
      * @param string $password password in plain-text
-     * @throws \Magento\Customer\Service\Entity\V1\Exception if unable to login due to issue with username or password or others
-     * @return \Magento\Customer\Service\V1\Dto\Customer
+     * @return Dto\Customer
+     * @throws \Magento\Exception\AuthenticationException if unable to authenticate
      */
     public function authenticate($username, $password);
 
@@ -84,7 +89,10 @@ interface CustomerAccountServiceInterface
      *
      * @param int $customerId
      * @param string $resetPasswordLinkToken
-     * @throws \Magento\Customer\Service\Entity\V1\Exception if expired or invalid
+     * @return void
+     * @throws \Magento\Exception\StateException if token is expired or mismatched
+     * @throws \Magento\Exception\InputException if token or customer id is invalid
+     * @throws \Magento\Exception\NoSuchEntityException if customer doesn't exist
      */
     public function validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken);
 
@@ -93,7 +101,8 @@ interface CustomerAccountServiceInterface
      *
      * @param string $email
      * @param int $websiteId
-     * @throws \Magento\Customer\Service\Entity\V1\Exception
+     * @return void
+     * @throws \Magento\Exception\NoSuchEntityException
      */
     public function sendPasswordResetLink($email, $websiteId);
 
@@ -104,6 +113,10 @@ interface CustomerAccountServiceInterface
      * @param int $customerId
      * @param string $password
      * @param string $resetToken
+     * @return void
+     * @throws \Magento\Exception\StateException if token is expired or mismatched
+     * @throws \Magento\Exception\InputException if token or customer id is invalid
+     * @throws \Magento\Exception\NoSuchEntityException if customer doesn't exist
      */
     public function resetPassword($customerId, $password, $resetToken);
 
@@ -111,15 +124,17 @@ interface CustomerAccountServiceInterface
      * Send Confirmation email
      *
      * @param string $email email address of customer
-     * @throws Entity\V1\Exception if error occurs getting customerId
+     * @return void
+     * @throws \Magento\Exception\NoSuchEntityException if no customer found for provided email
+     * @throws \Magento\Exception\StateException if confirmation is not needed
      */
     public function sendConfirmation($email);
 
     /**
      * Validate customer entity
      *
-     * @param \Magento\Customer\Service\V1\Dto\Customer $customer
-     * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] $attributes
+     * @param Dto\Customer $customer
+     * @param Dto\Eav\AttributeMetadata[] $attributes
      * @return array|bool
      */
     public function validateCustomerData(Dto\Customer $customer, array $attributes);
diff --git a/app/code/Magento/Customer/Service/V1/CustomerAddressService.php b/app/code/Magento/Customer/Service/V1/CustomerAddressService.php
index cc385b75d36308eb23588a209e175ebc677f01f1..cc82f53fde33305f0f3259547bdda3ac17b75a04 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerAddressService.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerAddressService.php
@@ -24,9 +24,15 @@
 
 namespace Magento\Customer\Service\V1;
 
-use Magento\Customer\Service\Entity\V1\AggregateException;
-use Magento\Customer\Service\Entity\V1\Exception;
+use Magento\Customer\Model\Address as CustomerAddressModel;
+use Magento\Exception\NoSuchEntityException;
+use Magento\Exception\InputException;
 
+/**
+ * Service related to Customer Address related functions
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
 class CustomerAddressService implements CustomerAddressServiceInterface
 {
     /** @var \Magento\Customer\Model\AddressFactory */
@@ -38,45 +44,47 @@ class CustomerAddressService implements CustomerAddressServiceInterface
     private $_converter;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\RegionBuilder
+     * @var Dto\RegionBuilder
      */
     private $_regionBuilder;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\AddressBuilder
+     * @var Dto\AddressBuilder
      */
     private $_addressBuilder;
 
+    /**
+     * Directory data
+     *
+     * @var \Magento\Directory\Helper\Data
+     */
+    protected $_directoryData;
 
     /**
      * Constructor
      *
-     * @param \Magento\Customer\Model\CustomerFactory $customerFactory
      * @param \Magento\Customer\Model\AddressFactory $addressFactory
-     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $eavMetadataService
-     * @param \Magento\Event\ManagerInterface $eventManager
-     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Math\Random $mathRandom
      * @param \Magento\Customer\Model\Converter $converter
-     * @param \Magento\Customer\Model\Metadata\Validator $validator
-     * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
-     * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
-     * @param \Magento\Customer\Service\V1\Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder
+     * @param Dto\RegionBuilder $regionBuilder
+     * @param Dto\AddressBuilder $addressBuilder
+     * @param \Magento\Directory\Helper\Data $directoryData
      */
     public function __construct(
         \Magento\Customer\Model\AddressFactory $addressFactory,
         \Magento\Customer\Model\Converter $converter,
         Dto\RegionBuilder $regionBuilder,
-        Dto\AddressBuilder $addressBuilder
+        Dto\AddressBuilder $addressBuilder,
+        \Magento\Directory\Helper\Data $directoryData
     ) {
         $this->_addressFactory = $addressFactory;
         $this->_converter = $converter;
         $this->_regionBuilder = $regionBuilder;
         $this->_addressBuilder = $addressBuilder;
+        $this->_directoryData = $directoryData;
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getAddresses($customerId)
     {
@@ -87,7 +95,7 @@ class CustomerAddressService implements CustomerAddressServiceInterface
         $defaultShippingId = $customer->getDefaultShipping();
 
         $result = array();
-        /** @var $address \Magento\Customer\Model\Address */
+        /** @var $address CustomerAddressModel */
         foreach ($addresses as $address) {
             $result[] = $this->_createAddress(
                 $address,
@@ -99,7 +107,7 @@ class CustomerAddressService implements CustomerAddressServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getDefaultBillingAddress($customerId)
     {
@@ -117,7 +125,7 @@ class CustomerAddressService implements CustomerAddressServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getDefaultShippingAddress($customerId)
     {
@@ -134,19 +142,18 @@ class CustomerAddressService implements CustomerAddressServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
-    public function getAddressById($customerId, $addressId)
+    public function getAddressById($addressId)
     {
         //TODO: use cache MAGETWO-16862
-        $customer = $this->_converter->getCustomerModel($customerId);
-        $address = $customer->getAddressById($addressId);
+        $address = $this->_addressFactory->create();
+        $address->load($addressId);
         if (!$address->getId()) {
-            throw new Exception(
-                'Address id ' . $addressId . ' not found',
-                Exception::CODE_ADDRESS_NOT_FOUND
-            );
+            throw new NoSuchEntityException('addressId', $addressId);
         }
+        $customer = $this->_converter->getCustomerModel($address->getCustomerId());
+
         return $this->_createAddress(
             $address,
             $customer->getDefaultBilling(),
@@ -155,93 +162,31 @@ class CustomerAddressService implements CustomerAddressServiceInterface
     }
 
     /**
-     * Create address based on model
-     *
-     * @param \Magento\Customer\Model\Address $addressModel
-     * @param int $defaultBillingId
-     * @param int $defaultShippingId
-     * @return \Magento\Customer\Service\V1\Dto\Address
-     */
-    private function _createAddress(\Magento\Customer\Model\Address $addressModel,
-                                      $defaultBillingId, $defaultShippingId
-    ) {
-        $addressId = $addressModel->getId();
-        $validAttributes = array_merge(
-            $addressModel->getDefaultAttributeCodes(),
-            [
-                'id', 'region_id', 'region', 'street', 'vat_is_valid',
-                'default_billing', 'default_shipping',
-                //TODO: create VAT object at MAGETWO-16860
-                'vat_request_id', 'vat_request_date', 'vat_request_success'
-            ]
-        );
-        $addressData = [];
-        foreach ($addressModel->getAttributes() as $attribute) {
-            $code = $attribute->getAttributeCode();
-            if (!in_array($code, $validAttributes) && $addressModel->getData($code) !== null) {
-                $addressData[$code] = $addressModel->getData($code);
-            }
-        }
-
-        $region = $this->_regionBuilder->setRegionCode($addressModel->getRegionCode())
-            ->setRegion($addressModel->getRegion())
-            ->setRegionId($addressModel->getRegionId())
-            ->create();
-        $this->_addressBuilder->populateWithArray(array_merge($addressData, [
-            'street' => $addressModel->getStreet(),
-            'id' => $addressId,
-            'default_billing' => $addressId === $defaultBillingId,
-            'default_shipping' => $addressId === $defaultShippingId,
-            'customer_id' => $addressModel->getCustomerId(),
-            'region' => $region
-        ]));
-
-        $retValue = $this->_addressBuilder->create();
-        return $retValue;
-    }
-
-
-    /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
-    public function deleteAddressFromCustomer($customerId, $addressId)
+    public function deleteAddress($addressId)
     {
-        if (!$addressId) {
-            throw new Exception('Invalid addressId', Exception::CODE_INVALID_ADDRESS_ID);
-        }
-
         $address = $this->_addressFactory->create();
         $address->load($addressId);
 
         if (!$address->getId()) {
-            throw new Exception(
-                'Address id ' . $addressId . ' not found',
-                Exception::CODE_ADDRESS_NOT_FOUND
-            );
-        }
-
-        // Validate address_id <=> customer_id
-        if ($address->getCustomerId() != $customerId) {
-            throw new Exception(
-                'The address does not belong to this customer',
-                Exception::CODE_CUSTOMER_ID_MISMATCH
-            );
+            throw new NoSuchEntityException('addressId', $addressId);
         }
 
         $address->delete();
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function saveAddresses($customerId, array $addresses)
     {
         $customerModel = $this->_converter->getCustomerModel($customerId);
         $addressModels = [];
 
-        $aggregateException = new AggregateException("All validation exceptions for all addresses.",
-            Exception::CODE_VALIDATION_FAILED);
-        foreach ($addresses as $address) {
+        $inputException = new InputException();
+        for ($i = 0; $i < count($addresses); $i++) {
+            $address = $addresses[$i];
             $addressModel = null;
             if ($address->getId()) {
                 $addressModel = $customerModel->getAddressItemById($address->getId());
@@ -252,38 +197,18 @@ class CustomerAddressService implements CustomerAddressServiceInterface
             }
             $this->_updateAddressModel($addressModel, $address);
 
-            $validationErrors = $addressModel->validate();
-            if ($validationErrors !== true) {
-                $aggregateException->pushException(
-                    new Exception(
-                        'There were one or more errors validating the address with id ' . $address->getId(),
-                        Exception::CODE_VALIDATION_FAILED,
-                        new \Magento\Validator\ValidatorException([$validationErrors])
-                    )
-                );
-                continue;
-            }
+            $inputException = $this->_validate($addressModel, $inputException, $i);
             $addressModels[] = $addressModel;
         }
-        if ($aggregateException->hasExceptions()) {
-            throw $aggregateException;
+        if ($inputException->getErrors()) {
+            throw $inputException;
         }
         $addressIds = [];
 
+        /** @var \Magento\Customer\Model\Address $addressModel */
         foreach ($addressModels as $addressModel) {
-            try {
-                $addressModel->save();
-                $addressIds[] = $addressModel->getId();
-            } catch (\Exception $e) {
-                switch ($e->getCode()) {
-                    case \Magento\Customer\Model\Customer::EXCEPTION_EMAIL_EXISTS:
-                        $code = Exception::CODE_EMAIL_EXISTS;
-                        break;
-                    default:
-                        $code = Exception::CODE_UNKNOWN;
-                }
-                throw new Exception($e->getMessage(), $code, $e);
-            }
+            $addressModel->save();
+            $addressIds[] = $addressModel->getId();
         }
 
         return $addressIds;
@@ -292,11 +217,10 @@ class CustomerAddressService implements CustomerAddressServiceInterface
     /**
      * Updates an Address Model based on information from an Address DTO.
      *
-     * @param \Magento\Customer\Model\Address $addressModel
-     * @param \Magento\Customer\Service\V1\Dto\Address $address
-     * return null
+     * @param CustomerAddressModel $addressModel
+     * @param Dto\Address $address
      */
-    private function _updateAddressModel(\Magento\Customer\Model\Address $addressModel, Dto\Address $address)
+    private function _updateAddressModel(CustomerAddressModel $addressModel, Dto\Address $address)
     {
         // Set all attributes
         foreach ($address->getAttributes() as $attributeCode => $attributeData) {
@@ -320,4 +244,161 @@ class CustomerAddressService implements CustomerAddressServiceInterface
         }
     }
 
+    /**
+     * Create address based on model
+     *
+     * @param CustomerAddressModel $addressModel
+     * @param int                  $defaultBillingId
+     * @param int                  $defaultShippingId
+     * @return Dto\Address
+     */
+    private function _createAddress(
+        CustomerAddressModel $addressModel,
+        $defaultBillingId,
+        $defaultShippingId
+    ) {
+        $addressId = $addressModel->getId();
+        $validAttributes = array_merge(
+            $addressModel->getDefaultAttributeCodes(),
+            [
+                'id',
+                'region_id',
+                'region',
+                'street',
+                'vat_is_valid',
+                'default_billing',
+                'default_shipping',
+                //TODO: create VAT object at MAGETWO-16860
+                'vat_request_id',
+                'vat_request_date',
+                'vat_request_success'
+            ]
+        );
+        $addressData = [];
+        foreach ($addressModel->getAttributes() as $attribute) {
+            $code = $attribute->getAttributeCode();
+            if (!in_array($code, $validAttributes) && $addressModel->getData($code) !== null) {
+                $addressData[$code] = $addressModel->getData($code);
+            }
+        }
+
+        $this->_addressBuilder->populateWithArray(
+            array_merge(
+                $addressData,
+                [
+                    'street'           => $addressModel->getStreet(),
+                    'id'               => $addressId,
+                    'default_billing'  => $addressId === $defaultBillingId,
+                    'default_shipping' => $addressId === $defaultShippingId,
+                    'customer_id'      => $addressModel->getCustomerId(),
+                    'region'           => [
+                        'region_code' => $addressModel->getRegionCode(),
+                        'region' => $addressModel->getRegion(),
+                        'region_id' => $addressModel->getRegionId(),
+                    ],
+                ]
+            )
+        );
+
+        $retValue = $this->_addressBuilder->create();
+        return $retValue;
+    }
+
+    /**
+     * Validate Customer Addrresss attribute values.
+     *
+     * @param CustomerAddressModel $customerAddressModel the model to validate
+     * @param InputException       $exception            the exception to add errors to
+     * @param int                  $index                the index of the address being saved
+     * @return InputException
+     *
+     * @SuppressWarnings(PHPMD.NPathComplexity)
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+     */
+    private function _validate(CustomerAddressModel $customerAddressModel, InputException $exception, $index)
+    {
+        if ($customerAddressModel->getShouldIgnoreValidation()) {
+            return $exception;
+        }
+
+        if (!\Zend_Validate::is($customerAddressModel->getFirstname(), 'NotEmpty')) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'firstname',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        if (!\Zend_Validate::is($customerAddressModel->getLastname(), 'NotEmpty')) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'lastname',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        if (!\Zend_Validate::is($customerAddressModel->getStreet(1), 'NotEmpty')) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'street',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        if (!\Zend_Validate::is($customerAddressModel->getCity(), 'NotEmpty')) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'city',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        if (!\Zend_Validate::is($customerAddressModel->getTelephone(), 'NotEmpty')) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'telephone',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        $_havingOptionalZip = $this->_directoryData->getCountriesWithOptionalZip();
+        if (!in_array($customerAddressModel->getCountryId(), $_havingOptionalZip)
+            && !\Zend_Validate::is($customerAddressModel->getPostcode(), 'NotEmpty')
+        ) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'postcode',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        if (!\Zend_Validate::is($customerAddressModel->getCountryId(), 'NotEmpty')) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'countryId',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        if ($customerAddressModel->getCountryModel()->getRegionCollection()->getSize()
+            && !\Zend_Validate::is($customerAddressModel->getRegionId(), 'NotEmpty')
+            && $this->_directoryData->isRegionRequired($customerAddressModel->getCountryId())
+        ) {
+            $exception->addError(
+                InputException::REQUIRED_FIELD,
+                'regionId',
+                null,
+                ['index' => $index]
+            );
+        }
+
+        return $exception;
+    }
 }
diff --git a/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php
index 7f4a619a0b7c261e5b2a1de2b22b0ba239912531..bc3a0b34c4e1c3d734fbb5d00135ecbec5291eec 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php
@@ -23,8 +23,6 @@
  */
 
 namespace Magento\Customer\Service\V1;
-use Magento\Customer\Service\Entity\V1\AggregateException;
-use Magento\Customer\Service\Entity\V1\Exception;
 
 /**
  * Manipulate Customer Address Entities *
@@ -35,8 +33,8 @@ interface CustomerAddressServiceInterface
      * Retrieve all Customer Addresses
      *
      * @param int $customerId,
-     * @return \Magento\Customer\Service\V1\Dto\Address[]
-     * @throws Exception
+     * @return Dto\Address[]
+     * @throws \Magento\Exception\NoSuchEntityException if the customer Id is invalid
      */
     public function getAddresses($customerId);
 
@@ -44,8 +42,8 @@ interface CustomerAddressServiceInterface
      * Retrieve default billing address
      *
      * @param int $customerId
-     * @return \Magento\Customer\Service\V1\Dto\Address
-     * @throws Exception
+     * @return Dto\Address
+     * @throws \Magento\Exception\NoSuchEntityException if the customer Id is invalid
      */
     public function getDefaultBillingAddress($customerId);
 
@@ -53,29 +51,27 @@ interface CustomerAddressServiceInterface
      * Retrieve default shipping address
      *
      * @param int $customerId
-     * @return \Magento\Customer\Service\V1\Dto\Address
-     * @throws Exception
+     * @return Dto\Address
+     * @throws \Magento\Exception\NoSuchEntityException if the customer Id is invalid
      */
     public function getDefaultShippingAddress($customerId);
 
     /**
      * Retrieve address by id
      *
-     * @param int $customerId
      * @param int $addressId
-     * @return \Magento\Customer\Service\V1\Dto\Address
-     * @throws Exception
+     * @return Dto\Address
+     * @throws \Magento\Exception\NoSuchEntityException If no address can be found for the provided id.
      */
-    public function getAddressById($customerId, $addressId);
+    public function getAddressById($addressId);
 
     /**
      * Removes an address by id.
      *
-     * @param int $customerId
      * @param int $addressId
-     * @throws Exception if the address does not belong to the given customer
+     * @throws \Magento\Exception\NoSuchEntityException If no address can be found for the provided id.
      */
-    public function deleteAddressFromCustomer($customerId, $addressId);
+    public function deleteAddress($addressId);
 
     /**
      * Insert and/or update a list of addresses.
@@ -89,11 +85,11 @@ interface CustomerAddressServiceInterface
      * This doesn't support partial updates to addresses, meaning
      * that a full set of data must be provided with each Address
      *
-     * @param int                 $customerId
-     * @param \Magento\Customer\Service\V1\Dto\Address[] $addresses
-     *
-     * @throws AggregateException if there are validation errors.
-     * @throws Exception If customerId is not found or other error occurs.
+     * @param int $customerId
+     * @param Dto\Address[] $addresses
+     * @throws \Magento\Exception\InputException if there are validation errors.
+     * @throws \Magento\Exception\NoSuchEntityException If customer with customerId is not found.
+     * @throws \Exception if there were issues during the save operation
      * @return int[] address ids
      */
     public function saveAddresses($customerId, array $addresses);
diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupService.php b/app/code/Magento/Customer/Service/V1/CustomerGroupService.php
index e001c415359271f42a994f2a97d3c96911174973..4b01a680922a79ad3a6473a6e97747ffe9981a96 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerGroupService.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerGroupService.php
@@ -25,40 +25,43 @@
  */
 namespace Magento\Customer\Service\V1;
 
-use Magento\Customer\Service\V1\Dto\SearchCriteria;
-use Magento\Customer\Service\Entity\V1\Exception;
+use Magento\Core\Model\Store\Config as StoreConfig;
+use Magento\Customer\Model\Group as CustomerGroupModel;
+use Magento\Customer\Model\GroupFactory;
+use Magento\Customer\Model\Resource\Group\Collection;
+use Magento\Exception\NoSuchEntityException;
 
 class CustomerGroupService implements CustomerGroupServiceInterface
 {
     /**
-     * @var \Magento\Customer\Model\GroupFactory
+     * @var GroupFactory
      */
     private $_groupFactory;
 
     /**
-     * @var \Magento\Core\Model\Store\Config
+     * @var StoreConfig
      */
     private $_storeConfig;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\SearchResultsBuilder
+     * @var Dto\SearchResultsBuilder
      */
     private $_searchResultsBuilder;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder
+     * @var Dto\CustomerGroupBuilder
      */
     private $_customerGroupBuilder;
 
     /**
-     * @param \Magento\Customer\Model\GroupFactory $groupFactory
-     * @param \Magento\Core\Model\Store\Config $storeConfig
-     * @param \Magento\Customer\Service\V1\Dto\SearchResultsBuilder $searchResultsBuilder
-     * @param \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $customerGroupBuilder
+     * @param GroupFactory $groupFactory
+     * @param StoreConfig $storeConfig
+     * @param Dto\SearchResultsBuilder $searchResultsBuilder
+     * @param Dto\CustomerGroupBuilder $customerGroupBuilder
      */
     public function __construct(
-        \Magento\Customer\Model\GroupFactory $groupFactory,
-        \Magento\Core\Model\Store\Config $storeConfig,
+        GroupFactory $groupFactory,
+        StoreConfig $storeConfig,
         Dto\SearchResultsBuilder $searchResultsBuilder,
         Dto\CustomerGroupBuilder $customerGroupBuilder
     ) {
@@ -69,12 +72,12 @@ class CustomerGroupService implements CustomerGroupServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getGroups($includeNotLoggedIn = true, $taxClassId = null)
     {
         $groups = array();
-        /** @var \Magento\Customer\Model\Resource\Group\Collection $collection */
+        /** @var Collection $collection */
         $collection = $this->_groupFactory->create()->getCollection();
         if (!$includeNotLoggedIn) {
             $collection->setRealGroupsFilter();
@@ -82,7 +85,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface
         if (!is_null($taxClassId)) {
             $collection->addFieldToFilter('tax_class_id', $taxClassId);
         }
-        /** @var \Magento\Customer\Model\Group $group */
+        /** @var CustomerGroupModel $group */
         foreach ($collection as $group) {
             $this->_customerGroupBuilder->setId($group->getId())
                 ->setCode($group->getCode())
@@ -93,37 +96,40 @@ class CustomerGroupService implements CustomerGroupServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
-    public function searchGroups(SearchCriteria $searchCriteria)
+    public function searchGroups(Dto\SearchCriteria $searchCriteria)
     {
         $this->_searchResultsBuilder->setSearchCriteria($searchCriteria);
 
         $groups = array();
-        /** @var \Magento\Customer\Model\Resource\Group\Collection $collection */
+        /** @var Collection $collection */
         $collection = $this->_groupFactory->create()->getCollection();
         foreach ($searchCriteria->getFilters() as $filter) {
             $collection->addFilter($filter->getField(), $filter->getValue(), $filter->getConditionType());
         }
         $this->_searchResultsBuilder->setTotalCount($collection->getSize());
-        foreach ($searchCriteria->getSortOrders() as $field => $direction) {
-            switch($field) {
-                case 'id' :
-                    $field = 'customer_group_id';
-                    break;
-                case 'code':
-                    $field = 'customer_group_code';
-                    break;
-                case "tax_class_id":
-                default:
-                    break;
+        $sortOrders = $searchCriteria->getSortOrders();
+        if ($sortOrders) {
+            foreach ($searchCriteria->getSortOrders() as $field => $direction) {
+                switch($field) {
+                    case 'id' :
+                        $field = 'customer_group_id';
+                        break;
+                    case 'code':
+                        $field = 'customer_group_code';
+                        break;
+                    case "tax_class_id":
+                    default:
+                        break;
+                }
+                $collection->addOrder($field, $direction == Dto\SearchCriteria::SORT_ASC ? 'ASC' : 'DESC');
             }
-            $collection->addOrder($field, $direction == SearchCriteria::SORT_ASC ? 'ASC' : 'DESC');
         }
         $collection->setCurPage($searchCriteria->getCurrentPage());
         $collection->setPageSize($searchCriteria->getPageSize());
 
-        /** @var \Magento\Customer\Model\Group $group */
+        /** @var CustomerGroupModel $group */
         foreach ($collection as $group) {
             $this->_customerGroupBuilder->setId($group->getId())
                 ->setCode($group->getCode())
@@ -135,7 +141,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getGroup($groupId)
     {
@@ -143,7 +149,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface
         $customerGroup->load($groupId);
         // Throw exception if a customer group does not exist
         if (is_null($customerGroup->getId())) {
-            throw new Exception(__('groupId ' . $groupId . ' does not exist.'));
+            throw new NoSuchEntityException('groupId', $groupId);
         }
         $this->_customerGroupBuilder->setId($customerGroup->getId())
             ->setCode($customerGroup->getCode())
@@ -152,16 +158,21 @@ class CustomerGroupService implements CustomerGroupServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getDefaultGroup($storeId)
     {
-        $groupId = $this->_storeConfig->getConfig(\Magento\Customer\Model\Group::XML_PATH_DEFAULT_ID, $storeId);
-        return $this->getGroup($groupId);
+        $groupId = $this->_storeConfig->getConfig(CustomerGroupModel::XML_PATH_DEFAULT_ID, $storeId);
+        try {
+            return $this->getGroup($groupId);
+        } catch (NoSuchEntityException $e) {
+            $e->addField('storeId', $storeId);
+            throw $e;
+        }
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function canDelete($groupId)
     {
@@ -171,7 +182,7 @@ class CustomerGroupService implements CustomerGroupServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function saveGroup(Dto\CustomerGroup $group)
     {
@@ -186,18 +197,14 @@ class CustomerGroupService implements CustomerGroupServiceInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function deleteGroup($groupId)
     {
-        try {
-            // Get group so we can throw an exception if it doesn't exist
-            $this->getGroup($groupId);
-            $customerGroup = $this->_groupFactory->create();
-            $customerGroup->setId($groupId);
-            $customerGroup->delete();
-        } catch (\Exception $e) {
-            throw new Exception($e->getMessage(), $e->getCode(), $e);
-        }
+        // Get group so we can throw an exception if it doesn't exist
+        $this->getGroup($groupId);
+        $customerGroup = $this->_groupFactory->create();
+        $customerGroup->setId($groupId);
+        $customerGroup->delete();
     }
 }
diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php
index fae88d4d955353f1a60f4a8462589fc2f712971c..d9787eb92ef7a4a642323ae2593c94b65097accb 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php
@@ -25,9 +25,7 @@
  */
 namespace Magento\Customer\Service\V1;
 
-use Magento\Customer\Service\V1\Dto\CustomerGroup;
-use Magento\Customer\Service\V1\Dto\SearchCriteria;
-use Magento\Validator\Test\True;
+use Magento\Exception\NoSuchEntityException;
 
 interface CustomerGroupServiceInterface
 {
@@ -44,14 +42,14 @@ interface CustomerGroupServiceInterface
      * @param boolean $includeNotLoggedIn
      * @param int $taxClassId
      *
-     * @return \Magento\Customer\Service\V1\Dto\CustomerGroup[]
+     * @return Dto\CustomerGroup[]
      */
     public function getGroups($includeNotLoggedIn = true, $taxClassId = null);
 
     /**
-     * @param \Magento\Customer\Service\V1\Dto\SearchCriteria $searchCriteria
+     * @param Dto\SearchCriteria $searchCriteria
      *
-     * @return \Magento\Customer\Service\V1\Dto\SearchResults
+     * @return Dto\SearchResults
      */
     public function searchGroups(Dto\SearchCriteria $searchCriteria);
 
@@ -59,15 +57,15 @@ interface CustomerGroupServiceInterface
      * Get a customer group by group ID.
      *
      * @param int $groupId
-     * @throws \Magento\Customer\Service\Entity\V1\Exception if groupId is not found
-     * @return \Magento\Customer\Service\V1\Dto\CustomerGroup
+     * @throws NoSuchEntityException if $groupId is not found
+     * @return Dto\CustomerGroup
      */
     public function getGroup($groupId);
 
     /**
      * @param int $storeId
-     *
-     * @return \Magento\Customer\Service\V1\Dto\CustomerGroup
+     * @throws NoSuchEntityException if default group for $storeId is not found
+     * @return Dto\CustomerGroup
      */
     public function getDefaultGroup($storeId);
 
@@ -79,15 +77,16 @@ interface CustomerGroupServiceInterface
     public function canDelete($groupId);
 
     /**
-     * @param \Magento\Customer\Service\V1\Dto\CustomerGroup $group
-     *
+     * @param Dto\CustomerGroup $group
+     * @throws \Exception if something goes wrong during save
      * @return int customer group ID
      */
-    public function saveGroup(CustomerGroup $group);
+    public function saveGroup(Dto\CustomerGroup $group);
 
     /**
      * @param int $groupId
-     *
+     * @throws NoSuchEntityException if $groupId is not found
+     * @throws \Exception if something goes wrong during delete
      * @return null
      */
     public function deleteGroup($groupId);
diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php
index a9e9cd5d702dc4c4ab561e4c0f4da1700573bf2d..1372bbe0bdbf01f288d9e73cbe77a6c1b45eea4b 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php
@@ -25,7 +25,7 @@
  */
 namespace Magento\Customer\Service\V1;
 
-use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
 
 class CustomerMetadataService implements CustomerMetadataServiceInterface
 {
@@ -48,12 +48,12 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
     private $_storeManager;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\Eav\OptionBuilder
+     * @var Dto\Eav\OptionBuilder
      */
     private $_optionBuilder;
 
     /**
-     * @var \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadataBuilder
+     * @var Dto\Eav\AttributeMetadataBuilder
      */
     private $_attributeMetadataBuilder;
 
@@ -61,15 +61,15 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
      * @param \Magento\Eav\Model\Config $eavConfig
      * @param \Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory $attrFormCollectionFactory
      * @param \Magento\Core\Model\StoreManager $storeManager
-     * @param \Magento\Customer\Service\V1\Dto\Eav\OptionBuilder $optionBuilder
-     * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder
+     * @param Dto\Eav\OptionBuilder $optionBuilder
+     * @param Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder
      */
     public function __construct(
         \Magento\Eav\Model\Config $eavConfig,
         \Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory $attrFormCollectionFactory,
         \Magento\Core\Model\StoreManager $storeManager,
-        \Magento\Customer\Service\V1\Dto\Eav\OptionBuilder $optionBuilder,
-        \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder
+        Dto\Eav\OptionBuilder $optionBuilder,
+        Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder
     ) {
         $this->_eavConfig = $eavConfig;
         $this->_cache = [];
@@ -84,7 +84,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
      *
      * @param   mixed $entityType
      * @param   mixed $attributeCode
-     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata
+     * @return Dto\Eav\AttributeMetadata
      */
     public function getAttributeMetadata($entityType, $attributeCode)
     {
@@ -93,7 +93,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
             return $dtoCache[$attributeCode];
         }
 
-        /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute */
+        /** @var AbstractAttribute $attribute */
         $attribute = $this->_eavConfig->getAttribute($entityType, $attributeCode);
         $attributeMetadata = $this->_createMetadataAttribute($attribute);
         $dtoCache[$attributeCode] = $attributeMetadata;
@@ -106,7 +106,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
      * @param string $entityType
      * @param int $attributeSetId
      * @param int $storeId
-     * @return AttributeMetadata[]
+     * @return Dto\Eav\AttributeMetadata[]
      */
     public function getAllAttributeSetMetadata($entityType, $attributeSetId = 0, $storeId = null)
     {
@@ -131,7 +131,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
      *
      * @param $entityType
      * @param $formCode
-     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[]
+     * @return Dto\Eav\AttributeMetadata[]
      */
     public function getAttributes($entityType, $formCode)
     {
@@ -143,6 +143,40 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
         return $attributes;
     }
 
+    /**
+     * @inheritdoc
+     */
+    public function getCustomerAttributeMetadata($attributeCode)
+    {
+        return $this->getAttributeMetadata('customer', $attributeCode);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function getAllCustomerAttributeMetadata()
+    {
+        return $this->getAllAttributeSetMetadata('customer', self::CUSTOMER_ATTRIBUTE_SET_ID);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function getAddressAttributeMetadata($attributeCode)
+    {
+        return $this->getAttributeMetadata('customer_address', $attributeCode);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function getAllAddressAttributeMetadata()
+    {
+        return $this->getAllAttributeSetMetadata('customer_address', self::ADDRESS_ATTRIBUTE_SET_ID);
+    }
+
+
+
     /**
      * Load collection with filters applied
      *
@@ -163,7 +197,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
 
     /**
      * @param \Magento\Customer\Model\Attribute $attribute
-     * @return AttributeMetadata
+     * @return Dto\Eav\AttributeMetadata
      */
     private function _createMetadataAttribute($attribute)
     {
@@ -181,8 +215,8 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
             ->setInputFilter($attribute->getInputFilter())
             ->setStoreLabel($attribute->getStoreLabel())
             ->setValidationRules($attribute->getValidateRules())
-            ->setIsVisible($attribute->getIsVisible())
-            ->setIsRequired($attribute->getIsRequired())
+            ->setVisible($attribute->getIsVisible())
+            ->setRequired($attribute->getIsRequired())
             ->setMultilineCount($attribute->getMultilineCount())
             ->setDataModel($attribute->getDataModel())
             ->setOptions($options)
@@ -195,39 +229,6 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface
         return $this->_attributeMetadataBuilder->create();
     }
 
-    /**
-     * @inheritdoc
-     */
-    public function getCustomerAttributeMetadata($attributeCode)
-    {
-        return $this->getAttributeMetadata('customer', $attributeCode);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function getAllCustomerAttributeMetadata()
-    {
-        return $this->getAllAttributeSetMetadata('customer', self::CUSTOMER_ATTRIBUTE_SET_ID);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function getAddressAttributeMetadata($attributeCode)
-    {
-        return $this->getAttributeMetadata('customer_address', $attributeCode);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function getAllAddressAttributeMetadata()
-    {
-        return $this->getAllAttributeSetMetadata('customer_address', self::ADDRESS_ATTRIBUTE_SET_ID);
-    }
-
-
     /**
      * Helper for getting access to an entity types DTO cache.
      *
diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataServiceInterface.php
index d0619bb0da4d83b521a4546f102a4d7e28eeec8f..bea359eafe4e3a81e3491a76a515b19b3a95ad96 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerMetadataServiceInterface.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataServiceInterface.php
@@ -24,8 +24,6 @@
 
 namespace Magento\Customer\Service\V1;
 
-use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata;
-
 /**
  * Manipulate Customer Metadata Attributes *
  */
@@ -39,7 +37,7 @@ interface CustomerMetadataServiceInterface
      *
      * @param   mixed $entityType
      * @param   mixed $attributeCode
-     * @return AttributeMetadata
+     * @return Dto\Eav\AttributeMetadata
      */
     public function getAttributeMetadata($entityType, $attributeCode);
 
@@ -49,7 +47,7 @@ interface CustomerMetadataServiceInterface
      * @param string $entityType
      * @param int $attributeSetId
      * @param int $storeId
-     * @return AttributeMetadata[]
+     * @return Dto\Eav\AttributeMetadata[]
      */
     public function getAllAttributeSetMetadata($entityType, $attributeSetId = 0, $storeId = null);
 
@@ -58,7 +56,7 @@ interface CustomerMetadataServiceInterface
      *
      * @param $entityType
      * @param $formCode
-     * @return AttributeMetadata[]
+     * @return Dto\Eav\AttributeMetadata[]
      */
     public function getAttributes($entityType, $formCode);
 
@@ -66,14 +64,14 @@ interface CustomerMetadataServiceInterface
      * Retrieve Customer EAV attribute metadata
      *
      * @param string $attributeCode
-     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata
+     * @return Dto\Eav\AttributeMetadata
      */
     public function getCustomerAttributeMetadata($attributeCode);
 
     /**
      * Returns all attribute metadata for customers
      *
-     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[]
+     * @return Dto\Eav\AttributeMetadata[]
      */
     public function getAllCustomerAttributeMetadata();
 
@@ -81,14 +79,14 @@ interface CustomerMetadataServiceInterface
      * Retrieve Customer Addresses EAV attribute metadata
      *
      * @param string $attributeCode
-     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata
+     * @return Dto\Eav\AttributeMetadata
      */
     public function getAddressAttributeMetadata($attributeCode);
 
     /**
      * Returns all attribute metadata for Addresses
      *
-     * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[]
+     * @return Dto\Eav\AttributeMetadata[]
      */
     public function getAllAddressAttributeMetadata();
 
diff --git a/app/code/Magento/Customer/Service/V1/CustomerService.php b/app/code/Magento/Customer/Service/V1/CustomerService.php
index 7f53131bfe711410341d2877666524aba14b2deb..05a79899755729c860e6763819add2fc50f0334c 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerService.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerService.php
@@ -24,8 +24,9 @@
 
 namespace Magento\Customer\Service\V1;
 
-use Magento\Customer\Service\Entity\V1\Exception;
-use Magento\Customer\Model\Customer;
+use Magento\Customer\Model\Converter;
+use Magento\Customer\Model\Customer as CustomerModel;
+use Magento\Exception\InputException;
 use Magento\Validator\ValidatorException;
 
 /**
@@ -37,37 +38,34 @@ class CustomerService implements CustomerServiceInterface
     /** @var array Cache of DTOs */
     private $_cache = [];
 
-
     /**
-     * @var \Magento\Customer\Model\Converter
+     * @var Converter
      */
     private $_converter;
 
+    /**
+     * @var CustomerMetadataService
+     */
+    private $_customerMetadataService;
+
 
     /**
      * Constructor
      *
-     * @param \Magento\Customer\Model\CustomerFactory $customerFactory
-     * @param \Magento\Customer\Model\AddressFactory $addressFactory
-     * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $eavMetadataService
-     * @param \Magento\Event\ManagerInterface $eventManager
-     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Math\Random $mathRandom
-     * @param \Magento\Customer\Model\Converter $converter
-     * @param \Magento\Customer\Model\Metadata\Validator $validator
-     * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
-     * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder
-     * @param \Magento\Customer\Service\V1\Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder
+     * @param Converter $converter
+     * @param CustomerMetadataService $customerMetadataService
      */
     public function __construct(
-        \Magento\Customer\Model\Converter $converter
+        Converter $converter,
+        CustomerMetadataService $customerMetadataService
     ) {
         $this->_converter = $converter;
+        $this->_customerMetadataService = $customerMetadataService;
     }
 
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function getCustomer($customerId)
     {
@@ -82,7 +80,7 @@ class CustomerService implements CustomerServiceInterface
 
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function saveCustomer(Dto\Customer $customer, $password = null)
     {
@@ -92,29 +90,53 @@ class CustomerService implements CustomerServiceInterface
             $customerModel->setPassword($password);
         }
 
-        $validationErrors = $customerModel->validate();
-        if ($validationErrors !== true) {
-            throw new Exception(
-                'There were one or more errors validating the customer object.',
-                Exception::CODE_VALIDATION_FAILED,
-                new ValidatorException([$validationErrors])
-            );
+        $this->_validate($customerModel);
+
+        $customerModel->save();
+        unset($this->_cache[$customerModel->getId()]);
+
+        return $customerModel->getId();
+    }
+
+    /**
+     * Validate customer attribute values.
+     *
+     * @param CustomerModel $customerModel
+     * @throws InputException
+     * @return void
+     *
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+     * @SuppressWarnings(PHPMD.NPathComplexity)
+     */
+    private function _validate(CustomerModel $customerModel)
+    {
+        $exception = new InputException();
+        if (!\Zend_Validate::is(trim($customerModel->getFirstname()), 'NotEmpty')) {
+            $exception->addError(InputException::REQUIRED_FIELD, 'firstname', '');
         }
 
-        try {
-            $customerModel->save();
-            unset($this->_cache[$customerModel->getId()]);
-        } catch (\Exception $e) {
-            switch ($e->getCode()) {
-                case Customer::EXCEPTION_EMAIL_EXISTS:
-                    $code = Exception::CODE_EMAIL_EXISTS;
-                    break;
-                default:
-                    $code = Exception::CODE_UNKNOWN;
-            }
-            throw new Exception($e->getMessage(), $code, $e);
+        if (!\Zend_Validate::is(trim($customerModel->getLastname()), 'NotEmpty')) {
+            $exception->addError(InputException::REQUIRED_FIELD, 'lastname', '');
         }
 
-        return $customerModel->getId();
+        if (!\Zend_Validate::is($customerModel->getEmail(), 'EmailAddress')) {
+            $exception->addError(InputException::INVALID_FIELD_VALUE, 'email', $customerModel->getEmail());
+        }
+
+        $dob = $this->_customerMetadataService->getCustomerAttributeMetadata('dob');
+        if ($dob->isRequired() && '' == trim($customerModel->getDob())) {
+            $exception->addError(InputException::REQUIRED_FIELD, 'dob', '');
+        }
+        $taxvat = $this->_customerMetadataService->getCustomerAttributeMetadata('taxvat');
+        if ($taxvat->isRequired() && '' == trim($customerModel->getTaxvat())) {
+            $exception->addError(InputException::REQUIRED_FIELD, 'taxvat', '');
+        }
+        $gender = $this->_customerMetadataService->getCustomerAttributeMetadata('gender');
+        if ($gender->isRequired() && '' == trim($customerModel->getGender())) {
+            $exception->addError(InputException::REQUIRED_FIELD, 'gender', '');
+        }
+        if ($exception->getErrors()) {
+            throw $exception;
+        }
     }
 }
diff --git a/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php
index 6d12afb3c3dbcb1fdb9fcecffb6a212d129d4d7d..a8683e7688fa1000b131b44ef7c6818b63e59bd6 100644
--- a/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php
+++ b/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php
@@ -24,6 +24,9 @@
 
 namespace Magento\Customer\Service\V1;
 
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+
 /**
  * Manipulate Customer Address Entities *
  */
@@ -32,9 +35,10 @@ interface CustomerServiceInterface
     /**
      * Create or update customer information
      *
-     * @param \Magento\Customer\Service\V1\Dto\Customer $customer
+     * @param Dto\Customer $customer
      * @param string $password
-     * @throws \Magento\Customer\Service\Entity\V1\Exception
+     * @throws \Magento\Customer\Exception If something goes wrong during save
+     * @throws InputException If bad input is provided
      * @return int customer ID
      */
     public function saveCustomer(Dto\Customer $customer, $password = null);
@@ -43,7 +47,8 @@ interface CustomerServiceInterface
      * Retrieve Customer
      *
      * @param int $customerId
-     * @return \Magento\Customer\Service\V1\Dto\Customer
+     * @throws NoSuchEntityException If customer with customerId is not found.
+     * @return Dto\Customer
      */
     public function getCustomer($customerId);
 
diff --git a/app/code/Magento/Customer/Service/V1/Dto/Address.php b/app/code/Magento/Customer/Service/V1/Dto/Address.php
index 9c0905ef8bf7593290ec1a130ade937b8e473b72..ef93eb3c521b43806899d4a112b81fdeb477c7bb 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/Address.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/Address.php
@@ -25,8 +25,6 @@
  */
 namespace Magento\Customer\Service\V1\Dto;
 
-use Magento\Customer\Service\V1\Dto\Region;
-
 class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityInterface
 {
 
@@ -73,9 +71,8 @@ class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityI
 
         /** This triggers some code in _updateAddressModel in CustomerV1 Service */
         if (!is_null($this->getRegion())) {
-            $attributes['region_id'] = $this->getRegion()->getRegionId();
-
-            $attributes['region'] = $this->getRegion()->getRegion();
+            $attributes['region']['region_id'] = $this->getRegion()->getRegionId();
+            $attributes['region']['region'] = $this->getRegion()->getRegion();
         }
 
         return $attributes;
@@ -96,7 +93,7 @@ class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityI
     }
 
     /**
-     * @return Region
+     * @return Region|null
      */
     public function getRegion()
     {
diff --git a/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php
index e5b6eb54f060b8f31b2945b5f46ac7fca5a62819..def7cd4dd966db63150eb78692babae1ea1488f1 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php
@@ -25,8 +25,6 @@
  */
 namespace Magento\Customer\Service\V1\Dto;
 
-use Magento\Customer\Service\V1\Dto\Region;
-
 class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 {
     protected $_regionBuilder;
@@ -34,9 +32,8 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
     /**
      * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
      */
-    public function __construct(
-      \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder
-    ) {
+    public function __construct(RegionBuilder $regionBuilder)
+    {
         parent::__construct();
         $this->_regionBuilder = $regionBuilder;
         $this->_data['region'] = $regionBuilder->create();
@@ -44,7 +41,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param int $id
-     * @return AddressBuilder
+     * @return $this
      */
     public function setId($id)
     {
@@ -53,7 +50,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param boolean $defaultShipping
-     * @return AddressBuilder
+     * @return $this
      */
     public function setDefaultShipping($defaultShipping)
     {
@@ -62,7 +59,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param boolean $defaultBilling
-     * @return AddressBuilder
+     * @return $this
      */
     public function setDefaultBilling($defaultBilling)
     {
@@ -70,27 +67,20 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
     }
 
     /**
-     * @param string[] $data
-     * @return AddressBuilder
+     * {@inheritdoc}
      */
     public function populateWithArray(array $data)
     {
-        unset($data['region_id']);
         if (isset($data['region'])) {
-            $region = $data['region'];
-            if (!($region instanceof Region)) {
-                unset($data['region']);
-            }
+            $data['region'] = new Region($data['region']);
         }
 
-        parent::populateWithArray($data);
-
-        return $this;
+        return parent::populateWithArray($data);
     }
 
     /**
      * @param Region $region
-     * @return AddressBuilder
+     * @return $this
      */
     public function setRegion(Region $region)
     {
@@ -99,7 +89,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param int $countryId
-     * @return AddressBuilder
+     * @return $this
      */
     public function setCountryId($countryId)
     {
@@ -108,7 +98,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param \string[] $street
-     * @return AddressBuilder
+     * @return $this
      */
     public function setStreet($street)
     {
@@ -117,7 +107,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $company
-     * @return AddressBuilder
+     * @return $this
      */
     public function setCompany($company)
     {
@@ -126,7 +116,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $telephone
-     * @return AddressBuilder
+     * @return $this
      */
     public function setTelephone($telephone)
     {
@@ -135,7 +125,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $fax
-     * @return AddressBuilder
+     * @return $this
      */
     public function setFax($fax)
     {
@@ -144,7 +134,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $postcode
-     * @return AddressBuilder
+     * @return $this
      */
     public function setPostcode($postcode)
     {
@@ -153,7 +143,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $city
-     * @return AddressBuilder
+     * @return $this
      */
     public function setCity($city)
     {
@@ -162,7 +152,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $firstname
-     * @return AddressBuilder
+     * @return $this
      */
     public function setFirstname($firstname)
     {
@@ -171,7 +161,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $lastname
-     * @return AddressBuilder
+     * @return $this
      */
     public function setLastname($lastname)
     {
@@ -180,7 +170,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $middlename
-     * @return AddressBuilder
+     * @return $this
      */
     public function setMiddlename($middlename)
     {
@@ -189,7 +179,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $prefix
-     * @return AddressBuilder
+     * @return $this
      */
     public function setPrefix($prefix)
     {
@@ -198,7 +188,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $suffix
-     * @return AddressBuilder
+     * @return $this
      */
     public function setSuffix($suffix)
     {
@@ -207,7 +197,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $vatId
-     * @return AddressBuilder
+     * @return $this
      */
     public function setVatId($vatId)
     {
@@ -216,7 +206,7 @@ class AddressBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 
     /**
      * @param string $customerId
-     * @return AddressBuilder
+     * @return $this
      */
     public function setCustomerId($customerId)
     {
diff --git a/app/code/Magento/Customer/Service/V1/Dto/Customer.php b/app/code/Magento/Customer/Service/V1/Dto/Customer.php
index 323759306b7da14a2fd5bb483ccce5ee5ccf6961..71030611147e6314d02b682d16bbfd2b66a218ed 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/Customer.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/Customer.php
@@ -27,7 +27,7 @@ namespace Magento\Customer\Service\V1\Dto;
  * Class Customer
  * Uses array to hold data, setters return $this so they can be chained.
  *
- * @package Magento\Customer\Service\Entity\V1
+ * @package Magento\Customer\Service\V1\Dto
  */
 class Customer extends \Magento\Service\Entity\AbstractDto implements Eav\EntityInterface
 {
@@ -65,7 +65,7 @@ class Customer extends \Magento\Service\Entity\AbstractDto implements Eav\Entity
     const DEFAULT_SHIPPING = 'default_shipping';
 
     /**
-     * Retrieve array of all attributes, in the form of 'attribute code' => <attribute value'
+     * Retrieve array of all attributes, in the form of 'attribute code' => 'attribute value'
      *
      * @return array|\ArrayAccess|\string[]
      */
@@ -117,15 +117,6 @@ class Customer extends \Magento\Service\Entity\AbstractDto implements Eav\Entity
         return $this->_get(self::CONFIRMATION);
     }
 
-    /**
-     * @param string $confirmation
-     * @return Customer
-     */
-    public function setConfirmation($confirmation)
-    {
-        return $this->_set(self::CONFIRMATION, $confirmation);
-    }
-
     /**
      * @return string
      */
diff --git a/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php
index 150e4a474ff06a515941daeef69005c70cbbad03..c4c1a5383214d50fc2f20f9e37de895cced43520 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php
@@ -22,13 +22,12 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 namespace Magento\Customer\Service\V1\Dto;
-use Magento\Customer\Service\V1\Dto\Customer;
 
 /**
  * Class Customer
  * Uses array to hold data, setters return $this so they can be chained.
  *
- * @package Magento\Customer\Service\Entity\V1
+ * @package Magento\Customer\Service\V1\Dto
  */
 class CustomerBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 {
diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php
index eeb75e9466a5edcb7f48769bc5b3d0eece10c17d..5ef55a9a4dae3d2526583748027f6068cf546650 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php
@@ -36,8 +36,8 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto
     const STORE_LABEL = 'store_label';
     const VALIDATION_RULES = 'validation_rules';
     const OPTIONS = 'options';
-    const VISIBLE = 'is_visible';
-    const REQUIRED = 'is_required';
+    const VISIBLE = 'visible';
+    const REQUIRED = 'required';
     const MULTILINE_COUNT = 'multiline_count';
     const DATA_MODEL = 'data_model';
     const IS_USER_DEFINED = 'is_user_defined';
diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php
index acbf32174ccdbbd6d6cf695e196752536652adbf..b7e50da8ca219dd65bdb800df9320a8a423d7fbe 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php
@@ -94,7 +94,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde
      * @param boolean $visible
      * @return AttributeMetadataBuilder
      */
-    public function setIsVisible($visible)
+    public function setVisible($visible)
     {
         return $this->_set(AttributeMetadata::VISIBLE, $visible);
     }
@@ -103,7 +103,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde
      * @param boolean $required
      * @return AttributeMetadataBuilder
      */
-    public function setIsRequired($required)
+    public function setRequired($required)
     {
         return $this->_set(AttributeMetadata::REQUIRED, $required);
     }
diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/OptionBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/OptionBuilder.php
index 045cfad463ad0ea4251f3f091265307adedbf466..aa10df8e18bf89707bffe4084d6bafcf1ae89548 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/Eav/OptionBuilder.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/OptionBuilder.php
@@ -25,8 +25,6 @@
  */
 namespace Magento\Customer\Service\V1\Dto\Eav;
 
-use Magento\Customer\Service\V1\Dto\Eav\Option;
-
 class OptionBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
 {
     /**
diff --git a/app/code/Magento/Customer/Service/V1/Dto/FilterBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/FilterBuilder.php
index f6f1c37619dcf3119221f86f9728c91f7eb97702..844234137c6419349c4b57060d407b72e3e1b1b9 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/FilterBuilder.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/FilterBuilder.php
@@ -34,7 +34,7 @@ class FilterBuilder extends \Magento\Service\Entity\AbstractDtoBuilder
     {
         parent::__construct();
 
-        /* XXX: special constructor to set default values */
+        // special constructor to set default values
         $this->_data['condition_type'] = 'and';
     }
 
diff --git a/app/code/Magento/Customer/Service/V1/Dto/SearchCriteria.php b/app/code/Magento/Customer/Service/V1/Dto/SearchCriteria.php
index 87136556f6fd8ba359328b9ffe46472995acfe0e..49b378c6c46ad074f1f53ce4586c46715fb285ab 100644
--- a/app/code/Magento/Customer/Service/V1/Dto/SearchCriteria.php
+++ b/app/code/Magento/Customer/Service/V1/Dto/SearchCriteria.php
@@ -63,4 +63,15 @@ class SearchCriteria extends \Magento\Service\Entity\AbstractDto
     {
         return $this->_get('current_page');
     }
+
+    /**
+     * Create Array
+     *
+     * @todo to be implemented in MAGETWO-18201
+     *
+     * @return array
+     */
+    private function _createArray()
+    {
+    }
 }
diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_group_index.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_group_index.xml
index a0bc92c40b450586f23e0a628c3580905ae4e279..676b222d0c43ed3590bf083c5fe0cdf61ba5d380 100644
--- a/app/code/Magento/Customer/view/adminhtml/layout/customer_group_index.xml
+++ b/app/code/Magento/Customer/view/adminhtml/layout/customer_group_index.xml
@@ -29,7 +29,7 @@
             <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.block.customer.group.grid" as="grid">
                 <arguments>
                     <argument name="id" xsi:type="string">customerGroupGrid</argument>
-                    <argument name="dataSource" xsi:type="object">Magento\Customer\Model\Resource\Group\Grid\Collection</argument>
+                    <argument name="dataSource" xsi:type="object">Magento\Customer\Model\Resource\Group\Grid\ServiceCollection</argument>
                     <argument name="default_sort" xsi:type="string">type</argument>
                     <argument name="default_dir" xsi:type="string">asc</argument>
                     <argument name="save_parameters_in_session" xsi:type="string">1</argument>
@@ -47,22 +47,22 @@
                         <arguments>
                             <argument name="header" xsi:type="string" translate="true">ID</argument>
                             <argument name="width" xsi:type="string">50px</argument>
-                            <argument name="id" xsi:type="string">customer_group_id</argument>
+                            <argument name="id" xsi:type="string">id</argument>
                             <argument name="align" xsi:type="string">right</argument>
-                            <argument name="index" xsi:type="string">customer_group_id</argument>
+                            <argument name="index" xsi:type="string">id</argument>
                         </arguments>
                     </block>
                     <block class="Magento\Backend\Block\Widget\Grid\Column" as="type">
                         <arguments>
                             <argument name="header" xsi:type="string" translate="true">Group</argument>
-                            <argument name="index" xsi:type="string">customer_group_code</argument>
+                            <argument name="index" xsi:type="string">code</argument>
                         </arguments>
                     </block>
                     <block class="Magento\Backend\Block\Widget\Grid\Column" as="class_name">
                         <arguments>
                             <argument name="header" xsi:type="string" translate="true">Tax Class</argument>
                             <argument name="width" xsi:type="string">200px</argument>
-                            <argument name="index" xsi:type="string">class_name</argument>
+                            <argument name="index" xsi:type="string">tax_class_id</argument>
                         </arguments>
                     </block>
                 </block>
diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml
index b384ce7a8be337470cc390980f12ebb2734618b0..977836cababd580fa66b7eabaf4f4bb034ee4ae0 100644
--- a/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml
+++ b/app/code/Magento/Customer/view/adminhtml/layout/customer_index_edit.xml
@@ -61,13 +61,9 @@
         <block class="Magento\Backend\Block\Template" template="Magento_Customer::edit/js.phtml" name="customer.edit.js" as="customer_edit_js"/>
     </referenceContainer>
     <referenceBlock name="customer_edit_tabs">
-        <action method="addTab">
-            <argument name="name" xsi:type="string">customer_edit_tab_agreements</argument>
-            <argument name="block" xsi:type="string">Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Agreement</argument>
-        </action>
         <action method="addTab">
             <argument name="name" xsi:type="string">customer_edit_tab_recurring_profile</argument>
-            <argument name="block" xsi:type="string">Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring\Profile</argument>
+            <argument name="block" xsi:type="string">Magento\RecurringProfile\Block\Adminhtml\Customer\Edit\Tab\RecurringProfile</argument>
         </action>
     </referenceBlock>
 </layout>
diff --git a/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml b/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml
index ee476da9eaeaf26c1e9133b66221f891e8194c01..7e6405f440366136c21a2c27c6641ec877715e17 100644
--- a/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml
+++ b/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml
@@ -51,7 +51,7 @@
     </legend>
     <br />
 
-    <div id="address-tabs" data-mage-init='{addressTabs:{itemCount: <?php echo count($addressCollection) ?>,
+    <div id="address-tabs" data-mage-init='{"addressTabs":{"itemCount": <?php echo count($addressCollection) ?>,
             deleteConfirmPrompt: "<?php echo __('Are you sure you want to delete this address?') ?>",
             regionsUrl: "<?php echo $this->getRegionsUrl(); ?>",
             optionalZipCountries: <?php echo $this->helper("Magento\Directory\Helper\Data")->getCountriesWithOptionalZip(true) ?>,
@@ -65,7 +65,7 @@
                 <?php foreach ($addressCollection as $_address): ?>
 
                     <li class="address-list-item" id="address_item_<?php echo $_address->getId() ?>" data-item="<?php echo $_address->getId() ?>">
-                        <a href="#form_address_item_<?php echo $_address->getId() ?>" data-mage-init="{dataItemDeleteButton: {}}">
+                        <a href="#form_address_item_<?php echo $_address->getId() ?>" data-mage-init='{"dataItemDeleteButton": {}}'>
                             <?php if (!$this->isReadonly()): ?>
                                 <div class="address-list-item-actions">
                                     <button class="action-delete" type="button" title="Remove address" id="delete_button<?php echo ++$_iterator ?>" data-role="delete">
@@ -103,7 +103,7 @@
         <script data-template="address-tab" type="text/x-jquery-tmpl">
             <div id="address_item_template" class="hidden template">
                 <li class="address-list-item" id="address_item_${itemId}" data-item="${itemId}">
-                    <a href="#form_new_item${itemId}" data-mage-init="{dataItemDeleteButton: {}}">
+                    <a href="#form_new_item${itemId}" data-mage-init='{"dataItemDeleteButton": {}}'>
                         <?php if (!$this->isReadonly()): ?>
                             <div class="address-list-item-actions">
                                 <button class="action-delete" type="button" title="Remove address" id="delete_button${itemId}" data-role="delete">
@@ -140,7 +140,7 @@
         <script data-template="address-form" type="text/x-jquery-tmpl">
             <div id="address_form_template" class="no-display template"><!-- Don`t delete class no-display, save customer stops work  -->
                 <div id="form_${formName}" data-item="${itemCount}" class="address-item-edit-content"
-                     data-mage-init="{observableInputs:{'name': '${formName}'}}">
+                     data-mage-init='{"observableInputs":{"name": "${formName}"}}'>
                     <?php
                     // Set form template elements prefix
                     $this->getForm()->setHtmlIdPrefix($_templatePrefix)
@@ -155,7 +155,7 @@
         <div data-container="address-forms" class="address-item-edit" id="address_form_container">
             <?php if(count($addressCollection)): ?>
                 <?php foreach ($addressCollection as $_address): ?>
-                    <div class="address-item-edit-content" id="form_address_item_<?php echo $_address->getId() ?>" data-item="<?php echo $_address->getId() ?>" style="display:none" data-mage-init="{observableInputs: {'name': 'address_item_<?php echo $_address->getId() ?>'}}">
+                    <div class="address-item-edit-content" id="form_address_item_<?php echo $_address->getId() ?>" data-item="<?php echo $_address->getId() ?>" style="display:none" data-mage-init='{"observableInputs": {"name": "address_item_<?php echo $_address->getId() ?>"}}'>
                         <?php
                         $this->getForm()->addValues($_address->getData())
                             ->setHtmlIdPrefix("_item{$_address->getId()}")
diff --git a/app/code/Magento/Customer/view/frontend/account/dashboard/address.phtml b/app/code/Magento/Customer/view/frontend/account/dashboard/address.phtml
index 5a86e478230db9dbaae34d460e51e468d5afd17c..5436ccf2e9f1b74478964f7bc11d83705349b702 100644
--- a/app/code/Magento/Customer/view/frontend/account/dashboard/address.phtml
+++ b/app/code/Magento/Customer/view/frontend/account/dashboard/address.phtml
@@ -22,6 +22,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
+
+/** @var \Magento\Customer\Block\Account\Dashboard\Address $this */
 ?>
 <div class="block dashboard addresses">
     <div class="title">
diff --git a/app/code/Magento/Customer/view/frontend/account/dashboard/hello.phtml b/app/code/Magento/Customer/view/frontend/account/dashboard/hello.phtml
index 9bb3bbbf382034e0937f7f5c75b97f6a4edae285..3883c90e1b06c758155064a157edc715cec08e18 100644
--- a/app/code/Magento/Customer/view/frontend/account/dashboard/hello.phtml
+++ b/app/code/Magento/Customer/view/frontend/account/dashboard/hello.phtml
@@ -22,6 +22,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
+
+/** @var \Magento\Customer\Block\Account\Dashboard\Hello $this */
 ?>
 <div class="block dashboard welcome">
     <div class="title"><strong><?php echo __('Hello, %1!', $this->escapeHtml($this->getCustomerName())) ?></strong></div>
diff --git a/app/code/Magento/Customer/view/frontend/account/dashboard/info.phtml b/app/code/Magento/Customer/view/frontend/account/dashboard/info.phtml
index 6c5279a97f11eeb9fadb406d3b3e7efbba395cbb..53974ab89836c128762612e64db5d40d6dca91c4 100644
--- a/app/code/Magento/Customer/view/frontend/account/dashboard/info.phtml
+++ b/app/code/Magento/Customer/view/frontend/account/dashboard/info.phtml
@@ -22,6 +22,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
+
+/** @var \Magento\Customer\Block\Account\Dashboard\Info $this */
 ?>
 <div class="block dashboard info">
     <div class="title"><strong><?php echo __('Account Information') ?></strong></div>
@@ -32,7 +34,7 @@
                 <a class="action edit" href="<?php echo $this->getUrl('customer/account/edit') ?>"><span><?php echo __('Edit') ?></span></a>
             </strong>
             <p>
-                <?php echo $this->escapeHtml($this->getCustomer()->getName()) ?><br>
+                <?php echo $this->escapeHtml($this->getName()) ?><br>
                 <?php echo $this->escapeHtml($this->getCustomer()->getEmail()) ?><br>
                 <a href="<?php echo $this->getChangePasswordUrl() ?>"><?php echo __('Change Password') ?></a>
             </p>
diff --git a/app/code/Magento/Customer/view/frontend/address/book.phtml b/app/code/Magento/Customer/view/frontend/address/book.phtml
index 3dedd47dddec079cac20329f3a42ec8bd8735f57..3cf3ef19df158b3ae6278b3e1d6c52df7214abfd 100644
--- a/app/code/Magento/Customer/view/frontend/address/book.phtml
+++ b/app/code/Magento/Customer/view/frontend/address/book.phtml
@@ -36,7 +36,7 @@
             <div class="box address billing">
                 <strong class="subtitle">
                     <span><?php echo __('Default Billing Address') ?></span>
-                    <a class="action edit" href="<?php echo $this->getAddressEditUrl($this->getAddressById($_pAddsses)) ?>">
+                    <a class="action edit" href="<?php echo $this->getAddressEditUrl($_pAddsses) ?>">
                         <span><?php echo __('Change Billing Address') ?></span>
                     </a>
                 </strong>
@@ -55,7 +55,7 @@
             <div class="box address shipping">
                 <strong class="subtitle">
                     <span><?php echo __('Default Shipping Address') ?></span>
-                    <a class="action edit" href="<?php echo $this->getAddressEditUrl($this->getAddressById($_pAddsses)) ?>">
+                    <a class="action edit" href="<?php echo $this->getAddressEditUrl($_pAddsses) ?>">
                         <span><?php echo __('Change Shipping Address') ?></span>
                     </a>
                 </strong>
diff --git a/app/code/Magento/Customer/view/frontend/address/button.phtml b/app/code/Magento/Customer/view/frontend/address/button.phtml
index 0456b98471743fc743ca353160e1325455b79915..0f683d1261c39402b7be51c73364ae61ce28b6cf 100644
--- a/app/code/Magento/Customer/view/frontend/address/button.phtml
+++ b/app/code/Magento/Customer/view/frontend/address/button.phtml
@@ -1,5 +1,5 @@
-<?php
-/**
+<?php
+/**
  * Magento
  *
  * NOTICE OF LICENSE
@@ -16,17 +16,17 @@
  *
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    design
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
-?>
-<?php
-/**
- * Temlate for \Magento\Customer\Block\Address\Book block
- * @var $this \Magento\Customer\Block\Address\Book
- */
-?>
-<button type="button" role="add-address" title="<?php echo __('Add New Address') ?>" class="action add"><span><?php echo __('Add New Address') ?></span></button>
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    design
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+?>
+<?php
+/**
+ * Temlate for \Magento\Customer\Block\Address\Book block
+ * @var $this \Magento\Customer\Block\Address\Book
+ */
+?>
+<button type="button" role="add-address" title="<?php echo __('Add New Address') ?>" class="action add"><span><?php echo __('Add New Address') ?></span></button>
diff --git a/app/code/Magento/Customer/view/frontend/address/edit.phtml b/app/code/Magento/Customer/view/frontend/address/edit.phtml
index 65f71070062b0a45cb191809a4c7fcd7e37539b8..5955d4651822c7a0169baa06c5e60621b02d83af 100644
--- a/app/code/Magento/Customer/view/frontend/address/edit.phtml
+++ b/app/code/Magento/Customer/view/frontend/address/edit.phtml
@@ -62,13 +62,13 @@
         <div class="field street required">
             <label for="street_1" class="label"><span><?php echo __('Street Address') ?></span></label>
             <div class="control">
-                <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" title="<?php echo __('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>"  />
+                <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getStreetLine(1)) ?>" title="<?php echo __('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>"  />
                 <div class="nested">
                     <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
-                    <?php for ($_i = 2, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?>
+                    <?php for ($_i = 1, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i < $_n; $_i++): ?>
                         <div class="field additional">
                             <div class="control">
-                                <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" title="<?php echo __('Street Address %1', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>">
+                                <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getStreetLine($_i+1)) ?>" title="<?php echo __('Street Address %1', $_i+1) ?>" id="street_<?php echo $_i+1 ?>" class="input-text <?php echo $_streetValidationClass ?>">
                             </div>
                         </div>
                     <?php endfor; ?>
@@ -96,7 +96,7 @@
                 <select id="region_id" name="region_id" title="<?php echo __('State/Province') ?>" class="validate-select" style="display:none;"<?php echo (!$this->getConfig('general/region/display_all')) ? ' disabled="disabled"' :'';?>>
                     <option value=""><?php echo __('Please select region, state or province') ?></option>
                 </select>
-                <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"  title="<?php echo __('State/Province') ?>" class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region') ?>"<?php echo (!$this->getConfig('general/region/display_all')) ? ' disabled="disabled"' :'';?>/>
+                <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>"  title="<?php echo __('State/Province') ?>" class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region') ?>"<?php echo (!$this->getConfig('general/region/display_all')) ? ' disabled="disabled"' :'';?>/>
             </div>
         </div>
         <div class="field zip required">
@@ -155,7 +155,7 @@
                     postcodeId: '#zip',
                     form: $('#form-validate').validation(),
                     regionJson: <?php echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson() ?>,
-                    defaultRegion: "<?php echo $this->getAddress()->getRegionId() ?>",
+                    defaultRegion: "<?php echo $this->getRegionId() ?>",
                     countriesWithOptionalZip: <?php echo $this->helper('Magento\Directory\Helper\Data')->getCountriesWithOptionalZip(true) ?>
                 });
             });
diff --git a/app/code/Magento/Customer/view/frontend/form/edit.phtml b/app/code/Magento/Customer/view/frontend/form/edit.phtml
index 3af62ec89d348f9c06274585e64c802aeb913963..96f462a5400f3296f2c02f7d9776fcc5993d3a64 100644
--- a/app/code/Magento/Customer/view/frontend/form/edit.phtml
+++ b/app/code/Magento/Customer/view/frontend/form/edit.phtml
@@ -22,6 +22,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
+
+/** @var \Magento\Customer\Block\Form\Edit $this */
 ?>
 <form class="form edit account" action="<?php echo $this->getUrl('customer/account/editPost') ?>" method="post" id="form-validate" enctype="multipart/form-data" data-hasrequired="<?php echo __('* Required Fields') ?>" autocomplete="off">
     <fieldset class="fieldset info">
diff --git a/app/code/Magento/Customer/view/frontend/form/login.phtml b/app/code/Magento/Customer/view/frontend/form/login.phtml
index c56b1e91438daa84457f2fd79557a4e887b76e92..5e1280c13c891c827571395de5f6591613ba6cdd 100644
--- a/app/code/Magento/Customer/view/frontend/form/login.phtml
+++ b/app/code/Magento/Customer/view/frontend/form/login.phtml
@@ -22,6 +22,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
+
+/** @var \Magento\Customer\Block\Form\Login $this */
 ?>
 <?php
 /**
diff --git a/app/code/Magento/Customer/view/frontend/form/register.phtml b/app/code/Magento/Customer/view/frontend/form/register.phtml
index f472a1a7c2780e1e45987b1d2bf2228a9f977a93..40c0d0c94249911aa33dcce462b3706496d95270 100644
--- a/app/code/Magento/Customer/view/frontend/form/register.phtml
+++ b/app/code/Magento/Customer/view/frontend/form/register.phtml
@@ -137,9 +137,9 @@
             </div>
             <?php $addressAttributes = $this->getChildBlock('customer_form_address_user_attributes');?>
             <?php if ($addressAttributes): ?>
-                <?php $addressAttributes->setEntity($this->getAddress());?>
+                <?php $addressAttributes->setEntityType('customer_address'); ?>
                 <?php $addressAttributes->setFieldIdFormat('address:%1$s')->setFieldNameFormat('address[%1$s]');?>
-                <?php $this->restoreSessionData($addressAttributes->getForm(), 'address');?>
+                <?php $this->restoreSessionData($addressAttributes->getMetadataForm(), 'address');?>
                 <?php echo $addressAttributes->setShowContainer(false)->toHtml()?>
             <?php endif;?>
             <input type="hidden" name="default_billing" value="1">
diff --git a/app/code/Magento/Customer/view/frontend/form/resetforgottenpassword.phtml b/app/code/Magento/Customer/view/frontend/form/resetforgottenpassword.phtml
index 44a8739f9f51dbf4af58797be5bb03710abdfdf0..e42ddf2bbbb905583b3f192e7160e0a187635d6f 100644
--- a/app/code/Magento/Customer/view/frontend/form/resetforgottenpassword.phtml
+++ b/app/code/Magento/Customer/view/frontend/form/resetforgottenpassword.phtml
@@ -22,6 +22,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
+
+/** @var \Magento\Customer\Block\Account\Resetpassword $this */
 ?>
 <form action="<?php echo $this->getUrl('*/*/resetpasswordpost', array('_query' => array('id' => $this->getCustomerId(), 'token' => $this->getResetPasswordLinkToken()))); ?>" method="post" id="form-validate" class="form password reset">
     <fieldset class="fieldset" data-hasrequired="<?php echo __('* Required Fields'); ?>">
diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account.xml
index 73ba6acc09d7d5f2e00bed525cbb608d90c3e327..3640a6062757ea1640c22644edfe052eac019448 100644
--- a/app/code/Magento/Customer/view/frontend/layout/customer_account.xml
+++ b/app/code/Magento/Customer/view/frontend/layout/customer_account.xml
@@ -51,6 +51,6 @@
                 </arguments>
             </block>
         </block>
-        <block class="Magento\Catalog\Block\Product\Compare\Sidebar" name="catalog.compare.sidebar" template="product/compare/sidebar.phtml"/>
     </referenceContainer>
+    <move element="catalog.compare.sidebar" destination="left"/>
 </layout>
diff --git a/app/code/Magento/Customer/view/frontend/layout/default.xml b/app/code/Magento/Customer/view/frontend/layout/default.xml
index 0154cacb206deb311bb6a8d0175d3bc9ef5b9356..54ca9840005ee75db915b2557fe0966305d7a7dc 100644
--- a/app/code/Magento/Customer/view/frontend/layout/default.xml
+++ b/app/code/Magento/Customer/view/frontend/layout/default.xml
@@ -30,11 +30,11 @@
                 <argument name="label" xsi:type="string">My Account</argument>
             </arguments>
         </block>
-        <block class="Magento\Customer\Block\Account\RegisterLink" after="authorization-link-login" name="register-link" cacheable="false">
+        <block class="Magento\Customer\Block\Account\RegisterLink" name="register-link" cacheable="false">
             <arguments>
                 <argument name="label" xsi:type="string">Register</argument>
             </arguments>
         </block>
-        <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" template="account/link/authorization.phtml" after="onepage-checkout-link" cacheable="false"/>
+        <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" template="account/link/authorization.phtml" cacheable="false"/>
     </referenceBlock>
 </layout>
diff --git a/app/code/Magento/Customer/view/frontend/newcustomer.phtml b/app/code/Magento/Customer/view/frontend/newcustomer.phtml
index 3b4a326e854680eadb1d941fedd28e759a72e4b7..9ab0e8732998304fb9bd59829b18776e172bf370 100644
--- a/app/code/Magento/Customer/view/frontend/newcustomer.phtml
+++ b/app/code/Magento/Customer/view/frontend/newcustomer.phtml
@@ -1,5 +1,5 @@
-<?php
-/**
+<?php
+/**
  * Magento
  *
  * NOTICE OF LICENSE
@@ -16,28 +16,28 @@
  *
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    design
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
-?>
-<?php
-/**
- * New Customer block template
- *
- * @see \Magento\Customer\Block\Form\Login
- */
-?>
-<?php if ($this->helper('Magento\Customer\Helper\Data')->isRegistrationAllowed()): ?>
-<div class="block new customer">
-    <div class="title"><strong><?php echo __('New Customers') ?></strong></div>
-    <div class="content">
-        <p><?php echo __('By creating an account with our store, you will be able to move through the checkout process faster, store multiple shipping addresses, view and track your orders in your account and more.') ?></p>
-        <div class="actions">
-            <a href="<?php echo $this->getCreateAccountUrl() ?>" class="action create"><span><?php echo __('Register') ?></span></a>
-        </div>
-    </div>
-</div>
-<?php endif; ?>
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    design
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+?>
+<?php
+/**
+ * New Customer block template
+ *
+ * @see \Magento\Customer\Block\Form\Login
+ */
+?>
+<?php if ($this->helper('Magento\Customer\Helper\Data')->isRegistrationAllowed()): ?>
+<div class="block new customer">
+    <div class="title"><strong><?php echo __('New Customers') ?></strong></div>
+    <div class="content">
+        <p><?php echo __('By creating an account with our store, you will be able to move through the checkout process faster, store multiple shipping addresses, view and track your orders in your account and more.') ?></p>
+        <div class="actions">
+            <a href="<?php echo $this->getCreateAccountUrl() ?>" class="action create"><span><?php echo __('Register') ?></span></a>
+        </div>
+    </div>
+</div>
+<?php endif; ?>
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php
index 100b37a92ca2ec407b032db43011a1885f1d018d..39eacf4d2135ce29c5f5690484275924c842189e 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Background.php
@@ -40,7 +40,7 @@ class Background
     /**
      * Add form elements
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Background
+     * @return $this
      */
     protected function _addFields()
     {
@@ -73,7 +73,7 @@ class Background
     /**
      * Add element types used in composite font element
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Background
+     * @return $this
      */
     protected function _addElementTypes()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php
index bc459bc1741bc390af2af0ff4c894c70a03cfc09..285ce2cb0f5a9609fa3cf065fb0f6556bcc9888e 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/BackgroundUploader.php
@@ -40,7 +40,7 @@ class BackgroundUploader
     /**
      * Add form elements
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\BackgroundUploader
+     * @return $this
      */
     protected function _addFields()
     {
@@ -81,7 +81,7 @@ class BackgroundUploader
     /**
      * Add element types used in composite font element
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\BackgroundUploader
+     * @return $this
      */
     protected function _addElementTypes()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php
index 998b88a80cf9e41f365dc7492c9bbc847da28112..97b776728f4f39e952ac2e6d4a377a5f034caaad 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php
@@ -182,14 +182,14 @@ abstract class AbstractComposite
     /**
      * Add form elements
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Composite\AbstractComposite
+     * @return $this
      */
     abstract protected function _addFields();
 
     /**
      * Add element types used in composite font element
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Composite\AbstractComposite
+     * @return $this
      */
     abstract protected function _addElementTypes();
 }
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Font.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Font.php
index 88843ec28796d773721d051508deb8a98ca34c0a..8daa9c228bb54c6d3d25b7fcf6f11d150545ac6a 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Font.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Font.php
@@ -40,7 +40,7 @@ class Font
     /**
      * Add form elements
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Font
+     * @return $this
      */
     protected function _addFields()
     {
@@ -80,7 +80,7 @@ class Font
     /**
      * Add element types used in composite font element
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Font
+     * @return $this
      */
     protected function _addElementTypes()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php
index 64c683e9dde25e914ba56931b9874a1fa62aac3b..581d62e9f91c761367cad01d0bb41b9aa3bdacd9 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element;
 
 /**
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php
index bd985dbd4d509809cad2fe56367593b66988038e..23cb905cbefebab8eb17ae5dcb6983a43a885599 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ImageUploader.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element;
 
 /**
  * Form element renderer to display logo uploader element for VDE
  */
-namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element;
-
 class ImageUploader
     extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Uploader
 {
@@ -38,12 +37,14 @@ class ImageUploader
     const CONTROL_TYPE = 'image-uploader';
 
     /**
-     * Default MIME types to accept
+     * @var string Default MIME types to accept
      */
     protected $_acceptTypesDefault = 'image/*';
 
     /**
      * Constructor helper
+     *
+     * @return void
      */
     public function _construct()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php
index e03a6d08f721746ecf5c01c1c6e4007807cb23d1..e12ecc4d7d941e1a6fc21d34a08aa6206900ca00 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Logo.php
@@ -40,7 +40,7 @@ class Logo
     /**
      * Add form elements
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Logo
+     * @return $this
      */
     protected function _addFields()
     {
@@ -63,7 +63,7 @@ class Logo
     /**
      * Add element types used in composite font element
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Logo
+     * @return $this
      */
     protected function _addElementTypes()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php
index baa69594d4e1e5667cd6cc4e95bae3492c65814b..3ba0b2d6b47ee2f9b18f00ab5a74d954664ab715 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/LogoUploader.php
@@ -40,7 +40,7 @@ class LogoUploader
     const CONTROL_TYPE = 'logo-uploader';
 
     /**
-     * Ability to upload multiple files by default is disabled for logo
+     * @var bool Ability to upload multiple files by default is disabled for logo
      */
     protected $_multipleFiles = false;
 }
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/AbstractBlock.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/AbstractBlock.php
index dfdfed730f3d315b376abe84f7cbc7a46fea44d4..eebf0e8e8dbd2a81865b4ec89bfd281d6e3e4dc5 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/AbstractBlock.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/AbstractBlock.php
@@ -52,7 +52,7 @@ abstract class AbstractBlock extends \Magento\Backend\Block\Template
      * Get current VDE mode
      *
      * @param int $mode
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\AbstractBlock
+     * @return $this
      */
     public function setMode($mode)
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php
index 0a21fa85fb011dd9da42854c0da09968bcd68f6c..7af7ed603f772e433e59aaaafc7867c6b0ec7071 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php
@@ -32,12 +32,12 @@ class Code
     extends \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Tabs\AbstractTabs
 {
     /**
-     * Tab HTML identifier
+     * @var string Tab HTML identifier
      */
     protected $_htmlId = 'vde-tab-code';
 
     /**
-     * Tab HTML title
+     * @var string Tab HTML title
      */
     protected $_title = 'Advanced';
 
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php
index 7a0ea73856d42a848814bc2a27a247f499c890d7..adbbcc750cb3dcaa2b4440c739c18eac94bcdff3 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Js.php
@@ -75,7 +75,7 @@ class Js extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Create a form element with necessary controls
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Js
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php
index 8d4db87fc18a22660b627564886df0df386d7390..42728d4d9ea210fba24d42d6fffb71d687dc9051 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php
@@ -23,26 +23,21 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools;
 
 /**
  * Block that renders Design tab
  */
-namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools;
-
 class QuickStyles
     extends \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Tabs\AbstractTabs
 {
     /**
-     * Tab HTML identifier
-     *
-     * @var string
+     * @var string Tab HTML identifier
      */
     protected $_htmlId = 'vde-tab-quick-styles';
 
     /**
-     * Tab HTML title
-     *
-     * @var string
+     * @var string Tab HTML title
      */
     protected $_title = 'Quick Styles';
 
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php
index d72fdd0cdd8a49c49b1965da39dd40659390c61d..d1d6b819dd9163ceec2d21ce0114725d3d094dcb 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php
@@ -43,12 +43,12 @@ abstract class AbstractTabs extends \Magento\View\Element\Template
     const TAB_BODY_BLOCK_ALIAS = 'tab_body';
 
     /**
-     * Tab HTML identifier
+     * @var string Tab HTML identifier
      */
     protected $_htmlId;
 
     /**
-     * Tab HTML title
+     * @var string Tab HTML title
      */
     protected $_title;
 
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php
index db94e73c4e626eb495423296c0869375772545f5..673a3fffa5ee11d428e558ca5d3fa07158bec5cc 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php
@@ -65,7 +65,7 @@ class Theme extends \Magento\Backend\Block\Template
      * Add button
      *
      * @param Button $button
-     * @return \Magento\DesignEditor\Block\Adminhtml\Theme
+     * @return $this
      */
     public function addButton($button)
     {
@@ -76,7 +76,7 @@ class Theme extends \Magento\Backend\Block\Template
     /**
      * Clear buttons
      *
-     * @return \Magento\DesignEditor\Block\Adminhtml\Theme
+     * @return $this
      */
     public function clearButtons()
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php
index c85c5e683e5a5463bf78ae6fb33986808ffcf320..67a6ab324b86a505bd07f32db2bd493e90d844f6 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Block\Adminhtml\Theme;
 
 /**
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php
index b3d3f54afde385997f4061519f26bb6469cf3749..74dc8723b2a1a0da77fe8f22bf5ffa3eec31775f 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php
@@ -54,7 +54,7 @@ abstract class AbstractSelectorList
      * Add theme buttons
      *
      * @param \Magento\DesignEditor\Block\Adminhtml\Theme $themeBlock
-     * @return \Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList\AbstractSelectorList
+     * @return $this
      */
     protected function _addThemeButtons($themeBlock)
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Assigned.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Assigned.php
index 05c0f95a9f54a5466497319b21ce648507209c61..730a301bc22fac97c73457ddd34cb1a469df8bd2 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Assigned.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Assigned.php
@@ -46,7 +46,7 @@ class Assigned
      * Add theme buttons
      *
      * @param \Magento\DesignEditor\Block\Adminhtml\Theme $themeBlock
-     * @return \Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList\Assigned
+     * @return $this
      */
     protected function _addThemeButtons($themeBlock)
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php
index ff1f08f3dcbbf933a9cb13b5ca59fb6ad9c6b4b7..bfeb6f710065d76d5d4a71800003a990ef2e80df 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList;
 
 /**
@@ -92,7 +91,7 @@ class Available
      * Add theme buttons
      *
      * @param \Magento\DesignEditor\Block\Adminhtml\Theme $themeBlock
-     * @return \Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList\AbstractSelectorList
+     * @return $this
      */
     protected function _addThemeButtons($themeBlock)
     {
diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php
index ac9207075c11eb0a8b81638cdeb2a72202a5edfe..2e4aca9608762084e81de538f80aaf7c8a66227d 100644
--- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php
+++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tab/Customizations.php
@@ -23,17 +23,18 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector\Tab;
 
 /**
  * Theme selector tab for customized themes
  */
-namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector\Tab;
-
 class Customizations
     extends \Magento\DesignEditor\Block\Adminhtml\Theme\Selector\Tab\AbstractTab
 {
     /**
      * Initialize tab block
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php
index c823745f74a8da9a33c7ae3e0f9efc6dfe3da591..91277b527bdd579cd622ca9ab3ac49abaa4a4926 100644
--- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php
+++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor;
 
 /**
diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php
index dcb27510fe8e6ac3f235f4f71a4b3aab59534835..5be1364bb92e632dfd12c3ece6eb72cd3384f962 100644
--- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php
+++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor;
 
 use Magento\Core\Exception as CoreException;
diff --git a/app/code/Magento/DesignEditor/Helper/Data.php b/app/code/Magento/DesignEditor/Helper/Data.php
index e5494195bf0019749a7275d286ef5b2c5d584d6d..caf31178a84b3da976634b53b1fc9e8ade835c8a 100644
--- a/app/code/Magento/DesignEditor/Helper/Data.php
+++ b/app/code/Magento/DesignEditor/Helper/Data.php
@@ -25,6 +25,7 @@
  */
 namespace Magento\DesignEditor\Helper;
 
+use Magento\App\Helper\Context;
 use Magento\App\RequestInterface;
 
 /**
@@ -62,12 +63,12 @@ class Data extends \Magento\App\Helper\AbstractHelper
     protected $_translationMode;
 
     /**
-     * @param \Magento\App\Helper\Context $context
+     * @param Context $context
      * @param string $frontName
      * @param array $disabledCacheTypes
      */
     public function __construct(
-        \Magento\App\Helper\Context $context,
+        Context $context,
         $frontName,
         array $disabledCacheTypes = array()
     ) {
diff --git a/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php b/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php
index ad51da83094328325b6e0013539ba32c3f0509ee..f30fdbd37545be00c546c10d6b3c385c12412637 100644
--- a/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php
+++ b/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php
@@ -40,13 +40,17 @@ class QuickStyles extends \Magento\DesignEditor\Model\Config\Control\AbstractCon
     protected $_controlAttributes = array('title', 'tab', 'column');
 
     /**
+     * Module configuration file reader
+     *
      * @var Reader
      */
     protected $_moduleReader;
 
     /**
+     * Constructor
+     *
      * @param array $configFiles
-     * @param \Magento\Module\Dir\Reader $moduleReader
+     * @param Reader $moduleReader
      */
     public function __construct(
         $configFiles,
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php
index e025cdc978eb3b2dcaec25e3579735f9894e4121..dce0699882f0d8391b8d66f58278f5e5056cf941 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Model\Editor\Tools\Controls;
 
 /**
@@ -164,7 +163,7 @@ class Configuration
     /**
      * Prepare list of control links
      *
-     * @param array $controls
+     * @param array &$controls
      * @return $this
      */
     protected function _prepareControlList(array &$controls)
@@ -181,7 +180,7 @@ class Configuration
     /**
      * Load data item values and default values from the view configuration
      *
-     * @param array $control
+     * @param array &$control
      * @param string $paramName
      * @param \Magento\Config\View $viewConfiguration
      * @return $this
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php
index cd60d6666a2c448b681a92cf2e4320cf39ad3a38..5d7cf43028e6e04218c7a6cacc82807a1954aeb3 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php
@@ -206,7 +206,7 @@ class Validator
     /**
      * Instantiate class validator
      *
-     * @param array $validators
+     * @param array &$validators
      * @return $this
      */
     protected function _instantiateValidators(array &$validators)
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php
index fbf86cca1436f66ebb769fbcdbdf998740a20374..7902305f58abb087d0146c00f7b653f418e146e2 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php
@@ -186,6 +186,7 @@ class Builder
      *
      * @param array $columns
      * @param string $tab
+     * @return void
      */
     protected function _populateColumns($columns, $tab)
     {
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php
index aa090553b6eb9bded6c204409b1fff9470abad01..01dd56646aa1a9e9de0bb78fbdaa9dd2907c1fe7 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php
@@ -25,6 +25,8 @@
  */
 namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Element;
 
+use Magento\ObjectManager;
+
 class Factory
 {
     /**
@@ -32,7 +34,10 @@ class Factory
      */
     protected $_objectManager;
 
-    public function __construct(\Magento\ObjectManager $objectManager)
+    /**
+     * @param ObjectManager $objectManager
+     */
+    public function __construct(ObjectManager $objectManager)
     {
         $this->_objectManager = $objectManager;
     }
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php
index 7859822286aa73c69d0c9e9066c402d30eab8c73..8df8770bd7ae905c641be96c8f1aac289defc470 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php
@@ -83,8 +83,8 @@ class Factory
     /**
      * Storage of renderers that could be shared between elements
      *
-     * @see self::create()
      * @var array
+     * @see self::create()
      */
     protected $_sharedRenderers = array();
 
@@ -125,7 +125,7 @@ class Factory
      *   reuse of renderer and then will not be restored.
      *
      * @param string $elementClassName
-     * @param string|null $rendererName
+     * @param string $rendererName
      * @return RendererInterface
      */
     public function getSharedInstance($elementClassName, $rendererName = null)
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php
index 30435b0e04c2970c64ef7623204ab8b79b9dd5c0..a5a4275bb41de2c657704ce23a349f4fef2aec84 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php
@@ -64,7 +64,7 @@ class Renderer
      * Render CSS recursively
      *
      * @param array $data
-     * @param string $content
+     * @param string &$content
      * @return $this
      */
     protected function _rendererCssRecursively($data, &$content)
diff --git a/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php b/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php
index 12b276d3cb836bd706f9e4bdc30179d4d337ff86..97f44b6388ecf66738936ae5571e6aa55e989462 100644
--- a/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php
+++ b/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php
@@ -23,6 +23,8 @@
  */
 namespace Magento\DesignEditor\Model\Plugin;
 
+use Magento\Code\Plugin\InvocationChain;
+
 class ThemeCopyService
 {
     /**
@@ -42,10 +44,10 @@ class ThemeCopyService
      * Copy additional information about theme change time
      *
      * @param array $methodArguments
-     * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @param InvocationChain $invocationChain
      * @return void
      */
-    public function aroundCopy(array $methodArguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
+    public function aroundCopy(array $methodArguments, InvocationChain $invocationChain)
     {
         $invocationChain->proceed($methodArguments);
 
diff --git a/app/code/Magento/DesignEditor/Model/State.php b/app/code/Magento/DesignEditor/Model/State.php
index 65424fc2ffa20be812696912b02c0af535f95d0b..3ad7b65e20e5edc16356b75684116f531812fa35 100644
--- a/app/code/Magento/DesignEditor/Model/State.php
+++ b/app/code/Magento/DesignEditor/Model/State.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\DesignEditor\Model;
 
 /**
@@ -185,6 +184,7 @@ class State
     /**
      * Create url model instance that will be used instead of \Magento\UrlInterface in navigation mode
      *
+     * @param string $mode
      * @return void
      */
     protected function _injectUrlModel($mode)
diff --git a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php
index 6e1d028722a2fa11dc0a6d37492e380a4fb32016..06244e7dd1d7c2c786563132fa38cb3c0b9728c0 100644
--- a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php
+++ b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php
@@ -48,6 +48,8 @@ class Change extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php b/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php
index 0c20236cb2dda69f189d5583cbe220fd86199950..5051be701cd7c1c407e063ad816dc7c893d0ecbe 100644
--- a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php
+++ b/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php
@@ -136,7 +136,7 @@ class InlineVde implements \Magento\Translate\InlineInterface
     /**
      * Replace VDE specific translation templates with HTML fragments
      *
-     * @param string[]|string $body
+     * @param string[]|string &$body
      * @param bool $isJson
      * @return $this
      */
@@ -169,6 +169,7 @@ class InlineVde implements \Magento\Translate\InlineInterface
     /**
      * Create block to render script and html with added inline translation content specific for vde.
      *
+     * @param string $content
      * @return void
      */
     private function _insertInlineScriptsHtml($content)
diff --git a/app/code/Magento/DesignEditor/Model/Url/Factory.php b/app/code/Magento/DesignEditor/Model/Url/Factory.php
index 8fcfd89fe4428434d8a3bbc2f70a670645b529dc..d7ea84c91c14fccd38c65100197fa24c99222ce9 100644
--- a/app/code/Magento/DesignEditor/Model/Url/Factory.php
+++ b/app/code/Magento/DesignEditor/Model/Url/Factory.php
@@ -50,7 +50,7 @@ class Factory
      * Replace name of url model
      *
      * @param string $className
-     * @return \Magento\DesignEditor\Model\Url\Factory
+     * @return $this
      */
     public function replaceClassName($className)
     {
diff --git a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php
index 87abae83f3505db4f92d7e43658cda52530b9560..93d9c8992a718df2686b00e3772b2569ef0ebb54 100644
--- a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php
+++ b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php
@@ -56,7 +56,7 @@ class NavigationMode extends \Magento\Url
      * @param \Magento\App\RequestInterface $request
      * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo
      * @param \Magento\Url\ScopeResolverInterface $scopeResolver
-     * @param \Magento\Core\Model\Session $session
+     * @param \Magento\Session\Generic $session
      * @param \Magento\Session\SidResolverInterface $sidResolver
      * @param \Magento\Url\RouteParamsResolverFactory $routeParamsResolver
      * @param \Magento\Url\QueryParamsResolverInterface $queryParamsResolver
@@ -68,7 +68,7 @@ class NavigationMode extends \Magento\Url
         \Magento\App\RequestInterface $request,
         \Magento\Url\SecurityInfoInterface $urlSecurityInfo,
         \Magento\Url\ScopeResolverInterface $scopeResolver,
-        \Magento\Core\Model\Session $session,
+        \Magento\Session\Generic $session,
         \Magento\Session\SidResolverInterface $sidResolver,
         \Magento\Url\RouteParamsResolverFactory $routeParamsResolver,
         \Magento\Url\QueryParamsResolverInterface $queryParamsResolver,
diff --git a/app/code/Magento/DesignEditor/view/frontend/translate_inline.phtml b/app/code/Magento/DesignEditor/view/frontend/translate_inline.phtml
index 3b8335078e7b995ee2ccce48f3ff6467d22fc474..79b6c44bd6841e2cc9eb9a077e3d43bdf84978ca 100644
--- a/app/code/Magento/DesignEditor/view/frontend/translate_inline.phtml
+++ b/app/code/Magento/DesignEditor/view/frontend/translate_inline.phtml
@@ -49,7 +49,7 @@
 </script>
 
 <div id="translate-dialog" data-role="translate-dialog"
-     data-mage-init="{loader: {icon: '<?php echo $this->getViewFileUrl('images/ajax-loader-tr.gif', array('area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)) ?>'}}">
+     data-mage-init='{"loader": {"icon": "<?php echo $this->getViewFileUrl('images/ajax-loader-tr.gif', array('area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)) ?>"}}'>
  </div>
 
 <script type="text/javascript">
diff --git a/app/code/Magento/Directory/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/Magento/Directory/Block/Adminhtml/Frontend/Region/Updater.php
index 0546c971e4978f05c0dec391e65e3bea55d3f1fa..b3cc15dd97f6df076271cf4bbc194d8e8abb7644 100644
--- a/app/code/Magento/Directory/Block/Adminhtml/Frontend/Region/Updater.php
+++ b/app/code/Magento/Directory/Block/Adminhtml/Frontend/Region/Updater.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Directory\Block\Adminhtml\Frontend\Region;
 
+use Magento\Data\Form\Element\AbstractElement;
+
 class Updater
     extends \Magento\Backend\Block\System\Config\Form\Field
 {
@@ -48,7 +50,11 @@ class Updater
         parent::__construct($context, $data);
     }
 
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(AbstractElement $element)
     {
         $html = parent::_getElementHtml($element);
         $html .= "<script type=\"text/javascript\">var updater = new RegionUpdater('tax_defaults_country',"
diff --git a/app/code/Magento/Directory/Controller/Currency.php b/app/code/Magento/Directory/Controller/Currency.php
index de4ce8aabb1caf39ee512d30683a97a135e5958e..8cb49bc7ff55740e84e7fecdc0cdf275168736ee 100644
--- a/app/code/Magento/Directory/Controller/Currency.php
+++ b/app/code/Magento/Directory/Controller/Currency.php
@@ -31,6 +31,9 @@ namespace Magento\Directory\Controller;
 
 class Currency extends \Magento\App\Action\Action
 {
+    /**
+     * @return void
+     */
     public function switchAction()
     {
         /** @var \Magento\Core\Model\StoreManagerInterface $storeManager */
diff --git a/app/code/Magento/Directory/Model/Config/Source/Allregion.php b/app/code/Magento/Directory/Model/Config/Source/Allregion.php
index 651cb23a0b1ecacb14837bdfd64ba834a442c0e7..11ab8d386d155d1d5a70d88d998da107a1fe39b0 100644
--- a/app/code/Magento/Directory/Model/Config/Source/Allregion.php
+++ b/app/code/Magento/Directory/Model/Config/Source/Allregion.php
@@ -60,6 +60,10 @@ class Allregion implements \Magento\Core\Model\Option\ArrayInterface
         $this->_regionCollectionFactory = $regionCollectionFactory;
     }
 
+    /**
+     * @param bool $isMultiselect
+     * @return array
+     */
     public function toOptionArray($isMultiselect = false)
     {
         if (!$this->_options) {
diff --git a/app/code/Magento/Directory/Model/Config/Source/Country.php b/app/code/Magento/Directory/Model/Config/Source/Country.php
index 7f46a57f8266274f9c462e2934a49c4da69737dc..25545a9d57eacb453111e57a263adad0aeb66088 100644
--- a/app/code/Magento/Directory/Model/Config/Source/Country.php
+++ b/app/code/Magento/Directory/Model/Config/Source/Country.php
@@ -47,7 +47,7 @@ class Country implements \Magento\Core\Model\Option\ArrayInterface
     /**
      * Options array
      *
-     * @var type
+     * @var array
      */
     protected $_options;
 
diff --git a/app/code/Magento/Directory/Model/Config/Source/Country/Full.php b/app/code/Magento/Directory/Model/Config/Source/Country/Full.php
index 76fecdd4eda1b941584daca5750f20c826377fc5..69f91fb4f4f401797b8dc5767bb9124fbebb2283 100644
--- a/app/code/Magento/Directory/Model/Config/Source/Country/Full.php
+++ b/app/code/Magento/Directory/Model/Config/Source/Country/Full.php
@@ -30,6 +30,10 @@ namespace Magento\Directory\Model\Config\Source\Country;
 class Full extends \Magento\Directory\Model\Config\Source\Country
     implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @param bool $isMultiselect
+     * @return array
+     */
     public function toOptionArray($isMultiselect=false) {
         return parent::toOptionArray(true);
     }
diff --git a/app/code/Magento/Directory/Model/Country.php b/app/code/Magento/Directory/Model/Country.php
index 786ade7a464c9af0a080dd63c744b37250227329..515b4e2f77496787dc9c35207de149118024c209 100644
--- a/app/code/Magento/Directory/Model/Country.php
+++ b/app/code/Magento/Directory/Model/Country.php
@@ -88,6 +88,9 @@ class Country extends \Magento\Core\Model\AbstractModel
         $this->_regionCollectionFactory = $regionCollectionFactory;
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Directory\Model\Resource\Country');
@@ -197,7 +200,7 @@ T: {{telephone}}";
      * Retrieve format
      *
      * @param string $type
-     * @return \Magento\Directory\Model\Country\Format
+     * @return \Magento\Directory\Model\Country\Format|null
      */
     public function getFormat($type)
     {
diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php
index 26ca8e06fe47464236f1d24ccb6b8f37ebf8e945..aa5da371fb7130bbc100ad91eece1ea92a3e53c7 100644
--- a/app/code/Magento/Directory/Model/Currency.php
+++ b/app/code/Magento/Directory/Model/Currency.php
@@ -33,6 +33,9 @@
  */
 namespace Magento\Directory\Model;
 
+use Magento\Directory\Exception;
+use Magento\Directory\Model\Currency\Filter;
+
 class Currency extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -42,6 +45,9 @@ class Currency extends \Magento\Core\Model\AbstractModel
     const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default';
     const XML_PATH_CURRENCY_BASE    = 'currency/options/base';
 
+    /**
+     * @var Filter
+     */
     protected $_filter;
 
     /**
@@ -102,6 +108,9 @@ class Currency extends \Magento\Core\Model\AbstractModel
         $this->_currencyFilterFactory = $currencyFilterFactory;
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Directory\Model\Resource\Currency');
@@ -138,8 +147,8 @@ class Currency extends \Magento\Core\Model\AbstractModel
     /**
      * Currency Rates setter
      *
-     * @param array Currency Rates
-     * @return \Magento\Directory\Model\Currency
+     * @param array $rates Currency Rates
+     * @return $this
      */
     public function setRates(array $rates)
     {
@@ -152,7 +161,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
      *
      * @param   string $id
      * @param   string $field
-     * @return  \Magento\Directory\Model\Currency
+     * @return  $this
      */
     public function load($id, $field = null)
     {
@@ -165,8 +174,8 @@ class Currency extends \Magento\Core\Model\AbstractModel
      * Get currency rate (only base => allowed)
      *
      * @param string $toCurrency
-     * @return double
-     * @throws \Magento\Directory\Exception
+     * @return float
+     * @throws Exception
      */
     public function getRate($toCurrency)
     {
@@ -175,7 +184,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
         } elseif ($toCurrency instanceof \Magento\Directory\Model\Currency) {
             $code = $toCurrency->getCurrencyCode();
         } else {
-            throw new \Magento\Directory\Exception(__('Please correct the target currency.'));
+            throw new Exception(__('Please correct the target currency.'));
         }
         $rates = $this->getRates();
         if (!isset($rates[$code])) {
@@ -189,8 +198,8 @@ class Currency extends \Magento\Core\Model\AbstractModel
      * Get currency rate (base=>allowed or allowed=>base)
      *
      * @param string $toCurrency
-     * @return double
-     * @throws \Magento\Directory\Exception
+     * @return float
+     * @throws Exception
      */
     public function getAnyRate($toCurrency)
     {
@@ -199,7 +208,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
         } elseif ($toCurrency instanceof \Magento\Directory\Model\Currency) {
             $code = $toCurrency->getCurrencyCode();
         } else {
-            throw new \Magento\Directory\Exception(__('Please correct the target currency.'));
+            throw new Exception(__('Please correct the target currency.'));
         }
         $rates = $this->getRates();
         if (!isset($rates[$code])) {
@@ -212,9 +221,9 @@ class Currency extends \Magento\Core\Model\AbstractModel
     /**
      * Convert price to currency format
      *
-     * @param   double $price
+     * @param   float $price
      * @param   string $toCurrency
-     * @return  double
+     * @return  float
      * @throws \Exception
      */
     public function convert($price, $toCurrency = null)
@@ -231,7 +240,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
     /**
      * Get currency filter
      *
-     * @return \Magento\Directory\Model\Currency\Filter
+     * @return Filter
      */
     public function getFilter()
     {
@@ -245,7 +254,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
     /**
      * Format price to currency format
      *
-     * @param double $price
+     * @param float $price
      * @param array $options
      * @param bool $includeContainer
      * @param bool $addBrackets
@@ -316,6 +325,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve allowed currencies according to config
      *
+     * @return array
      */
     public function getConfigAllowCurrencies()
     {
@@ -337,6 +347,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
     /**
      * Retrieve default currencies according to config
      *
+     * @return array
      */
     public function getConfigDefaultCurrencies()
     {
@@ -345,6 +356,9 @@ class Currency extends \Magento\Core\Model\AbstractModel
     }
 
 
+    /**
+     * @return array
+     */
     public function getConfigBaseCurrencies()
     {
         $defaultCurrencies = $this->_getResource()->getConfigCurrencies($this, self::XML_PATH_CURRENCY_BASE);
@@ -355,7 +369,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
      * Retrieve currency rates to other currencies
      *
      * @param string $currency
-     * @param array $toCurrencies
+     * @param array|null $toCurrencies
      * @return array
      */
     public function getCurrencyRates($currency, $toCurrencies=null)
@@ -371,7 +385,7 @@ class Currency extends \Magento\Core\Model\AbstractModel
      * Save currency rates
      *
      * @param array $rates
-     * @return object
+     * @return $this
      */
     public function saveRates($rates)
     {
diff --git a/app/code/Magento/Directory/Model/Currency/Filter.php b/app/code/Magento/Directory/Model/Currency/Filter.php
index 130b8561929bceb0e6fd49681a947ead19da2a2e..ee3157255de4a3459ecc4b3384ba5d224a045a2c 100644
--- a/app/code/Magento/Directory/Model/Currency/Filter.php
+++ b/app/code/Magento/Directory/Model/Currency/Filter.php
@@ -34,7 +34,7 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Rate value
      *
-     * @var decimal
+     * @var float
      */
     protected $_rate;
 
@@ -76,7 +76,8 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Set filter rate
      *
-     * @param double $rate
+     * @param float $rate
+     * @return void
      */
     public function setRate($rate)
     {
@@ -86,8 +87,8 @@ class Filter implements \Zend_Filter_Interface
     /**
      * Filter value
      *
-     * @param   double $value
-     * @return  string
+     * @param float $value
+     * @return string
      */
     public function filter($value)
     {
diff --git a/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php b/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php
index 2e85e2301eb97d535c8a255e7773ed3a7882385f..00278c8deb9eeafd11f849a9336b12a2015ff78b 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php
@@ -101,7 +101,7 @@ abstract class AbstractImport
     /**
      * Import rates
      *
-     * @return \Magento\Directory\Model\Currency\Import\AbstractImport
+     * @return $this
      */
     public function importRates()
     {
@@ -140,6 +140,10 @@ abstract class AbstractImport
         return $data;
     }
 
+    /**
+     * @param float|int $number
+     * @return float|int
+     */
     protected function _numberFormat($number)
     {
         return $number;
diff --git a/app/code/Magento/Directory/Model/Observer.php b/app/code/Magento/Directory/Model/Observer.php
index 2a0fe8ab0932dc5d07a173833a5ed5827aa1e44a..ba7041cc24a9687ba7f1fa6c82716327e77c77f4 100644
--- a/app/code/Magento/Directory/Model/Observer.php
+++ b/app/code/Magento/Directory/Model/Observer.php
@@ -33,7 +33,7 @@ namespace Magento\Directory\Model;
 
 class Observer
 {
-    const CRON_STRING_PATH = 'crontab/jobs/currency_rates_update/schedule/cron_expr';
+    const CRON_STRING_PATH = 'crontab/default/jobs/currency_rates_update/schedule/cron_expr';
     const IMPORT_ENABLE = 'currency/import/enabled';
     const IMPORT_SERVICE = 'currency/import/service';
 
@@ -97,6 +97,10 @@ class Observer
         $this->_currencyFactory = $currencyFactory;
     }
 
+    /**
+     * @param mixed $schedule
+     * @return void
+     */
     public function scheduledUpdateCurrencyRates($schedule)
     {
         $importWarnings = array();
diff --git a/app/code/Magento/Directory/Model/Region.php b/app/code/Magento/Directory/Model/Region.php
index 3284d75d286890780ea6bb4adbae6b30ace78fd8..e02e1b0ea0cb6aa6a3da0f9da9653a5d8ba491f9 100644
--- a/app/code/Magento/Directory/Model/Region.php
+++ b/app/code/Magento/Directory/Model/Region.php
@@ -45,6 +45,9 @@ namespace Magento\Directory\Model;
 
 class Region extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Directory\Model\Resource\Region');
@@ -66,6 +69,11 @@ class Region extends \Magento\Core\Model\AbstractModel
         return $name;
     }
 
+    /**
+     * @param string $code
+     * @param string $countryId
+     * @return $this
+     */
     public function loadByCode($code, $countryId)
     {
         if ($code) {
@@ -74,10 +82,14 @@ class Region extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param string $name
+     * @param string $countryId
+     * @return $this
+     */
     public function loadByName($name, $countryId)
     {
         $this->_getResource()->loadByName($this, $name, $countryId);
         return $this;
     }
-
 }
diff --git a/app/code/Magento/Directory/Model/Resource/Country/Collection.php b/app/code/Magento/Directory/Model/Resource/Country/Collection.php
index 4f446660e26749825c369d829f9012f23394e51d..9af35ea6589b8193ead8c50c0bc2e9d12684fc0e 100644
--- a/app/code/Magento/Directory/Model/Resource/Country/Collection.php
+++ b/app/code/Magento/Directory/Model/Resource/Country/Collection.php
@@ -97,6 +97,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Define main table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -140,9 +141,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * $iso can be either array containing 'iso2', 'iso3' values or string with containing one of that values directly.
      * The collection will contain countries where at least one of contry $iso fields matches $countryCode.
      *
-     * @param string|array $countryCode
-     * @param string|array $iso
-     * @return \Magento\Directory\Model\Resource\Country\Collection
+     * @param string|string[] $countryCode
+     * @param string|string[] $iso
+     * @return $this
      */
     public function addCountryCodeFilter($countryCode, $iso = array('iso3', 'iso2'))
     {
@@ -175,8 +176,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add filter by country code(s) to collection
      *
-     * @param string|array $countryId
-     * @return \Magento\Directory\Model\Resource\Country\Collection
+     * @param string|string[] $countryId
+     * @return $this
      */
     public function addCountryIdFilter($countryId)
     {
@@ -232,7 +233,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set foreground countries array
      *
      * @param string|array $foregroundCountries
-     * @return \Magento\Directory\Model\Resource\Country\Collection
+     * @return $this
      */
     public function setForegroundCountries($foregroundCountries)
     {
diff --git a/app/code/Magento/Directory/Model/Resource/Currency.php b/app/code/Magento/Directory/Model/Resource/Currency.php
index 47d839020eed72c4cb664c64f6e41d59c1282b5e..80b54ac8592631a1f1737107e2a8276aeccd9c64 100644
--- a/app/code/Magento/Directory/Model/Resource/Currency.php
+++ b/app/code/Magento/Directory/Model/Resource/Currency.php
@@ -48,6 +48,7 @@ class Currency extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main and currency rate tables
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -143,6 +144,7 @@ class Currency extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Saving currency rates
      *
      * @param array $rates
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function saveRates($rates)
@@ -176,7 +178,6 @@ class Currency extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Directory\Model\Currency $model
      * @param string $path
-     *
      * @return array
      */
     public function getConfigCurrencies($model, $path)
@@ -201,7 +202,6 @@ class Currency extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param string|array $currency
      * @param array $toCurrencies
-     *
      * @return array
      */
     public function getCurrencyRates($currency, $toCurrencies = null)
diff --git a/app/code/Magento/Directory/Model/Resource/Region.php b/app/code/Magento/Directory/Model/Resource/Region.php
index c32021b1d3fa2362ed76c1d9888a08dc36d066e9..d6d0604423899e780f3b118fd49a68ba604f8831 100644
--- a/app/code/Magento/Directory/Model/Resource/Region.php
+++ b/app/code/Magento/Directory/Model/Resource/Region.php
@@ -57,6 +57,8 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Define main and locale region name tables
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -109,7 +111,7 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int $countryId
      * @param string $value
      * @param string $field
-     * @return \Magento\Directory\Model\Resource\Region
+     * @return $this
      */
     protected function _loadByCountry($object, $countryId, $value, $field)
     {
@@ -142,7 +144,7 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param string $regionCode
      * @param string $countryId
      *
-     * @return \Magento\Directory\Model\Resource\Region
+     * @return $this
      */
     public function loadByCode(\Magento\Directory\Model\Region $region, $regionCode, $countryId)
     {
@@ -155,7 +157,7 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\Directory\Model\Region $region
      * @param string $regionName
      * @param string $countryId
-     * @return \Magento\Directory\Model\Resource\Region
+     * @return $this
      */
     public function loadByName(\Magento\Directory\Model\Region $region, $regionName, $countryId)
     {
diff --git a/app/code/Magento/Directory/Model/Resource/Region/Collection.php b/app/code/Magento/Directory/Model/Resource/Region/Collection.php
index fe0b8278dd0602b5b3a87e694d3e7b06bb0632ec..717cb18fead58a0a9e75c93e085defc937594f9e 100644
--- a/app/code/Magento/Directory/Model/Resource/Region/Collection.php
+++ b/app/code/Magento/Directory/Model/Resource/Region/Collection.php
@@ -74,6 +74,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Define main, country, locale region name tables
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -89,7 +91,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Initialize select object
      *
-     * @return \Magento\Directory\Model\Resource\Region\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -109,7 +111,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter by country_id
      *
      * @param string|array $countryId
-     * @return \Magento\Directory\Model\Resource\Region\Collection
+     * @return $this
      */
     public function addCountryFilter($countryId)
     {
@@ -127,7 +129,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter by country code (ISO 3)
      *
      * @param string $countryCode
-     * @return \Magento\Directory\Model\Resource\Region\Collection
+     * @return $this
      */
     public function addCountryCodeFilter($countryCode)
     {
@@ -145,7 +147,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter by Region code
      *
      * @param string|array $regionCode
-     * @return \Magento\Directory\Model\Resource\Region\Collection
+     * @return $this
      */
     public function addRegionCodeFilter($regionCode)
     {
@@ -163,7 +165,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter by region name
      *
      * @param string|array $regionName
-     * @return \Magento\Directory\Model\Resource\Region\Collection
+     * @return $this
      */
     public function addRegionNameFilter($regionName)
     {
@@ -181,7 +183,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter region by its code or name
      *
      * @param string|array $region
-     * @return \Magento\Directory\Model\Resource\Region\Collection
+     * @return $this
      */
     public function addRegionCodeOrNameFilter($region)
     {
diff --git a/app/code/Magento/Directory/etc/crontab.xml b/app/code/Magento/Directory/etc/crontab.xml
index d478b5d180ec630e8341a6d8fab4b7187eed1dee..74db0fa8db6d2a1999f163716d75a4174352dd37 100644
--- a/app/code/Magento/Directory/etc/crontab.xml
+++ b/app/code/Magento/Directory/etc/crontab.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="currency_rates_update" instance="Magento\Directory\Model\Observer" method="scheduledUpdateCurrencyRates" />
+    <group id="default">
+        <job name="currency_rates_update" instance="Magento\Directory\Model\Observer" method="scheduledUpdateCurrencyRates" />
+    </group>
 </config>
diff --git a/app/code/Magento/Downloadable/etc/adminhtml/events.xml b/app/code/Magento/Downloadable/etc/adminhtml/events.xml
index 6c175d47eca9d833bbf1680c778eb53055863253..189e9c81a74bdaf89e50beda9409c74dc3c6d3bd 100644
--- a/app/code/Magento/Downloadable/etc/adminhtml/events.xml
+++ b/app/code/Magento/Downloadable/etc/adminhtml/events.xml
@@ -31,6 +31,6 @@
         <observer name="downloadable_observer" instance="Magento\Downloadable\Model\Observer" method="setLinkStatus" />
     </event>
     <event name="catalog_product_transition_product_type">
-        <observer name="type_transition" instance="Magento\Downloadable\Model\Observer" method="transitionProductType" />
+        <observer name="downloadable_type_transition" instance="Magento\Downloadable\Model\Observer" method="transitionProductType" />
     </event>
 </config>
diff --git a/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml b/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml
index 28bbf52834180d8ab3c87098fc22e1d591acb7fc..f4843b14fed71eaee0d4bb46807bfd06d7a9c36f 100644
--- a/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml
+++ b/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml
@@ -51,7 +51,7 @@ $canApplyMsrp = $this->helper('Magento\Catalog\Helper\Data')->canApplyMsrp($_ite
                         <?php foreach ($_options as $_option) : ?>
                             <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
                             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
-                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+                            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                                 <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                     <div class="truncated_full_value">
                                         <dl class="item options">
diff --git a/app/code/Magento/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml
index fa64624d2b8230e9684b830b808690c162788a8b..70e320005f169bc6f689cfb2343390d982c907ac 100644
--- a/app/code/Magento/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml
+++ b/app/code/Magento/Downloadable/view/frontend/sales/order/creditmemo/items/renderer/downloadable.phtml
@@ -35,7 +35,7 @@
                     <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                     <?php if (!$this->getPrintStatus()): ?>
                         <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                             <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                 <div class="truncated_full_value">
                                     <dl class="item options">
diff --git a/app/code/Magento/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml
index 6c5b1895705f174239d49044bf7c7150f601b631..9be0ce1ede112e1ac7a3963fb8f3cbbf92e8225c 100644
--- a/app/code/Magento/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml
+++ b/app/code/Magento/Downloadable/view/frontend/sales/order/invoice/items/renderer/downloadable.phtml
@@ -35,7 +35,7 @@
                     <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                     <?php if (!$this->getPrintStatus()): ?>
                         <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                             <?php echo $_formatedOptionValue['value'] ?>
                             <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                 <div class="truncated_full_value">
diff --git a/app/code/Magento/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml
index 2c413fa787fbf347516a3d403cd875a66d0b2aa6..cf41bb41f5cd0bc08c7ae1124a9af56ae068c894 100644
--- a/app/code/Magento/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml
+++ b/app/code/Magento/Downloadable/view/frontend/sales/order/items/renderer/downloadable.phtml
@@ -34,7 +34,7 @@
                     <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                     <?php if (!$this->getPrintStatus()): ?>
                         <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                             <?php echo $_formatedOptionValue['value'] ?>
                             <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                 <div class="truncated_full_value">
diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php
index 0c718870e025a723938d8aa48b71e2466926959a..1cbdf8992ee190bea19b8488f263c8ceb7486d2f 100644
--- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php
+++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Block\Adminhtml\Attribute\Edit;
 
 /**
  * Eav Attribute Block with additional js scripts in template
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Block\Adminhtml\Attribute\Edit;
-
 class Js extends \Magento\Backend\Block\Template
 {
     /**
diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php
index 90a4f076b45aaeb03f1d89286c2a83e5a75d6652..659873cf320ada7b6a7acefb4b87fa509b18cb04 100644
--- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php
+++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php
@@ -38,7 +38,7 @@ abstract class AbstractOptions extends \Magento\View\Element\AbstractBlock
     /**
      * Preparing layout, adding buttons
      *
-     * @return \Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php
index ba1370c339d95353f8f1aee0c20297b51173ce5d..22d9a3860bee82bd01ad7ed839d9d44827bdb5e9 100644
--- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php
+++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Block\Adminhtml\Attribute\Edit\Options;
 
 /**
  * Attribute add/edit form options tab
@@ -31,15 +32,15 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Block\Adminhtml\Attribute\Edit\Options;
-
 class Labels extends \Magento\Backend\Block\Template
 {
-    /** @var \Magento\Core\Model\Registry */
+    /**
+     * @var \Magento\Core\Model\Registry
+     */
     protected $_registry;
 
     /**
-     * @inheritdoc
+     * @var string
      */
     protected $_template = 'Magento_Catalog::catalog/product/attribute/labels.phtml';
 
diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php
index c3e5dc39d251dcf8d4dd2f12c45cd2b1594a4b12..02ff145855820a63b7f8866b88c72438823fa70f 100644
--- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php
+++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php
@@ -37,14 +37,18 @@ use Magento\Core\Model\Resource\Store\Collection;
 
 class Options extends \Magento\Backend\Block\Template
 {
-    /** @var \Magento\Core\Model\Registry */
+    /**
+     * @var \Magento\Core\Model\Registry
+     */
     protected $_registry;
 
-    /** @var \Magento\Eav\Model\Resource\Entity\Attribute\Option\CollectionFactory */
+    /**
+     * @var \Magento\Eav\Model\Resource\Entity\Attribute\Option\CollectionFactory
+     */
     protected $_attrOptionCollectionFactory;
 
     /**
-     * @inheritdoc
+     * @var string
      */
     protected $_template = 'Magento_Catalog::catalog/product/attribute/options.phtml';
 
diff --git a/app/code/Magento/Eav/Helper/Data.php b/app/code/Magento/Eav/Helper/Data.php
index 5c7d774ac108823225f04cc98959977d16f50516..a50aab19ccac949d6c379fad87e1c5d600a630bd 100644
--- a/app/code/Magento/Eav/Helper/Data.php
+++ b/app/code/Magento/Eav/Helper/Data.php
@@ -23,21 +23,28 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Helper;
 
 /**
  * Eav data helper
  */
-namespace Magento\Eav\Helper;
-
 class Data extends \Magento\App\Helper\AbstractHelper
 {
     /**
      * XML path to input types validator data in config
+     *
+     * @var string
      */
     const XML_PATH_VALIDATOR_DATA_INPUT_TYPES = 'general/validator_data/input_types';
 
+    /**
+     * @var array
+     */
     protected $_attributesLockedFields = array();
 
+    /**
+     * @var array
+     */
     protected $_entityTypeFrontendClasses = array();
 
     /**
diff --git a/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php b/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php
index 25f399f03637dfe71e18ee4311d342cff99e4634..fbf896570e1c2e475b3998370829004f5898821f 100644
--- a/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php
+++ b/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype;
 
 /**
  * Validator for check input type value
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype;
-
 class Validator extends \Zend_Validate_InArray
 {
 
@@ -67,7 +66,7 @@ class Validator extends \Zend_Validate_InArray
     /**
      * Initialize message templates with translating
      *
-     * @return \Magento\Core\Model\File\Validator\AvailablePath
+     * @return $this
      */
     protected function _initMessageTemplates()
     {
@@ -84,7 +83,7 @@ class Validator extends \Zend_Validate_InArray
      * Add input type to haystack
      *
      * @param string $type
-     * @return \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator
+     * @return $this
      */
     public function addInputType($type)
     {
diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php
index d654c79e59e6ac3c3da0dd65e8cf69f6e9cae8ac..180eab096ffecc5e319e16a844157228da28225f 100644
--- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php
+++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php
@@ -554,7 +554,7 @@ abstract class AbstractData
      * Extract data from request and return value
      *
      * @param RequestInterface $request
-     * @return array|string
+     * @return array|string|bool
      */
     abstract public function extractValue(RequestInterface $request);
 
diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Boolean.php b/app/code/Magento/Eav/Model/Attribute/Data/Boolean.php
index 0a361ad83caba0fff3092656666d6827ebe3abfb..cf6c5cc14c79db6a0de8a2d92bf30da1d4882f48 100644
--- a/app/code/Magento/Eav/Model/Attribute/Data/Boolean.php
+++ b/app/code/Magento/Eav/Model/Attribute/Data/Boolean.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Attribute\Data;
 
 /**
  * EAV Entity Attribute Boolean Data Model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Attribute\Data;
-
 class Boolean extends \Magento\Eav\Model\Attribute\Data\Select
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Hidden.php b/app/code/Magento/Eav/Model/Attribute/Data/Hidden.php
index 9f29cd0c4373d0ffce447dc033c24ce35e352c32..346d543e01b78930821d12d002cc22fdf434d039 100644
--- a/app/code/Magento/Eav/Model/Attribute/Data/Hidden.php
+++ b/app/code/Magento/Eav/Model/Attribute/Data/Hidden.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Attribute\Data;
 
 /**
  * EAV Entity Attribute Hidden text Data Model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Attribute\Data;
-
 class Hidden extends \Magento\Eav\Model\Attribute\Data\Text
 {
 }
diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Textarea.php b/app/code/Magento/Eav/Model/Attribute/Data/Textarea.php
index 91fbf5e2ba1723b9cca51cf90b178d16b5cd2355..37f8cfb64b968ab86f8e60badf63cc20922aed05 100644
--- a/app/code/Magento/Eav/Model/Attribute/Data/Textarea.php
+++ b/app/code/Magento/Eav/Model/Attribute/Data/Textarea.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Attribute\Data;
 
 /**
  * EAV Entity Attribute Text Area Data Model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Attribute\Data;
-
 class Textarea extends \Magento\Eav\Model\Attribute\Data\Text
 {
 }
diff --git a/app/code/Magento/Eav/Model/AttributeDataFactory.php b/app/code/Magento/Eav/Model/AttributeDataFactory.php
index 78311163b85ce8af80f1e270e6c0846a6ed84cee..f5efdf428e40b79288db0ab2017c86ae580c5c85 100644
--- a/app/code/Magento/Eav/Model/AttributeDataFactory.php
+++ b/app/code/Magento/Eav/Model/AttributeDataFactory.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model;
 
 /**
  * EAV Entity Attribute Data Factory
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model;
-
 class AttributeDataFactory
 {
     const OUTPUT_FORMAT_JSON    = 'json';
diff --git a/app/code/Magento/Eav/Model/AttributeFactory.php b/app/code/Magento/Eav/Model/AttributeFactory.php
index 8526f8b56c1e49cebd986daed02fd0818d91a899..646662ccfa03d9f20fe53ba5116574b1d33e3147 100644
--- a/app/code/Magento/Eav/Model/AttributeFactory.php
+++ b/app/code/Magento/Eav/Model/AttributeFactory.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model;
 
 /**
  * EAV attribute model factory
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model;
-
 class AttributeFactory
 {
     /**
@@ -49,7 +48,7 @@ class AttributeFactory
     }
 
     /**
-     * create new Eav attribute instance
+     * Create new Eav attribute instance
      *
      * @param string $className
      * @param array $arguments
diff --git a/app/code/Magento/Eav/Model/Cache/Type.php b/app/code/Magento/Eav/Model/Cache/Type.php
index fce17ec89a91bcc65981652b84df254969e36096..acbc75e0182772bb169dba60e02343c4524226c3 100644
--- a/app/code/Magento/Eav/Model/Cache/Type.php
+++ b/app/code/Magento/Eav/Model/Cache/Type.php
@@ -23,14 +23,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Cache;
 
 /**
  * System / Cache Management / Cache type "EAV types and attributes"
  *
  * @todo utilize the class for all manipulations with the cache type
  */
-namespace Magento\Eav\Model\Cache;
-
 class Type extends \Magento\Cache\Frontend\Decorator\TagScope
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity.php b/app/code/Magento/Eav/Model/Entity.php
index aa47e0a4aa989626ef63854638040778f620140a..92f7ef815fc97d217af9e7037f584beb81f3d335 100644
--- a/app/code/Magento/Eav/Model/Entity.php
+++ b/app/code/Magento/Eav/Model/Entity.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model;
 
 /**
  * EAV entity model
@@ -31,8 +31,6 @@
  * @category   Magento
  * @package    Magento_Eav
  */
-namespace Magento\Eav\Model;
-
 class Entity extends \Magento\Eav\Model\Entity\AbstractEntity
 {
     const DEFAULT_ENTITY_MODEL      = 'Magento\Eav\Model\Entity';
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index 343c53fb3653a2653b3e36af733d5fa0c378f5d7..d67aca2d8c2b18a55afee1ddfa6211faaa79a86d 100644
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -23,28 +23,26 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
-/**
- * Entity/Attribute/Model - entity abstract
- *
- * @category   Magento
- * @package    Magento_Eav
- * @author     Magento Core Team <core@magentocommerce.com>
- */
 namespace Magento\Eav\Model\Entity;
 
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
 use Magento\Eav\Model\Entity\Type;
 use Magento\Core\Exception;
 use Magento\Core\Model\Config\Element;
-use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
 use Magento\Core\Model\AbstractModel;
 use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
 use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
 use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
 
+/**
+ * Entity/Attribute/Model - entity abstract
+ *
+ * @category   Magento
+ * @package    Magento_Eav
+ * @author     Magento Core Team <core@magentocommerce.com>
+ */
 abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResource
-    implements \Magento\Eav\Model\Entity\EntityInterface
+    implements EntityInterface
 {
     /**
      * Read connection
@@ -82,7 +80,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou
     protected $_attributesByCode            = array();
 
     /**
-     * 2-dimentional array by table name and attribute name
+     * Two-dimensional array by table name and attribute name
      *
      * @var array
      */
@@ -518,7 +516,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou
      * Return default static virtual attribute that doesn't exists in EAV attributes
      *
      * @param string $attributeCode
-     * @return \Magento\Eav\Model\Entity\Attribute
+     * @return Attribute
      */
     protected function _getDefaultAttribute($attributeCode)
     {
@@ -651,8 +649,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou
     /**
      * Compare attributes
      *
-     * @param \Magento\Eav\Model\Entity\Attribute $firstAttribute
-     * @param \Magento\Eav\Model\Entity\Attribute $secondAttribute
+     * @param Attribute $firstAttribute
+     * @param Attribute $secondAttribute
      * @return int
      */
     public function attributesCompare($firstAttribute, $secondAttribute)
@@ -1208,7 +1206,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou
     /**
      * Aggregate Data for attributes that will be deleted
      *
-     * @param array $delete
+     * @param array &$delete
      * @param AbstractAttribute $attribute
      * @param \Magento\Eav\Model\Entity\AbstractEntity $object
      * @return void
@@ -1226,7 +1224,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou
     /**
      * Prepare entity object data for save
      *
-     * result array structure:
+     * Result array structure:
      * array (
      *  'newObject', 'entityRow', 'insert', 'update', 'delete'
      * )
@@ -1540,7 +1538,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou
     }
 
     /**
-     * Save and detele collected attribute values
+     * Save and delete collected attribute values
      *
      * @return $this
      */
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php
index fda3501c7cc4d308facdc697716f1aa2d7c32c1b..ac842cfbf6683e6963d4a46a4138e7442851904e 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Entity\Attribute\Backend;
 
 /**
  * Backend model for attribute with multiple values
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute\Backend;
-
 class ArrayBackend extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php
index 7841426fc59122e25199d90b14c3a82c17450f75..823545c7278727a31980b40442607402cf0cf47e 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Entity\Attribute\Backend;
 
 /**
  * Entity/Attribute/Model - attribute backend default
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute\Backend;
-
 class DefaultBackend extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
 
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php
index 18bdda894e49a98885945ed64323fc1c7210d18d..66e2a31e4f25ceb032690453a9027ca929095a2d 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Entity\Attribute\Backend;
 
 /**
  * Entity/Attribute/Model - attribute backend default
@@ -31,15 +32,13 @@
  * @package    Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute\Backend;
-
 class Increment extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
      * Set new increment id
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Increment
+     * @return $this
      */
     public function beforeSave($object)
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Serialized.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Serialized.php
index 16ba7c96063ed462f48b80ac94cd7e0b569a9a44..5dce2285186e4521694c7e4fdf709aafd7334603 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Serialized.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Serialized.php
@@ -23,19 +23,18 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Entity\Attribute\Backend;
 
 /**
  * "Serialized" attribute backend
  */
-namespace Magento\Eav\Model\Entity\Attribute\Backend;
-
 class Serialized extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
 {
     /**
      * Serialize before saving
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Serialized
+     * @return $this
      */
     public function beforeSave($object)
     {
@@ -52,7 +51,7 @@ class Serialized extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBac
      * Unserialize after saving
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Serialized
+     * @return $this
      */
     public function afterSave($object)
     {
@@ -65,7 +64,7 @@ class Serialized extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBac
      * Unserialize after loading
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Serialized
+     * @return $this
      */
     public function afterLoad($object)
     {
@@ -78,7 +77,7 @@ class Serialized extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBac
      * Try to unserialize the attribute value
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Serialized
+     * @return $this
      */
     protected function _unserialize(\Magento\Object $object)
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php
index 4f2956ec48a808f4db782bc3d250fc02ba17adc8..028769264ded36fb050c159681e629f8f3bb3f0d 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php
@@ -48,7 +48,7 @@ class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
      * Prepare data before save
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Store
+     * @return $this
      */
     protected function _beforeSave($object)
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php
index 58971baf0deda2e10cbbdf1f34be51efed53f4e9..f7e99470c288c93f740b4814de1951d048f0481b 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php
@@ -52,7 +52,7 @@ class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken
      * Set created date
      *
      * @param \Magento\Core\Model\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Time\Created
+     * @return $this
      */
     public function beforeSave($object)
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php
index 348896b8dca64edf4f01c606693ffff143c829c2..1506839e02d6d78fe380f084f0115941cf8ce776 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php
@@ -53,7 +53,7 @@ class Updated extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken
      * Set modified date
      *
      * @param \Magento\Object $object
-     * @return \Magento\Eav\Model\Entity\Attribute\Backend\Time\Updated
+     * @return $this
      */
     public function beforeSave($object)
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php b/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php
index 7b3531c89ea06c9a63dff5baac5e4916d5343a4f..6613229dcf1525d3f06ec3a2bed8c99c8ad2ad1b 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Entity\Attribute;
 
 /**
  * EAV entity attribute exception
@@ -32,8 +32,6 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute;
-
 class Exception extends \Exception
 {
     /**
@@ -55,7 +53,7 @@ class Exception extends \Exception
      * Set Eav entity attribute
      *
      * @param string $attribute
-     * @return \Magento\Eav\Model\Entity\Attribute\Exception
+     * @return $this
      */
     public function setAttributeCode($attribute)
     {
@@ -67,7 +65,7 @@ class Exception extends \Exception
      * Set Eav entity attribute type
      *
      * @param string $part
-     * @return \Magento\Eav\Model\Entity\Attribute\Exception
+     * @return $this
      */
     public function setPart($part) {
         $this->_part = $part;
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php
index 25134cfde93bb15df9808047843dff73bafde904..d432bee01bf2cad1873194a52cb1ba9b5254ae06 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php
@@ -50,6 +50,9 @@ abstract class AbstractFrontend
      */
     protected $_attrBooleanFactory;
 
+    /**
+     * @param \Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory $attrBooleanFactory
+     */
     function __construct(\Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory $attrBooleanFactory)
     {
         $this->_attrBooleanFactory = $attrBooleanFactory;
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
index 3c48de0b455016358f9f62e74dad72811dda3157..1b04760dc80b74cb8d9342e9d53fed7716b001a3 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Eav\Model\Entity\Attribute\Frontend;
 
 class Datetime extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php
index ebb2834587405d0e76e4018a9e862680d1f97156..a2d74b8bed15e91b507dacf6c9f48075057e8206 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Eav\Model\Entity\Attribute\Frontend;
 
 class DefaultFrontend extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php
index f65433c6f840533cfa5c2e265b5a1a96e018d18c..187e67271726179840d5e4588178ab5e20d36c33 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php
@@ -71,7 +71,7 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Delete groups
      *
-     * @return \Magento\Eav\Model\Entity\Attribute\Group
+     * @return $this
      */
     public function deleteGroups()
     {
@@ -81,7 +81,7 @@ class Group extends \Magento\Core\Model\AbstractModel
     /**
      * Processing object before save data
      *
-     * @return \Magento\Eav\Model\Entity\Attribute\Group
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php
index a13bc212944cc43a9dac984b9c842df7dd1ac702..4c08812c31cad4867503c0e91b1d98d8f071ef38 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Entity\Attribute;
 
 /**
  * Emtity attribute option model
@@ -38,8 +39,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute;
-
 class Option extends \Magento\Core\Model\AbstractModel
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php
index 15239bc57909753b1b80925cd36d9d13c31fb12e..66d9c151a2c2456b4ab2d8a8c63148623030b935 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php
@@ -93,7 +93,7 @@ abstract class AbstractSource
     }
 
     /**
-     * @param $value string
+     * @param string $value
      * @return null|string
      */
     public function getOptionId($value)
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php
index 3a5db9d3535ff05f766575ddfad714e26e110721..832419e40d4217d00abd2c3ab1adc1dd84d6f88c 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Eav\Model\Entity\Attribute\Source;
 
 class Boolean extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
@@ -100,7 +98,7 @@ class Boolean extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
      * Get a text for option value
      *
      * @param string|int $value
-     * @return string
+     * @return string|false
      */
     public function getOptionText($value)
     {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Config.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Config.php
index 0260ebd88770fb400b4c55aa4dc1f1e7e01fc89a..bca82ac6728f492f421c6dccdcb59ac14880ec15 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Config.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Config.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Entity\Attribute\Source;
 
 /**
  * Entity/Attribute/Model - attribute selection source from configuration
@@ -34,8 +34,6 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute\Source;
-
 class Config extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php
index dd3751e8777e25df203eeb817cf89e996f3e7eab..f44144ff283f1ebe4d3428d8bfb410c2d8c47adb 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Entity\Attribute\Source;
 
 /**
  * Customer store_id attribute source
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity\Attribute\Source;
-
 class Store extends \Magento\Eav\Model\Entity\Attribute\Source\Table
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
index 69fab6c3c3e20ee5e9ceded266c75b5576bada15..ca9da43215add79c46f06de5ab149d6f45cd1186 100644
--- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
+++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
@@ -241,7 +241,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *
      * @param \Magento\Eav\Model\Entity\AbstractEntity $entity
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function setEntity($entity)
     {
@@ -259,7 +259,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Get collection's entity object
      *
      * @return \Magento\Eav\Model\Entity\AbstractEntity
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function getEntity()
     {
@@ -283,7 +283,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * Set template object for the collection
      *
      * @param   \Magento\Object $object
-     * @return  $this
+     * @return $this
      */
     public function setObject($object = null)
     {
@@ -300,7 +300,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *
      * @param \Magento\Object $object
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function addItem(\Magento\Object $object)
     {
@@ -334,11 +334,13 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *     array('attribute'=>'lastname', 'like'=>'test%'),
      * )
      *
-     * @see self::_getConditionSql for $condition
      * @param \Magento\Eav\Model\Entity\Attribute\AttributeInterface|integer|string|array $attribute
      * @param null|string|array $condition
      * @param string $joinType
      * @return $this
+     * @throws \Magento\Core\Exception
+     *
+     * @see self::_getConditionSql for $condition
      */
     public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner')
     {
@@ -463,7 +465,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param array|string|integer|\Magento\Core\Model\Config\Element $attribute
      * @param bool|string $joinType flag for joining attribute
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function addAttributeToSelect($attribute, $joinType = false)
     {
@@ -501,6 +503,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     }
 
     /**
+     * Add entity type to select statement
+     *
      * @param string $entityType
      * @param string $prefix
      * @return $this
@@ -539,7 +543,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param string $expression
      * @param string $attribute
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function addExpressionAttributeToSelect($alias, $expression, $attribute)
     {
@@ -647,7 +651,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param string $joinType inner|left
      * @param null $storeId
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinType = 'inner', $storeId = null)
     {
@@ -737,7 +741,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param string|array $cond "{{table}}.language_code='en'" OR array('language_code'=>'en')
      * @param string $joinType 'left'
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function joinField($alias, $table, $field, $bind, $cond = null, $joinType = 'inner')
     {
@@ -801,7 +805,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param null|array $cond
      * @param string $joinType
      * @return $this
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     public function joinTable($table, $bind, $fields = null, $cond = null, $joinType = 'inner')
     {
@@ -1074,6 +1078,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
 
     /**
      * Set row id field name
+     *
      * @param string $fieldName
      * @return $this
      */
@@ -1085,7 +1090,6 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Load entities records into items
      *
-     *
      * @param bool $printQuery
      * @param bool $logQuery
      * @return $this
@@ -1208,6 +1212,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     }
 
     /**
+     * Add select values
+     *
      * @param \Magento\DB\Select $select
      * @param string $table
      * @param string $type
@@ -1222,11 +1228,11 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Initialize entity ubject property value
      *
-     * $valueInfo is _getLoadAttributesSelect fetch result row
+     * Parameter $valueInfo is _getLoadAttributesSelect fetch result row
      *
-     * @param   array $valueInfo
-     * @return  $this
-     * @throws \Magento\Core\Exception
+     * @param array $valueInfo
+     * @return $this
+     * @throws \Magento\Eav\Exception
      */
     protected function _setItemAttributeValue($valueInfo)
     {
@@ -1269,7 +1275,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *
      * @param string $attributeCode
      * @return string
-     * @throws \Magento\Core\Exception
+     * @throws \Magento\Eav\Exception
      */
     protected function _getAttributeFieldName($attributeCode)
     {
@@ -1308,8 +1314,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      *
      * @param   string $attributeCode
      * @param   string $joinType inner|left
-     * @return  $this
-     * @throws \Magento\Core\Exception
+     * @return $this
      * @throws \Magento\Eav\Exception
      */
     protected function _addAttributeJoin($attributeCode, $joinType = 'inner')
@@ -1396,7 +1401,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
      * @param   array $condition
      * @param   string $fieldCode
      * @param   string $fieldAlias
-     * @return  $this
+     * @return $this
      */
     protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias)
     {
@@ -1411,11 +1416,12 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Get condition sql for the attribute
      *
-     * @see self::_getConditionSql
      * @param string $attribute
      * @param mixed $condition
      * @param string $joinType
      * @return string
+     *
+     * @see self::_getConditionSql
      */
     protected function _getAttributeConditionSql($attribute, $condition, $joinType = 'inner')
     {
@@ -1454,7 +1460,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db
     /**
      * Set sorting order
      *
-     * $attribute can also be an array of attributes
+     * Parameter $attribute can also be an array of attributes
      *
      * @param string|array $attribute
      * @param string $dir
diff --git a/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php b/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php
index 7ab346f1b539458a4c1977ed24557f3d8e2fee49..6e7aece5650bcfe55473bbf7f5755208a27a40eb 100644
--- a/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php
+++ b/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php
@@ -29,5 +29,10 @@ namespace Magento\Eav\Model\Entity\Increment;
 
 interface IncrementInterface
 {
+    /**
+     * Get next id
+     *
+     * @return mixed
+     */
     public function getNextId();
 }
diff --git a/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php b/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php
index ef3d5ae58b202b0867f9ee98e00b550e8fa904a2..aad47a8d8a07182a0e2caa1b9e785f0b0bca0d99 100644
--- a/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php
+++ b/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Entity\Increment;
 
 /**
  * Enter description here...
@@ -34,8 +34,6 @@
  * - pad_char
  * - last_id
  */
-namespace Magento\Eav\Model\Entity\Increment;
-
 class Numeric extends \Magento\Eav\Model\Entity\Increment\AbstractIncrement
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity/Store.php b/app/code/Magento/Eav/Model/Entity/Store.php
index f13fce5007aacf230f4442bc39267cbbc6ecd02e..e45bc6b4e98281c7d688f7890c85f6db641cb920 100644
--- a/app/code/Magento/Eav/Model/Entity/Store.php
+++ b/app/code/Magento/Eav/Model/Entity/Store.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Entity;
 
 /**
  * @method \Magento\Eav\Model\Resource\Entity\Store _getResource()
@@ -41,8 +41,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Entity;
-
 class Store extends \Magento\Core\Model\AbstractModel
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php
index b0d4dc0fd29d5a3c4c04a7be431f980f222d855f..96a285394277fab2a254b7ea066c9ad230d1469a 100644
--- a/app/code/Magento/Eav/Model/Entity/Type.php
+++ b/app/code/Magento/Eav/Model/Entity/Type.php
@@ -92,7 +92,7 @@ class Type extends \Magento\Core\Model\AbstractModel
      */
     protected $_attSetFactory;
 
-    /***
+    /**
      * @var \Magento\Eav\Model\Entity\StoreFactory
      */
     protected $_storeFactory;
diff --git a/app/code/Magento/Eav/Model/Form/Element.php b/app/code/Magento/Eav/Model/Form/Element.php
index 001b3a4916306fe6a81d9d880d8d0aac396269e0..3dc2c829d7760017a8d68848f4d17e70e96e4ba2 100644
--- a/app/code/Magento/Eav/Model/Form/Element.php
+++ b/app/code/Magento/Eav/Model/Form/Element.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Form;
 
+use Magento\Core\Exception;
 
 /**
  * Eav Form Element Model
@@ -42,10 +44,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Form;
-
-use Magento\Core\Exception;
-
 class Element extends \Magento\Core\Model\AbstractModel
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Form/Factory.php b/app/code/Magento/Eav/Model/Form/Factory.php
index 7759b032f32ba6f82be9dc3531ffb93f46bbe021..fdad334bed4b476261472c04bba30db66767b4a7 100644
--- a/app/code/Magento/Eav/Model/Form/Factory.php
+++ b/app/code/Magento/Eav/Model/Form/Factory.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Eav\Model\Form;
 
 /**
diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php
index 6fdad573e822bfebaab15644bcd0398edfbb6917..4fb96b91f8bfbf745214d0645f7d587ab9320f66 100644
--- a/app/code/Magento/Eav/Model/Form/Fieldset.php
+++ b/app/code/Magento/Eav/Model/Form/Fieldset.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Form;
 
 /**
  * Eav Form Fieldset Model
@@ -40,8 +40,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Form;
-
 class Fieldset extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -56,6 +54,14 @@ class Fieldset extends \Magento\Core\Model\AbstractModel
      */
     protected $_storeManager;
 
+    /**
+     * @param \Magento\Core\Model\Context $context
+     * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param \Magento\Core\Model\Resource\AbstractResource $resource
+     * @param \Magento\Data\Collection\Db $resourceCollection
+     * @param array $data
+     */
     public function __construct(
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
@@ -102,7 +108,7 @@ class Fieldset extends \Magento\Core\Model\AbstractModel
      * Validate data before save data
      *
      * @throws \Magento\Core\Exception
-     * @return \Magento\Eav\Model\Form\Fieldset
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -134,7 +140,7 @@ class Fieldset extends \Magento\Core\Model\AbstractModel
      * Input array where key - store_id and value = label
      *
      * @param array $labels
-     * @return \Magento\Eav\Model\Form\Fieldset
+     * @return $this
      */
     public function setLabels(array $labels)
     {
@@ -146,7 +152,7 @@ class Fieldset extends \Magento\Core\Model\AbstractModel
      *
      * @param int $storeId
      * @param string $label
-     * @return \Magento\Eav\Model\Form\Fieldset
+     * @return $this
      */
     public function setStoreLabel($storeId, $label)
     {
diff --git a/app/code/Magento/Eav/Model/Form/Type.php b/app/code/Magento/Eav/Model/Form/Type.php
index 6cac42a4a9e49095b3268057cdaf304d5a96fc2d..89b8a3a3bfb5d7c33ede4e6eb228dc23e8b3e89c 100644
--- a/app/code/Magento/Eav/Model/Form/Type.php
+++ b/app/code/Magento/Eav/Model/Form/Type.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Eav\Model\Form;
 
 /**
diff --git a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php
index 0200129248c51d7cc6c8815f680b2e6d81606469..7bf63b2f7b95b7fa798a0e312fa303ea0d3e8591 100644
--- a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Attribute;
 
+use Magento\Core\Model\Website;
 
 /**
  * EAV additional attribute resource collection (Using Forms)
@@ -32,9 +34,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Attribute;
-use Magento\Core\Model\Website;
-
 abstract class Collection
     extends \Magento\Eav\Model\Resource\Entity\Attribute\Collection
 {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php
index 8b48fee9d4c69aff702ad8ce18e2beefbc84c013..fcdfbd0700fae3f72095a196d1790433753d0204 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php
@@ -23,7 +23,12 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Entity;
 
+use Magento\Core\Model\AbstractModel;
+use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
+use Magento\DB\Select;
 
 /**
  * EAV attribute resource model
@@ -32,12 +37,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity;
-
-use Magento\Core\Model\AbstractModel;
-use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
-use Magento\DB\Select;
-
 class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -60,7 +59,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
     protected $_storeManager;
 
     /**
-     * @var \Magento\Eav\Model\Resource\Entity\Type
+     * @var Type
      */
     protected $_eavEntityType;
 
@@ -69,12 +68,12 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\App\Resource $resource
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType
+     * @param Type $eavEntityType
      */
     public function __construct(
         \Magento\App\Resource $resource,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Eav\Model\Resource\Entity\Type $eavEntityType
+        Type $eavEntityType
     ) {
         $this->_storeManager = $storeManager;
         $this->_eavEntityType = $eavEntityType;
@@ -547,11 +546,11 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Retrieve Select For Flat Attribute update
      *
-     * @param EntityAttribute\AbstractAttribute $attribute
+     * @param AbstractAttribute $attribute
      * @param int $storeId
      * @return Select
      */
-    public function getFlatUpdateSelect(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $storeId)
+    public function getFlatUpdateSelect(AbstractAttribute $attribute, $storeId)
     {
         $adapter = $this->_getReadAdapter();
         $joinConditionTemplate = "%s.entity_id=%s.entity_id"
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php
index 17dfc977b5baa9b77151a7f02ed538dc7d907f45..6bebb398d5a88bcab151b21dcbf5e7333a728e29 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Entity\Attribute;
 
+use Magento\Eav\Model\Entity\Type;
 
 /**
  * EAV attribute resource collection
@@ -32,10 +34,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute;
-
-use Magento\Eav\Model\Entity\Type;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -168,7 +166,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Filter for selecting of attributes that is in all sets
      *
-     * @param array $setIds
+     * @param int[] $setIds
      * @return $this
      */
     public function setInAllAttributeSetsFilter(array $setIds)
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php
index 0cc90e933799eb19d06c18dd27663faab61fc0b1..090b316c34fa1bcafe06c86c0abf2f61c0d2bf47 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Entity\Attribute\Grid;
+
+use Magento\Core\Model\Resource\Db\Collection\AbstractCollection;
 
 /**
  * Eav Resource Attribute Set Collection
@@ -31,10 +34,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute\Grid;
-
-use Magento\Core\Model\Resource\Db\Collection\AbstractCollection;
-
 class Collection
     extends \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection
 {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php
index 3c9814c13fdbee848d8907953a89bce843c7a6d0..ea59fc8dea77027be1ecb732a7d1f496ee7b666d 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Entity\Attribute;
 
 /**
  * Eav Resource Entity Attribute Group
@@ -31,7 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute;
 
 class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
@@ -125,7 +125,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Set any group default if old one was removed
      *
      * @param integer $attributeSetId
-     * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group
+     * @return $this
      */
     public function updateDefaultGroup($attributeSetId)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php
index d1ce8c4e087b099af848eb6af54316756376539f..259dcb412f4cdd589d7f4e7cdb3b28819b1972bb 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Entity\Attribute\Group;
 
 /**
  * Eav attribute group resource collection
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute\Group;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -50,7 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set Attribute Set Filter
      *
      * @param int $setId
-     * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection
+     * @return $this
      */
     public function setAttributeSetFilter($setId)
     {
@@ -63,7 +61,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set sort order
      *
      * @param string $direction
-     * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection
+     * @return $this
      */
     public function setSortOrder($direction = self::SORT_ORDER_ASC)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php
index 088cb78ed53c277a87f106886886e39c0776ac8a..1b8e4e2b034c25bfff1770ef1e842913f64fa4b2 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Entity\Attribute;
 
 /**
  * Entity attribute option resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute;
-
 class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -52,7 +50,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
      * @param \Magento\Eav\Model\Entity\Attribute $attribute
      * @param \Zend_Db_Expr $valueExpr
-     * @return \Magento\Eav\Model\Resource\Entity\Attribute\Option
+     * @return $this
      */
     public function addOptionValueToCollection($collection, $attribute, $valueExpr)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php
index 30fc7eeb374e9824cf9725d8d95f8480131778bb..b1e80c09b207b8c77898a20fd8fc354f913c103d 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Entity\Attribute\Option;
 
 /**
  * Entity attribute option collection
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute\Option;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
index 6d45164fd0a88550bdbf7b567f70a56deb3c9135..e1580bdc6cb90a7d7dc2c0b604d9d2feb8dc22c9 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Entity\Attribute;
 
 /**
  * Eav attribute set resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute;
-
 class Set extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -67,7 +65,7 @@ class Set extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Perform actions after object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Eav\Model\Resource\Entity\Attribute\Set
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php
index 980ffa845ee1a2a6449eb7d8e1b141d75943a9b7..8a47097f54aeb65f0d1663dd0f8634cf3c5aad7b 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Entity\Attribute\Set;
 
 /**
  * Eav Resource Attribute Set Collection
@@ -31,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Attribute\Set;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -49,7 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by entity type id to collection
      *
      * @param int $typeId
-     * @return \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection
+     * @return $this
      */
     public function setEntityTypeFilter($typeId)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Store.php b/app/code/Magento/Eav/Model/Resource/Entity/Store.php
index aa608799e36eea030af8e8841897198d2e375a11..2c055712829d261c454b15434a30c55db9bdd633 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Store.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Store.php
@@ -23,7 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Entity;
 
+use Magento\Core\Model\AbstractModel;
+use Magento\Object;
 
 /**
  * Eav Entity store resource model
@@ -32,8 +35,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity;
-
 class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -49,12 +50,12 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Load an object by entity type and store
      *
-     * @param \Magento\Object $object
+     * @param Object|AbstractModel $object
      * @param int $entityTypeId
      * @param int $storeId
      * @return bool
      */
-    public function loadByEntityStore(\Magento\Core\Model\AbstractModel $object, $entityTypeId, $storeId)
+    public function loadByEntityStore(AbstractModel $object, $entityTypeId, $storeId)
     {
         $adapter = $this->_getWriteAdapter();
         $bind    = array(
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Type.php b/app/code/Magento/Eav/Model/Resource/Entity/Type.php
index 851702ca45550a223949450ad980a0a6e0430bca..22c5f42f63c7f475610c6d25e3ee2b9c1a63ee8c 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Type.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Type.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Entity;
 
 /**
  * EAV entity type resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity;
-
 class Type extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -51,7 +49,7 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Core\Model\AbstractModel $object
      * @param string $code
-     * @return \Magento\Eav\Model\Resource\Entity\Type
+     * @return $this
      */
     public function loadByCode($object, $code)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php
index 7726d8c897196c41949f068df3a62b072ec10b95..5aa5a39dad093f95abc75b9522c221ca924303af 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Entity\Type;
 
 /**
  * Eav Resource Entity Type Collection Model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Entity\Type;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php
index f1c13a50ffc8665497eef8afda33e7b49b4ca3a4..e57a37981954995daa17293f9aa0f2061d3ab592 100644
--- a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Form\Attribute;
 
 /**
  * EAV Form Attribute Resource Collection
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Form\Attribute;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -132,7 +130,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set current store to collection
      *
      * @param \Magento\Core\Model\Store|string|int $store
-     * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection
+     * @return $this
      */
     public function setStore($store)
     {
@@ -157,7 +155,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set entity type instance to collection
      *
      * @param \Magento\Eav\Model\Entity\Type|string|int $entityType
-     * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection
+     * @return $this
      */
     public function setEntityType($entityType)
     {
@@ -182,7 +180,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add Form Code filter to collection
      *
      * @param string $code
-     * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection
+     * @return $this
      */
     public function addFormCodeFilter($code)
     {
@@ -193,7 +191,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set order by attribute sort order
      *
      * @param string $direction
-     * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection
+     * @return $this
      */
     public function setSortOrder($direction = self::SORT_ORDER_ASC)
     {
@@ -204,7 +202,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add joins to select
      *
-     * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection
+     * @return $this
      */
     protected function _beforeLoad()
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Form/Element.php b/app/code/Magento/Eav/Model/Resource/Form/Element.php
index 64a2f2d5e187ffd321cc50b77814d91db013eec2..a0c5c9af4055899ef2ac35543a86c2f88f44570b 100644
--- a/app/code/Magento/Eav/Model/Resource/Form/Element.php
+++ b/app/code/Magento/Eav/Model/Resource/Form/Element.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Form;
 
 /**
  * Eav Form Element Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Form;
-
 class Element extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php
index dcc599553b77e6b3f2b985824536dd1b45bffaa2..139b94794ac8813bdeb4a61bf125333e1e0a411a 100644
--- a/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php
+++ b/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource\Form\Element;
 
 /**
  * Eav Form Element Resource Collection
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Form\Element;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -50,7 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add Form Type filter to collection
      *
      * @param \Magento\Eav\Model\Form\Type|int $type
-     * @return \Magento\Eav\Model\Resource\Form\Element\Collection
+     * @return $this
      */
     public function addTypeFilter($type)
     {
@@ -65,7 +63,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add Form Fieldset filter to collection
      *
      * @param \Magento\Eav\Model\Form\Fieldset|int $fieldset
-     * @return \Magento\Eav\Model\Resource\Form\Element\Collection
+     * @return $this
      */
     public function addFieldsetFilter($fieldset)
     {
@@ -81,7 +79,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|int $attribute
      *
-     * @return \Magento\Eav\Model\Resource\Form\Element\Collection
+     * @return $this
      */
     public function addAttributeFilter($attribute)
     {
@@ -95,7 +93,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Set order by element sort order
      *
-     * @return \Magento\Eav\Model\Resource\Form\Element\Collection
+     * @return $this
      */
     public function setSortOrder()
     {
@@ -107,7 +105,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Join attribute data
      *
-     * @return \Magento\Eav\Model\Resource\Form\Element\Collection
+     * @return $this
      */
     protected function _joinAttributeData()
     {
@@ -125,7 +123,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param bool $printQuery
      * @param bool $logQuery
-     * @return \Magento\Eav\Model\Resource\Form\Element\Collection
+     * @return $this
      */
     public function load($printQuery = false, $logQuery = false)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php
index d8b8630501cae37e0ea427c301706f7bd3e78587..6e329a4901826b6b4aa5dc2776cd13931680bb2b 100644
--- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php
+++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php
@@ -23,7 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Form;
 
+use Magento\Core\Model\AbstractModel;
+use Magento\Eav\Model\Form\Fieldset as FormFieldset;
+use Magento\DB\Select;
 
 /**
  * Eav Form Fieldset Resource Model
@@ -32,8 +36,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Form;
-
 class Fieldset extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -53,10 +55,10 @@ class Fieldset extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * After save (save labels)
      *
-     * @param \Magento\Eav\Model\Form\Fieldset $object
-     * @return \Magento\Eav\Model\Resource\Form\Fieldset
+     * @param FormFieldset|AbstractModel $object
+     * @return $this
      */
-    protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
+    protected function _afterSave(AbstractModel $object)
     {
         if ($object->hasLabels()) {
             $new        = $object->getLabels();
@@ -120,7 +122,7 @@ class Fieldset extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Retrieve fieldset labels for stores
      *
-     * @param \Magento\Eav\Model\Form\Fieldset $object
+     * @param FormFieldset $object
      * @return array
      */
     public function getLabels($object)
@@ -143,8 +145,8 @@ class Fieldset extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param string $field
      * @param mixed $value
-     * @param \Magento\Eav\Model\Form\Fieldset $object
-     * @return \Magento\DB\Select
+     * @param FormFieldset $object
+     * @return Select
      */
     protected function _getLoadSelect($field, $value, $object)
     {
diff --git a/app/code/Magento/Eav/Model/Resource/Form/Type.php b/app/code/Magento/Eav/Model/Resource/Form/Type.php
index 48a5874f0714d3e5e8a2566c43121cd4f4103ad4..faf0ea00532a81f6d9787d00306b269c8286552b 100644
--- a/app/code/Magento/Eav/Model/Resource/Form/Type.php
+++ b/app/code/Magento/Eav/Model/Resource/Form/Type.php
@@ -23,7 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Resource\Form;
 
+use Magento\Eav\Model\Form\Type as FormType;
+use Magento\Core\Model\AbstractModel;
 
 /**
  * Eav Form Type Resource Model
@@ -32,10 +35,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource\Form;
-
-use Magento\Eav\Model\Form\Type as FormType;
-
 class Type extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -55,12 +54,12 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Load an object
      *
-     * @param FormType $object
+     * @param FormType|AbstractModel $object
      * @param mixed $value
      * @param string $field field to load by (defaults to model id)
      * @return $this
      */
-    public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null)
+    public function load(AbstractModel $object, $value, $field = null)
     {
         if (is_null($field) && !is_numeric($value)) {
             $field = 'code';
@@ -94,10 +93,10 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @see \Magento\Core\Model\Resource\Db\AbstractDb#_afterSave($object)
      *
-     * @param FormType $object
+     * @param FormType|AbstractModel $object
      * @return $this
      */
-    protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
+    protected function _afterSave(AbstractModel $object)
     {
         if ($object->hasEntityTypes()) {
             $new = $object->getEntityTypes();
diff --git a/app/code/Magento/Eav/Model/Resource/Helper.php b/app/code/Magento/Eav/Model/Resource/Helper.php
index 9ee54e8d65e9238d37837beab746f8ab26f6bc96..75d0e2205d59e92460cae75e23d3150c3ad412f0 100644
--- a/app/code/Magento/Eav/Model/Resource/Helper.php
+++ b/app/code/Magento/Eav/Model/Resource/Helper.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Eav\Model\Resource;
 
 /**
  * Eav Mysql resource helper model
@@ -32,8 +32,6 @@
  * @package     Magento_Eav
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Resource;
-
 class Helper extends \Magento\Core\Model\Resource\Helper
 {
     /**
diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php b/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php
index 2a8ee2715114f05d5ce51666ded793915f39d9a2..fa97417274ab668db4af660303b2785eaf2c031b 100644
--- a/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php
+++ b/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Eav\Model\Validator\Attribute;
 
 /**
  * Validation EAV entity via EAV attributes' backend models
@@ -31,8 +32,6 @@
  * @package    Magento_Eav
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Eav\Model\Validator\Attribute;
-
 class Backend extends \Magento\Validator\AbstractValidator
 {
     /**
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template.php b/app/code/Magento/Email/Block/Adminhtml/Template.php
index f454217afa990dfd7c2205d1c20c58cd2ed8ed16..dfabecdd0caa723200c3ca0058d5aba403c8d767 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template.php
@@ -31,7 +31,6 @@
  * @package    Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
 namespace Magento\Email\Block\Adminhtml;
 
 class Template extends \Magento\Backend\Block\Template
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php
index 4c4775378aa3c1c674df00accd8b874ffe08eb24..c9b0322d3ef4bbe64cecb7622fc19742c68afe6a 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Block\Adminhtml\Template;
 
 /**
  * Adminhtml system template edit block
@@ -32,8 +33,6 @@
  * @author      Magento Core Team <core@magentocommerce.com>
  * @method array getTemplateOptions()
  */
-namespace Magento\Email\Block\Adminhtml\Template;
-
 class Edit extends \Magento\Backend\Block\Widget
 {
     /**
@@ -105,7 +104,7 @@ class Edit extends \Magento\Backend\Block\Widget
     /**
      * Prepare layout
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -206,7 +205,7 @@ class Edit extends \Magento\Backend\Block\Widget
     /**
      * Collect, sort and set template options
      *
-     * @return \Magento\Email\Block\Adminhtml\Template\Edit
+     * @return $this
      */
     protected function _beforeToHtml()
     {
@@ -463,9 +462,9 @@ class Edit extends \Magento\Backend\Block\Widget
     /**
      * Convert xml config paths to decorated names
      *
-     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @param array $paths
      * @return array
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      */
     protected function _getSystemConfigPathsParts($paths)
     {
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Edit/Form.php b/app/code/Magento/Email/Block/Adminhtml/Template/Edit/Form.php
index 7312a0d1f338884fcd81d03cb8121d22dc9424f8..d04321a6b97eecb69d67bf13006b526e4f763c11 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Edit/Form.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Edit/Form.php
@@ -67,7 +67,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * Prepare layout.
      * Add files to use dialog windows
      *
-     * @return \Magento\Email\Block\Adminhtml\Template\Edit\Form
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -97,7 +97,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
                 'magento-adminhtml-variables-js',
                 'Magento\Theme\Block\Html\Head\Script',
                 array(
-                    'file' => 'Magento_Adminhtml::variables.js'
+                    'file' => 'Magento_Backend::variables.js'
                 )
             );
         }
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php
index ef111c0bf921c280201451294658f748682ea62d..631aeecc8a9be8742db20e1e861d6898b62be091 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Block\Adminhtml\Template\Grid\Filter;
 
 /**
  * Adminhtml system template grid type filter
@@ -31,9 +32,6 @@
  * @package    Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Email\Block\Adminhtml\Template\Grid\Filter;
-
 class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
 {
     /**
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php
index bf5e253a6dc0577cce3fa9b9e4b28d504f58e86d..e02bb84574c9417014266a9f5d6929a2521497c8 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer;
 
 /**
  * Email templates grid block action item renderer
@@ -31,9 +32,6 @@
  * @package    Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer;
-
 class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
 {
     /**
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php
index e90bd3c1e2287111a03adba5f6fdf37bc076db69..68b7420290c212ef6030b2998d702c30ef418ecf 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer;
 
 /**
  * Adminhtml system templates grid block sender item renderer
@@ -31,9 +32,6 @@
  * @package    Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
- 
-namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer;
-
 class Sender extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
     /**
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php
index ee1b23251f131c9fd72512712960dfb24fb73896..9914474f69a49173218f1339966e780e599811ac 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer;
 
 /**
  * Adminhtml system templates grid block type item renderer
@@ -31,9 +32,6 @@
  * @package    Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer;
-
 class Type extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
     /**
diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php
index a41a6e1d3aeba0f1a75d304e9fd52ab85d1f4455..1fe3730df8af25ae8de6881266ea40114217fa4f 100644
--- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php
+++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Controller\Adminhtml\Email;
 
 /**
  * System Template admin controller
@@ -31,8 +32,6 @@
  * @package    Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Email\Controller\Adminhtml\Email;
-
 class Template extends \Magento\Backend\App\Action
 {
     /**
diff --git a/app/code/Magento/Email/Model/Resource/Template.php b/app/code/Magento/Email/Model/Resource/Template.php
index 584ed59c0435ca3c53f3259aeb20992663d89c2e..79146d4f587f463bbb2fe0704a1afaf03d028fa7 100644
--- a/app/code/Magento/Email/Model/Resource/Template.php
+++ b/app/code/Magento/Email/Model/Resource/Template.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Model\Resource;
 
+use Magento\Core\Model\AbstractModel;
 
 /**
  * Template db resource
@@ -32,8 +34,6 @@
  * @package     Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Email\Model\Resource;
-
 class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -54,6 +54,7 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize email template resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -83,7 +84,7 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Check usage of template code in other templates
      *
      * @param \Magento\Email\Model\Template $template
-     * @return boolean
+     * @return bool
      */
     public function checkCodeUsage(\Magento\Email\Model\Template $template)
     {
@@ -112,10 +113,10 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Set template type, added at and modified at time
      *
-     * @param \Magento\Email\Model\Template $object
-     * @return \Magento\Email\Model\Resource\Template
+     * @param AbstractModel $object
+     * @return $this
      */
-    protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
+    protected function _beforeSave(AbstractModel $object)
     {
         if ($object->isObjectNew()) {
             $object->setCreatedAt($this->dateTime->formatDate(true));
diff --git a/app/code/Magento/Email/Model/Sender.php b/app/code/Magento/Email/Model/Sender.php
index 568d3a259c81a0b50170dc7847bd466a577f8f88..aeb7681b37fb653d6cf944ba98e7afd833944380 100644
--- a/app/code/Magento/Email/Model/Sender.php
+++ b/app/code/Magento/Email/Model/Sender.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Model;
 
 /**
  * Common sender
@@ -31,17 +32,21 @@
  * @package    Magento_Email
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Email\Model;
-
 class Sender
 {
-    /** @var \Magento\Email\Model\Template\Mailer */
+    /**
+     * @var \Magento\Email\Model\Template\Mailer
+     */
     protected $_mailer;
 
-    /** @var \Magento\Email\Model\Info */
+    /**
+     * @var \Magento\Email\Model\Info
+     */
     protected $_emailInfo;
 
-    /** @var \Magento\Core\Model\Store */
+    /**
+     * @var \Magento\Core\Model\Store
+     */
     protected $_store;
 
     /**
diff --git a/app/code/Magento/Email/Model/Source/Variables.php b/app/code/Magento/Email/Model/Source/Variables.php
index 4539d2ed5466884b79eb1a196a873647225379de..4c07c230f4e0349a6494ebb803be467f9501c456 100644
--- a/app/code/Magento/Email/Model/Source/Variables.php
+++ b/app/code/Magento/Email/Model/Source/Variables.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Email\Model\Source;
 
 /**
  * Store Contact Information source model
@@ -32,8 +32,6 @@
  * @package    Magento_Email
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Email\Model\Source;
-
 class Variables implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
@@ -45,7 +43,6 @@ class Variables implements \Magento\Core\Model\Option\ArrayInterface
 
     /**
      * Constructor
-     *
      */
     public function __construct()
     {
diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php
index dc53c0b5a734a3f91892137abe466e0afdea0676..335f8b39a856ba5240f64ce20aef49a0d0bebc86 100644
--- a/app/code/Magento/Email/Model/Template.php
+++ b/app/code/Magento/Email/Model/Template.php
@@ -89,7 +89,7 @@ class Template extends \Magento\Core\Model\Template
     /**
      * Email template filter
      *
-     * @var Filter
+     * @var FilterTemplate
      */
     protected $_templateFilter;
 
@@ -221,8 +221,7 @@ class Template extends \Magento\Core\Model\Template
     }
 
     /**
-     * Return logo URL for emails
-     * Take logo from theme if custom logo is undefined
+     * Return logo URL for emails. Take logo from theme if custom logo is undefined
      *
      * @param  \Magento\Core\Model\Store|int|string $store
      * @return string
@@ -376,7 +375,7 @@ class Template extends \Magento\Core\Model\Template
      * Set id of template
      *
      * @param int $value
-     * @return \Magento\Email\Model\Template
+     * @return $this
      */
     public function setId($value)
     {
@@ -490,8 +489,8 @@ class Template extends \Magento\Core\Model\Template
      * @param array|string $email E-mail(s)
      * @param array|string|null $name receiver name(s)
      * @param array $variables template variables
-     * @return boolean
-     **/
+     * @return bool
+     */
     public function send($email, $name = null, array $variables = array())
     {
         if (!$this->isValidForSend()) {
@@ -748,7 +747,7 @@ class Template extends \Magento\Core\Model\Template
      * Validate email template code
      *
      * @throws Exception
-     * @return \Magento\Email\Model\Template
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Email/Model/Template/Config/FileResolver.php b/app/code/Magento/Email/Model/Template/Config/FileResolver.php
index e62fa17c37379ef35dfc8f908674a2123286aeb5..0b1ab5a45dd3bc92ffb34f309e39ecbbde053a87 100644
--- a/app/code/Magento/Email/Model/Template/Config/FileResolver.php
+++ b/app/code/Magento/Email/Model/Template/Config/FileResolver.php
@@ -50,7 +50,7 @@ class FileResolver implements \Magento\Config\FileResolverInterface
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function get($filename, $scope)
     {
diff --git a/app/code/Magento/Email/Model/Template/Config/Reader.php b/app/code/Magento/Email/Model/Template/Config/Reader.php
index b2e2dd25decf749f452cf4757de1ea54854a40c8..9d4f1fb654ddf5f6e38e89ba5f1e53efa9b67578 100644
--- a/app/code/Magento/Email/Model/Template/Config/Reader.php
+++ b/app/code/Magento/Email/Model/Template/Config/Reader.php
@@ -25,6 +25,11 @@
  */
 namespace Magento\Email\Model\Template\Config;
 
+use Magento\Config\FileResolverInterface;
+use Magento\Email\Model\Template\Config\Converter;
+use Magento\Email\Model\Template\Config\SchemaLocator;
+use Magento\Config\ValidationStateInterface;
+
 class Reader extends \Magento\Config\Reader\Filesystem
 {
     /**
@@ -37,20 +42,20 @@ class Reader extends \Magento\Config\Reader\Filesystem
     );
 
     /**
-     * @param \Magento\Config\FileResolverInterface $fileResolver
+     * @param FileResolverInterface $fileResolver
      * @param Converter $converter
      * @param SchemaLocator $schemaLocator
-     * @param \Magento\Config\ValidationStateInterface $validationState
+     * @param ValidationStateInterface $validationState
      * @param string $fileName
      * @param array $idAttributes
      * @param string $domDocumentClass
      * @param string $defaultScope
      */
     public function __construct(
-        \Magento\Config\FileResolverInterface $fileResolver,
-        \Magento\Email\Model\Template\Config\Converter $converter,
-        \Magento\Email\Model\Template\Config\SchemaLocator $schemaLocator,
-        \Magento\Config\ValidationStateInterface $validationState,
+        FileResolverInterface $fileResolver,
+        Converter $converter,
+        SchemaLocator $schemaLocator,
+        ValidationStateInterface $validationState,
         $fileName = 'email_templates.xml',
         $idAttributes = array(),
         $domDocumentClass = 'Magento\Config\Dom',
diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php
index a0bf661a8df9710547e75fb66a87954ec789049b..476e7ea8cfc523a316028daec5556bc3abfcbaa5 100644
--- a/app/code/Magento/Email/Model/Template/Filter.php
+++ b/app/code/Magento/Email/Model/Template/Filter.php
@@ -231,10 +231,10 @@ class Filter extends \Magento\Filter\Template
     /**
      * Retrieve Block html directive
      *
+     * @param array $construction
+     * @return string
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
-     * @param string[] $construction
-     * @return string
      */
     public function blockDirective($construction)
     {
@@ -589,9 +589,9 @@ class Filter extends \Magento\Filter\Template
      * Filter the string as template.
      * Rewrited for logging exceptions
      *
-     * @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass)
      * @param string $value
      * @return string
+     * @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass)
      */
     public function filter($value)
     {
diff --git a/app/code/Magento/Email/Model/Template/Mailer.php b/app/code/Magento/Email/Model/Template/Mailer.php
index 71ece3a2a82257e778e0875f2177868b07084f21..3725becbef482b4d0b8bb3faefa8ea6e4ee5391d 100644
--- a/app/code/Magento/Email/Model/Template/Mailer.php
+++ b/app/code/Magento/Email/Model/Template/Mailer.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Email\Model\Template;
+
+use Magento\Email\Model\Info;
 
 /**
  * Email Template Mailer Model
@@ -31,17 +34,13 @@
  * @package     Magento_Email
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Email\Model\Template;
-
-use Magento\Email\Model\Info;
-
 class Mailer extends \Magento\Object
 {
     /**
      * List of email infos
-     * @see Info
      *
      * @var array
+     * @see Info
      */
     protected $_emailInfos = array();
 
@@ -80,7 +79,7 @@ class Mailer extends \Magento\Object
      * Send all emails from email list
      * @see self::$_emailInfos
      *
-     * @return \Magento\Email\Model\Template\Mailer
+     * @return $this
      */
     public function send()
     {
@@ -114,7 +113,7 @@ class Mailer extends \Magento\Object
      * Set email sender
      *
      * @param string|array $sender
-     * @return \Magento\Email\Model\Template\Mailer
+     * @return $this
      */
     public function setSender($sender)
     {
@@ -135,7 +134,7 @@ class Mailer extends \Magento\Object
      * Set store id
      *
      * @param int $storeId
-     * @return \Magento\Email\Model\Template\Mailer
+     * @return $this
      */
     public function setStoreId($storeId)
     {
@@ -156,7 +155,7 @@ class Mailer extends \Magento\Object
      * Set template id
      *
      * @param int $templateId
-     * @return \Magento\Email\Model\Template\Mailer
+     * @return $this
      */
     public function setTemplateId($templateId)
     {
@@ -177,7 +176,7 @@ class Mailer extends \Magento\Object
      * Set template parameters
      *
      * @param array $templateParams
-     * @return \Magento\Email\Model\Template\Mailer
+     * @return $this
      */
     public function setTemplateParams(array $templateParams)
     {
diff --git a/app/code/Magento/Email/sql/email_setup/install-1.0.0.0.php b/app/code/Magento/Email/sql/email_setup/install-1.0.0.0.php
index c5711aa57820ffa61b803aa4735b3510f35bcacb..1037559b3a677700d82a4e55c0365befd72a2561 100644
--- a/app/code/Magento/Email/sql/email_setup/install-1.0.0.0.php
+++ b/app/code/Magento/Email/sql/email_setup/install-1.0.0.0.php
@@ -26,7 +26,7 @@
 $installer = $this;
 
 /**
- * Create table 'core_email_template'
+ * Create table 'email_template'
  */
 $table = $installer->getConnection()
     ->newTable($installer->getTable('email_template'))
diff --git a/app/code/Magento/GiftMessage/view/frontend/inline.phtml b/app/code/Magento/GiftMessage/view/frontend/inline.phtml
index a64b5f0a36988aa377285c5e0aaecd29cbc7f5bd..093481a9a76dc4ab4cacc06a364200a77dd1580c 100644
--- a/app/code/Magento/GiftMessage/view/frontend/inline.phtml
+++ b/app/code/Magento/GiftMessage/view/frontend/inline.phtml
@@ -55,7 +55,7 @@
                 <div class="options-order-container" id="options-order-container-<?php echo $this->getEntity()->getId() ?>"></div>
                 <input type="hidden" name="giftoptions[<?php echo $this->getEntity()->getId() ?>][type]" value="quote" />
                 <?php if ($this->isMessagesAvailable()): ?>
-                    <a href="#" class="activate message" data-mage-init='{toggleAdvanced: {selectorsToggleClass:"no-display", toggleContainers:"#allow-gift-messages-for-order-container"}}'><?php echo __('Gift Message') ?></a>
+                    <a href="#" class="activate message" data-mage-init='{"toggleAdvanced": {"selectorsToggleClass":"no-display", "toggleContainers":"#allow-gift-messages-for-order-container"}}'><?php echo __('Gift Message') ?></a>
                     <div id="allow-gift-messages-for-order-container" class="no-display">
                         <fieldset class="fieldset">
                             <input type="hidden" name="giftmessage[<?php echo $this->getEntity()->getId() ?>][type]"  value="quote" />
@@ -115,7 +115,7 @@
                          <div class="item options">
                              <div class="options-items-container" id="options-items-container-<?php echo $this->getEntity()->getId() ?>-<?php echo $_item->getId() ?>"></div>
                              <?php if ($this->isItemMessagesAvailable($_item)): ?>
-                             <a href="#" class="activate message" data-mage-init='{toggleAdvanced: {selectorsToggleClass:"no-display", toggleContainers:"#gift-messages-for-item-container-<?php echo $_item->getId() ?>"}}'><?php echo __('Gift Message') ?></a>
+                             <a href="#" class="activate message" data-mage-init='{"toggleAdvanced": {"selectorsToggleClass":"no-display", "toggleContainers":"#gift-messages-for-item-container-<?php echo $_item->getId() ?>"}}'><?php echo __('Gift Message') ?></a>
                              <div id="gift-messages-for-item-container-<?php echo $_item->getId() ?>" class="block message no-display">
                                  <fieldset class="fieldset">
                                      <p><?php echo __('You can leave a box blank if you don\'t wish to add a gift message for the item.') ?></p>
@@ -186,7 +186,7 @@
                 <input type="hidden" name="giftoptions[<?php echo $this->getEntity()->getId() ?>][type]" value="quote_address" />
                 <?php if ($this->isMessagesAvailable()): ?>
                     <?php $_giftMessage = true; ?>
-                    <a href="#" class="activate message" data-mage-init='{toggleAdvanced: {selectorsToggleClass:"no-display", toggleContainers:"#gift-messages-for-order-container-<?php echo $this->getEntity()->getId() ?>"}}'><?php echo __('Gift Message') ?></a>
+                    <a href="#" class="activate message" data-mage-init='{"toggleAdvanced": {"selectorsToggleClass":"no-display", "toggleContainers":"#gift-messages-for-order-container-<?php echo $this->getEntity()->getId() ?>"}}'><?php echo __('Gift Message') ?></a>
                     <div id="gift-messages-for-order-container-<?php echo $this->getEntity()->getId() ?>" class="block message no-display">
                         <fieldset class="fieldset">
                             <p><?php echo __('You can leave this box blank if you do not wish to add a gift message for this address.') ?></p>
@@ -246,7 +246,7 @@
 
                              <?php if ($this->isItemMessagesAvailable($_item)): ?>
                              <?php $_giftMessage = true; ?>
-                                 <a href="#" class="activate message" data-mage-init='{toggleAdvanced: {selectorsToggleClass:"no-display", toggleContainers:"#gift-messages-for-item-container-<?php echo $_item->getId() ?>"}}'><?php echo __('Gift Message') ?></a>
+                                 <a href="#" class="activate message" data-mage-init='{"toggleAdvanced": {"selectorsToggleClass":"no-display", "toggleContainers":"#gift-messages-for-item-container-<?php echo $_item->getId() ?>"}}'><?php echo __('Gift Message') ?></a>
                                  <div id="gift-messages-for-item-container-<?php echo $_item->getId() ?>" class="block message no-display">
                                      <fieldset class="fieldset">
                                         <p><?php echo __('You can leave this box blank if you do not wish to add a gift message for the item.') ?></p>
diff --git a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php
index b2c1fca711dcfdbc9190378ccd1bb6b5f22a57db..8ab09a8cca5522694d05112484a7c6131402ad24 100644
--- a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php
+++ b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php
@@ -31,7 +31,7 @@ namespace Magento\GoogleAdwords\Model\Config\Backend;
 abstract class AbstractConversion extends \Magento\Core\Model\Config\Value
 {
     /**
-     * @var \Magento\Validator\Composite\VarienObject
+     * @var \Magento\Validator\Object
      */
     protected $_validatorComposite;
 
@@ -45,7 +45,7 @@ abstract class AbstractConversion extends \Magento\Core\Model\Config\Value
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\App\ConfigInterface $config
-     * @param \Magento\Validator\Composite\VarienObjectFactory $validatorCompositeFactory
+     * @param \Magento\Validator\ObjectFactory $validatorCompositeFactory
      * @param \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
@@ -56,7 +56,7 @@ abstract class AbstractConversion extends \Magento\Core\Model\Config\Value
         \Magento\Core\Model\Registry $registry,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\App\ConfigInterface $config,
-        \Magento\Validator\Composite\VarienObjectFactory $validatorCompositeFactory,
+        \Magento\Validator\ObjectFactory $validatorCompositeFactory,
         \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
diff --git a/app/code/Magento/GoogleAnalytics/Block/Ga.php b/app/code/Magento/GoogleAnalytics/Block/Ga.php
index a750442b4ffef255a6f12058a813eca96ce69413..163e4501e78edbb9547973ce6dc8351bbf049656 100644
--- a/app/code/Magento/GoogleAnalytics/Block/Ga.php
+++ b/app/code/Magento/GoogleAnalytics/Block/Ga.php
@@ -88,10 +88,10 @@ class Ga extends \Magento\View\Element\Template
      * Render regular page tracking javascript code
      * The custom "page name" may be set from layout or somewhere else. It must start from slash.
      *
-     * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._trackPageview
-     * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html
      * @param string $accountId
      * @return string
+     * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._trackPageview
+     * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html
      */
     public function getPageTrackingCode($accountId)
     {
@@ -110,7 +110,7 @@ _gaq.push(['_trackPageview'{$optPageURL}]);
      * Render information about specified orders and their items
      *
      * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans
-     * @return string
+     * @return string|void
      */
     public function getOrdersTrackingCode()
     {
diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php
index 5d7c97f621108ddbdc669376775a5b533e771201..d8f0a3da515026361d55df7cb8ad20a1cd0e2d06 100644
--- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php
+++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php
@@ -114,7 +114,7 @@ abstract class AbstractXml extends \Magento\Object
     public function getCurrency()
     {
         if (!$this->hasData('currency')) {
-            $this->setData('currency', $this->objectManager->get('Magento\Core\Mode\StoreManager')->getStore()->getBaseCurrencyCode());
+            $this->setData('currency', $this->objectManager->get('Magento\Core\Model\StoreManager')->getStore()->getBaseCurrencyCode());
             //$this->setData('currency', $this->getLocale()=='en_US' ? 'USD' : 'GBP');
         }
         return $this->getData('currency');
@@ -257,7 +257,7 @@ abstract class AbstractXml extends \Magento\Object
     {
         if ($quote->getQuoteCurrencyCode() != $quote->getBaseCurrencyCode()) {
             $amount = $amount * $quote->getStoreToQuoteRate();
-            $amount = $this->objectManager->get('Magento\Core\Mode\StoreManager')->getStore()->roundPrice($amount);
+            $amount = $this->objectManager->get('Magento\Core\Model\StoreManager')->getStore()->roundPrice($amount);
         }
         return $amount;
     }
diff --git a/app/code/Magento/GoogleOptimizer/Helper/Form.php b/app/code/Magento/GoogleOptimizer/Helper/Form.php
index 6a8783e30ac4ec27e8620038ec6717539e331261..1ceb365b222ea09b5b574f00de6b350ed1905e68 100644
--- a/app/code/Magento/GoogleOptimizer/Helper/Form.php
+++ b/app/code/Magento/GoogleOptimizer/Helper/Form.php
@@ -48,7 +48,7 @@ class Form extends \Magento\App\Helper\AbstractHelper
         $fieldset->addField('experiment_script', 'textarea', array(
             'name' => 'experiment_script',
             'label' => __('Experiment Code'),
-            'value' => $experimentCodeModel ? $experimentCodeModel->getExperimentScript() : array(),
+            'value' => $experimentCodeModel ? $experimentCodeModel->getExperimentScript() : '',
             'class' => 'textarea googleoptimizer',
             'required' => false,
             'note' => __('Note: Experiment code should be added to the original page only.'),
diff --git a/app/code/Magento/GoogleOptimizer/Model/Code.php b/app/code/Magento/GoogleOptimizer/Model/Code.php
index 2a53cb101daf59d3bfaee79f06bd43229c0f7bcf..0f8fd39e8593cf89b17ff4b24628debd57aadb28 100644
--- a/app/code/Magento/GoogleOptimizer/Model/Code.php
+++ b/app/code/Magento/GoogleOptimizer/Model/Code.php
@@ -1,4 +1,6 @@
 <?php
+namespace Magento\GoogleOptimizer\Model;
+
 /**
  * Google Experiment Code Model
  *
@@ -33,8 +35,6 @@
  * @method \Magento\GoogleOptimizer\Model\Code setExperimentScript(int $value)
  * @method string getExperimentScript()
  */
-namespace Magento\GoogleOptimizer\Model;
-
 class Code extends \Magento\Core\Model\AbstractModel
 {
     /**#@+
@@ -52,6 +52,7 @@ class Code extends \Magento\Core\Model\AbstractModel
 
     /**
      * Model construct that should be used for object initialization
+     * @return void
      */
     protected function _construct()
     {
@@ -65,7 +66,7 @@ class Code extends \Magento\Core\Model\AbstractModel
      * @param int $entityId
      * @param string $entityType One of self::CODE_ENTITY_TYPE_
      * @param int $storeId
-     * @return \Magento\GoogleOptimizer\Model\Code
+     * @return $this
      */
     public function loadByEntityIdAndType($entityId, $entityType, $storeId = 0)
     {
diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php b/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php
index e204596e2c3c4675d0eeff5d3785999daec06e68..4444b209a31280c802ee56bbbcae67b90e64fcc0 100644
--- a/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php
+++ b/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php
@@ -93,7 +93,7 @@ abstract class AbstractSave
     /**
      * Check is Google Experiment enabled
      *
-     * @return void
+     * @return bool
      */
     protected function _isGoogleExperimentActive()
     {
diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Delete.php b/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Delete.php
index 734638d11dba393706b171eb3fa30b23a7d6996f..ab12ec863ba36bdf213b16d3f8e333605e440633 100644
--- a/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Delete.php
+++ b/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Delete.php
@@ -44,7 +44,7 @@ class Delete
      * Delete Product scripts after deleting product
      *
      * @param \Magento\Object $observer
-     * @return \Magento\GoogleOptimizer\Model\Observer\Category\Delete
+     * @return $this
      */
     public function deleteCategoryGoogleExperimentScript($observer)
     {
diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Delete.php b/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Delete.php
index deff3dcd5cdd79a86b42fbd5b139ed1c524a0a19..77642bd9ffe686b8d2e90481aa22ed5ebd226803 100644
--- a/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Delete.php
+++ b/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Delete.php
@@ -44,7 +44,7 @@ class Delete
      * Delete Product scripts after deleting product
      *
      * @param \Magento\Object $observer
-     * @return \Magento\GoogleOptimizer\Model\Observer\CmsPage\Delete
+     * @return $this
      */
     public function deleteCmsGoogleExperimentScript($observer)
     {
diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Delete.php b/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Delete.php
index d85e2c1e6b7899320efda69c4fb0afa1a3711b51..48cb965db30f7a28560b0d9971ee1401219d956c 100644
--- a/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Delete.php
+++ b/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Delete.php
@@ -44,7 +44,7 @@ class Delete
      * Delete Product scripts after deleting product
      *
      * @param \Magento\Object $observer
-     * @return \Magento\GoogleOptimizer\Model\Observer\Product\Delete
+     * @return $this
      */
     public function deleteProductGoogleExperimentScript($observer)
     {
diff --git a/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php b/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php
index ce762a66b425982f4a0cfc8cba6719b6cbe7cfd6..0bd827f601a5b707d36fdf2ba8cfe49c1e4c029e 100644
--- a/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php
+++ b/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php
@@ -44,7 +44,7 @@ class Code extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int $entityId
      * @param string $entityType
      * @param int $storeId
-     * @return \Magento\GoogleOptimizer\Model\Resource\Code
+     * @return $this
      */
     public function loadByEntityType($object, $entityId, $entityType, $storeId)
     {
diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php
index 22de2d2926fde2238136cf5fb9368e3353ec3669..213a6bf347d174556e14f4225f08fa0cb4a8cd81 100644
--- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php
+++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php
@@ -118,7 +118,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form before rendering HTML
      *
-     * @return \Magento\GoogleShopping\Block\Adminhtml\Types\Edit\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php
index 3b3d9268aaa3555837dad85afd3e9123a54f94c1..3eab73c9e639c0ba67b2a12ae45542e00276aa9b 100644
--- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php
+++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php
@@ -51,7 +51,7 @@ class Country
         \Magento\Backend\Block\Context $context,
         \Magento\GoogleShopping\Model\Config $config,
         array $data = array()
-    ) {
+    ) {
         $this->_config = $config;
         parent::__construct($context, $data);
     }
diff --git a/app/code/Magento/GoogleShopping/Block/SiteVerification.php b/app/code/Magento/GoogleShopping/Block/SiteVerification.php
index e126a7ecac4ca905d10b61fb84e8947f2b614218..05d5ffa314db672c340b5f0d4a7b1c2688af9d95 100644
--- a/app/code/Magento/GoogleShopping/Block/SiteVerification.php
+++ b/app/code/Magento/GoogleShopping/Block/SiteVerification.php
@@ -30,7 +30,9 @@ use Magento\View\Element\AbstractBlock;
  */
 class SiteVerification extends \Magento\View\Element\AbstractBlock
 {
-    /** @var \Magento\GoogleShopping\Model\Config */
+    /**
+     * @var \Magento\GoogleShopping\Model\Config
+     */
     protected $_config;
 
     /**
diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php
index 0eb1cc36f19d4c2237050e675dc449b8f0127250..59151f747614305310867fe87b5ed6fb524c9592 100644
--- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php
+++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php
@@ -29,7 +29,7 @@ use Magento\App\RequestInterface;
 
 /**
  * GoogleShopping Admin Item Types Controller
-*/
+ */
 class Types extends \Magento\Backend\App\Action
 {
     /**
diff --git a/app/code/Magento/GoogleShopping/Helper/Data.php b/app/code/Magento/GoogleShopping/Helper/Data.php
index 00c1d419a32dbce5023a1bd026ba40c5e2898ef4..17b9a8a04f4a624266edc8fc41f1255aee59b3e9 100644
--- a/app/code/Magento/GoogleShopping/Helper/Data.php
+++ b/app/code/Magento/GoogleShopping/Helper/Data.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\GoogleShopping\Helper;
 
 /**
  * Google Content Data Helper
@@ -31,8 +32,6 @@
  * @package    Magento_GoogleShopping
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\GoogleShopping\Helper;
-
 class Data extends \Magento\App\Helper\AbstractHelper
 {
     /**
@@ -79,8 +78,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Remove characters and words not allowed by Google Content in title and content (description).
      *
-     * (to avoid "Expected response code 200, got 400.
-     * Reason: There is a problem with the character encoding of this attribute")
+     * To avoid "Expected response code 200, got 400.
+     * Reason: There is a problem with the character encoding of this attribute"
      *
      * @param string $string
      * @return string
diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php
index 969735df7c3cad839553ad74134ad0677ccaabdf..8bced43baca90634b119b87d9d41a15167c54f57 100644
--- a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php
+++ b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php
@@ -25,6 +25,9 @@
  */
 namespace Magento\GoogleShopping\Model\Attribute;
 
+use Magento\Catalog\Model\Product;
+use Magento\Gdata\Gshopping\Entry;
+
 /**
  * Price attribute model
  *
@@ -77,7 +80,6 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute
      * @param \Magento\Tax\Helper\Data $taxData
      * @param \Magento\Core\Model\Store\Config $coreStoreConfig
      * @param \Magento\GoogleShopping\Model\Config $config
-     * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
      */
@@ -117,9 +119,9 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute
     /**
      * Set current attribute to entry (for specified product)
      *
-     * @param \Magento\Catalog\Model\Product $product
-     * @param \Magento\Gdata\Gshopping\Entry $entry
-     * @return \Magento\Gdata\Gshopping\Entry
+     * @param Product $product
+     * @param Entry $entry
+     * @return Entry
      */
     public function convertAttribute($product, $entry)
     {
@@ -203,12 +205,12 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute
     /**
      * Custom setter for 'price' attribute
      *
-     * @param \Magento\Gdata\Gshopping\Entry $entry
-     * @param string $attribute Google Content attribute name
+     * @param Entry $entry
+     * @param Product $product
+     * @param string $targetCountry
      * @param mixed $value Fload price value
-     * @param string $type Google Content attribute type
      * @param string $name Google Content attribute name
-     * @return \Magento\Gdata\Gshopping\Entry
+     * @return Entry
      */
     protected function _setAttributePrice($entry, $product, $targetCountry, $value, $name = 'price')
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php
index 67dbaf904c7dac4cd70486a21aa0a1abf774d54e..ea9b5986e5e726afee4089fd819c67f316bd5257 100644
--- a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php
+++ b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php
@@ -44,7 +44,9 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute
      */
     protected $_taxData = null;
 
-    /** @var \Magento\GoogleCheckout\Helper\Data  */
+    /**
+     * @var \Magento\GoogleCheckout\Helper\Data
+     */
     protected $checkoutDataHelper;
 
     /**
diff --git a/app/code/Magento/GoogleShopping/Model/Item.php b/app/code/Magento/GoogleShopping/Model/Item.php
index 55e11ba0c93a902ee681fb148026b84dc5cd4544..151a4b994341f6eb513b44d3ff075937592b2084 100644
--- a/app/code/Magento/GoogleShopping/Model/Item.php
+++ b/app/code/Magento/GoogleShopping/Model/Item.php
@@ -84,7 +84,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * @param \Magento\GoogleShopping\Model\Service\ItemFactory $itemFactory
      * @param \Magento\GoogleShopping\Model\TypeFactory $typeFactory
      * @param \Magento\Catalog\Model\ProductFactory $productFactory
-     * @param \Magento\Core\Model\Resource\AbstractResource $resource
+     * @param \Magento\GoogleShopping\Model\Resource\Item $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param \Magento\GoogleShopping\Model\Config $config
      * @param array $data
diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php
index 74695060e8bdbe3ad5136f54a7335ed989877406..0062368d953326e446b311667b0082dbc3393644 100644
--- a/app/code/Magento/GoogleShopping/Model/MassOperations.php
+++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php
@@ -38,11 +38,15 @@ use Magento\GoogleShopping\Model\Resource\Item\Collection as ItemCollection;
 class MassOperations
 {
     /**
+     * GoogleShopping data
+     *
      * @var \Magento\GoogleShopping\Helper\Data
      */
     protected $_gleShoppingData = null;
 
     /**
+     * GoogleShopping category
+     *
      * @var \Magento\GoogleShopping\Helper\Category|null
      */
     protected $_gleShoppingCategory = null;
@@ -136,6 +140,8 @@ class MassOperations
     protected $_flag;
 
     /**
+     * Logger
+     *
      * @var \Magento\Logger
      */
     protected $_logger;
@@ -144,7 +150,7 @@ class MassOperations
      * Set process locking flag.
      *
      * @param \Magento\GoogleShopping\Model\Flag $flag
-     * @return \Magento\GoogleShopping\Model\MassOperations
+     * @return $this
      */
     public function setFlag(\Magento\GoogleShopping\Model\Flag $flag)
     {
@@ -157,9 +163,8 @@ class MassOperations
      *
      * @param int[] $productIds
      * @param int $storeId
-     * @throws \Zend_Gdata_App_CaptchaRequiredException
-     * @throws CoreException
      * @return $this
+     * @throws \Exception|\Zend_Gdata_App_CaptchaRequiredException
      */
     public function addProducts($productIds, $storeId)
     {
@@ -229,9 +234,8 @@ class MassOperations
      * Update Google Content items.
      *
      * @param int[]|ItemCollection $items
-     * @throws \Zend_Gdata_App_CaptchaRequiredException
-     * @throws CoreException
      * @return $this
+     * @throws \Exception|\Zend_Gdata_App_CaptchaRequiredException
      */
     public function synchronizeItems($items)
     {
@@ -304,8 +308,8 @@ class MassOperations
      * Remove Google Content items.
      *
      * @param int[]|ItemCollection $items
-     * @throws \Zend_Gdata_App_CaptchaRequiredException
      * @return $this
+     * @throws \Exception|\Zend_Gdata_App_CaptchaRequiredException
      */
     public function deleteItems($items)
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Observer.php b/app/code/Magento/GoogleShopping/Model/Observer.php
index 7a71ecaf6b78553e199a6bbedf6978d9d997bae5..f546e4a819ec30edb89d4c0446cef93929c897b9 100644
--- a/app/code/Magento/GoogleShopping/Model/Observer.php
+++ b/app/code/Magento/GoogleShopping/Model/Observer.php
@@ -99,7 +99,7 @@ class Observer
      * Update product item in Google Content
      *
      * @param \Magento\Object $observer
-     * @return \Magento\GoogleShopping\Model\Observer
+     * @return $this
      */
     public function saveProductItem($observer)
     {
@@ -119,7 +119,7 @@ class Observer
      * Delete product item from Google Content
      *
      * @param \Magento\Object $observer
-     * @return \Magento\GoogleShopping\Model\Observer
+     * @return $this
      */
     public function deleteProductItem($observer)
     {
@@ -161,7 +161,7 @@ class Observer
      * Check if synchronize process is finished and generate notification message
      *
      * @param  \Magento\Event\Observer $observer
-     * @return \Magento\GoogleShopping\Model\Observer
+     * @return $this
      */
     public function checkSynchronizationOperations(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php
index c1306b59df09d7bf11332efbd52342dea64522fa..6b0e2e865bc4405e0e889fb9950385e9aabad571 100644
--- a/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php
+++ b/app/code/Magento/GoogleShopping/Model/Resource/Attribute/Collection.php
@@ -52,7 +52,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param int $attributeSetId
      * @param string $targetCountry two words ISO format
-     * @return \Magento\GoogleShopping\Model\Resource\Attribute\Collection
+     * @return $this
      */
     public function addAttributeSetFilter($attributeSetId, $targetCountry)
     {
@@ -68,7 +68,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add type filter
      *
      * @param int $type_id
-     * @return \Magento\GoogleShopping\Model\Resource\Attribute\Collection
+     * @return $this
      */
     public function addTypeFilter($type_id)
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Item.php b/app/code/Magento/GoogleShopping/Model/Resource/Item.php
index c1b9005abfec80bdaa830bb3d5211c030a652912..ddfaf2cfb47d8e0982ca4c044f024827c53d251c 100644
--- a/app/code/Magento/GoogleShopping/Model/Resource/Item.php
+++ b/app/code/Magento/GoogleShopping/Model/Resource/Item.php
@@ -44,7 +44,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Load Item model by product
      *
      * @param \Magento\GoogleShopping\Model\Item $model
-     * @return \Magento\GoogleShopping\Model\Resource\Item
+     * @return $this
      */
     public function loadByProduct($model)
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php
index 7c5661aae954b12802b335e3a8be7463166e043f..2cd8560359dbc865591fa36ad396e539f0be5385 100644
--- a/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php
+++ b/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php
@@ -120,10 +120,10 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add field filter to collection
      *
-     * @see self::_getConditionSql for $condition
      * @param string $field
      * @param null|string|array $condition
      * @return $this
+     * @see self::_getConditionSql for $condition
      */
     public function addFieldToFilter($field, $condition=null)
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Type.php b/app/code/Magento/GoogleShopping/Model/Resource/Type.php
index 50f453904009370195a474d51088d6cb929bedd8..d28bf9c8acac028ee51653016b47fa609f56de35 100644
--- a/app/code/Magento/GoogleShopping/Model/Resource/Type.php
+++ b/app/code/Magento/GoogleShopping/Model/Resource/Type.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\GoogleShopping\Model\Resource;
 
 /**
  * Google Content Type resource model
@@ -31,10 +32,11 @@
  * @package    Magento_GoogleShopping
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\GoogleShopping\Model\Resource;
-
 class Type extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('googleshopping_types', 'type_id');
diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php
index a0eb5e3dcf8213cd531c79bda9ea756634032853..d842d4326ef84ec2d22300ff250b5a3b53491815 100644
--- a/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php
+++ b/app/code/Magento/GoogleShopping/Model/Resource/Type/Collection.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\GoogleShopping\Model\Resource\Type;
 
 /**
  * GoogleShopping Item Types collection
@@ -31,11 +32,11 @@
  * @package    Magento_GoogleShopping
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\GoogleShopping\Model\Resource\Type;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
-
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\GoogleShopping\Model\Type', 'Magento\GoogleShopping\Model\Resource\Type');
@@ -44,7 +45,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Init collection select
      *
-     * @return \Magento\GoogleShopping\Model\Resource\Type\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -68,7 +69,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add total count of Items for each type
      *
-     * @return \Magento\GoogleShopping\Model\Resource\Type\Collection
+     * @return $this
      */
     public function addItemsCount()
     {
@@ -85,7 +86,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add country ISO filter to collection
      *
      * @param string $iso Two-letter country ISO code
-     * @return \Magento\GoogleShopping\Model\Resource\Type\Collection
+     * @return $this
      */
     public function addCountryFilter($iso)
     {
@@ -96,7 +97,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Join Attribute Set data
      *
-     * @return \Magento\GoogleShopping\Model\Resource\Type\Collection
+     * @return $this
      */
     protected function _joinAttributeSet()
     {
diff --git a/app/code/Magento/GoogleShopping/Model/Type.php b/app/code/Magento/GoogleShopping/Model/Type.php
index 833885012a45c05706243336680be85475959546..8bf42813b7183eb4ab805287454c347730ab649c 100644
--- a/app/code/Magento/GoogleShopping/Model/Type.php
+++ b/app/code/Magento/GoogleShopping/Model/Type.php
@@ -120,7 +120,7 @@ class Type extends \Magento\Core\Model\AbstractModel
      *
      * @param int $attributeSetId Attribute Set
      * @param string $targetCountry Two-letters country ISO code
-     * @return \Magento\GoogleShopping\Model\Type
+     * @return $this
      */
     public function loadByAttributeSetId($attributeSetId, $targetCountry)
     {
@@ -131,7 +131,7 @@ class Type extends \Magento\Core\Model\AbstractModel
     /**
      * Prepare Entry data and attributes before saving in Google Content
      *
-     * @param CatalogModelProduct $entry
+     * @param CatalogModelProduct $product
      * @param Entry $entry
      * @return Entry
      */
diff --git a/app/code/Magento/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php b/app/code/Magento/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php
index 6ad1fbae746744f0d175a94f092b34ceb3184784..2a946be9f000285926fe2930fe58b4f7607c9f07 100644
--- a/app/code/Magento/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php
+++ b/app/code/Magento/GoogleShopping/sql/googleshopping_setup/upgrade-1.6.0.0-1.6.0.0.1.php
@@ -31,4 +31,4 @@ $installer->getConnection()->addColumn($installer->getTable('googleshopping_type
     'TYPE'    => \Magento\DB\Ddl\Table::TYPE_TEXT,
     'LENGTH'  => 40,
     'COMMENT' => 'Google product category',
-));
\ No newline at end of file
+));
diff --git a/app/code/Magento/GoogleShopping/view/adminhtml/items.phtml b/app/code/Magento/GoogleShopping/view/adminhtml/items.phtml
index 6a41cf29b23a78acea7bfdb8bf5c8597c7439665..bf7b4742124891e128a4f6dec46f3099d93cac51 100644
--- a/app/code/Magento/GoogleShopping/view/adminhtml/items.phtml
+++ b/app/code/Magento/GoogleShopping/view/adminhtml/items.phtml
@@ -31,7 +31,7 @@
 <div class="grid-title">
     <span class="title"><?php echo __('Google Content Items') ?></span>
 </div>
-<div data-mage-init="{loader: {}}" data-container="googleContent">
+<div data-mage-init='{"loader": {}}' data-container="googleContent">
 <?php echo $this->getChildHtml('item') ?>
 </div>
 
@@ -39,7 +39,7 @@
     <div class="page-actions"><?php echo $this->getAddButtonHtml() ?></div>
     <span class="title"><?php echo __('Available Products') ?></span>
 </div>
-<div data-mage-init="{loader: {}}" data-container="products">
+<div data-mage-init='{"loader": {}}' data-container="products">
 <?php echo $this->getChildHtml('product') ?>
 </div>
 
diff --git a/app/code/Magento/GroupedProduct/etc/di.xml b/app/code/Magento/GroupedProduct/etc/di.xml
index 9d1b6014d6132ebd965f3f1bfcd9b7661f16b985..ec5064f78316df72a23ed6076a80688c1003130f 100644
--- a/app/code/Magento/GroupedProduct/etc/di.xml
+++ b/app/code/Magento/GroupedProduct/etc/di.xml
@@ -34,7 +34,7 @@
     <type name="Magento\Sales\Model\Quote\Item\RelatedProducts">
         <param name="relatedProductTypes">
             <array>
-                <item key="grouped"><value type="const">\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item>
+                <item key="grouped"><value type="const">Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item>
             </array>
         </param>
     </type>
@@ -48,7 +48,7 @@
     <type name="Magento\Sales\Model\Resource\Report\Bestsellers">
         <param name="ignoredProductTypes">
             <array>
-                <item key="grouped"><value type="const">\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item>
+                <item key="grouped"><value type="const">Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item>
             </array>
         </param>
     </type>
diff --git a/app/code/Magento/Index/Block/Adminhtml/Process/Edit.php b/app/code/Magento/Index/Block/Adminhtml/Process/Edit.php
index f000ce4798d86fad34b7f603db7fa5464b895cf0..d091e2951ffa8cc6db391465f4fa52a8205ea682 100644
--- a/app/code/Magento/Index/Block/Adminhtml/Process/Edit.php
+++ b/app/code/Magento/Index/Block/Adminhtml/Process/Edit.php
@@ -49,6 +49,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_objectId = 'process_id';
diff --git a/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tabs.php b/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tabs.php
index f967e3cdb8d3a7b402759efae511ee05b897e4ab..7c8c0fac73294aac21e5af1389c35611a1e935e6 100644
--- a/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tabs.php
+++ b/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tabs.php
@@ -23,12 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Index\Block\Adminhtml\Process\Edit;
 
 class Tabs extends \Magento\Backend\Block\Widget\Tabs
 {
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
diff --git a/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php b/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php
index 8aafd141cb35126d2ad62e5068e94c5b9c41d231..6fc6524df7f9c1d634d37a5bc24769f8e27b9947 100644
--- a/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php
+++ b/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Index\Block\Adminhtml\Process;
 
 class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
@@ -78,6 +77,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 
     /**
      * Class constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -90,7 +91,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare grid collection
      *
-     * @return \Magento\Index\Block\Adminhtml\Process\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
@@ -103,7 +104,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add name and description to collection elements
      *
-     * @return \Magento\Index\Block\Adminhtml\Process\Grid
+     * @return $this
      */
     protected function _afterLoadCollection()
     {
@@ -126,7 +127,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare grid columns
      *
-     * @return \Magento\Index\Block\Adminhtml\Process\Grid
+     * @return $this
      */
     protected function _prepareColumns()
     {
@@ -291,7 +292,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Add mass-actions to grid
      *
-     * @return \Magento\Index\Block\Adminhtml\Process\Grid
+     * @return $this
      */
     protected function _prepareMassaction()
     {
diff --git a/app/code/Magento/Index/Model/Event.php b/app/code/Magento/Index/Model/Event.php
index e68a2896415cd038eab61b60dcd93b8a949685b4..9bb89c8ed8e2fbc343d9f7627a1db52a9cca513f 100644
--- a/app/code/Magento/Index/Model/Event.php
+++ b/app/code/Magento/Index/Model/Event.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model;
+
+use Magento\Index\Model\Indexer;
 
 /**
  * @method \Magento\Index\Model\Resource\Event _getResource()
@@ -41,10 +44,6 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model;
-
-use Magento\Index\Model\Indexer;
-
 class Event extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -110,6 +109,8 @@ class Event extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initialize resource
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -276,9 +277,10 @@ class Event extends \Magento\Core\Model\AbstractModel
     /**
      * Get event old data array
      *
-     * @deprecated since 1.6.2.0
      * @param bool $useNamespace
      * @return array
+     *
+     * @deprecated since 1.6.2.0
      */
     public function getOldData($useNamespace = true)
     {
@@ -308,10 +310,11 @@ class Event extends \Magento\Core\Model\AbstractModel
     /**
      * Add new values to old data array (overwrite if value with same key exist)
      *
-     * @deprecated since 1.6.2.0
      * @param array|string $key
      * @param null|mixed $value
      * @return $this
+     *
+     * @deprecated since 1.6.2.0
      */
     public function addOldData($key, $value = null)
     {
diff --git a/app/code/Magento/Index/Model/Indexer.php b/app/code/Magento/Index/Model/Indexer.php
index 37250560234a8e67851d3f366546d42ca2fa3399..db6f453fc3c3009ad7367c17e330dadb4590ca4a 100644
--- a/app/code/Magento/Index/Model/Indexer.php
+++ b/app/code/Magento/Index/Model/Indexer.php
@@ -23,16 +23,15 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Indexer strategy
- */
 namespace Magento\Index\Model;
 
 use Magento\Event\ManagerInterface;
 use Magento\Index\Model\Resource\Process as ResourceProcess;
 use Magento\Index\Model\Resource\Process\Collection;
 
+/**
+ * Indexer strategy
+ */
 class Indexer
 {
     /**
@@ -266,7 +265,7 @@ class Indexer
      * @param Collection $collection
      * @return void
      */
-    private function _reindexCollection(\Magento\Index\Model\Resource\Process\Collection $collection)
+    private function _reindexCollection(Collection $collection)
     {
         /** @var $process \Magento\Index\Model\Process */
         foreach ($collection as $process) {
diff --git a/app/code/Magento/Index/Model/IndexerInterface.php b/app/code/Magento/Index/Model/IndexerInterface.php
index 73f58e0f97a2b7f488dc95a43de5a4608b3d3d35..6247926b8082ba9761e543d43ce2030c6da591ab 100644
--- a/app/code/Magento/Index/Model/IndexerInterface.php
+++ b/app/code/Magento/Index/Model/IndexerInterface.php
@@ -49,7 +49,7 @@ interface IndexerInterface
      * Register data required by process in event object
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Index\Model\IndexerInterface
+     * @return $this
      */
     public function register(\Magento\Index\Model\Event $event);
 
@@ -57,7 +57,7 @@ interface IndexerInterface
      * Process event
      *
      * @param \Magento\Index\Model\Event $event
-     * @return \Magento\Index\Model\IndexerInterface
+     * @return $this
      */
     public function processEvent(\Magento\Index\Model\Event $event);
 
@@ -80,6 +80,8 @@ interface IndexerInterface
 
     /**
      * Rebuild all index data
+     *
+     * @return void
      */
     public function reindexAll();
 
diff --git a/app/code/Magento/Index/Model/Observer.php b/app/code/Magento/Index/Model/Observer.php
index 50336598d4b46e4aa5ef9d62011c82a0c5885291..2ff1be27fd364093464247d17bf5a61f59bdf83b 100644
--- a/app/code/Magento/Index/Model/Observer.php
+++ b/app/code/Magento/Index/Model/Observer.php
@@ -33,8 +33,6 @@ class Observer
     /**
      * @var \Magento\Index\Model\Indexer
      *
-     * @var \Magento\Index\Model\Indexer
-     */
     protected $_indexer;
 
     /**
diff --git a/app/code/Magento/Index/Model/Process.php b/app/code/Magento/Index/Model/Process.php
index 98c0fddae5295c3432f4e11f005868558f727bfd..4cdb1a0d4d2a95ac191806fead861e14356acd59 100644
--- a/app/code/Magento/Index/Model/Process.php
+++ b/app/code/Magento/Index/Model/Process.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model;
+
+use Magento\Index\Model\Resource\Event\Collection;
 
 /**
  * @method \Magento\Index\Model\Resource\Process _getResource()
@@ -42,10 +45,6 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model;
-
-use Magento\Index\Model\Resource\Event\Collection;
-
 class Process extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -155,6 +154,8 @@ class Process extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initialize resource
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -167,7 +168,7 @@ class Process extends \Magento\Core\Model\AbstractModel
      * @param   Event $event
      * @return  $this
      */
-    protected function _setEventNamespace(\Magento\Index\Model\Event $event)
+    protected function _setEventNamespace(Event $event)
     {
         $namespace = get_class($this->getIndexer());
         $event->setDataNamespace($namespace);
@@ -194,7 +195,7 @@ class Process extends \Magento\Core\Model\AbstractModel
      * @param Event $event
      * @return $this
      */
-    public function register(\Magento\Index\Model\Event $event)
+    public function register(Event $event)
     {
         if ($this->matchEvent($event)) {
             $this->_setEventNamespace($event);
@@ -212,10 +213,10 @@ class Process extends \Magento\Core\Model\AbstractModel
     /**
      * Check if event can be matched by process
      *
-     * @param \Magento\Index\Model\Event $event
+     * @param Event $event
      * @return bool
      */
-    public function matchEvent(\Magento\Index\Model\Event $event)
+    public function matchEvent(Event $event)
     {
         return $this->getIndexer()->matchEvent($event);
     }
@@ -618,7 +619,7 @@ class Process extends \Magento\Core\Model\AbstractModel
      * @return $this
      * @throws \Exception
      */
-    public function safeProcessEvent(\Magento\Index\Model\Event $event)
+    public function safeProcessEvent(Event $event)
     {
         if (!$this->matchEvent($event)) {
             return $this;
diff --git a/app/code/Magento/Index/Model/Process/File.php b/app/code/Magento/Index/Model/Process/File.php
index b24b2e7dcea1c21322f6192da30a3104641e690b..4adc6aec5d5129aff596445c78e9f5a991781c7b 100644
--- a/app/code/Magento/Index/Model/Process/File.php
+++ b/app/code/Magento/Index/Model/Process/File.php
@@ -70,7 +70,7 @@ class File
      * Lock process file
      *
      * @param bool $nonBlocking
-     * @return bool
+     * @return void
      */
     public function processLock($nonBlocking = true)
     {
diff --git a/app/code/Magento/Index/Model/Process/FileFactory.php b/app/code/Magento/Index/Model/Process/FileFactory.php
index b6d2d55341b4c3c0ce33a5167a286ea6e3247523..0b009801edbce58082d955c94d2f8f51cd2e6aea 100644
--- a/app/code/Magento/Index/Model/Process/FileFactory.php
+++ b/app/code/Magento/Index/Model/Process/FileFactory.php
@@ -23,12 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model\Process;
 
 /**
  * Process file entity
  */
-namespace Magento\Index\Model\Process;
-
 class FileFactory
 {
     /**
diff --git a/app/code/Magento/Index/Model/Resource/Event.php b/app/code/Magento/Index/Model/Resource/Event.php
index 9c5283b33d5399577e18edd1ff3fcbbccabfbbde..ebcf98071eef85cdecbff03ed8754e5b678b1b06 100644
--- a/app/code/Magento/Index/Model/Resource/Event.php
+++ b/app/code/Magento/Index/Model/Resource/Event.php
@@ -23,7 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model\Resource;
 
+use Magento\Core\Model\AbstractModel;
+use Magento\Index\Model\Process as ProcessModel;
 
 /**
  * Index Event Resource Model
@@ -32,13 +35,11 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model\Resource;
-
-use Magento\Core\Model\AbstractModel;
-use Magento\Index\Model\Process as ProcessModel;
-
 class Event extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('index_event', 'event_id');
diff --git a/app/code/Magento/Index/Model/Resource/Event/Collection.php b/app/code/Magento/Index/Model/Resource/Event/Collection.php
index ddd28a9887bd60df269ba625e0f6a0ca82d6f7f7..b58698b4fcf3e8e882a46eaa8f26514f923a3e55 100644
--- a/app/code/Magento/Index/Model/Resource/Event/Collection.php
+++ b/app/code/Magento/Index/Model/Resource/Event/Collection.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model\Resource\Event;
 
+use Magento\Index\Model\Process;
 
 /**
  * Index Event Collection
@@ -32,15 +34,12 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model\Resource\Event;
-
-use Magento\Index\Model\Process;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Initialize resource
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -50,7 +49,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add filter by entity
      *
-     * @param string | array $entity
+     * @param string|array $entity
      * @return $this
      */
     public function addEntityFilter($entity)
@@ -66,7 +65,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add filter by type
      *
-     * @param string | array $type
+     * @param string|array $type
      * @return $this
      */
     public function addTypeFilter($type)
diff --git a/app/code/Magento/Index/Model/Resource/Process.php b/app/code/Magento/Index/Model/Resource/Process.php
index 91e60e17913634233190a6e4b8f2ef8ef46da744..e1439105d7955af1face54113587beb41ff79258 100644
--- a/app/code/Magento/Index/Model/Resource/Process.php
+++ b/app/code/Magento/Index/Model/Resource/Process.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model\Resource;
 
+use Magento\Index\Model\Process as ModelProcess;
 
 /**
  * Index Process Resource Model
@@ -32,10 +34,6 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model\Resource;
-
-use Magento\Index\Model\Process as ModelProcess;
-
 class Process extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -55,6 +53,8 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Initialize  table and table pk
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Index/Model/Resource/Process/Collection.php b/app/code/Magento/Index/Model/Resource/Process/Collection.php
index 6df69c02415fb6938db0f9a4177cf76a314c9695..486ed903c19e3922e7ffca4b68bd8352bbf5295a 100644
--- a/app/code/Magento/Index/Model/Resource/Process/Collection.php
+++ b/app/code/Magento/Index/Model/Resource/Process/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Index\Model\Resource\Process;
 
 /**
  * Index Process Collection
@@ -32,13 +32,12 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model\Resource\Process;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Initialize resource
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -48,7 +47,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add count of unprocessed events to process collection
      *
-     * @return \Magento\Index\Model\Resource\Process\Collection
+     * @return $this
      */
     public function addEventsStats()
     {
diff --git a/app/code/Magento/Index/Model/Resource/Setup.php b/app/code/Magento/Index/Model/Resource/Setup.php
index 3a6b92a59d742f510b3c6bcae4daa9f5cfce0548..578f8e69c2b135c412001e3c8c099a3a7e768674 100644
--- a/app/code/Magento/Index/Model/Resource/Setup.php
+++ b/app/code/Magento/Index/Model/Resource/Setup.php
@@ -73,7 +73,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup
     /**
      * Sync indexes declarations in config and in DB
      *
-     * @return \Magento\Index\Model\Resource\Setup
+     * @return $this
      */
     protected function _syncIndexes()
     {
diff --git a/app/code/Magento/Index/Model/Shell.php b/app/code/Magento/Index/Model/Shell.php
index b3bf2c8d0d28b1d7220fa6e5c5c0703be903e6a9..e2a53a234156fcd8cdd589fa6a1f9e2bb419884d 100644
--- a/app/code/Magento/Index/Model/Shell.php
+++ b/app/code/Magento/Index/Model/Shell.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Index\Model;
 
 /**
  * Shell model, used to work with indexers via command line
@@ -31,8 +32,6 @@
  * @package     Magento_Index
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Index\Model;
-
 class Shell extends \Magento\Core\Model\AbstractShell
 {
     /**
@@ -55,7 +54,7 @@ class Shell extends \Magento\Core\Model\AbstractShell
     public function __construct(
         \Magento\App\Filesystem $filesystem,
         $entryPoint,
-        \Magento\Index\Model\Indexer $indexer
+        Indexer $indexer
     ) {
         $this->_indexer = $indexer;
         parent::__construct($filesystem, $entryPoint);
@@ -182,8 +181,6 @@ class Shell extends \Magento\Core\Model\AbstractShell
 
     /**
      * Reindexes indexer(s)
-     *
-     * @return $this
      */
     protected function _runReindex()
     {
diff --git a/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Mode.php b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Scheduled.php
similarity index 68%
rename from app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Mode.php
rename to app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Scheduled.php
index 55814d9decdabcb8f10efd1c10bf9e64fe99ca5e..48a9a277dee96b0a40b226703cf3ae1225da46d3 100644
--- a/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Mode.php
+++ b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Scheduled.php
@@ -24,27 +24,22 @@
 
 namespace Magento\Indexer\Block\Backend\Grid\Column\Renderer;
 
-class Mode extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
+class Scheduled extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
     /**
-     * Render indexer mode
+     * Render whether indexer is scheduled
      *
      * @param \Magento\Object $row
      * @return string
      */
     public function render(\Magento\Object $row)
     {
-        $class = '';
-        $text = '';
-        switch ($this->_getValue($row)) {
-            case \Magento\Mview\View\StateInterface::MODE_DISABLED:
-                $class = 'grid-severity-notice';
-                $text = __('Update on Save');
-                break;
-            case \Magento\Mview\View\StateInterface::MODE_ENABLED:
-                $class = 'grid-severity-major';
-                $text = __('Update by Schedule');
-                break;
+        if ($this->_getValue($row)) {
+            $class = 'grid-severity-notice';
+            $text = __('Update by Schedule');
+        } else {
+            $class = 'grid-severity-major';
+            $text = __('Update on Save');
         }
         return '<span class="' . $class . '"><span>' . $text . '</span></span>';
     }
diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php
index ba2e376c6aa1b756d4cc594de0117bca2e33b53e..f3e14f5fc6ab3483f2674bbc6104ff65154b5b44 100644
--- a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php
+++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php
@@ -50,10 +50,10 @@ class Indexer extends \Magento\Backend\App\Action
         } else {
             try {
                 foreach ($indexerIds as $indexer_id) {
-                    /** @var \Magento\Indexer\Model\Indexer $model */
-                    $model = $this->_objectManager->create('Magento\Indexer\Model\Indexer')
+                    /** @var \Magento\Indexer\Model\IndexerInterface $model */
+                    $model = $this->_objectManager->create('Magento\Indexer\Model\IndexerInterface')
                         ->load($indexer_id);
-                    $model->turnViewOff();
+                    $model->setScheduled(false);
                 }
                 $this->messageManager->addSuccess(
                     __('A total of %1 indexer(s) have been turned Update on Save mode on.', count($indexerIds))
@@ -81,10 +81,10 @@ class Indexer extends \Magento\Backend\App\Action
         } else {
             try {
                 foreach ($indexerIds as $indexer_id) {
-                    /** @var \Magento\Indexer\Model\Indexer $model */
-                    $model = $this->_objectManager->create('Magento\Indexer\Model\Indexer')
+                    /** @var \Magento\Indexer\Model\IndexerInterface $model */
+                    $model = $this->_objectManager->create('Magento\Indexer\Model\IndexerInterface')
                         ->load($indexer_id);
-                    $model->turnViewOn();
+                    $model->setScheduled(true);
                 }
                 $this->messageManager->addSuccess(
                     __('A total of %1 indexer(s) have been turned Update by Schedule mode on.', count($indexerIds))
diff --git a/app/code/Magento/Indexer/Model/Config.php b/app/code/Magento/Indexer/Model/Config.php
index db905bd786423329124c2473cc5de3d0d01161ae..ff786f783be2517a8d4cc32ab1383e8416e4ea68 100644
--- a/app/code/Magento/Indexer/Model/Config.php
+++ b/app/code/Magento/Indexer/Model/Config.php
@@ -24,29 +24,40 @@
 
 namespace Magento\Indexer\Model;
 
-class Config extends \Magento\Config\Data implements ConfigInterface
+class Config implements ConfigInterface
 {
     /**
-     * @param \Magento\Indexer\Model\Config\Reader $reader
-     * @param \Magento\Config\CacheInterface $cache
-     * @param string $cacheId
+     * @var Config\Data
      */
-    public function __construct(
-        \Magento\Indexer\Model\Config\Reader $reader,
-        \Magento\Config\CacheInterface $cache,
-        $cacheId = 'indexer_config'
-    ) {
-        parent::__construct($reader, $cache, $cacheId);
+    protected $configData;
+
+    /**
+     * @param Config\Data $configData
+     */
+    public function __construct(Config\Data $configData)
+    {
+        $this->configData = $configData;
     }
 
     /**
-     * Get indexer's config
+     * Get indexers list
      *
-     * @return mixed
+     * @return array[]
+     */
+    public function getIndexers()
+    {
+        return $this->configData->get();
+    }
+
+    /**
+     * Get indexer by ID
+     *
+     * @param string $indexerId
+     * @return array
      */
-    public function getAll()
+    public function getIndexer($indexerId)
     {
-        return $this->get();
+        return $this->configData->get($indexerId);
     }
 
     /**
diff --git a/app/code/Magento/Indexer/Model/Config/Data.php b/app/code/Magento/Indexer/Model/Config/Data.php
new file mode 100644
index 0000000000000000000000000000000000000000..975259bf832d7a23f572f95c82ccf5450f3288d7
--- /dev/null
+++ b/app/code/Magento/Indexer/Model/Config/Data.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Indexer\Model\Config;
+
+class Data extends \Magento\Config\Data
+{
+    /**
+     * @var \Magento\Indexer\Model\Resource\Indexer\State\Collection
+     */
+    protected $stateCollection;
+
+    /**
+     * @param \Magento\Indexer\Model\Config\Reader $reader
+     * @param \Magento\Config\CacheInterface $cache
+     * @param \Magento\Indexer\Model\Resource\Indexer\State\Collection $stateCollection
+     * @param string $cacheId
+     */
+    public function __construct(
+        \Magento\Indexer\Model\Config\Reader $reader,
+        \Magento\Config\CacheInterface $cache,
+        \Magento\Indexer\Model\Resource\Indexer\State\Collection $stateCollection,
+        $cacheId = 'indexer_config'
+    ) {
+        $this->stateCollection = $stateCollection;
+
+        $isCacheExists = $cache->test($cacheId);
+
+        parent::__construct($reader, $cache, $cacheId);
+
+        if (!$isCacheExists) {
+            $this->deleteNonexistentStates();
+        }
+    }
+
+    /**
+     * Delete all states that are not in configuration
+     */
+    protected function deleteNonexistentStates()
+    {
+        foreach ($this->stateCollection->getItems() as $state) {
+            /** @var \Magento\Indexer\Model\Indexer\State $state */
+            if (!isset($this->_data[$state->getIndexerId()])) {
+                $state->delete();
+            }
+        }
+    }
+}
diff --git a/app/code/Magento/Indexer/Model/ConfigInterface.php b/app/code/Magento/Indexer/Model/ConfigInterface.php
index 258219ee9c8b23bf6ba626f9b8ea21f00f3f3cbf..6e323223cf8874ff990e461d37c60ad2e2660e6d 100644
--- a/app/code/Magento/Indexer/Model/ConfigInterface.php
+++ b/app/code/Magento/Indexer/Model/ConfigInterface.php
@@ -27,25 +27,17 @@ namespace Magento\Indexer\Model;
 interface ConfigInterface
 {
     /**
-     * Get indexer's config
+     * Get indexers list
      *
-     * @return array
-     */
-    public function getAll();
-
-    /**
-     * Get config value by key
-     *
-     * @param string $path
-     * @param mixed $default
-     * @return mixed
+     * @return array[]
      */
-    public function get($path = null, $default = null);
+    public function getIndexers();
 
     /**
-     * Get list of indexer ids
+     * Get indexer by ID
      *
+     * @param string $indexerId
      * @return array
      */
-    public function getIndexerIds();
+    public function getIndexer($indexerId);
 }
diff --git a/app/code/Magento/Indexer/Model/Indexer.php b/app/code/Magento/Indexer/Model/Indexer.php
index 670a6c569379e0f46a8a363d4f205d60b625acad..2e5f0b61878bb0da9aec88fd39b201b62bcb7b62 100644
--- a/app/code/Magento/Indexer/Model/Indexer.php
+++ b/app/code/Magento/Indexer/Model/Indexer.php
@@ -24,13 +24,7 @@
 
 namespace Magento\Indexer\Model;
 
-/**
- * @method int getViewId()
- * @method string getActionClass()
- * @method string getTitle()
- * @method string getDescription()
- */
-class Indexer extends \Magento\Object
+class Indexer extends \Magento\Object implements IndexerInterface
 {
     /**
      * @var string
@@ -48,7 +42,7 @@ class Indexer extends \Magento\Object
     protected $actionFactory;
 
     /**
-     * @var \Magento\Mview\View
+     * @var \Magento\Mview\ViewInterface
      */
     protected $view;
 
@@ -91,16 +85,56 @@ class Indexer extends \Magento\Object
         parent::__construct($data);
     }
 
+    /**
+     * Return indexer's view ID
+     *
+     * @return string
+     */
+    public function getViewId()
+    {
+        return $this->getData('view_id');
+    }
+
+    /**
+     * Return indexer action class
+     *
+     * @return string
+     */
+    public function getActionClass()
+    {
+        return $this->getData('action_class');
+    }
+
+    /**
+     * Return indexer title
+     *
+     * @return string
+     */
+    public function getTitle()
+    {
+        return $this->getData('title');
+    }
+
+    /**
+     * Return indexer description
+     *
+     * @return string
+     */
+    public function getDescription()
+    {
+        return $this->getData('description');
+    }
+
     /**
      * Fill indexer data from config
      *
      * @param string $indexerId
-     * @return \Magento\Indexer\Model\Indexer
+     * @return IndexerInterface
      * @throws \InvalidArgumentException
      */
     public function load($indexerId)
     {
-        $indexer = $this->config->get($indexerId);
+        $indexer = $this->config->getIndexer($indexerId);
         if (empty($indexer) || empty($indexer['indexer_id']) || $indexer['indexer_id'] != $indexerId) {
             throw new \InvalidArgumentException("{$indexerId} indexer does not exist.");
         }
@@ -114,7 +148,7 @@ class Indexer extends \Magento\Object
     /**
      * Return related view object
      *
-     * @return \Magento\Mview\View
+     * @return \Magento\Mview\ViewInterface
      */
     public function getView()
     {
@@ -145,7 +179,7 @@ class Indexer extends \Magento\Object
      * Set indexer state object
      *
      * @param Indexer\State $state
-     * @return Indexer
+     * @return IndexerInterface
      */
     public function setState(Indexer\State $state)
     {
@@ -154,35 +188,66 @@ class Indexer extends \Magento\Object
     }
 
     /**
-     * Return indexer mode
+     * Check whether indexer is run by schedule
      *
-     * @return string
+     * @return bool
      */
-    public function getMode()
+    public function isScheduled()
     {
-        return $this->getView()->getMode();
+        return $this->getView()->isEnabled();
     }
 
     /**
-     * Turn changelog mode of
+     * Turn scheduled mode on/off
      *
-     * @return string
+     * @param bool $scheduled
      */
-    public function turnViewOff()
+    public function setScheduled($scheduled)
     {
-        $this->getView()->unsubscribe();
+        if ($scheduled) {
+            $this->getView()->subscribe();
+        } else {
+            $this->getView()->unsubscribe();
+        }
         $this->getState()->save();
     }
 
     /**
-     * Turn changelog mode on
+     * Check whether indexer is valid
      *
-     * @return string
+     * @return bool
      */
-    public function turnViewOn()
+    public function isValid()
     {
-        $this->getView()->subscribe();
-        $this->getState()->save();
+        return $this->getState()->getStatus() == Indexer\State::STATUS_VALID;
+    }
+
+    /**
+     * Check whether indexer is invalid
+     *
+     * @return bool
+     */
+    public function isInvalid()
+    {
+        return $this->getState()->getStatus() == Indexer\State::STATUS_INVALID;
+    }
+
+    /**
+     * Check whether indexer is working
+     *
+     * @return bool
+     */
+    public function isWorking()
+    {
+        return $this->getState()->getStatus() == Indexer\State::STATUS_WORKING;
+    }
+
+    /**
+     * Set indexer invalid
+     */
+    public function invalidate()
+    {
+        $this->getState()->setStatus(Indexer\State::STATUS_INVALID)->save();
     }
 
     /**
@@ -192,24 +257,17 @@ class Indexer extends \Magento\Object
      */
     public function getStatus()
     {
-        if ($this->getView()->getMode() == \Magento\Mview\View\StateInterface::MODE_ENABLED
-            && $this->getView()->getStatus() == \Magento\Mview\View\StateInterface::STATUS_WORKING
-        ) {
-            return \Magento\Indexer\Model\Indexer\State::STATUS_WORKING;
-        }
         return $this->getState()->getStatus();
     }
 
     /**
-     * Return indexer updated time
+     * Return indexer or mview latest updated time
      *
      * @return string
      */
-    public function getUpdated()
+    public function getLatestUpdated()
     {
-        if ($this->getView()->getMode() == \Magento\Mview\View\StateInterface::MODE_ENABLED
-            && $this->getView()->getUpdated()
-        ) {
+        if ($this->getView()->isEnabled() && $this->getView()->getUpdated()) {
             if (!$this->getState()->getUpdated()) {
                 return $this->getView()->getUpdated();
             }
@@ -243,15 +301,20 @@ class Indexer extends \Magento\Object
             $this->getState()
                 ->setStatus(Indexer\State::STATUS_WORKING)
                 ->save();
+            if ($this->getView()->isEnabled()) {
+                $this->getView()->suspend();
+            }
             try {
                 $this->getActionInstance()->executeFull();
                 $this->getState()
                     ->setStatus(Indexer\State::STATUS_VALID)
                     ->save();
+                $this->getView()->resume();
             } catch (\Exception $exception) {
                 $this->getState()
                     ->setStatus(Indexer\State::STATUS_INVALID)
                     ->save();
+                $this->getView()->resume();
                 throw $exception;
             }
         }
@@ -265,6 +328,7 @@ class Indexer extends \Magento\Object
     public function reindexRow($id)
     {
         $this->getActionInstance()->executeRow($id);
+        $this->getState()->save();
     }
 
     /**
@@ -275,5 +339,6 @@ class Indexer extends \Magento\Object
     public function reindexList($ids)
     {
         $this->getActionInstance()->executeList($ids);
+        $this->getState()->save();
     }
 }
diff --git a/app/code/Magento/Indexer/Model/Indexer/Collection.php b/app/code/Magento/Indexer/Model/Indexer/Collection.php
index ac1582b80f486038653f6956093840e9a70af8fd..181ef4885c9e59ba71bceba472e408a828b920f2 100644
--- a/app/code/Magento/Indexer/Model/Indexer/Collection.php
+++ b/app/code/Magento/Indexer/Model/Indexer/Collection.php
@@ -31,7 +31,7 @@ class Collection extends \Magento\Data\Collection
      *
      * @var string
      */
-    protected $_itemObjectClass = 'Magento\Indexer\Model\Indexer';
+    protected $_itemObjectClass = 'Magento\Indexer\Model\IndexerInterface';
 
     /**
      * @var \Magento\Indexer\Model\ConfigInterface
@@ -71,8 +71,8 @@ class Collection extends \Magento\Data\Collection
     {
         if (!$this->isLoaded()) {
             $states = $this->statesFactory->create();
-            foreach ($this->config->getIndexerIds() as $indexerId) {
-                /** @var \Magento\Indexer\Model\Indexer $indexer */
+            foreach (array_keys($this->config->getIndexers()) as $indexerId) {
+                /** @var \Magento\Indexer\Model\IndexerInterface $indexer */
                 $indexer = $this->getNewEmptyItem();
                 $indexer->load($indexerId);
                 foreach ($states->getItems() as $state) {
@@ -88,24 +88,4 @@ class Collection extends \Magento\Data\Collection
         }
         return $this;
     }
-
-    /**
-     * Return indexers by given state status
-     *
-     * @param string $status
-     * @return \Magento\Indexer\Model\Indexer[]
-     */
-    public function getIndexersByStateStatus($status)
-    {
-        $this->load();
-
-        $result = array();
-        foreach ($this as $indexer) {
-            /** @var \Magento\Indexer\Model\Indexer $indexer */
-            if ($indexer->getState()->getStatus() == $status) {
-                $result[] = $indexer;
-            }
-        }
-        return $result;
-    }
 }
diff --git a/app/code/Magento/Indexer/Model/IndexerInterface.php b/app/code/Magento/Indexer/Model/IndexerInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..a49de7cd6a217c0e20ec0b98ea4e48e23aa5ee62
--- /dev/null
+++ b/app/code/Magento/Indexer/Model/IndexerInterface.php
@@ -0,0 +1,169 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Indexer\Model;
+
+interface IndexerInterface
+{
+    /**
+     * Return indexer ID
+     *
+     * @return string
+     */
+    public function getId();
+
+    /**
+     * Return indexer's view ID
+     *
+     * @return string
+     */
+    public function getViewId();
+
+    /**
+     * Return indexer action class
+     *
+     * @return string
+     */
+    public function getActionClass();
+
+    /**
+     * Return indexer title
+     *
+     * @return string
+     */
+    public function getTitle();
+
+    /**
+     * Return indexer description
+     *
+     * @return string
+     */
+    public function getDescription();
+
+    /**
+     * Fill indexer data from config
+     *
+     * @param string $indexerId
+     * @return IndexerInterface
+     * @throws \InvalidArgumentException
+     */
+    public function load($indexerId);
+
+    /**
+     * Return related view object
+     *
+     * @return \Magento\Mview\ViewInterface
+     */
+    public function getView();
+
+    /**
+     * Return related state object
+     *
+     * @return Indexer\State
+     */
+    public function getState();
+
+    /**
+     * Set indexer state object
+     *
+     * @param Indexer\State $state
+     * @return IndexerInterface
+     */
+    public function setState(Indexer\State $state);
+
+    /**
+     * Check whether indexer is run by schedule
+     *
+     * @return bool
+     */
+    public function isScheduled();
+
+    /**
+     * Turn scheduled mode on/off
+     *
+     * @param bool $scheduled
+     */
+    public function setScheduled($scheduled);
+
+    /**
+     * Check whether indexer is valid
+     *
+     * @return bool
+     */
+    public function isValid();
+
+    /**
+     * Check whether indexer is invalid
+     *
+     * @return bool
+     */
+    public function isInvalid();
+
+    /**
+     * Check whether indexer is working
+     *
+     * @return bool
+     */
+    public function isWorking();
+
+    /**
+     * Set indexer invalid
+     */
+    public function invalidate();
+
+    /**
+     * Return indexer status
+     *
+     * @return string
+     */
+    public function getStatus();
+
+    /**
+     * Return indexer or mview latest updated time
+     *
+     * @return string
+     */
+    public function getLatestUpdated();
+
+    /**
+     * Regenerate full index
+     *
+     * @throws \Exception
+     */
+    public function reindexAll();
+
+    /**
+     * Regenerate one row in index by ID
+     *
+     * @param int $id
+     */
+    public function reindexRow($id);
+
+    /**
+     * Regenerate rows in index by ID list
+     *
+     * @param int[] $ids
+     */
+    public function reindexList($ids);
+}
diff --git a/app/code/Magento/Indexer/Model/Processor.php b/app/code/Magento/Indexer/Model/Processor.php
index f152c82a1e4de867d0b32f9077c76ed808e3c5ce..1e486528807053e1a73e60b45c86fa2a87adc02a 100644
--- a/app/code/Magento/Indexer/Model/Processor.php
+++ b/app/code/Magento/Indexer/Model/Processor.php
@@ -27,7 +27,7 @@ namespace Magento\Indexer\Model;
 class Processor
 {
     /**
-     * @var Config
+     * @var ConfigInterface
      */
     protected $config;
 
@@ -47,13 +47,13 @@ class Processor
     protected $mviewProcessor;
 
     /**
-     * @param Config $config
+     * @param ConfigInterface $config
      * @param IndexerFactory $indexerFactory
      * @param Indexer\CollectionFactory $indexersFactory
      * @param \Magento\Mview\ProcessorInterface $mviewProcessor
      */
     public function __construct(
-        Config $config,
+        ConfigInterface $config,
         IndexerFactory $indexerFactory,
         Indexer\CollectionFactory $indexersFactory,
         \Magento\Mview\ProcessorInterface $mviewProcessor
@@ -69,10 +69,10 @@ class Processor
      */
     public function reindexAllInvalid()
     {
-        foreach ($this->config->getIndexerIds() as $indexerId) {
+        foreach (array_keys($this->config->getIndexers()) as $indexerId) {
             $indexer = $this->indexerFactory->create();
             $indexer->load($indexerId);
-            if ($indexer->getState()->getStatus() == Indexer\State::STATUS_INVALID) {
+            if ($indexer->isInvalid()) {
                 $indexer->reindexAll();
             }
         }
@@ -83,7 +83,7 @@ class Processor
      */
     public function reindexAll()
     {
-        /** @var Indexer[] $indexers */
+        /** @var IndexerInterface[] $indexers */
         $indexers = $this->indexersFactory->create()->getItems();
         foreach ($indexers as $indexer) {
             $indexer->reindexAll();
diff --git a/app/code/Magento/Indexer/Model/Shell.php b/app/code/Magento/Indexer/Model/Shell.php
index c94cf987b40f3d81202e1f3b3745093f0558616c..be4829e44c311d95f568b836a41a792454fc3de3 100644
--- a/app/code/Magento/Indexer/Model/Shell.php
+++ b/app/code/Magento/Indexer/Model/Shell.php
@@ -125,20 +125,12 @@ class Shell extends \Magento\Core\Model\AbstractShell
                     case \Magento\Indexer\Model\Indexer\State::STATUS_INVALID:
                         $status = 'Reindex required';
                         break;
-
                     case \Magento\Indexer\Model\Indexer\State::STATUS_WORKING:
                         $status = 'Processing';
                         break;
                 }
             } else {
-                switch ($indexer->getMode()) {
-                    case \Magento\Mview\View\StateInterface::MODE_DISABLED:
-                        $status = 'Update on Save';
-                        break;
-                    case \Magento\Mview\View\StateInterface::MODE_ENABLED:
-                        $status = 'Update by Schedule';
-                        break;
-                }
+                $status = $indexer->isScheduled() ? 'Update by Schedule' : 'Update on Save';
             }
             echo sprintf('%-50s ', $indexer->getTitle() . ':') . $status . PHP_EOL;
         }
@@ -212,7 +204,7 @@ class Shell extends \Magento\Core\Model\AbstractShell
      * Parses string with indexers and return array of indexer instances
      *
      * @param string $string
-     * @return Indexer[]
+     * @return IndexerInterface[]
      */
     protected function parseIndexerString($string)
     {
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_customergrid.xml b/app/code/Magento/Indexer/etc/cron_groups.xml
similarity index 65%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_customergrid.xml
rename to app/code/Magento/Indexer/etc/cron_groups.xml
index 1723a054a6885bff1f64bd5abb61b6410c0fda30..b0e208ab57aed02a482bf633d2e1b7e25cf63699 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_customergrid.xml
+++ b/app/code/Magento/Indexer/etc/cron_groups.xml
@@ -19,10 +19,20 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
+ * @category    Magento
+ * @package     Magento_Cron
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 -->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <block class="Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Agreement" name="customer.billing.agreement.grid" output="1"/>
-</layout>
+<config>
+    <group id="index">
+        <schedule_generate_every>1</schedule_generate_every>
+        <schedule_ahead_for>4</schedule_ahead_for>
+        <schedule_lifetime>2</schedule_lifetime>
+        <history_cleanup_every>10</history_cleanup_every>
+        <history_success_lifetime>60</history_success_lifetime>
+        <history_failure_lifetime>600</history_failure_lifetime>
+        <use_separate_process>1</use_separate_process>
+    </group>
+</config>
\ No newline at end of file
diff --git a/app/code/Magento/Indexer/etc/crontab.xml b/app/code/Magento/Indexer/etc/crontab.xml
index 55aece105ca417d7138898353171354a093296c5..0c0b6192f770c0b3a1d4d8af536748ed2aae2906 100644
--- a/app/code/Magento/Indexer/etc/crontab.xml
+++ b/app/code/Magento/Indexer/etc/crontab.xml
@@ -24,13 +24,15 @@
  */
 -->
 <config>
-    <job name="indexer_reindex_all_invalid" instance="Magento\Indexer\Model\Processor" method="reindexAllInvalid">
-        <schedule>* * * * *</schedule>
-    </job>
-    <job name="indexer_update_all_views" instance="Magento\Indexer\Model\Processor" method="updateMview">
-        <schedule>* * * * *</schedule>
-    </job>
-    <job name="indexer_clean_all_changelogs" instance="Magento\Indexer\Model\Processor" method="clearChangelog">
-        <schedule>0 * * * *</schedule>
-    </job>
+    <group id="index">
+        <job name="indexer_reindex_all_invalid" instance="Magento\Indexer\Model\Processor" method="reindexAllInvalid">
+            <schedule>* * * * *</schedule>
+        </job>
+        <job name="indexer_update_all_views" instance="Magento\Indexer\Model\Processor" method="updateMview">
+            <schedule>* * * * *</schedule>
+        </job>
+        <job name="indexer_clean_all_changelogs" instance="Magento\Indexer\Model\Processor" method="clearChangelog">
+            <schedule>0 * * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Indexer/etc/di.xml b/app/code/Magento/Indexer/etc/di.xml
index 01003bc4b1d5e5280c119658129a6a749b579103..fc6a11d8398780d784e090f22ea2025a977146bb 100644
--- a/app/code/Magento/Indexer/etc/di.xml
+++ b/app/code/Magento/Indexer/etc/di.xml
@@ -25,9 +25,20 @@
 -->
 <config>
     <preference for="Magento\Indexer\Model\ConfigInterface" type="Magento\Indexer\Model\Config" />
+    <preference for="Magento\Indexer\Model\IndexerInterface" type="Magento\Indexer\Model\Indexer" />
     <type name="Magento\Indexer\Model\Indexer">
         <param name="view">
             <instance type="Magento\Mview\View" shared="false"/>
         </param>
     </type>
+    <type name="Magento\Indexer\Model\Config">
+        <param name="configData">
+            <instance type="Magento\Indexer\Model\Config\Data\Proxy"/>
+        </param>
+    </type>
+    <type name="Magento\Indexer\Model\Config\Data">
+        <param name="stateCollection">
+            <instance type="Magento\Indexer\Model\Resource\Indexer\State\Collection" shared="false"/>
+        </param>
+    </type>
 </config>
\ No newline at end of file
diff --git a/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml b/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml
index ee5b6db133add6849fef211f5e30fdfb7a57d002..58e1d48d842ef850c90a914997bfda0e80df19ec 100644
--- a/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml
+++ b/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml
@@ -79,8 +79,8 @@
                         <argument name="header" xsi:type="string" translate="true">Mode</argument>
                         <argument name="width" xsi:type="string">150</argument>
                         <argument name="align" xsi:type="string">left</argument>
-                        <argument name="getter" xsi:type="string">getMode</argument>
-                        <argument name="renderer" xsi:type="string">\Magento\Indexer\Block\Backend\Grid\Column\Renderer\Mode</argument>
+                        <argument name="getter" xsi:type="string">isScheduled</argument>
+                        <argument name="renderer" xsi:type="string">Magento\Indexer\Block\Backend\Grid\Column\Renderer\Scheduled</argument>
                         <argument name="sortable" xsi:type="string">0</argument>
                         <argument name="column_css_class" xsi:type="string">indexer-mode</argument>
                     </arguments>
@@ -91,7 +91,7 @@
                         <argument name="width" xsi:type="string">120</argument>
                         <argument name="align" xsi:type="string">left</argument>
                         <argument name="getter" xsi:type="string">getStatus</argument>
-                        <argument name="renderer" xsi:type="string">\Magento\Indexer\Block\Backend\Grid\Column\Renderer\Status</argument>
+                        <argument name="renderer" xsi:type="string">Magento\Indexer\Block\Backend\Grid\Column\Renderer\Status</argument>
                         <argument name="sortable" xsi:type="string">0</argument>
                         <argument name="column_css_class" xsi:type="string">indexer-status</argument>
                     </arguments>
@@ -103,8 +103,8 @@
                         <argument name="align" xsi:type="string">left</argument>
                         <argument name="index" xsi:type="string">updated</argument>
                         <argument name="type" xsi:type="string">datetime</argument>
-                        <argument name="getter" xsi:type="string">getUpdated</argument>
-                        <argument name="renderer" xsi:type="string">\Magento\Indexer\Block\Backend\Grid\Column\Renderer\Updated</argument>
+                        <argument name="getter" xsi:type="string">getLatestUpdated</argument>
+                        <argument name="renderer" xsi:type="string">Magento\Indexer\Block\Backend\Grid\Column\Renderer\Updated</argument>
                         <argument name="sortable" xsi:type="string">0</argument>
                         <argument name="column_css_class" xsi:type="string">indexer-updated</argument>
                     </arguments>
diff --git a/app/code/Magento/Install/App/Action/Plugin/Dir.php b/app/code/Magento/Install/App/Action/Plugin/Dir.php
index 348085244ff56058c62da5c608f26b0d5f808ca5..1551dc5e0bc48694b9fe3a6a47ec6fb5fad8dc0e 100644
--- a/app/code/Magento/Install/App/Action/Plugin/Dir.php
+++ b/app/code/Magento/Install/App/Action/Plugin/Dir.php
@@ -69,8 +69,8 @@ class Dir
     /**
      * Clear temporary directories
      *
-     * @param $arguments
-     * @return mixed
+     * @param array $arguments
+     * @return array
      */
     public function beforeDispatch($arguments)
     {
diff --git a/app/code/Magento/Install/App/Console.php b/app/code/Magento/Install/App/Console.php
index 233df7afc90f9226c51ae13097bf9d8781b86f1b..3d53c3a0a938db55dea4f6b54739797b72f709ee 100644
--- a/app/code/Magento/Install/App/Console.php
+++ b/app/code/Magento/Install/App/Console.php
@@ -67,12 +67,12 @@ class Console implements \Magento\LauncherInterface
 
     /**
      * @param \Magento\Install\Model\Installer\ConsoleFactory $installerFactory
-     * @param Output $output
+     * @param \Magento\Install\App\Output $output
      * @param \Magento\App\State $state
      * @param \Magento\App\ObjectManager\ConfigLoader $loader
      * @param \Magento\ObjectManager $objectManager
-     * @param Response $response
      * @param \Magento\App\Filesystem $filesystem
+     * @param Response $response
      * @param array $arguments
      */
     public function __construct(
@@ -123,6 +123,7 @@ class Console implements \Magento\LauncherInterface
      * Install/Uninstall application
      *
      * @param \Magento\Install\Model\Installer\Console $installer
+     * @return void
      */
     protected function _handleInstall(\Magento\Install\Model\Installer\Console $installer)
     {
diff --git a/app/code/Magento/Install/App/Output.php b/app/code/Magento/Install/App/Output.php
index 29927dc6341664399241f764bd62d76ee7bd2c0b..83533db9873dbd8f141233ad91fbf39f7d8f519e 100644
--- a/app/code/Magento/Install/App/Output.php
+++ b/app/code/Magento/Install/App/Output.php
@@ -29,6 +29,7 @@ class Output
      * Export variable
      *
      * @param mixed $var
+     * @return void
      */
     public function export($var)
     {
@@ -39,6 +40,7 @@ class Output
      * Display message
      *
      * @param string $message
+     * @return void
      */
     public function success($message)
     {
@@ -49,6 +51,7 @@ class Output
      * Display error
      *
      * @param string $message
+     * @return void
      * @SuppressWarnings(PHPMD.ExitExpression)
      */
     public function error($message)
diff --git a/app/code/Magento/Install/Block/Begin.php b/app/code/Magento/Install/Block/Begin.php
index a88d772ad912eb72ef7b051392abd86f77b3ae65..85029cbf6dcaf7e2525c0c0bd62735102a9dd6ec 100644
--- a/app/code/Magento/Install/Block/Begin.php
+++ b/app/code/Magento/Install/Block/Begin.php
@@ -31,6 +31,9 @@ namespace Magento\Install\Block;
 
 class Begin extends \Magento\Install\Block\AbstractBlock
 {
+    /**
+     * @var string
+     */
     protected $_template = 'begin.phtml';
 
     /**
diff --git a/app/code/Magento/Install/Block/Db/Main.php b/app/code/Magento/Install/Block/Db/Main.php
index b6afdd6ad6ef3d51bcefac6231c8ab968d6319e0..fda729744c6f1960f3fb1fc41691a51f8044d3ca 100644
--- a/app/code/Magento/Install/Block/Db/Main.php
+++ b/app/code/Magento/Install/Block/Db/Main.php
@@ -75,7 +75,7 @@ class Main extends \Magento\View\Element\Template
      * @param  string $type database type
      * @param  string $block database block type
      * @param  string $template
-     * @return \Magento\Install\Block\Db\Main
+     * @return $this
      */
     public function addDatabaseBlock($type, $block, $template)
     {
diff --git a/app/code/Magento/Install/Block/End.php b/app/code/Magento/Install/Block/End.php
index 0d427c0d60cd56ee5457626532b3754cf6790509..5f9d9aa4831955c7db7cbcc41ec00349b90af5aa 100644
--- a/app/code/Magento/Install/Block/End.php
+++ b/app/code/Magento/Install/Block/End.php
@@ -62,7 +62,7 @@ class End extends \Magento\Install\Block\AbstractBlock
      * @param \Magento\Session\Generic $session
      * @param \Magento\App\ConfigInterface $coreConfig
      * @param \Magento\AdminNotification\Model\Survey $survey
-     * @param $cryptKey
+     * @param string $cryptKey
      * @param array $data
      */
     public function __construct(
diff --git a/app/code/Magento/Install/Block/Locale.php b/app/code/Magento/Install/Block/Locale.php
index d1e2163623eed3ca9a743f7e7b52f68a2e364028..54e9cd9f0d6498d40f4e630096858645f173e42a 100644
--- a/app/code/Magento/Install/Block/Locale.php
+++ b/app/code/Magento/Install/Block/Locale.php
@@ -52,8 +52,8 @@ class Locale extends \Magento\Install\Block\AbstractBlock
     /**
      * Set locale code
      *
-     * @param $localeCode
-     * @return \Magento\Install\Block\Locale
+     * @param string $localeCode
+     * @return $this
      */
     public function setLocaleCode($localeCode)
     {
diff --git a/app/code/Magento/Install/Controller/Index.php b/app/code/Magento/Install/Controller/Index.php
index 7566b6454c166bf575abfbde3197d4da5abdd398..6502b5e5f5f65c5dc60ddceb4e6ae7d13b139682 100644
--- a/app/code/Magento/Install/Controller/Index.php
+++ b/app/code/Magento/Install/Controller/Index.php
@@ -45,6 +45,8 @@ class Index extends \Magento\Install\Controller\Action
 
     /**
      * Index action
+     *
+     * @return void
      */
     public function indexAction()
     {
diff --git a/app/code/Magento/Install/Controller/Wizard.php b/app/code/Magento/Install/Controller/Wizard.php
index 4f7df71c578d61a667e6e4576af2aa0adda8fc34..ed18670da6604aa3843f1f9dab471ec08329f93c 100644
--- a/app/code/Magento/Install/Controller/Wizard.php
+++ b/app/code/Magento/Install/Controller/Wizard.php
@@ -23,15 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Installation wizard controller
- */
 namespace Magento\Install\Controller;
 
-use Magento\App\Action\NotFoundException;
 use Magento\App\RequestInterface;
+use Magento\App\ResponseInterface;
 
+/**
+ * Installation wizard controller
+ */
 class Wizard extends \Magento\Install\Controller\Action
 {
     /**
@@ -139,7 +138,7 @@ class Wizard extends \Magento\Install\Controller\Action
     /**
      * Prepare layout
      *
-     * @return \Magento\Install\Controller\Wizard
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -172,6 +171,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Index action
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -180,6 +181,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Begin installation action
+     *
+     * @return void
      */
     public function beginAction()
     {
@@ -198,6 +201,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Process begin step POST data
+     *
+     * @return void
      */
     public function beginPostAction()
     {
@@ -213,6 +218,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Localization settings
+     *
+     * @return void
      */
     public function localeAction()
     {
@@ -233,6 +240,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Change current locale
+     *
+     * @return void
      */
     public function localeChangeAction()
     {
@@ -252,6 +261,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Saving localization settings
+     *
+     * @return void
      */
     public function localePostAction()
     {
@@ -268,6 +279,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Download page action
+     *
+     * @return void
      */
     public function downloadAction()
     {
@@ -284,6 +297,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Download post action
+     *
+     * @return void
      */
     public function downloadPostAction()
     {
@@ -310,6 +325,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Download auto action
+     *
+     * @return void
      */
     public function downloadAutoAction()
     {
@@ -319,6 +336,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Install action
+     *
+     * @return void
      * @SuppressWarnings(PHPMD.ExitExpression)
      */
     public function installAction()
@@ -352,6 +371,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Install success callback
+     *
+     * @return void
      */
     public function installSuccessCallback()
     {
@@ -360,6 +381,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Install failure callback
+     *
+     * @return void
      */
     public function installFailureCallback()
     {
@@ -368,6 +391,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Download manual action
+     *
+     * @return void
      */
     public function downloadManualAction()
     {
@@ -377,6 +402,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Configuration data installation
+     *
+     * @return void
      */
     public function configAction()
     {
@@ -400,6 +427,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Process configuration POST data
+     *
+     * @return ResponseInterface|void
      */
     public function configPostAction()
     {
@@ -430,6 +459,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Install DB
+     *
+     * @return void
      */
     public function installDbAction()
     {
@@ -454,6 +485,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Install administrator account
+     *
+     * @return void
      */
     public function administratorAction()
     {
@@ -468,6 +501,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * Process administrator installation POST data
+     *
+     * @return void
      */
     public function administratorPostAction()
     {
@@ -495,6 +530,8 @@ class Wizard extends \Magento\Install\Controller\Action
 
     /**
      * End installation
+     *
+     * @return void
      */
     public function endAction()
     {
diff --git a/app/code/Magento/Install/Model/Config.php b/app/code/Magento/Install/Model/Config.php
index f95272ee31d88415e58d0ecefce98b9a30c66aea..ddcd2bc0ebea0c3dfa3c2e1997afbf12b9581114 100644
--- a/app/code/Magento/Install/Model/Config.php
+++ b/app/code/Magento/Install/Model/Config.php
@@ -67,7 +67,7 @@ class Config
     /**
      * Get array of wizard steps
      *
-     * array($index => \Magento\Object)
+     * Array($index => \Magento\Object)
      *
      * @return array
      */
@@ -85,7 +85,7 @@ class Config
     /**
      * Retrieve writable path for checking
      *
-     * array(
+     * Array(
      *      ['writeable'] => array(
      *          [$index] => array(
      *              ['path']
diff --git a/app/code/Magento/Install/Model/Installer.php b/app/code/Magento/Install/Model/Installer.php
index b3cc7b69e6abace708e0672e4b323cfde9d5f44c..efdf1abdf6d2f3858da4bf09ffddbe4b6e5ed3fd 100644
--- a/app/code/Magento/Install/Model/Installer.php
+++ b/app/code/Magento/Install/Model/Installer.php
@@ -258,7 +258,7 @@ class Installer extends \Magento\Object
      * Set data model to store data between installation steps
      *
      * @param \Magento\Object $model
-     * @return \Magento\Install\Model\Installer
+     * @return $this
      */
     public function setDataModel($model)
     {
@@ -318,7 +318,7 @@ class Installer extends \Magento\Object
      * Installation config data
      *
      * @param   array $data
-     * @return  \Magento\Install\Model\Installer
+     * @return  $this
      */
     public function installConfig($data)
     {
@@ -341,7 +341,7 @@ class Installer extends \Magento\Object
     /**
      * Database installation
      *
-     * @return \Magento\Install\Model\Installer
+     * @return $this
      */
     public function installDb()
     {
@@ -417,6 +417,7 @@ class Installer extends \Magento\Object
      *
      * @param \Magento\Core\Model\Resource\Setup $setupModel
      * @param string $orderIncrementPrefix
+     * @return void
      */
     protected function _setOrderIncrementPrefix(\Magento\Core\Model\Resource\Setup $setupModel, $orderIncrementPrefix)
     {
@@ -435,6 +436,7 @@ class Installer extends \Magento\Object
      * Create an admin user
      *
      * @param array $data
+     * @return void
      */
     public function createAdministrator($data)
     {
@@ -456,7 +458,7 @@ class Installer extends \Magento\Object
      * Install encryption key into the application, generate and return a random one, if no value is specified
      *
      * @param string $key
-     * @return \Magento\Install\Model\Installer
+     * @return $this
      */
     public function installEncryptionKey($key)
     {
@@ -499,6 +501,8 @@ class Installer extends \Magento\Object
 
     /**
      * Store install date and set application into installed state
+     *
+     * @return void
      */
     protected function _setAppInstalled()
     {
@@ -509,6 +513,8 @@ class Installer extends \Magento\Object
 
     /**
      * Ensure changes in the configuration, if any, take effect
+     *
+     * @return void
      */
     protected function _refreshConfig()
     {
diff --git a/app/code/Magento/Install/Model/Installer/Config.php b/app/code/Magento/Install/Model/Installer/Config.php
index 3ac3817922180fa0bb5d7fbcb432cffdafb5f776..87b14a3b56b70c57c2d13db91ef3981d8df57130 100644
--- a/app/code/Magento/Install/Model/Installer/Config.php
+++ b/app/code/Magento/Install/Model/Installer/Config.php
@@ -46,6 +46,9 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
      */
     protected $_request;
 
+    /**
+     * @var array
+     */
     protected $_configData = array();
 
     /**
@@ -98,6 +101,10 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
         $this->messageManager = $messageManager;
     }
 
+    /**
+     * @param array $data
+     * @return $this
+     */
     public function setConfigData($data)
     {
         if (is_array($data)) {
@@ -106,6 +113,9 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
         return $this;
     }
 
+    /**
+     * @return array
+     */
     public function getConfigData()
     {
         return $this->_configData;
@@ -113,6 +123,8 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
 
     /**
      * Generate installation data and record them into local.xml using local.xml.template
+     *
+     * @return void
      */
     public function install()
     {
@@ -168,6 +180,9 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
         $this->_configDirectory->changePermissions($this->_localConfigFile, 0777);
     }
 
+    /**
+     * @return \Magento\Object
+     */
     public function getFormData()
     {
         $uri = \Zend_Uri::factory($this->_storeManager->getStore()->getBaseUrl('web'));
@@ -198,6 +213,7 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
      * Check validity of a base URL
      *
      * @param string $baseUrl
+     * @return void
      * @throws \Magento\Core\Exception
      * @throws \Exception
      */
@@ -251,6 +267,10 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
         return null;
     }
 
+    /**
+     * @param string $date
+     * @return $this
+     */
     public function replaceTmpInstallDate($date = 'now')
     {
         $stamp    = strtotime((string) $date);
@@ -261,6 +281,10 @@ class Config extends \Magento\Install\Model\Installer\AbstractInstaller
         return $this;
     }
 
+    /**
+     * @param string $key
+     * @return $this
+     */
     public function replaceTmpEncryptKey($key)
     {
         $localXml = $this->_configDirectory->readFile($this->_localConfigFile);
diff --git a/app/code/Magento/Install/Model/Installer/Console.php b/app/code/Magento/Install/Model/Installer/Console.php
index 761c921c3b137d355419e19e1b3cf5142f8318db..1bdcbb71ef5a44fdeb7c32a4549a516bd6f492f2 100644
--- a/app/code/Magento/Install/Model/Installer/Console.php
+++ b/app/code/Magento/Install/Model/Installer/Console.php
@@ -163,7 +163,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller
      * Retrieve validated installation options
      *
      * @param array $options
-     * @return array|boolean
+     * @return array|false
      */
     protected function _getInstallOptions(array $options)
     {
@@ -202,7 +202,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller
      * Add error
      *
      * @param string $error
-     * @return \Magento\Install\Model\Installer\Console
+     * @return $this
      */
     public function addError($error)
     {
@@ -246,7 +246,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller
      * Install Magento
      *
      * @param array $options
-     * @return string|boolean
+     * @return string|false
      */
     public function install(array $options)
     {
@@ -379,6 +379,8 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller
 
     /**
      * Cleanup database use system configuration
+     *
+     * @return void
      */
     protected function _cleanUpDatabase()
     {
diff --git a/app/code/Magento/Install/Model/Installer/Data.php b/app/code/Magento/Install/Model/Installer/Data.php
index 64a7fd0fc6c8201f7667f87d01c7a31f0b29d87f..442fb529c71f84ffe0b6b808b213b5fb90533274 100644
--- a/app/code/Magento/Install/Model/Installer/Data.php
+++ b/app/code/Magento/Install/Model/Installer/Data.php
@@ -44,7 +44,7 @@ class Data extends \Magento\Object
      * Add error
      *
      * @param string $error
-     * @return \Magento\Install\Model\Installer\Data
+     * @return $this
      */
     public function addError($error)
     {
diff --git a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php
index f6581c25612265ae34748e6a6c2a360fb7044fcb..54796b750be9f3243629758767eaaa28712766c0 100644
--- a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php
+++ b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php
@@ -117,6 +117,7 @@ abstract class AbstractDb
      * Set configuration data
      *
      * @param array $config the connection configuration
+     * @return void
      */
     public function setConfig($config)
     {
diff --git a/app/code/Magento/Install/Model/Installer/Db/Factory.php b/app/code/Magento/Install/Model/Installer/Db/Factory.php
index c7d84a335c50baa967ba526720a5579ae6c0a78e..0b3615830a4317db85ac3d06106f464d10ea40f7 100644
--- a/app/code/Magento/Install/Model/Installer/Db/Factory.php
+++ b/app/code/Magento/Install/Model/Installer/Db/Factory.php
@@ -31,6 +31,9 @@ namespace Magento\Install\Model\Installer\Db;
 
 class Factory
 {
+    /**
+     * @var array
+     */
     protected $_types = array(
         'mysql4' => 'Magento\Install\Model\Installer\Db\Mysql4'
     );
diff --git a/app/code/Magento/Install/Model/Installer/Filesystem.php b/app/code/Magento/Install/Model/Installer/Filesystem.php
index 15c629a5118fc9d635c2b769d5abeb53e1df221b..c0084001fa9c68b5998a6ff990bfc4b63f25d708 100644
--- a/app/code/Magento/Install/Model/Installer/Filesystem.php
+++ b/app/code/Magento/Install/Model/Installer/Filesystem.php
@@ -83,6 +83,8 @@ class Filesystem extends \Magento\Install\Model\Installer\AbstractInstaller
     /**
      * Check and prepare file system
      *
+     * @return $this
+     * @throws \Exception
      */
     public function install()
     {
diff --git a/app/code/Magento/Install/Model/Installer/Pear.php b/app/code/Magento/Install/Model/Installer/Pear.php
index 078429b3c21513d109d33cf1d84de5691bb0ed87..03c65c6db57507a619f6cfbb5800e07888486522 100644
--- a/app/code/Magento/Install/Model/Installer/Pear.php
+++ b/app/code/Magento/Install/Model/Installer/Pear.php
@@ -50,7 +50,7 @@ class Pear extends \Magento\Install\Model\Installer\AbstractInstaller
 
 
     /**
-     * @return array
+     * @return string[]
      */
     public function getPackages()
     {
diff --git a/app/code/Magento/Install/Model/Wizard.php b/app/code/Magento/Install/Model/Wizard.php
index 9d9289ce722912c2851cd7d5a6e1e9cd6d31f2cf..e06748041f7005da1a303be51f0ebfd7f74e7512 100644
--- a/app/code/Magento/Install/Model/Wizard.php
+++ b/app/code/Magento/Install/Model/Wizard.php
@@ -29,6 +29,8 @@
  */
 namespace Magento\Install\Model;
 
+use Magento\UrlInterface;
+
 class Wizard
 {
     /**
@@ -41,20 +43,25 @@ class Wizard
     /**
      * Url builder
      *
-     * @var \Magento\UrlInterface
+     * @var UrlInterface
      */
     protected $_urlBuilder;
 
     /**
      * Init install wizard
+     * @param UrlInterface $urlBuilder
+     * @param Config $installConfig
      */
-    public function __construct(\Magento\UrlInterface $urlBuilder, \Magento\Install\Model\Config $installConfig)
+    public function __construct(UrlInterface $urlBuilder, Config $installConfig)
     {
         $this->_steps = $installConfig->getWizardSteps();
         $this->_urlBuilder = $urlBuilder;
         $this->_initSteps();
     }
 
+    /**
+     * @return void
+     */
     protected function _initSteps()
     {
         foreach (array_keys($this->_steps) as $index) {
diff --git a/app/code/Magento/Integration/view/adminhtml/layout/adminhtml_integration_edit.xml b/app/code/Magento/Integration/view/adminhtml/layout/adminhtml_integration_edit.xml
index 0e38a9e138f4be9cb95c34b703a1c6502660a48c..1d872c21272d3278c871c3aa015d9f9daa2bcf62 100644
--- a/app/code/Magento/Integration/view/adminhtml/layout/adminhtml_integration_edit.xml
+++ b/app/code/Magento/Integration/view/adminhtml/layout/adminhtml_integration_edit.xml
@@ -1,6 +1,6 @@
-<?xml version="1.0"?>
-<!--
-/**
+<?xml version="1.0"?>
+<!--
+/**
  * Magento
  *
  * NOTICE OF LICENSE
@@ -17,26 +17,26 @@
  *
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="editor"/>
-    <referenceContainer name="left">
-        <block class="Magento\Integration\Block\Adminhtml\Integration\Edit\Tabs" name="integration_edit_tabs">
-            <block class="Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info" name="integration_edit_tab_info">
-                <block class="Magento\Integration\Block\Adminhtml\Integration\Tokens" name="integration_tokens"/>
-            </block>
-            <action method="addTab">
-                <argument name="name" xsi:type="string">info_section</argument>
-                <argument name="block" xsi:type="string">integration_edit_tab_info</argument>
-            </action>
-        </block>
-    </referenceContainer>
-    <referenceContainer name="content">
-        <block class="Magento\Integration\Block\Adminhtml\Integration\Edit" name="integration_edit_content"/>
-    </referenceContainer>
-</layout>
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <update handle="editor"/>
+    <referenceContainer name="left">
+        <block class="Magento\Integration\Block\Adminhtml\Integration\Edit\Tabs" name="integration_edit_tabs">
+            <block class="Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info" name="integration_edit_tab_info">
+                <block class="Magento\Integration\Block\Adminhtml\Integration\Tokens" name="integration_tokens"/>
+            </block>
+            <action method="addTab">
+                <argument name="name" xsi:type="string">info_section</argument>
+                <argument name="block" xsi:type="string">integration_edit_tab_info</argument>
+            </action>
+        </block>
+    </referenceContainer>
+    <referenceContainer name="content">
+        <block class="Magento\Integration\Block\Adminhtml\Integration\Edit" name="integration_edit_content"/>
+    </referenceContainer>
+</layout>
diff --git a/app/code/Magento/Log/Model/Aggregation.php b/app/code/Magento/Log/Model/Aggregation.php
index ba257b5f6faf062e23563ecb3063ead4a85f33bd..68f0bbfaf11078876e3ff991c3a336eb7cc3fcb3 100644
--- a/app/code/Magento/Log/Model/Aggregation.php
+++ b/app/code/Magento/Log/Model/Aggregation.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Log\Model;
 
 /**
  * Log Aggregation Model
@@ -34,8 +35,6 @@
  * @package    Magento_Log
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model;
-
 class Aggregation extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -72,6 +71,8 @@ class Aggregation extends \Magento\Core\Model\AbstractModel
 
     /**
      * Init model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -80,6 +81,7 @@ class Aggregation extends \Magento\Core\Model\AbstractModel
 
     /**
      * Run action
+     *
      * @return void
      */
     public function run()
@@ -94,7 +96,7 @@ class Aggregation extends \Magento\Core\Model\AbstractModel
      * Remove empty records before $lastDate
      *
      * @param  string $lastDate
-     * @return void
+     * @return null|void
      */
     private function _removeEmpty($lastDate)
     {
diff --git a/app/code/Magento/Log/Model/Cron.php b/app/code/Magento/Log/Model/Cron.php
index e2a34618db1addc65dd3a9c6414adcf91e9a1240..376a45bb2d5d40e4d87e7ac0ed4d5750f08f0c3d 100644
--- a/app/code/Magento/Log/Model/Cron.php
+++ b/app/code/Magento/Log/Model/Cron.php
@@ -110,7 +110,7 @@ class Cron extends \Magento\Core\Model\AbstractModel
     /**
      * Send Log Clean Warnings
      *
-     * @return \Magento\Log\Model\Cron
+     * @return $this
      */
     protected function _sendLogCleanEmail()
     {
@@ -146,7 +146,7 @@ class Cron extends \Magento\Core\Model\AbstractModel
     /**
      * Clean logs
      *
-     * @return \Magento\Log\Model\Cron
+     * @return $this
      */
     public function logClean()
     {
diff --git a/app/code/Magento/Log/Model/Customer.php b/app/code/Magento/Log/Model/Customer.php
index bd433594d6d939f52fe8af674cce551737f11632..61d0abcf90d55728fd006029339b5efad63925d9 100644
--- a/app/code/Magento/Log/Model/Customer.php
+++ b/app/code/Magento/Log/Model/Customer.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Log\Model;
 
 /**
  * Customer log model
@@ -44,8 +45,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model;
-
 class Customer extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -75,6 +74,8 @@ class Customer extends \Magento\Core\Model\AbstractModel
 
     /**
      * Define resource model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -86,7 +87,7 @@ class Customer extends \Magento\Core\Model\AbstractModel
      * Load last log by customer id
      *
      * @param \Magento\Customer\Model\Customer|int $customer
-     * @return \Magento\Log\Model\Customer
+     * @return $this
      */
     public function loadByCustomer($customer)
     {
diff --git a/app/code/Magento/Log/Model/Log.php b/app/code/Magento/Log/Model/Log.php
index b16efc3fa5c61661581153910e49124010d330f0..4727613c54faac98228ff37ea9217892c83dd274 100644
--- a/app/code/Magento/Log/Model/Log.php
+++ b/app/code/Magento/Log/Model/Log.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model;
 
 /**
  * Log Model
@@ -45,8 +45,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model;
-
 class Log extends \Magento\Core\Model\AbstractModel
 {
     const XML_LOG_CLEAN_DAYS    = 'system/log/clean_after_day';
@@ -81,6 +79,7 @@ class Log extends \Magento\Core\Model\AbstractModel
     /**
      * Init Resource Model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -89,6 +88,7 @@ class Log extends \Magento\Core\Model\AbstractModel
 
     /**
      * Return log clean time in seconds
+     *
      * @return null|string
      */
     public function getLogCleanTime()
@@ -99,7 +99,7 @@ class Log extends \Magento\Core\Model\AbstractModel
     /**
      * Clean Logs
      *
-     * @return \Magento\Log\Model\Log
+     * @return $this
      */
     public function clean()
     {
diff --git a/app/code/Magento/Log/Model/Resource/Aggregation.php b/app/code/Magento/Log/Model/Resource/Aggregation.php
index bf7a9748ae7f282221d063e931a8192452007f43..745d52f8c014e6b18a55838a51ed7b044ec86f26 100644
--- a/app/code/Magento/Log/Model/Resource/Aggregation.php
+++ b/app/code/Magento/Log/Model/Resource/Aggregation.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Resource;
 
 /**
  * Log aggregation resource model 
@@ -32,13 +32,12 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model\Resource;
-
 class Aggregation extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Resource initialization
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -107,6 +106,7 @@ class Aggregation extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param array $data
      * @param int $id
+     * @return void
      */
     public function saveLog($data, $id = null)
     {
diff --git a/app/code/Magento/Log/Model/Resource/Customer.php b/app/code/Magento/Log/Model/Resource/Customer.php
index 96eee2265c757558e71dd728a9ba5065a859f026..ce11e54fba014b230627ad71415832dadbad0906 100644
--- a/app/code/Magento/Log/Model/Resource/Customer.php
+++ b/app/code/Magento/Log/Model/Resource/Customer.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Resource;
 
 /**
  * Customer log resource
@@ -32,9 +32,6 @@
  * @package    Magento_Log
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Log\Model\Resource;
-
 class Customer extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -81,6 +78,8 @@ class Customer extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Log/Model/Resource/Log.php b/app/code/Magento/Log/Model/Resource/Log.php
index 2cbcd3542171d540c97275480e99a0be065684bf..b6fd9c6a8cfb43a24af22aafbc203ea50db8deff 100644
--- a/app/code/Magento/Log/Model/Resource/Log.php
+++ b/app/code/Magento/Log/Model/Resource/Log.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Resource;
 
 /**
  * Log Resource Model
@@ -32,8 +32,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model\Resource;
-
 class Log extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -74,6 +72,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Init Resource model and connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -84,7 +83,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Clean logs
      *
      * @param \Magento\Log\Model\Log $object
-     * @return \Magento\Log\Model\Resource\Log
+     * @return $this
      */
     public function clean(\Magento\Log\Model\Log $object)
     {
@@ -101,7 +100,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Clean visitors table
      *
      * @param int $time
-     * @return \Magento\Log\Model\Resource\Log
+     * @return $this
      */
     protected function _cleanVisitors($time)
     {
@@ -150,7 +149,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Clean customer table
      *
      * @param int $time
-     * @return \Magento\Log\Model\Resource\Log
+     * @return $this
      */
     protected function _cleanCustomers($time)
     {
@@ -247,7 +246,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Clean url table
      *
-     * @return \Magento\Log\Model\Resource\Log
+     * @return $this
      */
     protected function _cleanUrls()
     {
diff --git a/app/code/Magento/Log/Model/Resource/Visitor.php b/app/code/Magento/Log/Model/Resource/Visitor.php
index fda04a5d81882a3680721ce114dec825cfacbea2..0a3a6b27ed24bef977470d1381bf092d46fdac76 100644
--- a/app/code/Magento/Log/Model/Resource/Visitor.php
+++ b/app/code/Magento/Log/Model/Resource/Visitor.php
@@ -68,6 +68,8 @@ class Visitor extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Define main table
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -117,7 +119,7 @@ class Visitor extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save url info before save
      *
      * @param \Magento\Core\Model\AbstractModel $visitor
-     * @return \Magento\Log\Model\Resource\Visitor
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $visitor)
     {
@@ -131,7 +133,7 @@ class Visitor extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Actions after save
      *
      * @param \Magento\Core\Model\AbstractModel $visitor
-     * @return \Magento\Log\Model\Resource\Visitor
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $visitor)
     {
diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php
index 9453c6dbee4b34d131dd5c3a565f5d3e16b83a20..3a15ed7b999d4aeefea88b5dbf18a2ba0547ad7f 100644
--- a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php
+++ b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Resource\Visitor;
 
 /**
  * Visitor log collection
@@ -32,9 +32,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Log\Model\Resource\Visitor;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -115,6 +112,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Collection resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -133,7 +132,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Filter for customers only
      *
-     * @return \Magento\Log\Model\Resource\Visitor\Collection
+     * @return $this
      */
     public function showCustomersOnly()
     {
@@ -197,7 +196,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Return true if online filter used
      *
-     * @return boolean
+     * @return bool
      */
     public function getIsOnlineFilterUsed()
     {
diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online.php b/app/code/Magento/Log/Model/Resource/Visitor/Online.php
index cb8d8abe99d29d969f87dd27cb311d82e2e4dc3f..66c836c0ee95dde9e61421fc867df230edf29341 100644
--- a/app/code/Magento/Log/Model/Resource/Visitor/Online.php
+++ b/app/code/Magento/Log/Model/Resource/Visitor/Online.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Resource\Visitor;
 
 /**
  * Log Prepare Online visitors resource 
@@ -32,8 +32,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model\Resource\Visitor;
-
 class Online extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -54,6 +52,7 @@ class Online extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection and define resource
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -64,7 +63,8 @@ class Online extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Prepare online visitors for collection
      *
      * @param \Magento\Log\Model\Visitor\Online $object
-     * @return \Magento\Log\Model\Resource\Visitor\Online
+     * @return $this
+     * @throws \Exception
      */
     public function prepare(\Magento\Log\Model\Visitor\Online $object)
     {
diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php
index 82575aef75a9209ca7c6a631806c92a18e9d2404..0e4b50b3ae27af722a05109beeafdfcbc01f7e7e 100644
--- a/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php
+++ b/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Resource\Visitor\Online;
 
 /**
  * Log Online visitors collection
@@ -32,12 +32,10 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model\Resource\Visitor\Online;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
-     * joined fields array
+     * Joined fields array
      *
      * @var array
      */
@@ -73,6 +71,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Initialize collection model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -82,7 +81,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add Customer data to collection
      *
-     * @return \Magento\Log\Model\Resource\Visitor\Online\Collection
+     * @return $this
      */
     public function addCustomerData()
     {
@@ -154,11 +153,11 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *     array('attribute'=>'lastname', 'like'=>'test%'),
      * )
      *
-     * @see self::_getConditionSql for $condition
-     *
      * @param string $field
      * @param null|string|array $condition
      * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
+     *
+     * @see self::_getConditionSql for $condition
      */
     public function addFieldToFilter($field, $condition = null)
     {
diff --git a/app/code/Magento/Log/Model/Shell.php b/app/code/Magento/Log/Model/Shell.php
index 2fa004b9672d3d990b8fcf9b1bc355edc15e955d..e90e674e3dbb03dd96a966173bee87509e94f87b 100644
--- a/app/code/Magento/Log/Model/Shell.php
+++ b/app/code/Magento/Log/Model/Shell.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Log\Model;
 
 /**
  * Shell model, used to work with logs via command line
@@ -31,8 +32,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model;
-
 class Shell extends \Magento\Core\Model\AbstractShell
 {
     /**
@@ -43,7 +42,7 @@ class Shell extends \Magento\Core\Model\AbstractShell
     /**
      * @param \Magento\App\Filesystem $filesystem
      * @param string $entryPoint
-     * @param Shell\Command\Factory $commandFactory
+     * @param \Magento\Log\Model\Shell\Command\Factory $commandFactory
      */
     public function __construct(
         \Magento\App\Filesystem $filesystem,
@@ -57,7 +56,7 @@ class Shell extends \Magento\Core\Model\AbstractShell
     /**
      * Runs script
      *
-     * @return \Magento\Log\Model\Shell
+     * @return $this
      */
     public function run()
     {
diff --git a/app/code/Magento/Log/Model/Visitor.php b/app/code/Magento/Log/Model/Visitor.php
index f0f182386896273741b58e223df5a2eb00358ed9..35a192d1cd97e38fae186ed8883db2cb18f64a08 100644
--- a/app/code/Magento/Log/Model/Visitor.php
+++ b/app/code/Magento/Log/Model/Visitor.php
@@ -169,6 +169,8 @@ class Visitor extends \Magento\Core\Model\AbstractModel
 
     /**
      * Object initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -194,7 +196,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize visitor information from server data
      *
-     * @return \Magento\Log\Model\Visitor
+     * @return $this
      */
     public function initServerData()
     {
diff --git a/app/code/Magento/Log/Model/Visitor/Online.php b/app/code/Magento/Log/Model/Visitor/Online.php
index bcbd41ab3f41a3f9f2cd7914b42b0b6b89cb7cfc..38c8f12e7de9d51dd20a12c04504612208842bc5 100644
--- a/app/code/Magento/Log/Model/Visitor/Online.php
+++ b/app/code/Magento/Log/Model/Visitor/Online.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Log\Model\Visitor;
 
 /**
  * Prepare Log Online Visitors Model
@@ -46,8 +46,6 @@
  * @package     Magento_Log
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Log\Model\Visitor;
-
 class Online extends \Magento\Core\Model\AbstractModel
 {
     const XML_PATH_ONLINE_INTERVAL      = 'customer/online_customers/online_minutes_interval';
@@ -83,6 +81,7 @@ class Online extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -102,7 +101,7 @@ class Online extends \Magento\Core\Model\AbstractModel
     /**
      * Prepare Online visitors collection
      *
-     * @return \Magento\Log\Model\Visitor\Online
+     * @return $this
      */
     public function prepare()
     {
@@ -124,7 +123,7 @@ class Online extends \Magento\Core\Model\AbstractModel
      * Set Prepare at timestamp (if time is null, set current timestamp)
      *
      * @param int $time
-     * @return \Magento\Log\Model\Resource\Visitor\Online
+     * @return $this
      */
     public function setPrepareAt($time = null)
     {
diff --git a/app/code/Magento/Log/etc/crontab.xml b/app/code/Magento/Log/etc/crontab.xml
index 9b363ca7766e3fa333da035de853e08626a77bee..a5326641e094abdc9880fd61d149cad21aaa610a 100644
--- a/app/code/Magento/Log/etc/crontab.xml
+++ b/app/code/Magento/Log/etc/crontab.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="log_clean" instance="Magento\Log\Model\Cron" method="logClean" />
+    <group id="default">
+        <job name="log_clean" instance="Magento\Log\Model\Cron" method="logClean" />
+    </group>
 </config>
diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address.php b/app/code/Magento/Multishipping/Controller/Checkout/Address.php
index 5e88dadc4b0d771dfb2d94100dae60e7e82deb60..08bfabfc5e57c938ea12e93d676d091b1a3ce9b3 100644
--- a/app/code/Magento/Multishipping/Controller/Checkout/Address.php
+++ b/app/code/Magento/Multishipping/Controller/Checkout/Address.php
@@ -180,7 +180,7 @@ class Address extends \Magento\App\Action\Action
             $addressForm->setTitle(__('Edit Billing Address'))
                 ->setSuccessUrl($this->_url->getUrl('*/*/saveBilling', array('id'=>$this->getRequest()->getParam('id'))))
                 ->setErrorUrl($this->_url->getUrl('*/*/*', array('id'=>$this->getRequest()->getParam('id'))))
-                ->setBackUrl($this->_url->getUrl('*/multishipping/overview'));
+                ->setBackUrl($this->_url->getUrl('*/checkout/overview'));
             if ($headBlock = $this->_view->getLayout()->getBlock('head')) {
                 $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle());
             }
@@ -194,7 +194,7 @@ class Address extends \Magento\App\Action\Action
             $this->_objectManager->create('Magento\Multishipping\Model\Checkout\Type\Multishipping')
                 ->setQuoteCustomerBillingAddress($addressId);
         }
-        $this->_redirect('*/multishipping/billing');
+        $this->_redirect('*/checkout/billing');
     }
 
     public function saveBillingAction()
@@ -203,6 +203,6 @@ class Address extends \Magento\App\Action\Action
             $this->_objectManager->create('Magento\Multishipping\Model\Checkout\Type\Multishipping')
                 ->setQuoteCustomerBillingAddress($addressId);
         }
-        $this->_redirect('*/multishipping/overview');
+        $this->_redirect('*/checkout/overview');
     }
 }
diff --git a/app/code/Magento/Multishipping/etc/frontend/di.xml b/app/code/Magento/Multishipping/etc/frontend/di.xml
index ea42a2ca7b490064134c60f49d541675f87189f0..559def86f8b6f65d53da0ade71fe92bfb47aab95 100644
--- a/app/code/Magento/Multishipping/etc/frontend/di.xml
+++ b/app/code/Magento/Multishipping/etc/frontend/di.xml
@@ -48,7 +48,7 @@
                     <value>Magento\Multishipping\Model\Payment\Method\Specification\Enabled</value>
                 </item>
                 <item key="3dsecure">
-                    <value>\Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure</value>
+                    <value>Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure</value>
                 </item>
             </array>
         </param>
diff --git a/app/code/Magento/Multishipping/view/frontend/checkout/item/default.phtml b/app/code/Magento/Multishipping/view/frontend/checkout/item/default.phtml
index 7708607582b106ae5882837803e3c72890f0abeb..6598bbc8a354475b702f1a940b205ddb00f8aa34 100644
--- a/app/code/Magento/Multishipping/view/frontend/checkout/item/default.phtml
+++ b/app/code/Magento/Multishipping/view/frontend/checkout/item/default.phtml
@@ -30,7 +30,7 @@
             <?php foreach ($_options as $_option) : ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
                 <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                         <dl class="item options">
                             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
diff --git a/app/code/Magento/Multishipping/view/frontend/multishipping/item/default.phtml b/app/code/Magento/Multishipping/view/frontend/multishipping/item/default.phtml
index 7708607582b106ae5882837803e3c72890f0abeb..6598bbc8a354475b702f1a940b205ddb00f8aa34 100644
--- a/app/code/Magento/Multishipping/view/frontend/multishipping/item/default.phtml
+++ b/app/code/Magento/Multishipping/view/frontend/multishipping/item/default.phtml
@@ -30,7 +30,7 @@
             <?php foreach ($_options as $_option) : ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
                 <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                         <dl class="item options">
                             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php b/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php
index 44979e66fe841c19c90679747daa02183c7e4481..20fef787912d2aa613ac5545196af2268243a734 100644
--- a/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php
+++ b/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Block\Adminhtml;
+
+use Magento\Newsletter\Model\Resource\Problem\Collection;
 
 /**
  * Newsletter problem block template.
@@ -31,10 +34,6 @@
  * @package    Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Block\Adminhtml;
-
-use Magento\Newsletter\Model\Resource\Problem\Collection;
-
 class Problem extends \Magento\Backend\Block\Template
 {
 
@@ -62,6 +61,9 @@ class Problem extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php
index a60fe76a1558247d49ddd717556cb58ab936a0b2..9862e6010fcfe61c545a2b4ff062e83b33bd4b39 100644
--- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php
+++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php
@@ -23,15 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-/**
- * Newsletter queue edit block
- */
 namespace Magento\Newsletter\Block\Adminhtml\Queue;
 
 use Magento\View\Element\AbstractBlock;
 use Magento\Newsletter\Model\Queue as ModelQueue;
 
+/**
+ * Newsletter queue edit block
+ */
 class Edit extends \Magento\Backend\Block\Template
 {
     /**
@@ -68,6 +67,9 @@ class Edit extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php
index a1ef161a4b851c97ef0bdc72aa818f810fc834a4..9fc76b5c5d4384aaa1c9120293b11dfd87714b93 100644
--- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php
+++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Block\Adminhtml\Queue\Edit;
 
 /**
  * Newsletter queue edit form
@@ -31,9 +32,6 @@
  * @package    Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Newsletter\Block\Adminhtml\Queue\Edit;
-
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
     /**
@@ -80,8 +78,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * Form can be run from newsletter template grid by option "Queue newsletter"
      * or from  newsletter queue grid by edit option.
      *
-     * @param void
-     * @return \Magento\Newsletter\Block\Adminhtml\Queue\Edit\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php
index cf2b9369664e8c23fc79c5047da48229744ec34e..9b7b2f862d7dbad08023545d156d6ac78c8eb518 100644
--- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php
+++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php
@@ -84,7 +84,7 @@ class Edit extends \Magento\Backend\Block\Widget
     /**
      * Preparing block layout
      *
-     * @return \Magento\Newsletter\Block\Adminhtml\Template\Edit
+     * @return $this
      */
     protected function _prepareLayout()
     {
@@ -232,7 +232,7 @@ class Edit extends \Magento\Backend\Block\Widget
      * Set edit flag for block
      *
      * @param boolean $value
-     * @return \Magento\Newsletter\Block\Adminhtml\Template\Edit
+     * @return $this
      */
     public function setEditMode($value = true)
     {
diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit/Form.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit/Form.php
index 8eed1a6b7b5e9c0046add038e52b2f3ba84e63f5..1eb60eb5e4a5d82c5c0b7e6ac1ee1ddf244ec6f8 100644
--- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit/Form.php
+++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit/Form.php
@@ -72,7 +72,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Prepare form before rendering HTML
      *
-     * @return \Magento\Newsletter\Block\Adminhtml\Template\Edit\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/GroupOptionHash.php b/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/GroupOptionHash.php
index b7fe4e510de56237efcf4523e8aa2c566f708a5f..71db70818e461e09f1c91807aadcf92fa4c15c89 100644
--- a/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/GroupOptionHash.php
+++ b/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/GroupOptionHash.php
@@ -25,19 +25,21 @@
  */
 namespace Magento\Newsletter\Block\Subscribe\Grid\Options;
 
+use Magento\Core\Model\System\Store;
+
 class GroupOptionHash implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
      * System Store Model
      *
-     * @var \Magento\Core\Model\System\Store
+     * @var Store
      */
     protected $_systemStore;
 
     /**
-     * @param \Magento\Core\Model\System\Store
+     * @param Store $systemStore
      */
-    public function __construct(\Magento\Core\Model\System\Store $systemStore)
+    public function __construct(Store $systemStore)
     {
         $this->_systemStore = $systemStore;
     }
diff --git a/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/StoreOptionHash.php b/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/StoreOptionHash.php
index f4903ebc65f2b21da2158f355187fe5afcedadfd..b48e45a4b149fc5b2219b2d09e63c47717e61bfd 100644
--- a/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/StoreOptionHash.php
+++ b/app/code/Magento/Newsletter/Block/Subscribe/Grid/Options/StoreOptionHash.php
@@ -25,19 +25,21 @@
  */
 namespace Magento\Newsletter\Block\Subscribe\Grid\Options;
 
+use Magento\Core\Model\System\Store;
+
 class StoreOptionHash implements \Magento\Core\Model\Option\ArrayInterface
 {
     /**
      * System Store Model
      *
-     * @var \Magento\Core\Model\System\Store
+     * @var Store
      */
     protected $_systemStore;
 
     /**
-     * @param \Magento\Core\Model\System\Store
+     * @param Store $systemStore
      */
-    public function __construct(\Magento\Core\Model\System\Store $systemStore)
+    public function __construct(Store $systemStore)
     {
         $this->_systemStore = $systemStore;
     }
diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php
index 339b2f5110aaaa6225e2a786b67110001b031b66..4bb0ad505e229b204a31b4057e1784f56cc32de1 100644
--- a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php
+++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Newsletter\Controller\Adminhtml;
 
+use Magento\App\ResponseInterface;
+
 /**
  * Newsletter subscribers controller
  */
@@ -86,7 +87,7 @@ class Subscriber extends \Magento\Backend\App\Action
     /**
      * Export subscribers grid to CSV format
      *
-     * @return void
+     * @return ResponseInterface
      */
     public function exportCsvAction()
     {
@@ -104,7 +105,7 @@ class Subscriber extends \Magento\Backend\App\Action
     /**
      * Export subscribers grid to XML format
      *
-     * @return void
+     * @return ResponseInterface
      */
     public function exportXmlAction()
     {
diff --git a/app/code/Magento/Newsletter/Controller/Manage.php b/app/code/Magento/Newsletter/Controller/Manage.php
index dac326c3f391183bfdbf251eb69e94a1fe309c04..c2fc92e977ea2eded134dfa868f66d5be0340c04 100644
--- a/app/code/Magento/Newsletter/Controller/Manage.php
+++ b/app/code/Magento/Newsletter/Controller/Manage.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Newsletter\Controller;
 
 use Magento\App\Action\NotFoundException;
@@ -103,7 +102,7 @@ class Manage extends \Magento\App\Action\Action
     /**
      * Save newsletter subscription preference action
      *
-     * @return void
+     * @return void|null
      */
     public function saveAction()
     {
diff --git a/app/code/Magento/Newsletter/Model/Problem.php b/app/code/Magento/Newsletter/Model/Problem.php
index ae679d7bdb277dce668908a47d6302df4b50f28d..a16c5a65ab3531d1f4a1964491d222cc9f951665 100644
--- a/app/code/Magento/Newsletter/Model/Problem.php
+++ b/app/code/Magento/Newsletter/Model/Problem.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Model;
 
 /**
  * Newsletter problem model
@@ -42,8 +43,6 @@
  * @package     Magento_Newsletter
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model;
-
 class Problem extends \Magento\Core\Model\AbstractModel
 {
     /**
@@ -84,6 +83,8 @@ class Problem extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initialize Newsletter Problem Model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -94,7 +95,7 @@ class Problem extends \Magento\Core\Model\AbstractModel
      * Add Subscriber Data
      *
      * @param \Magento\Newsletter\Model\Subscriber $subscriber
-     * @return \Magento\Newsletter\Model\Problem
+     * @return $this
      */
     public function addSubscriberData(\Magento\Newsletter\Model\Subscriber $subscriber)
     {
@@ -106,7 +107,7 @@ class Problem extends \Magento\Core\Model\AbstractModel
      * Add Queue Data
      *
      * @param \Magento\Newsletter\Model\Queue $queue
-     * @return \Magento\Newsletter\Model\Problem
+     * @return $this
      */
     public function addQueueData(\Magento\Newsletter\Model\Queue $queue)
     {
@@ -118,7 +119,7 @@ class Problem extends \Magento\Core\Model\AbstractModel
      * Add Error Data
      *
      * @param \Exception $e
-     * @return \Magento\Newsletter\Model\Problem
+     * @return $this
      */
     public function addErrorData(\Exception $e)
     {
@@ -149,7 +150,7 @@ class Problem extends \Magento\Core\Model\AbstractModel
     /**
      * Unsubscribe Subscriber
      *
-     * @return \Magento\Newsletter\Model\Problem
+     * @return $this
      */
     public function unsubscribe()
     {
diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php
index 49e1f4251d1dfc37d37836d41b684e382f2e4611..65c4851d1bab5ade626e1194e44582c87e05531d 100644
--- a/app/code/Magento/Newsletter/Model/Queue.php
+++ b/app/code/Magento/Newsletter/Model/Queue.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Model;
 
 /**
  * Newsletter queue model.
@@ -51,8 +52,6 @@
  * @method \Magento\Newsletter\Model\Queue setQueueFinishAt(string $value)
  * @SuppressWarnings(PHPMD.LongVariable)
  */
-namespace Magento\Newsletter\Model;
-
 class Queue extends \Magento\Core\Model\Template
 {
     /**
@@ -178,6 +177,8 @@ class Queue extends \Magento\Core\Model\Template
 
     /**
      * Initialize resource model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -353,7 +354,6 @@ class Queue extends \Magento\Core\Model\Template
     /**
      * Getter for save stores flag.
      *
-     * @param void
      * @return boolean
      */
     public function getSaveStoresFlag()
diff --git a/app/code/Magento/Newsletter/Model/Resource/Problem.php b/app/code/Magento/Newsletter/Model/Resource/Problem.php
index 6716399382caa804e5990123fe9eea29d49b1cd7..b52a02d6a442bc99c979382cdf71ce84f2f2543a 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Problem.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Problem.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Newsletter\Model\Resource;
 
 /**
  * Newsletter problem resource model
@@ -32,13 +32,12 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource;
-
 class Problem extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Define main table
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php
index f435457ca12546fec83e440beb2b5685c97a35c5..a82f74980b4dd2007cb984b1f9034d7d9d5ada38 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php
@@ -79,6 +79,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Define resource model and model
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue.php b/app/code/Magento/Newsletter/Model/Resource/Queue.php
index 2864392ba96e81383ca3093109af0e1df5b9154b..c015813b1cd09e1e6a3a0b4aa4f002391b4cabbc 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Queue.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Queue.php
@@ -23,7 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Model\Resource;
 
+use Magento\Newsletter\Model\Queue as ModelQueue;
+use Magento\Core\Model\AbstractModel;
 
 /**
  * Newsletter queue resource model
@@ -32,11 +35,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource;
-
-use Magento\Newsletter\Model\Queue as ModelQueue;
-use Magento\Core\Model\AbstractModel;
-
 class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -63,6 +61,7 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -74,6 +73,7 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param ModelQueue $queue
      * @param array $subscriberIds
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function addSubscribersToQueue(ModelQueue $queue, array $subscriberIds)
diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php
index b1f728ab26421e639896e079eecf752a7ee6e246..56917891583b5e861e9911a0eb2c254fc6d0c666 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Newsletter\Model\Resource\Queue;
 
 /**
  * Newsletter queue collection.
@@ -32,8 +32,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource\Queue;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -82,6 +80,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Initializes collection
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue/Grid/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Queue/Grid/Collection.php
index 61304dc0507daac30e33233447b7a7d033c914ef..d75398b51b7c816804f34d57e54f2dd6f4f2db87 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Queue/Grid/Collection.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Queue/Grid/Collection.php
@@ -38,7 +38,7 @@ class Collection
     extends \Magento\Newsletter\Model\Resource\Queue\Collection
 {
     /**
-     * @return \Magento\Newsletter\Model\Resource\Queue\Grid\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php
index a3785ec09894cd49e57eca5be6113ac5f0c553e4..82daf384d7f5c8c1fed1f733774fdfe6cb015320 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Newsletter\Model\Resource;
 
 /**
  * Newsletter subscriber resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource;
-
 class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -97,6 +95,7 @@ class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Initialize resource model
      * Get tablename from config
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php
index 60f0f8cd43230e2caff5aeb2a542abbbfba1317f..112c002e2e2328d9e17066550211783c76d5e0bb 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php
@@ -23,7 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Model\Resource\Subscriber;
 
+use Magento\Newsletter\Model\Queue as ModelQueue;
 
 /**
  * Newsletter subscribers collection
@@ -32,10 +34,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource\Subscriber;
-
-use Magento\Newsletter\Model\Queue as ModelQueue;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
 
@@ -108,6 +106,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Constructor
      * Configures collection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -133,7 +132,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * @param ModelQueue $queue
      * @return $this
      */
-    public function useQueue(\Magento\Newsletter\Model\Queue $queue)
+    public function useQueue(ModelQueue $queue)
     {
         $this->getSelect()
             ->join(array('link'=>$this->_queueLinkTable), "link.subscriber_id = main_table.subscriber_id", array())
diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Grid/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Grid/Collection.php
index c66c90402372d0a8ea5c6acf5e67a39cc9177675..e353de82da284712645c75270271145cb758fc90 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Grid/Collection.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Grid/Collection.php
@@ -31,7 +31,7 @@ class Collection
     /**
      * Sets flag for customer info loading on load
      *
-     * @return \Magento\Newsletter\Model\Resource\Subscriber\Grid\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/Newsletter/Model/Resource/Template.php b/app/code/Magento/Newsletter/Model/Resource/Template.php
index 1e25f1e4dc843c6362f30af6610fd1cae26e157e..472589fc8659305c65ef611c09288b35b317b0b6 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Template.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Template.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Newsletter\Model\Resource;
 
 /**
  * Newsletter template resource model
@@ -32,8 +32,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource;
-
 class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
@@ -56,6 +54,7 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -67,7 +66,7 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Newsletter\Model\Template $object
      * @param string $templateCode
-     * @return \Magento\Newsletter\Model\Resource\Template
+     * @return $this
      */
     public function loadByCode(\Magento\Newsletter\Model\Template $object, $templateCode)
     {
@@ -142,7 +141,7 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Perform actions before object save
      *
      * @param \Magento\Core\Model\AbstractModel $object
-     * @return \Magento\Newsletter\Model\Resource\Template
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
diff --git a/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php
index c4c5a5b57beab6cd5a5563a3b1f02b1abdc59435..54415b79ced59a43439ca89297fb602f9400cbc0 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Template/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Newsletter\Model\Resource\Template;
 
 /**
  * Newsletter templates collection
@@ -32,13 +32,12 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model\Resource\Template;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Define resource model and model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -48,7 +47,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Load only actual template
      *
-     * @return \Magento\Newsletter\Model\Resource\Template\Collection
+     * @return $this
      */
     public function useOnlyActual()
     {
diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php
index 904d27946bb3cf9a5bde341734f3be254f9bf918..083eb89e181674e48c91040ab26f62205350db54 100644
--- a/app/code/Magento/Newsletter/Model/Subscriber.php
+++ b/app/code/Magento/Newsletter/Model/Subscriber.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Model;
 
 /**
  * Subscriber model
@@ -46,8 +47,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model;
-
 class Subscriber extends \Magento\Core\Model\AbstractModel
 {
     const STATUS_SUBSCRIBED     = 1;
@@ -178,6 +177,8 @@ class Subscriber extends \Magento\Core\Model\AbstractModel
 
     /**
      * Initialize resource model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -271,7 +272,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel
      * Set the error messages scope for subscription
      *
      * @param boolean $scope
-     * @return Subscriber
+     * @return $this
      */
 
     public function setMessagesScope($scope)
@@ -475,6 +476,24 @@ class Subscriber extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * Update newsletter subscription for given customer
+     *
+     * @param int $customerId
+     * @param boolean $subscribe
+     *
+     * @return  \Magento\Newsletter\Model\Subscriber
+     */
+    public function updateSubscription($customerId, $subscribe)
+    {
+        /** @var \Magento\Customer\Model\Customer $customerModel */
+        $customerModel = $this->_customerFactory->create()->load($customerId);
+        $customerModel->setIsSubscribed($subscribe);
+        $this->subscribeCustomer($customerModel);
+
+        return $this;
+    }
+
     /**
      * Saving customer subscription status
      *
diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php
index 044fcfcdeeb69036c4c41275e70b54a9b2521392..2b710a5c01ed2f81ade35ae77f51158d49ff591e 100644
--- a/app/code/Magento/Newsletter/Model/Template.php
+++ b/app/code/Magento/Newsletter/Model/Template.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Newsletter\Model;
 
 /**
  * Template model
@@ -54,8 +55,6 @@
  * @package     Magento_Newsletter
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Newsletter\Model;
-
 class Template extends \Magento\Core\Model\Template
 {
 
@@ -151,6 +150,7 @@ class Template extends \Magento\Core\Model\Template
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -160,7 +160,7 @@ class Template extends \Magento\Core\Model\Template
     /**
      * Validate Newsletter template
      *
-     * @return bool
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function validate()
@@ -196,7 +196,7 @@ class Template extends \Magento\Core\Model\Template
     /**
      * Processing object before save data
      *
-     * @return \Magento\Newsletter\Model\Template
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -208,7 +208,7 @@ class Template extends \Magento\Core\Model\Template
      * Load template by code
      *
      * @param string $templateCode
-     * @return \Magento\Newsletter\Model\Template
+     * @return $this
      */
     public function loadByCode($templateCode)
     {
diff --git a/app/code/Magento/Newsletter/etc/crontab.xml b/app/code/Magento/Newsletter/etc/crontab.xml
index 5efe49164e2d0afb69a8ace1b7c3fa8bbc2c2d21..9f0f64538aa7556ef7cbc95ff9abfa46d3756d89 100644
--- a/app/code/Magento/Newsletter/etc/crontab.xml
+++ b/app/code/Magento/Newsletter/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="newsletter_send_all" instance="Magento\Newsletter\Model\Observer" method="scheduledSend">
-        <schedule>*/5 * * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="newsletter_send_all" instance="Magento\Newsletter\Model\Observer" method="scheduledSend">
+            <schedule>*/5 * * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml
index e868be41992643a7b507b344357bb5587b149205..0c908f2d70f9962f5afe99a704cf18b215ef72e1 100644
--- a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml
+++ b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml
@@ -126,21 +126,23 @@
                         <argument name="header" xsi:type="string" translate="true">Status</argument>
                         <argument name="index" xsi:type="string">subscriber_status</argument>
                         <argument name="type" xsi:type="string">options</argument>
-                        <argument name="status_not_active" xsi:type="array">
-                            <item name="value" xsi:type="string">2</item>
-                            <item name="label" xsi:type="string" translate="true">Not Activated</item>
-                        </argument>
-                        <argument name="status_subscribed" xsi:type="array">
-                            <item name="value" xsi:type="string">1</item>
-                            <item name="label" xsi:type="string" translate="true">Subscribed</item>
-                        </argument>
-                        <argument name="status_unsubscribed" xsi:type="array">
-                            <item name="value" xsi:type="string">3</item>
-                            <item name="label" xsi:type="string" translate="true">Unsubscribed</item>
-                        </argument>
-                        <argument name="status_unconfirmed" xsi:type="array">
-                            <item name="value" xsi:type="string">4</item>
-                            <item name="label" xsi:type="string" translate="true">Unconfirmed</item>
+                        <argument name="options" xsi:type="array">
+                            <item name="status_not_active" xsi:type="array">
+                                <item name="value" xsi:type="string">2</item>
+                                <item name="label" xsi:type="string" translate="true">Not Activated</item>
+                            </item>
+                            <item name="status_subscribed" xsi:type="array">
+                                <item name="value" xsi:type="string">1</item>
+                                <item name="label" xsi:type="string" translate="true">Subscribed</item>
+                            </item>
+                            <item name="status_unsubscribed" xsi:type="array">
+                                <item name="value" xsi:type="string">3</item>
+                                <item name="label" xsi:type="string" translate="true">Unsubscribed</item>
+                            </item>
+                            <item name="status_unconfirmed" xsi:type="array">
+                                <item name="value" xsi:type="string">4</item>
+                                <item name="label" xsi:type="string" translate="true">Unconfirmed</item>
+                            </item>
                         </argument>
                         <argument name="header_css_class" xsi:type="string">col-status</argument>
                         <argument name="column_css_class" xsi:type="string">col-status</argument>
diff --git a/app/code/Magento/Ogone/view/frontend/layout/ogone_api_paypage.xml b/app/code/Magento/Ogone/view/frontend/layout/ogone_api_paypage.xml
index f39f141de04b8316be9b48f41a115feff09dea1f..2d355541c9091861c2261e4abf5a977743774e32 100644
--- a/app/code/Magento/Ogone/view/frontend/layout/ogone_api_paypage.xml
+++ b/app/code/Magento/Ogone/view/frontend/layout/ogone_api_paypage.xml
@@ -25,12 +25,12 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <remove name="catalog.topnav"/>
-    <referenceBlock name="header-wrapper">
+    <referenceContainer name="header-wrapper">
         <remove name="top.links"/>
         <remove name="top.search"/>
         <remove name="store_language"/>
         <remove name="top.container"/>
-    </referenceBlock>
+    </referenceContainer>
     <referenceBlock name="footer">
         <remove name="cms_footer_links"/>
         <remove name="footer_links"/>
diff --git a/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php b/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php
new file mode 100644
index 0000000000000000000000000000000000000000..b0afe9afc9735223c28cbf84917b333bbf3eb990
--- /dev/null
+++ b/app/code/Magento/PageCache/Block/System/Config/Form/Field/Export.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\PageCache\Block\System\Config\Form\Field;
+
+/**
+ * Class Export
+ */
+class Export extends \Magento\Backend\Block\System\Config\Form\Field
+{
+    /**
+     * @var \Magento\App\ConfigInterface
+     */
+    protected $config;
+
+    public function __construct(
+        \Magento\Backend\Block\Template\Context $context,
+        \Magento\App\ConfigInterface $config,
+        array $data = array()
+    ){
+        $this->config = $config;
+        parent::__construct($context, $data);
+    }
+
+    /**
+     * Retrieve element HTML markup
+     *
+     * @param \Magento\Data\Form\Element\AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+    {
+        /** @var \Magento\Backend\Block\Widget\Button $buttonBlock  */
+        $buttonBlock = $this->getForm()
+            ->getLayout()
+            ->createBlock('Magento\Backend\Block\Widget\Button');
+
+        $params = array(
+            'website' => $buttonBlock->getRequest()->getParam('website')
+        );
+
+        $url = $this->getUrl("*/PageCache/exportVarnishConfig", $params);
+        $data = array(
+            'id'        => 'system_full_page_cache_varnish_export_button',
+            'label'     => __('Export VCL'),
+            'onclick'   => "setLocation('" . $url . "')"
+        );
+
+        $html = $buttonBlock->setData($data)->toHtml();
+        return $html;
+    }
+
+    /**
+     * Return PageCache TTL value from config
+     * to avoid saving empty field
+     *
+     * @return string
+     */
+    public function getTtlValue()
+    {
+        return $this->config->getValue(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL);
+    }
+}
\ No newline at end of file
diff --git a/app/code/Magento/PageCache/Controller/Adminhtml/PageCache.php b/app/code/Magento/PageCache/Controller/Adminhtml/PageCache.php
new file mode 100644
index 0000000000000000000000000000000000000000..1de92ad996d55be929cf4a1e8f0c866c3ca26a8d
--- /dev/null
+++ b/app/code/Magento/PageCache/Controller/Adminhtml/PageCache.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\PageCache\Controller\Adminhtml;
+
+/**
+ * Page cache admin controller
+ */
+class PageCache extends \Magento\Backend\App\Action
+{
+    /**
+     * @var \Magento\Backend\App\Response\Http\FileFactory
+     */
+    protected $fileFactory;
+
+    /**
+     * @var \Magento\PageCache\Model\Config
+     */
+    protected $config;
+
+    /**
+     * @param \Magento\Backend\App\Action\Context $context
+     * @param \Magento\App\Response\Http\FileFactory $fileFactory
+     * @param \Magento\PageCache\Model\Config $config
+     */
+    public function __construct(
+        \Magento\Backend\App\Action\Context $context,
+        \Magento\App\Response\Http\FileFactory $fileFactory,
+        \Magento\PageCache\Model\Config $config
+    ) {
+        parent::__construct($context);
+        $this->config = $config;
+        $this->fileFactory = $fileFactory;
+    }
+
+    /**
+     * Export Varnish Configuration as .vcl
+     *
+     * @return \Magento\App\ResponseInterface
+     */
+    public function exportVarnishConfigAction()
+    {
+        $fileName = 'varnish.vcl';
+        $content = $this->config->getVclFile();
+        return $this->fileFactory->create($fileName, $content, \Magento\App\Filesystem::VAR_DIR);
+    }
+}
diff --git a/app/code/Magento/PageCache/Controller/Block.php b/app/code/Magento/PageCache/Controller/Block.php
index 93acf9c4d12aae5e5bf5d9913630e3af6332fcc9..0e06632dedb1911beb0dc6f2a6cde198b2bdb870 100644
--- a/app/code/Magento/PageCache/Controller/Block.php
+++ b/app/code/Magento/PageCache/Controller/Block.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\PageCache\Controller;
 
 use Magento\PageCache\Helper\Data;
@@ -32,6 +31,8 @@ class Block extends \Magento\App\Action\Action
 {
     /**
      * Returns block content depends on ajax request
+     *
+     * @return void
      */
     public function renderAction()
     {
diff --git a/app/code/Magento/PageCache/Helper/Data.php b/app/code/Magento/PageCache/Helper/Data.php
index 068007b5fcef43af2e0984aa37c9c39ac8cb5a62..77d610b6f3b3d492c315d0e6801c56c82417a6fa 100644
--- a/app/code/Magento/PageCache/Helper/Data.php
+++ b/app/code/Magento/PageCache/Helper/Data.php
@@ -43,32 +43,4 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * Private caching time one year
      */
     const PRIVATE_MAX_AGE_CACHE = 31536000;
-
-    /**
-     * XML path to value for public max-age parameter
-     */
-    const PUBLIC_MAX_AGE_PATH = 'system/headers/public-max-age';
-
-    /**
-     * @var \Magento\App\ConfigInterface
-     */
-    protected $config;
-
-    /**
-     * @param \Magento\App\Helper\Context $context
-     * @param \Magento\App\ConfigInterface $config
-     */
-    public function __construct(\Magento\App\Helper\Context $context, \Magento\App\ConfigInterface $config)
-    {
-        parent::__construct($context);
-        $this->config = $config;
-    }
-
-    /**
-     * @return mixed
-     */
-    public function getPublicMaxAgeCache()
-    {
-        return $this->config->getValue(self::PUBLIC_MAX_AGE_PATH);
-    }
 }
diff --git a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php
index 6995bbec41c058b04e474a9a1981743391abc6c1..99dc23b1fba756ad0b3b568342ce7f7bc997ed1e 100644
--- a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php
+++ b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php
@@ -39,33 +39,25 @@ class HeaderPlugin
      * @var \Magento\App\ConfigInterface
      */
     protected $config;
-    
-    /**
-     * @var \Magento\PageCache\Model\Version
-     */
-    private $version;
 
     /**
-     * @var \Magento\PageCache\Helper\Data
+     * @var \Magento\PageCache\Model\Version
      */
-    private $helper;
+    protected $version;
 
     /**
      * Constructor
      *
      * @param \Magento\Core\Model\Layout $layout
      * @param \Magento\App\ConfigInterface $config
-     * @param \Magento\PageCache\Helper\Data
      * @param \Magento\PageCache\Model\Version $version
      */
     public function __construct(
         \Magento\Core\Model\Layout $layout,
         \Magento\App\ConfigInterface $config,
-        \Magento\PageCache\Helper\Data $helper,
         \Magento\PageCache\Model\Version $version
-    ){
+    ) {
         $this->layout = $layout;
-        $this->helper = $helper;
         $this->config = $config;
         $this->version = $version;
     }
@@ -96,14 +88,10 @@ class HeaderPlugin
      */
     protected function setPublicHeaders(\Magento\App\Response\Http $response)
     {
-        $maxAge = $this->helper->getPublicMaxAgeCache();
+        $maxAge = $this->config->getValue(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL);
         $response->setHeader('pragma', 'cache', true);
-        $response->setHeader('cache-control', 'public, max-age=' . $maxAge, true);
-        $response->setHeader(
-            'expires',
-            gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')),
-            true
-        );
+        $response->setHeader('cache-control', 'public, max-age=' . $maxAge . ', s-maxage=' . $maxAge, true);
+        $response->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), true);
     }
 
     /**
@@ -113,11 +101,7 @@ class HeaderPlugin
     {
         $response->setHeader('pragma', 'no-cache', true);
         $response->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true);
-        $response->setHeader(
-            'expires',
-            gmdate('D, d M Y H:i:s T', strtotime('-1 year')),
-            true
-        );
+        $response->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('-1 year')), true);
     }
 
     /**
@@ -127,12 +111,9 @@ class HeaderPlugin
      */
     protected function setPrivateHeaders(\Magento\App\Response\Http $response)
     {
+        $maxAge = Data::PRIVATE_MAX_AGE_CACHE;
         $response->setHeader('pragma', 'cache', true);
-        $response->setHeader('cache-control', 'private, max-age=' . Data::PRIVATE_MAX_AGE_CACHE, true);
-        $response->setHeader(
-            'expires',
-            gmdate('D, d M Y H:i:s T', strtotime('+' . Data::PRIVATE_MAX_AGE_CACHE . ' seconds')),
-            true
-        );
+        $response->setHeader('cache-control', 'private, max-age=' . $maxAge, true);
+        $response->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), true);
     }
 }
diff --git a/app/code/Magento/PageCache/Model/Config.php b/app/code/Magento/PageCache/Model/Config.php
new file mode 100644
index 0000000000000000000000000000000000000000..47a065085b4177639d55160e10e7194696eaec3a
--- /dev/null
+++ b/app/code/Magento/PageCache/Model/Config.php
@@ -0,0 +1,172 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+/**
+ * Model is responsible for replacing default vcl template
+ * file configuration with user-defined from configuration
+ *
+ * @category   Magento
+ * @package    Magento_PageCache
+ * @author     Magento Core Team <core@magentocommerce.com>
+ */
+
+namespace Magento\PageCache\Model;
+
+use Magento\App\Filesystem;
+
+/**
+ * Class Config
+ *
+ * @package Magento\PageCache\Model
+ */
+class Config
+{
+    /**#@+
+     * XML path to Varnish settings
+     */
+    const XML_PAGECACHE_TTL = 'system/full_page_cache/ttl';
+    const XML_VARNISH_PAGECACHE_ACCESS_LIST = 'system/full_page_cache/varnish/access_list';
+    const XML_VARNISH_PAGECACHE_BACKEND_PORT = 'system/full_page_cache/varnish/backend_port';
+    const XML_VARNISH_PAGECACHE_BACKEND_HOST = 'system/full_page_cache/varnish/backend_host';
+    const XML_VARNISH_PAGECACHE_DESIGN_THEME_REGEX = 'design/theme/ua_regexp';
+    /**#@-*/
+
+    /**
+     * @var \Magento\Core\Model\Store\Config
+     */
+    protected $_coreStoreConfig;
+
+    /**
+     * @var \Magento\App\ConfigInterface
+     */
+    protected $_config;
+
+    /**
+     * XML path to value for saving temporary .vcl configuration
+     */
+    const VARNISH_CONFIGURATION_PATH = 'system/full_page_cache/varnish/path';
+
+    /**
+     * @var \Magento\Filesystem\Directory\WriteInterface
+     */
+    protected $_modulesDirectory;
+
+    public function __construct(
+        \Magento\App\Filesystem $filesystem,
+        \Magento\Core\Model\Store\Config $coreStoreConfig,
+        \Magento\App\ConfigInterface $config
+    ) {
+        $this->_modulesDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MODULES_DIR);
+        $this->_coreStoreConfig = $coreStoreConfig;
+        $this->_config = $config;
+    }
+
+    /**
+     * Return generated varnish.vcl configuration file
+     *
+     * @return string
+     */
+    public function getVclFile()
+    {
+        $data = $this->_modulesDirectory->readFile(
+            $this->_config->getValue(self::VARNISH_CONFIGURATION_PATH)
+        );
+        return strtr($data, $this->_getReplacements());
+    }
+
+    /**
+     * Prepare data for VCL config
+     *
+     * @return array
+     */
+    protected function _getReplacements()
+    {
+        return array(
+            '{{ host }}' => $this->_coreStoreConfig->getConfig(self::XML_VARNISH_PAGECACHE_BACKEND_HOST),
+            '{{ port }}' => $this->_coreStoreConfig->getConfig(self::XML_VARNISH_PAGECACHE_BACKEND_PORT),
+            '{{ ips }}' => $this->_getAccessList(),
+            '{{ design_exceptions_code }}' => $this->_getDesignExceptions()
+        );
+    }
+
+    /**
+     * Get IPs access list that can purge Varnish configuration for config file generation
+     * and transform it to appropriate view
+     *
+     * acl purge{
+     *  "127.0.0.1";
+     *  "127.0.0.2";
+     *
+     * @return mixed|null|string
+     */
+    protected function _getAccessList()
+    {
+        $result = '';
+        $tpl = "    \"%s\";";
+        $accessList = $this->_coreStoreConfig->getConfig(self::XML_VARNISH_PAGECACHE_ACCESS_LIST);
+        if (!empty($accessList)) {
+            $ips = explode(', ', $accessList);
+            foreach ($ips as $ip) {
+                $result[] = sprintf($tpl, $ip);
+            }
+            return implode("\n", $result);
+        }
+        return $result;
+    }
+
+    /**
+     * Get regexs for design exceptions
+     * Different browser user-agents may use different themes
+     * Varnish supports regex with internal modifiers only so
+     * we have to convert "/pattern/iU" into "(?Ui)pattern"
+     *
+     * @return string
+     */
+    protected function _getDesignExceptions()
+    {
+        $result = '';
+        $tpl = "%s (req.http.user-agent ~ \"%s\") {\n"
+             . "        hash_data(\"%s\");\n"
+             . "    }";
+
+        $expressions = $this->_coreStoreConfig->getConfig(self::XML_VARNISH_PAGECACHE_DESIGN_THEME_REGEX);
+        if ($expressions) {
+            $rules = array_values(unserialize($expressions));
+            foreach ($rules as $i => $rule) {
+                if (preg_match('/^[\W]{1}(.*)[\W]{1}(\w+)?$/', $rule['regexp'], $matches)) {
+                    if (!empty($matches[2])) {
+                        $pattern = sprintf("(?%s)%s", $matches[2], $matches[1]);
+                    } else {
+                        $pattern = $matches[1];
+                    }
+                    $if = ($i == 0) ? 'if' : ' elsif';
+                    $result .= sprintf($tpl, $if, $pattern, $rule['value']);
+                }
+            }
+        }
+        return $result;
+    }
+}
diff --git a/app/code/Magento/PageCache/Model/Observer.php b/app/code/Magento/PageCache/Model/Observer.php
index d190f82f0b3dcd73ac97b73a00da13999e5dcfbb..f4c13b1d53c1a4f38fc16e3a81eda764e06f590e 100644
--- a/app/code/Magento/PageCache/Model/Observer.php
+++ b/app/code/Magento/PageCache/Model/Observer.php
@@ -37,6 +37,7 @@ class Observer
      * Blocks are wrapped only if page is cacheable
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function processLayoutRenderElement(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php b/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php
new file mode 100644
index 0000000000000000000000000000000000000000..39336b5f30e9a8497911d3732f4cb813c28db144
--- /dev/null
+++ b/app/code/Magento/PageCache/Model/System/Config/Backend/Varnish.php
@@ -0,0 +1,90 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\PageCache\Model\System\Config\Backend;
+
+/**
+ * Backend model for processing Varnish settings
+ *
+ * Class Varnish
+ * @package Magento\PageCache\Model\System\Config\Backend
+ */
+class Varnish extends \Magento\Core\Model\Config\Value
+{
+    /**
+     * @var array
+     */
+    protected $defaultValues;
+
+    /**
+     * Set default data if empty fields have been left
+     *
+     * @return $this|\Magento\Core\Model\AbstractModel
+     * @throws \Magento\Core\Exception
+     */
+    protected function _beforeSave()
+    {
+        $data = $this->_getDefaultValues();
+        $currentValue = $this->getValue();
+        if(!$currentValue) {
+            $replaceValue = isset($data[$this->getField()]) ? $data[$this->getField()] : false;
+            $this->setValue($replaceValue);
+        }
+        return $this;
+    }
+
+    /**
+     * Get Default Config Values
+     *
+     * @return array
+     */
+    protected function _getDefaultValues()
+    {
+        if (!$this->defaultValues) {
+            $this->defaultValues = $this->_config->getValue('system/full_page_cache/default');
+        }
+        return $this->defaultValues;
+    }
+
+    /**
+     * If fields are empty fill them with default data
+     *
+     * @return $this|\Magento\Core\Model\AbstractModel
+     */
+    protected function _afterLoad()
+    {
+        $data = $this->_getDefaultValues();
+        $currentValue = $this->getValue();
+        if(!$currentValue) {
+            foreach ($data as $field => $value) {
+                if(strstr($this->getPath(), $field)) {
+                    $this->setValue($value);
+                    $this->save();
+                    break;
+                }
+            }
+        }
+        return $this;
+    }
+}
\ No newline at end of file
diff --git a/app/code/Magento/PageCache/Model/System/Config/Source/Application.php b/app/code/Magento/PageCache/Model/System/Config/Source/Application.php
new file mode 100644
index 0000000000000000000000000000000000000000..5385933adc4686cb545f0adc44ab706cbe4d7f12
--- /dev/null
+++ b/app/code/Magento/PageCache/Model/System/Config/Source/Application.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+/**
+ * Used in creating options for Caching Application config value selection
+ */
+namespace Magento\PageCache\Model\System\Config\Source;
+
+/**
+ * Class Application
+ *
+ * @package Magento\PageCache\Model\System\Config\Source
+ */
+class Application implements \Magento\Core\Model\Option\ArrayInterface
+{
+    /**
+     * Options getter
+     *
+     * @return array
+     */
+    public function toOptionArray()
+    {
+        return array(
+            array('value' => 0, 'label'=>__('Built-in Application')),
+            array('value' => 1, 'label'=>__('Varnish Caching')),
+        );
+    }
+
+    /**
+     * Get options in "key-value" format
+     *
+     * @return array
+     */
+    public function toArray()
+    {
+        return array(
+            0 => __('Built-in Application'),
+            1 => __('Varnish Caching'),
+        );
+    }
+} 
diff --git a/app/code/Magento/PageCache/Model/Version.php b/app/code/Magento/PageCache/Model/Version.php
index 727fb8dfaa0aa55a3910c20f806c432febd0378d..4c54215b69f6510d81f932714233849fad36214d 100644
--- a/app/code/Magento/PageCache/Model/Version.php
+++ b/app/code/Magento/PageCache/Model/Version.php
@@ -23,9 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\PageCache\Model;
 
+use Magento\App\Request\Http;
+use Magento\Stdlib\Cookie;
+
 /**
  * Class Version
  * @package Magento\PageCache\Model
@@ -45,20 +47,24 @@ class Version
     /**
      * Cookie
      *
-     * @var \Magento\Stdlib\Cookie
+     * @var Cookie
      */
     private $cookie;
 
     /**
      * Request
      *
-     * @var \Magento\App\Request\Http
+     * @var Http
      */
     private $request;
 
+    /**
+     * @param Cookie $cookie
+     * @param Http $request
+     */
     public function __construct(
-        \Magento\Stdlib\Cookie $cookie,
-        \Magento\App\Request\Http $request
+        Cookie $cookie,
+        Http $request
     ) {
         $this->cookie = $cookie;
         $this->request = $request;
@@ -66,6 +72,8 @@ class Version
 
     /**
      * Increment private content version cookie (for user to pull new private content)
+     *
+     * @return void
      */
     private function set()
     {
@@ -87,6 +95,8 @@ class Version
      * Set cookie if it is not set.
      * Increment version on post requests.
      * In all other cases do nothing.
+     *
+     * @return void
      */
     public function process()
     {
diff --git a/app/code/Magento/PageCache/etc/adminhtml/routes.xml b/app/code/Magento/PageCache/etc/adminhtml/routes.xml
new file mode 100644
index 0000000000000000000000000000000000000000..56861269b0f6a6e9ea2f9cbc9276a793f77103ad
--- /dev/null
+++ b/app/code/Magento/PageCache/etc/adminhtml/routes.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <router id="admin">
+        <route id="adminhtml">
+            <module name="Magento_PageCache" before="Magento_Adminhtml" />
+        </route>
+    </router>
+</config>
diff --git a/app/code/Magento/PageCache/etc/adminhtml/system.xml b/app/code/Magento/PageCache/etc/adminhtml/system.xml
new file mode 100644
index 0000000000000000000000000000000000000000..977693ce49f6097af815420609eb3f8d4db8d4df
--- /dev/null
+++ b/app/code/Magento/PageCache/etc/adminhtml/system.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <system>
+        <section id="system">
+            <group id="full_page_cache" translate="label" showInDefault="1" showInWebsite="0" showInStore="0" sortOrder="600">
+                <label>Full Page Cache</label>
+                <field id="caching_application" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0">
+                    <label>Caching Application</label>
+                    <source_model>Magento\PageCache\Model\System\Config\Source\Application</source_model>
+                </field>
+                <group id="varnish" translate="label" showInDefault="1" showInWebsite="0" showInStore="0" sortOrder="605">
+                    <label>Varnish Configuration</label>
+                    <field id="access_list" type="text" translate="label comment" sortOrder="15" showInDefault="1" showInWebsite="0" showInStore="0">
+                        <label>Access list</label>
+                        <comment>IPs access list separated with ',' that can purge Varnish configuration for config file generation.
+                            If field is empty default value localhost will be saved.</comment>
+                        <backend_model>Magento\PageCache\Model\System\Config\Backend\Varnish</backend_model>
+                        <depends>
+                            <field id="caching_application">1</field>
+                        </depends>
+                    </field>
+                    <field id="backend_host" type="text" translate="label comment" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
+                        <label>Backend host</label>
+                        <comment>Specify backend host for config file generation. If field is empty default value localhost will be saved.</comment>
+                        <backend_model>Magento\PageCache\Model\System\Config\Backend\Varnish</backend_model>
+                        <depends>
+                            <field id="caching_application">1</field>
+                        </depends>
+                    </field>
+                    <field id="backend_port" type="text" translate="label comment" sortOrder="25" showInDefault="1" showInWebsite="0" showInStore="0">
+                        <label>Backend port</label>
+                        <comment>Specify backend port for config file generation. If field is empty default value 8080 will be saved.</comment>
+                        <backend_model>Magento\PageCache\Model\System\Config\Backend\Varnish</backend_model>
+                        <depends>
+                            <field id="caching_application">1</field>
+                        </depends>
+                    </field>
+                    <field id="export_button" type="button" sortOrder="35" showInDefault="1" showInWebsite="0" showInStore="0">
+                        <label>Export Varnish Configuration</label>
+                        <frontend_model>Magento\PageCache\Block\System\Config\Form\Field\Export</frontend_model>
+                        <depends>
+                            <field id="caching_application">1</field>
+                        </depends>
+                    </field>
+                    <depends>
+                        <field id="caching_application">1</field>
+                    </depends>
+                </group>
+                <field id="ttl" type="text" translate="label comment" sortOrder="5" showInDefault="1" showInWebsite="0" showInStore="0">
+                    <label>TTL for public content</label>
+                    <comment>Public content cache lifetime in seconds. If field is empty default value 120 will be saved. </comment>
+                    <backend_model>Magento\PageCache\Model\System\Config\Backend\Varnish</backend_model>
+                </field>
+            </group>
+        </section>
+    </system>
+</config>
diff --git a/app/code/Magento/PageCache/etc/config.xml b/app/code/Magento/PageCache/etc/config.xml
index 50809da39d5435b60c8d779acf442e934a921858..a0523c924f09fde48d8df03fd5f12d297e2422c0 100644
--- a/app/code/Magento/PageCache/etc/config.xml
+++ b/app/code/Magento/PageCache/etc/config.xml
@@ -31,6 +31,17 @@
             <headers>
                 <public-max-age>0</public-max-age>
             </headers>
+            <full_page_cache>
+                <varnish>
+                    <path>Magento/PageCache/etc/varnish.vcl</path>
+                </varnish>
+                <default>
+                    <access_list>localhost</access_list>
+                    <backend_host>localhost</backend_host>
+                    <backend_port>8080</backend_port>
+                    <ttl>120</ttl>
+                </default>
+            </full_page_cache>
         </system>
     </default>
 </config>
\ No newline at end of file
diff --git a/app/code/Magento/PageCache/etc/module.xml b/app/code/Magento/PageCache/etc/module.xml
index bf7c69345b084a9af77c82d0990d8bb342c2ba30..04678d1ca83a30f0bf1a57b2de2bc19f60370058 100755
--- a/app/code/Magento/PageCache/etc/module.xml
+++ b/app/code/Magento/PageCache/etc/module.xml
@@ -29,6 +29,7 @@
             <module name="Magento_Core"/>
         </sequence>
         <depends>
+            <module name="Magento_Backend"/>
             <module name="Magento_Core"/>
             <module name="Magento_Theme"/>
         </depends>
diff --git a/app/code/Magento/PageCache/etc/varnish.vcl b/app/code/Magento/PageCache/etc/varnish.vcl
new file mode 100644
index 0000000000000000000000000000000000000000..aa30cbc19b084fcaa1a28941a03a41a22ffd1317
--- /dev/null
+++ b/app/code/Magento/PageCache/etc/varnish.vcl
@@ -0,0 +1,102 @@
+import std;
+
+backend default {
+    .host = "{{ host }}";
+    .port = "{{ port }}";
+}
+
+acl purge {
+{{ ips }}
+}
+
+sub vcl_recv {
+    # prevent from gzipping on backend
+    unset req.http.accept-encoding;
+
+    if (req.restarts == 0) {
+        if (req.http.x-forwarded-for) {
+            set req.http.X-Forwarded-For =
+            req.http.X-Forwarded-For + ", " + client.ip;
+        } else {
+            set req.http.X-Forwarded-For = client.ip;
+        }
+    }
+
+    if (req.request == "PURGE") {
+        if (client.ip !~ purge) {
+            error 405 "Method not allowed";
+        }
+        if (!req.http.X-Magento-Tags-Pattern) {
+            error 400 "X-Magento-Tags-Pattern header required";
+        }
+        ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
+        error 200 "Purged";
+    }
+
+    if (req.request != "GET" &&
+        req.request != "HEAD" &&
+        req.request != "PUT" &&
+        req.request != "POST" &&
+        req.request != "TRACE" &&
+        req.request != "OPTIONS" &&
+        req.request != "DELETE") {
+          /* Non-RFC2616 or CONNECT which is weird. */
+          return (pipe);
+    }
+
+    # We only deal with GET and HEAD by default
+    if (req.request != "GET" && req.request != "HEAD") {
+        return (pass);
+    }
+
+    if (req.url ~ "\.(css|js|jpg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf)(\?|$)") {
+         unset req.http.Cookie;
+    }
+
+    set req.grace = 1m;
+
+    return (lookup);
+}
+
+sub vcl_hash {
+    if (req.http.cookie ~ "X-Magento-Vary=") {
+        hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
+    }
+    {{ design_exceptions_code }}
+}
+
+sub vcl_fetch {
+    if (req.url !~ "\.(jpg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf)(\?|$)") {
+        set beresp.do_gzip = true;
+        if (req.url !~ "\.(css|js)(\?|$)") {
+            set beresp.do_esi = true;
+        }
+    }
+
+    # cache only successfully responses
+    if (beresp.status != 200) {
+        set beresp.ttl = 0s;
+        return (hit_for_pass);
+    }
+
+    # validate if we need to cache it and prevent from setting cookie
+    # images, css and js are cacheable by default so we have to remove cookie also
+    if (beresp.ttl > 0s && (req.request == "GET" || req.request == "HEAD")) {
+        unset beresp.http.set-cookie;
+        if (req.url !~ "\.(css|js|jpg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf)(\?|$)") {
+            set beresp.http.Pragma = "no-cache";
+            set beresp.http.Expires = "-1";
+            set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
+            set beresp.grace = 1m;
+        }
+    }
+}
+
+sub vcl_deliver {
+    unset resp.http.X-Magento-Tags;
+    unset resp.http.X-Powered-By;
+    unset resp.http.Server;
+    unset resp.http.X-Varnish;
+    unset resp.http.Via;
+    unset resp.http.Link;
+}
\ No newline at end of file
diff --git a/app/code/Magento/PageCache/view/adminhtml/layout/adminhtml_system_config_edit.xml b/app/code/Magento/PageCache/view/adminhtml/layout/adminhtml_system_config_edit.xml
new file mode 100644
index 0000000000000000000000000000000000000000..84054e66e0b1e9d36c0265cb53aff4ec91816922
--- /dev/null
+++ b/app/code/Magento/PageCache/view/adminhtml/layout/adminhtml_system_config_edit.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <referenceContainer name="js">
+        <block class="Magento\PageCache\Block\System\Config\Form\Field\Export" template="Magento_PageCache::page_cache_validation.phtml"/>
+    </referenceContainer>
+</layout>
diff --git a/app/code/Magento/PageCache/view/adminhtml/page_cache_validation.phtml b/app/code/Magento/PageCache/view/adminhtml/page_cache_validation.phtml
new file mode 100644
index 0000000000000000000000000000000000000000..0c552a8d7cb6aa3f3d3ec0af2af119803c8169aa
--- /dev/null
+++ b/app/code/Magento/PageCache/view/adminhtml/page_cache_validation.phtml
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+?>
+
+<?php /** @var \Magento\PageCache\Block\System\Config\Form\Field\Export $this */
+?>
+<script type="text/javascript">
+    //<![CDATA[
+    (function ($) {
+        var fieldset = $('#system_full_page_cache_varnish'),
+            fields = fieldset.find(':input:not(button)');
+        if (fieldset.is(':visible') == false) {
+            fieldset.show();
+            fields.show();
+        }
+        fields.each(function (e) {
+            $(this).data('previous-value', $(this).val());
+        });
+        fieldset.on('change', function (e) {
+            var invalidFields = fields.filter(function () {
+                return ($(this).val().length == 0 || ($(this).val() != $(this).data('previous-value')));
+            });
+            $('#system_full_page_cache_varnish_export_button').prop('disabled', (invalidFields.length > 0));
+        });
+    })(jQuery);
+    //]]>
+</script>
\ No newline at end of file
diff --git a/app/code/Magento/PageCache/view/frontend/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/js/page-cache.js
index f306ada4af1546155675395f0b1676200ad51951..a6a2b0ce9b7efe851d6d571e45b020160a360b1c 100644
--- a/app/code/Magento/PageCache/view/frontend/js/page-cache.js
+++ b/app/code/Magento/PageCache/view/frontend/js/page-cache.js
@@ -39,7 +39,9 @@
                 return ;
             }
             var placeholders = this._searchPlaceholders(this.element.comments());
-            this._ajax(placeholders, version);
+            if (placeholders.length) {
+                this._ajax(placeholders, version);
+            }
         },
         _searchPlaceholders: function (elements) {
             var placeholders = [],
diff --git a/app/code/Magento/Payment/Block/Form.php b/app/code/Magento/Payment/Block/Form.php
index 70bd146153ca4f7d88abc0c43068abecce237f28..814346bac9c7d66228299b7ae126cb71e8bb9b70 100644
--- a/app/code/Magento/Payment/Block/Form.php
+++ b/app/code/Magento/Payment/Block/Form.php
@@ -67,14 +67,4 @@ class Form extends \Magento\View\Element\Template
     {
         return $this->escapeHtml($this->getMethod()->getInfoInstance()->getData($field));
     }
-
-    /**
-     * Check whether current payment method can create billing agreement
-     *
-     * @return bool
-     */
-    public function canCreateBillingAgreement()
-    {
-        return $this->getMethod()->canCreateBillingAgreement();
-    }
 }
diff --git a/app/code/Magento/Payment/Helper/Data.php b/app/code/Magento/Payment/Helper/Data.php
index 42ee51a7f76f8d14e26d9bc18917133474125aef..17aefd45873b266013615432fde413815d4ce6ee 100644
--- a/app/code/Magento/Payment/Helper/Data.php
+++ b/app/code/Magento/Payment/Helper/Data.php
@@ -224,24 +224,6 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return $paymentBlockHtml;
     }
 
-    /**
-     * Retrieve available billing agreement methods
-     *
-     * @param mixed $store
-     * @param \Magento\Sales\Model\Quote $quote
-     * @return array
-     */
-    public function getBillingAgreementMethods($store = null, $quote = null)
-    {
-        $result = array();
-        foreach ($this->getStoreMethods($store, $quote) as $method) {
-            if ($method->canManageBillingAgreements()) {
-                $result[] = $method;
-            }
-        }
-        return $result;
-    }
-
     /**
      * Get payment methods that implement recurring profilez management
      *
@@ -339,27 +321,6 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return $methods;
     }
 
-    /**
-     * Retrieve all billing agreement methods (code and label)
-     *
-     * @return array
-     */
-    public function getAllBillingAgreementMethods()
-    {
-        $result = array();
-        $interface = 'Magento\Payment\Model\Billing\Agreement\MethodInterface';
-        foreach ($this->getPaymentMethods() as $code => $data) {
-            if (!isset($data['model'])) {
-                continue;
-            }
-            $method = $data['model'];
-            if (in_array($interface, class_implements($method))) {
-                $result[$code] = $data['title'];
-            }
-        }
-        return $result;
-    }
-
     /**
      * Returns value of Zero Subtotal Checkout / Enabled
      *
diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php
index 34fba2e5f0f8b7faadeda74ccc2d30e07ad4eb72..4a94fcc70f324772de6e93fa16d78e6679ae2625 100644
--- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php
+++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php
@@ -85,7 +85,6 @@ abstract class AbstractMethod extends \Magento\Object
     protected $_isInitializeNeeded          = false;
     protected $_canFetchTransactionInfo     = false;
     protected $_canReviewPayment            = false;
-    protected $_canCreateBillingAgreement   = false;
     protected $_canManageRecurringProfiles  = true;
     /**#@-*/
 
@@ -266,16 +265,6 @@ abstract class AbstractMethod extends \Magento\Object
         return $this->_canFetchTransactionInfo;
     }
 
-    /**
-     * Check whether payment method instance can create billing agreements
-     *
-     * @return bool
-     */
-    public function canCreateBillingAgreement()
-    {
-        return $this->_canCreateBillingAgreement;
-    }
-
     /**
      * Fetch transaction info
      *
@@ -340,16 +329,6 @@ abstract class AbstractMethod extends \Magento\Object
         return true;
     }
 
-    /**
-     * Check manage billing agreements availability
-     *
-     * @return bool
-     */
-    public function canManageBillingAgreements()
-    {
-        return ($this instanceof \Magento\Payment\Model\Billing\Agreement\MethodInterface);
-    }
-
     /**
      * Whether can manage recurring profiles
      *
diff --git a/app/code/Magento/Payment/Model/Observer.php b/app/code/Magento/Payment/Model/Observer.php
index 8f0939cb4e10e7b5a75286a0aa98218799d2483f..2c7a1d8dc425c0796a07c9c6d40d30eefb1fa4a8 100644
--- a/app/code/Magento/Payment/Model/Observer.php
+++ b/app/code/Magento/Payment/Model/Observer.php
@@ -31,27 +31,6 @@ namespace Magento\Payment\Model;
 
 class Observer
 {
-    /**
-     * Locale model
-     *
-     * @var \Magento\Core\Model\LocaleInterface
-     */
-    protected $_locale;
-
-    /**
-     * Store manager
-     *
-     * @var \Magento\Core\Model\StoreManagerInterface
-     */
-    protected $_storeManager;
-
-    /**
-     * Recurring profile factory
-     *
-     * @var \Magento\Payment\Model\Recurring\ProfileFactory
-     */
-    protected $_profileFactory;
-
     /**
      * @var \Magento\Sales\Model\Order\Config
      */
@@ -70,24 +49,15 @@ class Observer
     /**
      * Construct
      *
-     * @param \Magento\Core\Model\LocaleInterface $locale
-     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
-     * @param \Magento\Payment\Model\Recurring\ProfileFactory $profileFactory
      * @param \Magento\Sales\Model\Order\Config $salesOrderConfig
      * @param \Magento\Payment\Model\Config $paymentConfig
      * @param \Magento\Core\Model\Resource\Config $resourceConfig
      */
     public function __construct(
-        \Magento\Core\Model\LocaleInterface $locale,
-        \Magento\Core\Model\StoreManagerInterface $storeManager,
-        \Magento\Payment\Model\Recurring\ProfileFactory $profileFactory,
         \Magento\Sales\Model\Order\Config $salesOrderConfig,
         \Magento\Payment\Model\Config $paymentConfig,
         \Magento\Core\Model\Resource\Config $resourceConfig
     ) {
-        $this->_locale = $locale;
-        $this->_storeManager = $storeManager;
-        $this->_profileFactory = $profileFactory;
         $this->_salesOrderConfig = $salesOrderConfig;
         $this->_paymentConfig = $paymentConfig;
         $this->_resourceConfig = $resourceConfig;
@@ -122,52 +92,6 @@ class Observer
         return $this;
     }
 
-    /**
-     * Collect buy request and set it as custom option
-     *
-     * Also sets the collected information and schedule as informational static options
-     *
-     * @param \Magento\Event\Observer $observer
-     */
-    public function prepareProductRecurringProfileOptions($observer)
-    {
-        $product = $observer->getEvent()->getProduct();
-        $buyRequest = $observer->getEvent()->getBuyRequest();
-
-        if (!$product->isRecurring()) {
-            return;
-        }
-
-        /** @var \Magento\Payment\Model\Recurring\Profile $profile */
-        $profile = $this->_profileFactory->create();
-        $profile->setLocale($this->_locale)
-            ->setStore($this->_storeManager->getStore())
-            ->importBuyRequest($buyRequest)
-            ->importProduct($product);
-        if (!$profile) {
-            return;
-        }
-
-        // add the start datetime as product custom option
-        $product->addCustomOption(\Magento\Payment\Model\Recurring\Profile::PRODUCT_OPTIONS_KEY,
-            serialize(array('start_datetime' => $profile->getStartDatetime()))
-        );
-
-        // duplicate as 'additional_options' to render with the product statically
-        $infoOptions = array(array(
-            'label' => $profile->getFieldLabel('start_datetime'),
-            'value' => $profile->exportStartDatetime(true),
-        ));
-
-        foreach ($profile->exportScheduleInfo() as $info) {
-            $infoOptions[] = array(
-                'label' => $info->getTitle(),
-                'value' => $info->getSchedule(),
-            );
-        }
-        $product->addCustomOption('additional_options', serialize($infoOptions));
-    }
-
     /**
      * Sets current instructions for bank transfer account
      *
diff --git a/app/code/Magento/Payment/Model/Recurring/Profile/MethodInterface.php b/app/code/Magento/Payment/Model/Recurring/Profile/MethodInterface.php
index 512ae1dec9cd3efffc173c6e80ff33e7f9d8c2c8..09915846eafccd2afc09b4bed14a316d0f87b89c 100644
--- a/app/code/Magento/Payment/Model/Recurring/Profile/MethodInterface.php
+++ b/app/code/Magento/Payment/Model/Recurring/Profile/MethodInterface.php
@@ -34,18 +34,18 @@ interface MethodInterface
     /**
      * Validate data
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      * @throws \Magento\Core\Exception
      */
-    public function validateRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile);
+    public function validateRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile);
 
     /**
      * Submit to the gateway
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      * @param \Magento\Payment\Model\Info $paymentInfo
      */
-    public function submitRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile, \Magento\Payment\Model\Info $paymentInfo);
+    public function submitRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile, \Magento\Payment\Model\Info $paymentInfo);
 
     /**
      * Fetch details
@@ -65,14 +65,14 @@ interface MethodInterface
     /**
      * Update data
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function updateRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile);
+    public function updateRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile);
 
     /**
      * Manage status
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function updateRecurringProfileStatus(\Magento\Payment\Model\Recurring\Profile $profile);
+    public function updateRecurringProfileStatus(\Magento\RecurringProfile\Model\RecurringProfile $profile);
 }
diff --git a/app/code/Magento/Payment/etc/module.xml b/app/code/Magento/Payment/etc/module.xml
index 8e7c3f3b0db2217314d08e9a8f56e07f87cd7776..32167e3ad081e4ecaddf20cf8721e97a3d585c8a 100755
--- a/app/code/Magento/Payment/etc/module.xml
+++ b/app/code/Magento/Payment/etc/module.xml
@@ -31,10 +31,10 @@
         </sequence>
         <depends>
             <module name="Magento_Core"/>
-            <module name="Magento_Catalog"/>
             <module name="Magento_Sales"/>
             <module name="Magento_Centinel"/>
             <module name="Magento_Checkout"/>
+            <module name="Magento_RecurringProfile"/>
         </depends>
     </module>
 </config>
diff --git a/app/code/Magento/Payment/i18n/de_DE.csv b/app/code/Magento/Payment/i18n/de_DE.csv
index ef94b55e742df5424f55a0722dd69f0066bf10fe..01a02a0dfe5de9dcaf5f79d7339d531df1898c70 100644
--- a/app/code/Magento/Payment/i18n/de_DE.csv
+++ b/app/code/Magento/Payment/i18n/de_DE.csv
@@ -10,7 +10,6 @@
 "Auto Bill on Next Cycle","Automatische Abrechnung beim nächsten Zyklus"
 "Automatically Invoice All Items","Automatische Abrechnung aller Artikel"
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","Den ausstehenden Betrag automatisch im nächsten Rechnungslauf verrechnen (wenn es fehlgeschlagene Zahlungen gab)."
-"Billing Agreement status is not set.","Abrechnungsvereinbarungsstatus ist nicht gesetzt."
 "Billing Amount","Rechnungsbetrag"
 "Billing Frequency","Abrechnungsfrequenz"
 "Billing Interval","Abrechnungsperiode"
@@ -121,7 +120,6 @@
 "Trial period frequency is wrong.","Probeperiodenfrequenz ist falsch."
 "Trial period max cycles is wrong.","Maximale Zyklen für Probeperiode ist falsch."
 "Two Weeks","Zwei Wochen"
-"Unable to save Billing Agreement:","Abrechnungsvereinbarung kann nicht gespeichert werden:"
 "Unit for billing during the subscription period.","Einheit für Abrechnung der Abonnementperiode."
 "Unsupported currency code: %s.","Nicht unterstützter Währungscode: %s."
 "Void action is not available.","Leer-Aktion ist nicht verfügbar."
diff --git a/app/code/Magento/Payment/i18n/en_US.csv b/app/code/Magento/Payment/i18n/en_US.csv
index ef675a0b52b3cad80acac96293a9449694b3d030..d58c49c1acd610eb72d42155e828bf4053563076 100644
--- a/app/code/Magento/Payment/i18n/en_US.csv
+++ b/app/code/Magento/Payment/i18n/en_US.csv
@@ -11,7 +11,6 @@
 "Automatically Invoice All Items","Automatically Invoice All Items"
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments)."
 "Bank Transfer Payment","Bank Transfer Payment"
-"Billing Agreement status is not set.","Billing Agreement status is not set."
 "Billing Amount","Billing Amount"
 "Billing Frequency","Billing Frequency"
 "Billing Interval","Billing Interval"
@@ -128,7 +127,6 @@
 "Trial period frequency is wrong.","Trial period frequency is wrong."
 "Trial period max cycles is wrong.","Trial period max cycles is wrong."
 "Two Weeks","Two Weeks"
-"Unable to save Billing Agreement:","Unable to save Billing Agreement:"
 "Unit for billing during the subscription period.","Unit for billing during the subscription period."
 "Unsupported currency code: %s.","Unsupported currency code: %s."
 "Void action is not available.","Void action is not available."
diff --git a/app/code/Magento/Payment/i18n/es_ES.csv b/app/code/Magento/Payment/i18n/es_ES.csv
index f695a73f262412be4fcca73e274c3c5bdbaa4bd6..e39542c6cc65aa94622164c439bd561b47312368 100644
--- a/app/code/Magento/Payment/i18n/es_ES.csv
+++ b/app/code/Magento/Payment/i18n/es_ES.csv
@@ -10,7 +10,6 @@
 "Auto Bill on Next Cycle","Pasar la factura automáticamente en el próximo ciclo"
 "Automatically Invoice All Items","Facturar automáticamente todos los artículos"
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","Pasar automáticamente el saldo pendiente de la factura en el próximo ciclo de facturación (en caso de que se produzca un error en los pagos)."
-"Billing Agreement status is not set.","No se ha establecido el estado del acuerdo de facturación."
 "Billing Amount","Cantidad de facturación"
 "Billing Frequency","Frecuencia de facturación"
 "Billing Interval","Período de facturación"
@@ -121,7 +120,6 @@
 "Trial period frequency is wrong.","La frecuencia del período de prueba es incorrecta."
 "Trial period max cycles is wrong.","Los ciclos máximos del período de prueba son incorrectos."
 "Two Weeks","Dos Semanas"
-"Unable to save Billing Agreement:","No se puede guardar el Contrato de Facturación:"
 "Unit for billing during the subscription period.","Unidad de facturación durante el período de suscripción."
 "Unsupported currency code: %s.","Código de divisa no compatible: %s."
 "Void action is not available.","La anulación no se encuentra disponible."
diff --git a/app/code/Magento/Payment/i18n/fr_FR.csv b/app/code/Magento/Payment/i18n/fr_FR.csv
index 5cbd540ef7c826035642eb47ca4d0d193395750e..784d60447f09af40a22784c911328f12ba7afc29 100644
--- a/app/code/Magento/Payment/i18n/fr_FR.csv
+++ b/app/code/Magento/Payment/i18n/fr_FR.csv
@@ -10,7 +10,6 @@
 "Auto Bill on Next Cycle","Facturer automatiquement lors du prochain cycle."
 "Automatically Invoice All Items","Facturer automatiquement tous les objets."
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","Facturer automatiquement le montant restant dans le cycle suivant (si des paiements ont échoué)"
-"Billing Agreement status is not set.","Le statut du contrat de facturation n'est pas réglé."
 "Billing Amount","Montant de la facturation."
 "Billing Frequency","Fréquence de facturation."
 "Billing Interval","Période de facturation."
@@ -121,7 +120,6 @@
 "Trial period frequency is wrong.","La fréquence des périodes d'essai est incorrecte."
 "Trial period max cycles is wrong.","Le période maximale des cycles d'essai est incorrecte."
 "Two Weeks","Deux semaines"
-"Unable to save Billing Agreement:","Impossible d'enregistrer l'accord de facturation :"
 "Unit for billing during the subscription period.","Unité de facturation pour la période de souscription."
 "Unsupported currency code: %s.","Code de devise non supporté : %s."
 "Void action is not available.","L'action annuler n'est pas disponible."
diff --git a/app/code/Magento/Payment/i18n/nl_NL.csv b/app/code/Magento/Payment/i18n/nl_NL.csv
index c94f918fb1d76006c60570d9f128106f752678c0..c764d62ae203d015ae97b3e1fd42f4ccb89a63a3 100644
--- a/app/code/Magento/Payment/i18n/nl_NL.csv
+++ b/app/code/Magento/Payment/i18n/nl_NL.csv
@@ -10,7 +10,6 @@
 "Auto Bill on Next Cycle","Auto Rekening in Volgende Cyclus"
 "Automatically Invoice All Items","Automatische Factuur Alle Items"
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","Breng automatisch de uitstaande balanshoeveelheid in rekening in de volgende betaalcyclus (als er mislukte betalingen waren)."
-"Billing Agreement status is not set.","Betaalovereenkomst status is niet opgesteld."
 "Billing Amount","Grootte Rekening"
 "Billing Frequency","Frequentie Rekening"
 "Billing Interval","Periode Rekening"
@@ -121,7 +120,6 @@
 "Trial period frequency is wrong.","Trial periode frequentie is verkeerd."
 "Trial period max cycles is wrong.","Trial periode maximum hoeveelheid cycli is verkeerd."
 "Two Weeks","Twee Weken"
-"Unable to save Billing Agreement:","Niet mogelijk om Betalingsovereenkomst op te slaan:"
 "Unit for billing during the subscription period.","Eenheid voor het factureren tijdens de subscriptie periode."
 "Unsupported currency code: %s.","Niet-ondersteunde valuta code: %s."
 "Void action is not available.","Vernietigactie is niet beschikbaar."
diff --git a/app/code/Magento/Payment/i18n/pt_BR.csv b/app/code/Magento/Payment/i18n/pt_BR.csv
index b8bdf197f85dba5c1a507155d1d6c748376c3be7..8f20d79cd72b0a06415d489e801353c4bc7b7e0e 100644
--- a/app/code/Magento/Payment/i18n/pt_BR.csv
+++ b/app/code/Magento/Payment/i18n/pt_BR.csv
@@ -10,7 +10,6 @@
 "Auto Bill on Next Cycle","Faturar Automaticamente no Próximo Ciclo"
 "Automatically Invoice All Items","Faturar Automaticamente Todos os Itens"
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","Faturar automaticamente o valor do balanço em destaque no próximo ciclo de faturamento (se houve falha de pagamentos)."
-"Billing Agreement status is not set.","Acordo de estado de Faturamento não está definido."
 "Billing Amount","Valor de Faturamento"
 "Billing Frequency","Frequência de Faturamento"
 "Billing Interval","Período de Faturamento"
@@ -121,7 +120,6 @@
 "Trial period frequency is wrong.","Teste de faturamento de frequência está errado."
 "Trial period max cycles is wrong.","Ciclo máximo de período experimental está errado."
 "Two Weeks","Duas Semanas"
-"Unable to save Billing Agreement:","Não foi possível salvar Acordo de Cobrança:"
 "Unit for billing during the subscription period.","Unidade de faturamento durante o período de subscrição."
 "Unsupported currency code: %s.","Código de moeda não suportada: %s."
 "Void action is not available.","Ação de cancelamento não está disponível."
diff --git a/app/code/Magento/Payment/i18n/zh_CN.csv b/app/code/Magento/Payment/i18n/zh_CN.csv
index 650342707b6cebfb1f5ebcc56e242fab13d269d0..ad02c486e04bbf65ddf8b55ccf6ef12dd4ad95ad 100644
--- a/app/code/Magento/Payment/i18n/zh_CN.csv
+++ b/app/code/Magento/Payment/i18n/zh_CN.csv
@@ -10,7 +10,6 @@
 "Auto Bill on Next Cycle","下个周期自动记账"
 "Automatically Invoice All Items","对所有商品自动创建发票"
 "Automatically bill the outstanding balance amount in the next billing cycle (if there were failed payments).","下个记账周期对余款额度自动记账(如果有失败的支付的话)。"
-"Billing Agreement status is not set.","记账协议状态未设置。"
 "Billing Amount","记账额度"
 "Billing Frequency","记账频率"
 "Billing Interval","记账周期"
@@ -121,7 +120,6 @@
 "Trial period frequency is wrong.","尝试周期频率有误。"
 "Trial period max cycles is wrong.","尝试周期最大周期有误。"
 "Two Weeks","两周"
-"Unable to save Billing Agreement:","无法保存记账协议:"
 "Unit for billing during the subscription period.","订阅期限内的记账单位。"
 "Unsupported currency code: %s.","不支持的货币代码:%s"
 "Void action is not available.","空操作不可用。"
diff --git a/app/code/Magento/Payment/view/adminhtml/form/cc.phtml b/app/code/Magento/Payment/view/adminhtml/form/cc.phtml
index a959fe651697589bbccb3985e587fc2eaef6dfe7..9639d74df0d1a464cabf56c55b6c0b3b997e72cf 100644
--- a/app/code/Magento/Payment/view/adminhtml/form/cc.phtml
+++ b/app/code/Magento/Payment/view/adminhtml/form/cc.phtml
@@ -105,9 +105,9 @@
                 var SSChecked<?php echo $_code ?> = function() {
                     var elm = $('<?php echo $_code ?>_cc_type');
                     if (['SS','SM','SO'].indexOf(elm.value) != -1) {
-                        $('<?php echo $_code ?>_cc_type_ss_div').show();
+                        jQuery('#' + '<?php echo $_code ?>_cc_type_ss_div').show().removeClass('ignore-validate');
                     } else {
-                        $('<?php echo $_code ?>_cc_type_ss_div').hide();
+                        jQuery('#' + '<?php echo $_code ?>_cc_type_ss_div').hide().addClass('ignore-validate');
                     }
                 };
                 Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
diff --git a/app/code/Magento/Payment/view/adminhtml/form/ccsave.phtml b/app/code/Magento/Payment/view/adminhtml/form/ccsave.phtml
index f6d632f930b6732e2255a1cd30b07906fdac166e..5862d71eec5aea6d81688d8ada360dbed6a57d7c 100644
--- a/app/code/Magento/Payment/view/adminhtml/form/ccsave.phtml
+++ b/app/code/Magento/Payment/view/adminhtml/form/ccsave.phtml
@@ -116,9 +116,9 @@
                 var SSChecked<?php echo $_code ?> = function() {
                     var elm = $('<?php echo $_code ?>_cc_type');
                     if (['SS','SM','SO'].indexOf(elm.value) != -1) {
-                        $('<?php echo $_code ?>_cc_type_ss_div').show();
+                        jQuery('#' + '<?php echo $_code ?>_cc_type_ss_div').show().removeClass('ignore-validate');
                     } else {
-                        $('<?php echo $_code ?>_cc_type_ss_div').hide();
+                        jQuery('#' + '<?php echo $_code ?>_cc_type_ss_div').hide().addClass('ignore-validate');
                     }
                 };
                 Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
diff --git a/app/code/Magento/Payment/view/frontend/form/cc.phtml b/app/code/Magento/Payment/view/frontend/form/cc.phtml
index d6f5e0a38132a985340bde6f3fb66e3ebdcd8c53..f00b0f21cbe2c9802162eb7497c6813f2efeb74c 100644
--- a/app/code/Magento/Payment/view/frontend/form/cc.phtml
+++ b/app/code/Magento/Payment/view/frontend/form/cc.phtml
@@ -76,10 +76,10 @@
         <div class="control">
             <input type="number" title="<?php echo __('Card Verification Number') ?>" class="input-text cvv" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" data-validate='{required:true, "validate-cc-cvn":"#<?php echo $_code ?>_cc_type"}' />
             <div class="note">
-                <a href="#" class="action cvv" data-mage-init='{toggleAdvanced: {toggleContainers: "#<?php echo $_code ?>_cc_type_cvv_div .tooltip"}}'><span><?php echo __('What is this?') ?></span></a>
+                <a href="#" class="action cvv" data-mage-init='{"toggleAdvanced": {"toggleContainers": "#<?php echo $_code ?>_cc_type_cvv_div .tooltip"}}'><span><?php echo __('What is this?') ?></span></a>
             </div>
             <div class="tooltip hidden">
-                <a data-mage-init='{toggleAdvanced: {toggleContainers: "#<?php echo $_code ?>_cc_type_cvv_div .tooltip"}}' href="#" title="<?php echo __('Close') ?>" class="action close"><span><?php echo __('Close') ?></span></a>
+                <a data-mage-init='{"toggleAdvanced": {"toggleContainers": "#<?php echo $_code ?>_cc_type_cvv_div .tooltip"}}' href="#" title="<?php echo __('Close') ?>" class="action close"><span><?php echo __('Close') ?></span></a>
                 <div class="content">
                     <img src="<?php echo $this->getViewFileUrl('Magento_Checkout::cvv.gif') ?>" alt="<?php echo __('Card Verification Number Visual Reference') ?>" title="<?php echo __('Card Verification Number Visual Reference') ?>" />
                 </div>
diff --git a/app/code/Magento/Payment/view/frontend/form/ccsave.phtml b/app/code/Magento/Payment/view/frontend/form/ccsave.phtml
index 25a66a13ef903eb26aa7175cca3b145be919e4b1..5f3abdadc9b4b081c063ee1205399821ea11fbce 100644
--- a/app/code/Magento/Payment/view/frontend/form/ccsave.phtml
+++ b/app/code/Magento/Payment/view/frontend/form/ccsave.phtml
@@ -82,10 +82,10 @@
         <div class="control">
                 <input type="number" title="<?php echo __('Card Verification Number') ?>" class="input-text cvv" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" data-validate='{required:true, "validate-cc-cvn":"#<?php echo $_code ?>_cc_type"}'/>
             <div class="note">
-                <a href="#" class="action cvv" data-mage-init='{toggleAdvanced: {toggleContainers:"#ccv-save-tooltip"}}'><span><?php echo __('What is this?') ?></span></a>
+                <a href="#" class="action cvv" data-mage-init='{"toggleAdvanced": {"toggleContainers":"#ccv-save-tooltip"}}'><span><?php echo __('What is this?') ?></span></a>
             </div>
             <div class="tooltip hidden" id="ccv-save-tooltip">
-                <a data-mage-init='{toggleAdvanced: {toggleContainers:"#ccv-save-tooltip"}}' href="#" title="<?php echo __('Close') ?>" class="action close"><span><?php echo __('Close') ?></span></a>
+                <a data-mage-init='{"toggleAdvanced": {"toggleContainers":"#ccv-save-tooltip"}}' href="#" title="<?php echo __('Close') ?>" class="action close"><span><?php echo __('Close') ?></span></a>
                 <div class="content">
                     <img src="<?php echo $this->getViewFileUrl('Magento_Checkout::cvv.gif') ?>" alt="<?php echo __('Card Verification Number Visual Reference') ?>" title="<?php echo __('Card Verification Number Visual Reference') ?>" />
                 </div>
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement.php
similarity index 86%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement.php
index 9ee616c67fbf3a4b3422a084f2d3823cb674423a..dc3bd621092bcc1b7e6044cbee77ac2af60064b0 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreement grid container
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing;
+namespace Magento\Paypal\Block\Adminhtml\Billing;
 
 class Agreement extends \Magento\Backend\Block\Widget\Grid\Container
 {
@@ -40,7 +36,7 @@ class Agreement extends \Magento\Backend\Block\Widget\Grid\Container
     protected function _construct()
     {
         $this->_controller = 'adminhtml_billing_agreement';
-        $this->_blockGroup = 'Magento_Sales';
+        $this->_blockGroup = 'Magento_Paypal';
         $this->_headerText = __('Billing Agreements');
         parent::_construct();
         $this->_removeButton('add');
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php
similarity index 82%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php
index f21568db051d326acf8a7a92865fa9884e0ed834..b7f3db356c1e7394c7b20b27da2f0fb32bffd301 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php
@@ -18,55 +18,49 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreements grid
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement;
 
 class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 {
     /**
-     * Payment data
-     *
-     * @var \Magento\Payment\Helper\Data
+     * @var \Magento\Paypal\Helper\Data
      */
-    protected $_paymentData = null;
+    protected $_helper = null;
 
     /**
-     * @var \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory
      */
     protected $_agreementFactory;
 
     /**
-     * @var \Magento\Sales\Model\Billing\Agreement
+     * @var \Magento\Paypal\Model\Billing\Agreement
      */
     protected $_agreementModel;
 
     /**
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Backend\Helper\Data $backendHelper
-     * @param \Magento\Payment\Helper\Data $paymentData
-     * @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
-     * @param \Magento\Sales\Model\Billing\Agreement $agreementModel
+     * @param \Magento\Paypal\Helper\Data $helper
+     * @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
+     * @param \Magento\Paypal\Model\Billing\Agreement $agreementModel
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Backend\Helper\Data $backendHelper,
-        \Magento\Payment\Helper\Data $paymentData,
-        \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
-        \Magento\Sales\Model\Billing\Agreement $agreementModel,
+        \Magento\Paypal\Helper\Data $helper,
+        \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
+        \Magento\Paypal\Model\Billing\Agreement $agreementModel,
         array $data = array()
     ) {
-        $this->_paymentData = $paymentData;
+        $this->_helper = $helper;
         $this->_agreementFactory = $agreementFactory;
         $this->_agreementModel = $agreementModel;
         parent::__construct($context, $backendHelper, $data);
@@ -92,7 +86,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
      */
     public function getGridUrl()
     {
-        return $this->getUrl('sales/billing_agreement/grid', array('_current' => true));
+        return $this->getUrl('paypal/billing_agreement/grid', array('_current' => true));
     }
 
     /**
@@ -103,7 +97,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
      */
     public function getRowUrl($item)
     {
-        return $this->getUrl('sales/billing_agreement/view', array('agreement' => $item->getAgreementId()));
+        return $this->getUrl('paypal/billing_agreement/view', array('agreement' => $item->getAgreementId()));
     }
 
     /**
@@ -113,7 +107,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
      */
     protected function _prepareCollection()
     {
-        /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $collection */
+        /** @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection $collection */
         $collection = $this->_agreementFactory->create()
             ->addCustomerDetails();
         $this->setCollection($collection);
@@ -165,7 +159,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
             'header'            => __('Payment Method'),
             'index'             => 'method_code',
             'type'              => 'options',
-            'options'           => $this->_paymentData->getAllBillingAgreementMethods(),
+            'options'           => $this->_helper->getAllBillingAgreementMethods(),
             'header_css_class'  => 'col-payment',
             'column_css_class'  => 'col-payment'
         ));
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View.php
similarity index 90%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View.php
index 03499cfddc8888ff0cfb88327a0454498ca0c18c..ce8b172558d67d65394ac6e0d6b339103abcde01 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreement view
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement;
 
 class View extends \Magento\Backend\Block\Widget\Form\Container
 {
@@ -63,11 +59,11 @@ class View extends \Magento\Backend\Block\Widget\Form\Container
         $this->_objectId    = 'agreement';
         $this->_controller  = 'adminhtml_billing_agreement';
         $this->_mode        = 'view';
-        $this->_blockGroup  = 'Magento_Sales';
+        $this->_blockGroup  = 'Magento_Paypal';
 
         parent::_construct();
 
-        if (!$this->_isAllowed('Magento_Sales::actions_manage')) {
+        if (!$this->_isAllowed('Magento_Paypal::actions_manage')) {
             $this->_removeButton('delete');
         }
         $this->_removeButton('reset');
@@ -81,7 +77,7 @@ class View extends \Magento\Backend\Block\Widget\Form\Container
         ), -1);
 
         $agreement = $this->_getBillingAgreement();
-        if ($agreement && $agreement->canCancel() && $this->_isAllowed('Magento_Sales::actions_manage')) {
+        if ($agreement && $agreement->canCancel() && $this->_isAllowed('Magento_Paypal::actions_manage')) {
             $confirmText = __('Are you sure you want to do this?');
             $this->_addButton('cancel', array(
                 'label'     => __('Cancel'),
@@ -116,7 +112,7 @@ class View extends \Magento\Backend\Block\Widget\Form\Container
     /**
      * Retrieve billing agreement model
      *
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     protected function _getBillingAgreement()
     {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Form.php
similarity index 86%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Form.php
index 117e115db48df0fc6c77818b3c27a41a794680fd..46754f0d85bb03e48aeb155bfa4650bf9ee822a2 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Form.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Form.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreement view plane
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement\View;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View;
 
 class Form extends \Magento\Backend\Block\Template
 {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
similarity index 94%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
index fae56154761647a5a57a88eb0bf5da5b4f290524..c1e4c82731357eb7929c3afec5d3df6c410c29cd 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreement info tab
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab;
 
 class Info extends \Magento\Backend\Block\Template
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
@@ -106,7 +102,7 @@ class Info extends \Magento\Backend\Block\Template
     /**
      * Retrieve billing agreement model
      *
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     protected function _getBillingAgreement()
     {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php
similarity index 91%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php
index 99fb1502bc1b98211ee3d3d92d95a3f2b5907cfd..7911cfeff529d900a2f08fb440f069959d01907d 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/Orders.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreement related orders tab
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab;
 
 class Orders extends \Magento\View\Element\Text\ListText
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tabs.php
similarity index 88%
rename from app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tabs.php
index afb1b6b6ce51121d1b9e66ae49385cac263ecdb9..15be5c97f673713c2adb7a01b520a3edf868738c 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tabs.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tabs.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml billing agreements tabs view
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement\View;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View;
 
 class Tabs extends \Magento\Backend\Block\Widget\Tabs
 {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php b/app/code/Magento/Paypal/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
similarity index 82%
rename from app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
rename to app/code/Magento/Paypal/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
index 26967cda12b080af567f5b16ba3aef462df8c04b..cd7fa4af34ab1c5ee53fe54849cac8092f20f94e 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
+++ b/app/code/Magento/Paypal/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
@@ -18,21 +18,17 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Adminhtml customer billing agreement tab
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Customer\Edit\Tab;
+namespace Magento\Paypal\Block\Adminhtml\Customer\Edit\Tab;
 
 class Agreement
-    extends \Magento\Sales\Block\Adminhtml\Billing\Agreement\Grid
+    extends \Magento\Paypal\Block\Adminhtml\Billing\Agreement\Grid
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
     /**
@@ -52,18 +48,18 @@ class Agreement
     /**
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Backend\Helper\Data $backendHelper
-     * @param \Magento\Payment\Helper\Data $paymentData
-     * @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
-     * @param \Magento\Sales\Model\Billing\Agreement $agreementModel
+     * @param \Magento\Paypal\Helper\Data $helper
+     * @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
+     * @param \Magento\Paypal\Model\Billing\Agreement $agreementModel
      * @param \Magento\Core\Model\Registry $coreRegistry
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Backend\Helper\Data $backendHelper,
-        \Magento\Payment\Helper\Data $paymentData,
-        \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
-        \Magento\Sales\Model\Billing\Agreement $agreementModel,
+        \Magento\Paypal\Helper\Data $helper,
+        \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
+        \Magento\Paypal\Model\Billing\Agreement $agreementModel,
         \Magento\Core\Model\Registry $coreRegistry,
         array $data = array()
     ) {
@@ -71,7 +67,7 @@ class Agreement
         parent::__construct(
             $context,
             $backendHelper,
-            $paymentData,
+            $helper,
             $agreementFactory,
             $agreementModel,
             $data
@@ -131,7 +127,7 @@ class Agreement
 
     public function getGridUrl()
     {
-        return $this->getUrl('sales/billing_agreement/customerGrid', array('_current' => true));
+        return $this->getUrl('paypal/billing_agreement/customerGrid', array('_current' => true));
     }
 
     /**
@@ -147,7 +143,7 @@ class Agreement
     /**
      * Prepare collection for grid
      *
-     * @return \Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Agreement
+     * @return \Magento\Paypal\Block\Adminhtml\Customer\Edit\Tab\Agreement
      */
     protected function _prepareCollection()
     {
diff --git a/app/code/Magento/Sales/Block/Billing/Agreement/View.php b/app/code/Magento/Paypal/Block/Billing/Agreement/View.php
similarity index 89%
rename from app/code/Magento/Sales/Block/Billing/Agreement/View.php
rename to app/code/Magento/Paypal/Block/Billing/Agreement/View.php
index 1493ade7ffc04c242ed8824bfb9eb1e7c94c0e36..f20d35f33111fd78fd807e0f626b26128c97c548 100644
--- a/app/code/Magento/Sales/Block/Billing/Agreement/View.php
+++ b/app/code/Magento/Paypal/Block/Billing/Agreement/View.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Customer account billing agreement view block
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Billing\Agreement;
+namespace Magento\Paypal\Block\Billing\Agreement;
 
 class View extends \Magento\View\Element\Template
 {
@@ -43,7 +39,7 @@ class View extends \Magento\View\Element\Template
     /**
      * Billing Agreement instance
      *
-     * @var \Magento\Sales\Model\Billing\Agreement
+     * @var \Magento\Paypal\Model\Billing\Agreement
      */
     protected $_billingAgreementInstance = null;
 
@@ -77,9 +73,14 @@ class View extends \Magento\View\Element\Template
     protected $_orderConfig;
 
     /**
-     * @var \Magento\Payment\Helper\Data
+     * @var \Magento\Paypal\Helper\Data
+     */
+    protected $_helper;
+
+    /**
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement
      */
-    protected $_paymentHelper;
+    protected $_agreementResource;
 
     /**
      * @param \Magento\View\Element\Template\Context $context
@@ -87,7 +88,8 @@ class View extends \Magento\View\Element\Template
      * @param \Magento\Sales\Model\Resource\Order\CollectionFactory $orderCollectionFactory
      * @param \Magento\Customer\Model\Session $customerSession
      * @param \Magento\Sales\Model\Order\Config $orderConfig
-     * @param \Magento\Payment\Helper\Data $paymentHelper
+     * @param \Magento\Paypal\Helper\Data $helper
+     * @param \Magento\Paypal\Model\Resource\Billing\Agreement $agreementResource
      * @param array $data
      */
     public function __construct(
@@ -96,14 +98,16 @@ class View extends \Magento\View\Element\Template
         \Magento\Sales\Model\Resource\Order\CollectionFactory $orderCollectionFactory,
         \Magento\Customer\Model\Session $customerSession,
         \Magento\Sales\Model\Order\Config $orderConfig,
-        \Magento\Payment\Helper\Data $paymentHelper,
+        \Magento\Paypal\Helper\Data $helper,
+        \Magento\Paypal\Model\Resource\Billing\Agreement $agreementResource,
         array $data = array()
     ) {
-        $this->_paymentHelper = $paymentHelper;
+        $this->_helper = $helper;
         $this->_orderCollectionFactory = $orderCollectionFactory;
         $this->_customerSession = $customerSession;
         $this->_orderConfig = $orderConfig;
         $this->_coreRegistry = $registry;
+        $this->_agreementResource = $agreementResource;
         parent::__construct($context, $data);
         $this->_isScopePrivate = true;
     }
@@ -125,8 +129,8 @@ class View extends \Magento\View\Element\Template
                     'state',
                     array('in' => $this->_orderConfig->getVisibleOnFrontStates())
                 )
-                ->addBillingAgreementsFilter($billingAgreementId)
                 ->setOrder('created_at', 'desc');
+            $this->_agreementResource->addOrdersFilter($this->_relatedOrders, $billingAgreementId);
         }
         return $this->_relatedOrders;
     }
@@ -189,7 +193,7 @@ class View extends \Magento\View\Element\Template
     /**
      * Return current billing agreement.
      *
-     * @return \Magento\Sales\Model\Billing\Agreement|null
+     * @return \Magento\Paypal\Model\Billing\Agreement|null
      */
     protected function _getBillingAgreementInstance()
     {
@@ -207,7 +211,7 @@ class View extends \Magento\View\Element\Template
     protected function _loadPaymentMethods()
     {
         if (!$this->_paymentMethods) {
-            foreach ($this->_paymentHelper->getBillingAgreementMethods() as $paymentMethod) {
+            foreach ($this->_helper->getBillingAgreementMethods() as $paymentMethod) {
                 $this->_paymentMethods[$paymentMethod->getCode()] = $paymentMethod->getTitle();
             }
         }
@@ -240,7 +244,7 @@ class View extends \Magento\View\Element\Template
             $createdAt = $billingAgreement->getCreatedAt();
             $updatedAt = $billingAgreement->getUpdatedAt();
             $this->setAgreementCreatedAt(
-                ($createdAt)
+                $createdAt
                     ? $this->formatDate($createdAt, 'short', true)
                     : __('N/A')
             );
diff --git a/app/code/Magento/Sales/Block/Billing/Agreements.php b/app/code/Magento/Paypal/Block/Billing/Agreements.php
similarity index 78%
rename from app/code/Magento/Sales/Block/Billing/Agreements.php
rename to app/code/Magento/Paypal/Block/Billing/Agreements.php
index d1acdb294875654cb7ca26726e05c1abe0245ead..6499e65e1dbe4bee8e3d624fbc21cd2f438ffda6 100644
--- a/app/code/Magento/Sales/Block/Billing/Agreements.php
+++ b/app/code/Magento/Paypal/Block/Billing/Agreements.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Customer account billing agreements block
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Billing;
+namespace Magento\Paypal\Block\Billing;
 
 class Agreements extends \Magento\View\Element\Template
 {
@@ -43,7 +39,7 @@ class Agreements extends \Magento\View\Element\Template
     /**
      * Billing agreements collection
      *
-     * @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection
      */
     protected $_billingAgreements = null;
 
@@ -53,30 +49,30 @@ class Agreements extends \Magento\View\Element\Template
     protected $_customerSession;
 
     /**
-     * @var \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory
      */
     protected $_agreementCollection;
 
     /**
-     * @var \Magento\Payment\Helper\Data
+     * @var \Magento\Paypal\Helper\Data
      */
-    protected $_paymentHelper;
+    protected $_helper;
 
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementCollection
-     * @param \Magento\Payment\Helper\Data $paymentHelper
+     * @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementCollection
+     * @param \Magento\Paypal\Helper\Data $helper
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementCollection,
-        \Magento\Payment\Helper\Data $paymentHelper,
+        \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementCollection,
+        \Magento\Paypal\Helper\Data $helper,
         array $data = array()
     ) {
-        $this->_paymentHelper = $paymentHelper;
+        $this->_helper = $helper;
         $this->_customerSession = $customerSession;
         $this->_agreementCollection = $agreementCollection;
         parent::__construct($context, $data);
@@ -102,7 +98,7 @@ class Agreements extends \Magento\View\Element\Template
     /**
      * Retrieve billing agreements collection
      *
-     * @return \Magento\Sales\Model\Resource\Billing\Agreement\Collection
+     * @return \Magento\Paypal\Model\Resource\Billing\Agreement\Collection
      */
     public function getBillingAgreements()
     {
@@ -117,16 +113,16 @@ class Agreements extends \Magento\View\Element\Template
     /**
      * Retrieve item value by key
      *
-     * @param \Magento\Object|\Magento\Sales\Model\Billing\Agreement $item
+     * @param \Magento\Object|\Magento\Paypal\Model\Billing\Agreement $item
      * @param string $key
      * @return mixed
      */
-    public function getItemValue(\Magento\Sales\Model\Billing\Agreement $item, $key)
+    public function getItemValue(\Magento\Paypal\Model\Billing\Agreement $item, $key)
     {
         switch ($key) {
             case 'created_at':
             case 'updated_at':
-                $value = ($item->getData($key))
+                $value = $item->getData($key)
                     ? $this->formatDate($item->getData($key), 'short', true)
                     : __('N/A');
                 break;
@@ -135,13 +131,13 @@ class Agreements extends \Magento\View\Element\Template
                 break;
             case 'payment_method_label':
                 $label = $item->getAgreementLabel();
-                $value = ($label) ? $label : __('N/A');
+                $value = $label ? $label : __('N/A');
                 break;
             case 'status':
                 $value = $item->getStatusLabel();
                 break;
             default:
-                $value = ($item->getData($key)) ? $item->getData($key) : __('N/A');
+                $value = $item->getData($key) ? $item->getData($key) : __('N/A');
                 break;
         }
         return $this->escapeHtml($value);
@@ -155,7 +151,7 @@ class Agreements extends \Magento\View\Element\Template
     protected function _loadPaymentMethods()
     {
         if (!$this->_paymentMethods) {
-            foreach ($this->_paymentHelper->getBillingAgreementMethods() as $paymentMethod) {
+            foreach ($this->_helper->getBillingAgreementMethods() as $paymentMethod) {
                 $this->_paymentMethods[$paymentMethod->getCode()] = $paymentMethod->getTitle();
             }
         }
@@ -170,7 +166,7 @@ class Agreements extends \Magento\View\Element\Template
     public function getWizardPaymentMethodOptions()
     {
         $paymentMethodOptions = array();
-        foreach ($this->_paymentHelper->getBillingAgreementMethods() as $paymentMethod) {
+        foreach ($this->_helper->getBillingAgreementMethods() as $paymentMethod) {
             if ($paymentMethod->getConfigData('allow_billing_agreement_wizard') == 1) {
                 $paymentMethodOptions[$paymentMethod->getCode()] = $paymentMethod->getTitle();
             }
diff --git a/app/code/Magento/Paypal/Block/Checkout/Onepage/Success/BillingAgreement.php b/app/code/Magento/Paypal/Block/Checkout/Onepage/Success/BillingAgreement.php
new file mode 100644
index 0000000000000000000000000000000000000000..0ddb101ff76270740a0928a3a6b7bbadcbd35e4c
--- /dev/null
+++ b/app/code/Magento/Paypal/Block/Checkout/Onepage/Success/BillingAgreement.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+/**
+ * Billing agreement information on Order success page
+ */
+namespace Magento\Paypal\Block\Checkout\Onepage\Success;
+
+class BillingAgreement extends \Magento\View\Element\Template
+{
+    /**
+     * @var \Magento\Checkout\Model\Session
+     */
+    protected $_checkoutSession;
+
+    /**
+     * @var \Magento\Customer\Model\Session
+     */
+    protected $_customerSession;
+
+    /**
+     * @var \Magento\Paypal\Model\Billing\AgreementFactory
+     */
+    protected $_agreementFactory;
+
+    /**
+     * @param \Magento\View\Element\Template\Context $context
+     * @param \Magento\Checkout\Model\Session $checkoutSession
+     * @param \Magento\Customer\Model\Session $customerSession
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
+     * @param array $data
+     */
+    public function __construct(
+        \Magento\View\Element\Template\Context $context,
+        \Magento\Checkout\Model\Session $checkoutSession,
+        \Magento\Customer\Model\Session $customerSession,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory,
+        array $data = array()
+    ) {
+        $this->_checkoutSession = $checkoutSession;
+        $this->_customerSession = $customerSession;
+        $this->_agreementFactory = $agreementFactory;
+        parent::__construct($context, $data);
+    }
+
+    /**
+     * Return billing agreement information
+     *
+     * @return string
+     */
+    protected function _toHtml()
+    {
+        $agreementReferenceId = $this->_checkoutSession->getLastBillingAgreementReferenceId();
+        $customerId = $this->_customerSession->getCustomerId();
+        if (!$agreementReferenceId || !$customerId) {
+            return '';
+        }
+        $agreement = $this->_agreementFactory->create()->load($agreementReferenceId, 'reference_id');
+        if ($agreement->getId() && $customerId == $agreement->getCustomerId()) {
+            $this->addData(array(
+                'agreement_ref_id' => $agreement->getReferenceId(),
+                'agreement_url'    => $this->getUrl(
+                    'paypal/billing_agreement/view',
+                    array('agreement' => $agreement->getId())
+                )
+            ));
+            return parent::_toHtml();
+        }
+        return '';
+    }
+}
diff --git a/app/code/Magento/Paypal/Block/Express/Form.php b/app/code/Magento/Paypal/Block/Express/Form.php
index 0d3becb661669aa860c7d0955794f1f68e94c17e..b3c224442432619509690b7e4a0118b9abac91f3 100644
--- a/app/code/Magento/Paypal/Block/Express/Form.php
+++ b/app/code/Magento/Paypal/Block/Express/Form.php
@@ -81,18 +81,14 @@ class Form extends \Magento\Paypal\Block\Standard\Form
     }
 
     /**
-     * Set data to block
+     * Get billing agreement code
      *
-     * @return \Magento\View\Element\AbstractBlock
+     * @return string|null
      */
-    protected function _beforeToHtml()
+    public function getBillingAgreementCode()
     {
         $customerId = $this->_customerSession->getCustomerId();
-        if ($this->_paypalData->shouldAskToCreateBillingAgreement($this->_config, $customerId)
-            && $this->canCreateBillingAgreement()
-        ) {
-            $this->setCreateBACode(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
-        }
-        return parent::_beforeToHtml();
+        return $this->_paypalData->shouldAskToCreateBillingAgreement($this->_config, $customerId)
+            ? \Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT : null;
     }
 }
diff --git a/app/code/Magento/Paypal/Block/Express/Shortcut.php b/app/code/Magento/Paypal/Block/Express/Shortcut.php
index 8d12c03ee2d4133abfeda6bb77f8559fa8e0fbf1..57070b764b6117cd9b58f17288268af93bdc2524 100644
--- a/app/code/Magento/Paypal/Block/Express/Shortcut.php
+++ b/app/code/Magento/Paypal/Block/Express/Shortcut.php
@@ -29,14 +29,10 @@
  */
 namespace Magento\Paypal\Block\Express;
 
-class Shortcut extends \Magento\View\Element\Template
-{
-    /**
-     * Position of "OR" label against shortcut
-     */
-    const POSITION_BEFORE = 'before';
-    const POSITION_AFTER = 'after';
+use Magento\Catalog\Block as CatalogBlock;
 
+class Shortcut extends \Magento\View\Element\Template implements CatalogBlock\ShortcutInterface
+{
     /**
      * Whether the block should be eventually rendered
      *
@@ -136,10 +132,10 @@ class Shortcut extends \Magento\View\Element\Template
         \Magento\Core\Model\Registry $registry,
         \Magento\Customer\Model\Session $customerSession,
         \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory,
-        \Magento\Checkout\Model\Session $checkoutSession,
         \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory,
         \Magento\Math\Random $mathRandom,
         \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
+        \Magento\Checkout\Model\Session $checkoutSession = null,
         array $data = array()
     ) {
         $this->_registry = $registry;
@@ -164,7 +160,7 @@ class Shortcut extends \Magento\View\Element\Template
         $params = array($this->_paymentMethodCode);
         $config = $this->_paypalConfigFactory->create(array('params' => $params));
         $isInCatalog = $this->getIsInCatalogProduct();
-        $quote = ($isInCatalog || '' == $this->getIsQuoteAllowed()) ? null : $this->_checkoutSession->getQuote();
+        $quote = ($isInCatalog || !$this->_checkoutSession) ? null : $this->_checkoutSession->getQuote();
 
         // check visibility on cart or product page
         $context = $isInCatalog ? 'visible_on_product' : 'visible_on_cart';
@@ -251,8 +247,7 @@ class Shortcut extends \Magento\View\Element\Template
      */
     public function isOrPositionBefore()
     {
-        return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition())
-            || ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
+        return $this->getShowOrPosition() == CatalogBlock\ShortcutButtons::POSITION_BEFORE;
 
     }
 
@@ -263,7 +258,16 @@ class Shortcut extends \Magento\View\Element\Template
      */
     public function isOrPositionAfter()
     {
-        return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition())
-            || ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
+        return $this->getShowOrPosition() == CatalogBlock\ShortcutButtons::POSITION_AFTER;
+    }
+
+    /**
+     * Get shortcut alias
+     *
+     * @return string
+     */
+    public function getAlias()
+    {
+        return 'product.info.addtocart.paypal';
     }
 }
diff --git a/app/code/Magento/Paypal/Block/PayflowExpress/Form.php b/app/code/Magento/Paypal/Block/PayflowExpress/Form.php
index f6cf2bc63e289f6dcb0f944c56f2af8cd7225a7d..5db103346283026452a26c8a618d950bbf592d56 100644
--- a/app/code/Magento/Paypal/Block/PayflowExpress/Form.php
+++ b/app/code/Magento/Paypal/Block/PayflowExpress/Form.php
@@ -32,4 +32,14 @@ class Form extends \Magento\Paypal\Block\Express\Form
      * @var string
      */
     protected $_methodCode = \Magento\Paypal\Model\Config::METHOD_WPP_PE_EXPRESS;
+
+    /**
+     * No billing agreements available for payflow express
+     *
+     * @return string|null
+     */
+    public function getBillingAgreementCode()
+    {
+        return false;
+    }
 }
diff --git a/app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.php b/app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.php
index bc659ec1b76c3444f3dcdd1c1c22a6166816497b..adbf3c76148c20bfc98cba6ea7dd3fcefcc07c82 100644
--- a/app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.php
+++ b/app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.php
@@ -49,4 +49,14 @@ class Shortcut extends \Magento\Paypal\Block\Express\Shortcut
      * @var string
      */
     protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout';
+
+    /**
+     * Get shortcut alias
+     *
+     * @return string
+     */
+    public function getAlias()
+    {
+        return 'product.info.addtocart.payflow';
+    }
 }
diff --git a/app/code/Magento/Sales/Block/Payment/Form/Billing/Agreement.php b/app/code/Magento/Paypal/Block/Payment/Form/Billing/Agreement.php
similarity index 80%
rename from app/code/Magento/Sales/Block/Payment/Form/Billing/Agreement.php
rename to app/code/Magento/Paypal/Block/Payment/Form/Billing/Agreement.php
index 9e483abd50235402b4e8e083c53d417a9e51ee3e..ad2caa847ca9cae6e9038caf83ac4afa8a5aa33d 100644
--- a/app/code/Magento/Sales/Block/Payment/Form/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Block/Payment/Form/Billing/Agreement.php
@@ -18,37 +18,35 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
- * Sales Billing Agreement form block
+ * Paypal Billing Agreement form block
  */
-namespace Magento\Sales\Block\Payment\Form\Billing;
+namespace Magento\Paypal\Block\Payment\Form\Billing;
 
 class Agreement extends \Magento\Payment\Block\Form
 {
     /**
      * @var string
      */
-    protected $_template = 'Magento_Sales::payment/form/billing/agreement.phtml';
+    protected $_template = 'Magento_Paypal::payment/form/billing/agreement.phtml';
 
     /**
-     * @var \Magento\Sales\Model\Billing\AgreementFactory
+     * @var \Magento\Paypal\Model\Billing\AgreementFactory
      */
     protected $_agreementFactory;
 
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory,
         array $data = array()
     ) {
         $this->_agreementFactory = $agreementFactory;
@@ -61,7 +59,7 @@ class Agreement extends \Magento\Payment\Block\Form
         parent::_construct();
 
         $this->setTransportName(
-            \Magento\Sales\Model\Payment\Method\Billing\AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID
+            \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID
         );
     }
 
diff --git a/app/code/Magento/Sales/Block/Payment/Info/Billing/Agreement.php b/app/code/Magento/Paypal/Block/Payment/Info/Billing/Agreement.php
similarity index 79%
rename from app/code/Magento/Sales/Block/Payment/Info/Billing/Agreement.php
rename to app/code/Magento/Paypal/Block/Payment/Info/Billing/Agreement.php
index bb7f1af9cd3d422c928d03107a13c2c36b0b3e05..3fb2538d7c449478bc66520a77e8c1b14998e954 100644
--- a/app/code/Magento/Sales/Block/Payment/Info/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Block/Payment/Info/Billing/Agreement.php
@@ -18,25 +18,22 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
- * Sales Billing Agreement info block
- *
- * @author Magento Core Team <core@magentocommerce.com>
+ * Billing Agreement info block
  */
-namespace Magento\Sales\Block\Payment\Info\Billing;
+namespace Magento\Paypal\Block\Payment\Info\Billing;
 
 class Agreement extends \Magento\Payment\Block\Info
 {
-/**
+    /**
      * Add reference id to payment method information
      *
-     * @param \Magento\Object|array $transport
+     * @param \Magento\Object|array|null $transport
+     * @return \Magento\Object
      */
     protected function _prepareSpecificInformation($transport = null)
     {
@@ -45,9 +42,9 @@ class Agreement extends \Magento\Payment\Block\Info
         }
         $info = $this->getInfo();
         $referenceID = $info->getAdditionalInformation(
-            \Magento\Sales\Model\Payment\Method\Billing\AbstractAgreement::PAYMENT_INFO_REFERENCE_ID
+            \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::PAYMENT_INFO_REFERENCE_ID
         );
-        $transport = new \Magento\Object(array((string)__('Reference ID') => $referenceID,));
+        $transport = new \Magento\Object(array((string)__('Reference ID') => $referenceID));
         $transport = parent::_prepareSpecificInformation($transport);
 
         return $transport;
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php
similarity index 86%
rename from app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php
rename to app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php
index 9a8ae0c9627f24922a139c3c6a06c9711ad1174c..8ee9d36e99ab0ac08a88c07b5b3decc29d27aa26 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Adminhtml billing agreement controller
  */
-namespace Magento\Sales\Controller\Adminhtml\Billing;
+namespace Magento\Paypal\Controller\Adminhtml\Billing;
 
 class Agreement extends \Magento\Backend\App\Action
 {
@@ -59,7 +57,7 @@ class Agreement extends \Magento\Backend\App\Action
         $this->_title->add(__('Billing Agreements'));
 
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Sales::sales_billing_agreement');
+        $this->_setActiveMenu('Magento_Paypal::paypal_billing_agreement');
         $this->_view->renderLayout();
     }
 
@@ -86,12 +84,12 @@ class Agreement extends \Magento\Backend\App\Action
             $this->_title->add(sprintf("#%s", $agreementModel->getReferenceId()));
 
             $this->_view->loadLayout();
-            $this->_setActiveMenu('Magento_Sales::sales_billing_agreement');
+            $this->_setActiveMenu('Magento_Paypal::paypal_billing_agreement');
             $this->_view->renderLayout();
             return;
         }
 
-        $this->_redirect('sales/*/');
+        $this->_redirect('paypal/*/');
         return;
     }
 
@@ -129,7 +127,7 @@ class Agreement extends \Magento\Backend\App\Action
             try {
                 $agreementModel->cancel();
                 $this->messageManager->addSuccess(__('You canceled the billing agreement.'));
-                $this->_redirect('sales/*/view', array('_current' => true));
+                $this->_redirect('paypal/*/view', array('_current' => true));
                 return;
             } catch (\Magento\Core\Exception $e) {
                 $this->messageManager->addError($e->getMessage());
@@ -137,9 +135,9 @@ class Agreement extends \Magento\Backend\App\Action
                 $this->messageManager->addError(__('We could not cancel the billing agreement.'));
                 $this->_objectManager->get('Magento\Logger')->logException($e);
             }
-            $this->_redirect('sales/*/view', array('_current' => true));
+            $this->_redirect('paypal/*/view', array('_current' => true));
         }
-        return $this->_redirect('sales/*/');
+        return $this->_redirect('paypal/*/');
     }
 
     /**
@@ -153,7 +151,7 @@ class Agreement extends \Magento\Backend\App\Action
             try {
                 $agreementModel->delete();
                 $this->messageManager->addSuccess(__('You deleted the billing agreement.'));
-                $this->_redirect('sales/*/');
+                $this->_redirect('paypal/*/');
                 return;
             } catch (\Magento\Core\Exception $e) {
                 $this->messageManager->addError($e->getMessage());
@@ -161,20 +159,20 @@ class Agreement extends \Magento\Backend\App\Action
                 $this->messageManager->addError(__('We could not delete the billing agreement.'));
                 $this->_objectManager->get('Magento\Logger')->logException($e);
             }
-            $this->_redirect('sales/*/view', array('_current' => true));
+            $this->_redirect('paypal/*/view', array('_current' => true));
         }
-        $this->_redirect('sales/*/');
+        $this->_redirect('paypal/*/');
     }
 
     /**
      * Initialize billing agreement by ID specified in request
      *
-     * @return \Magento\Sales\Model\Billing\Agreement | false
+     * @return \Magento\Paypal\Model\Billing\Agreement | false
      */
     protected function _initBillingAgreement()
     {
         $agreementId = $this->getRequest()->getParam('agreement');
-        $agreementModel = $this->_objectManager->create('Magento\Sales\Model\Billing\Agreement')->load($agreementId);
+        $agreementModel = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement')->load($agreementId);
 
         if (!$agreementModel->getId()) {
             $this->messageManager->addError(__('Please specify the correct billing agreement ID and try again.'));
@@ -188,7 +186,7 @@ class Agreement extends \Magento\Backend\App\Action
     /**
      * Initialize customer by ID specified in request
      *
-     * @return \Magento\Sales\Controller\Adminhtml\Billing\Agreement
+     * @return \Magento\Paypal\Controller\Adminhtml\Billing\Agreement
      */
     protected function _initCustomer()
     {
@@ -210,12 +208,12 @@ class Agreement extends \Magento\Backend\App\Action
             case 'index':
             case 'grid' :
             case 'view' :
-                return $this->_authorization->isAllowed('Magento_Sales::billing_agreement_actions_view');
+                return $this->_authorization->isAllowed('Magento_Paypal::billing_agreement_actions_view');
             case 'cancel':
             case 'delete':
-                return $this->_authorization->isAllowed('Magento_Sales::actions_manage');
+                return $this->_authorization->isAllowed('Magento_Paypal::actions_manage');
             default:
-                return $this->_authorization->isAllowed('Magento_Sales::billing_agreement');
+                return $this->_authorization->isAllowed('Magento_Paypal::billing_agreement');
         }
     }
 }
diff --git a/app/code/Magento/Sales/Controller/Billing/Agreement.php b/app/code/Magento/Paypal/Controller/Billing/Agreement.php
similarity index 93%
rename from app/code/Magento/Sales/Controller/Billing/Agreement.php
rename to app/code/Magento/Paypal/Controller/Billing/Agreement.php
index e5e63f5cad58a03a303124db27776199d2e55105..3f5c76023cf2651ddaa5a5e60e2275d462e80d49 100644
--- a/app/code/Magento/Sales/Controller/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Controller/Billing/Agreement.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Billing agreements controller
  */
-namespace Magento\Sales\Controller\Billing;
+namespace Magento\Paypal\Controller\Billing;
 
 use Magento\App\RequestInterface;
 
@@ -104,7 +102,7 @@ class Agreement extends \Magento\App\Action\Action
         $this->_view->getLayout()->initMessages();
         $navigationBlock = $this->_view->getLayout()->getBlock('customer_account_navigation');
         if ($navigationBlock) {
-            $navigationBlock->setActive('sales/billing_agreement/');
+            $navigationBlock->setActive('paypal/billing_agreement/');
         }
         $this->_view->renderLayout();
     }
@@ -115,7 +113,7 @@ class Agreement extends \Magento\App\Action\Action
      */
     public function startWizardAction()
     {
-        $agreement = $this->_objectManager->create('Magento\Sales\Model\Billing\Agreement');
+        $agreement = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement');
         $paymentCode = $this->getRequest()->getParam('payment_method');
         if ($paymentCode) {
             try {
@@ -144,7 +142,7 @@ class Agreement extends \Magento\App\Action\Action
      */
     public function returnWizardAction()
     {
-        $agreement = $this->_objectManager->create('Magento\Sales\Model\Billing\Agreement');
+        $agreement = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement');
         $paymentCode = $this->getRequest()->getParam('payment_method');
         $token = $this->getRequest()->getParam('token');
         if ($token && $paymentCode) {
@@ -209,14 +207,14 @@ class Agreement extends \Magento\App\Action\Action
     /**
      * Init billing agreement model from request
      *
-     * @return \Magento\Sales\Model\Billing\Agreement|bool
+     * @return \Magento\Paypal\Model\Billing\Agreement|bool
      */
     protected function _initAgreement()
     {
         $agreementId = $this->getRequest()->getParam('agreement');
         if ($agreementId) {
-            /** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */
-            $billingAgreement = $this->_objectManager->create('Magento\Sales\Model\Billing\Agreement')
+            /** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */
+            $billingAgreement = $this->_objectManager->create('Magento\Paypal\Model\Billing\Agreement')
                 ->load($agreementId);
             $currentCustomerId = $this->_getSession()->getCustomerId();
             $agreementCustomerId = $billingAgreement->getCustomerId();
diff --git a/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php b/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php
index 8871cc6223f81222bac25af012a428cbe8d4ad81..1c72c05f8a38ac1e6731372a074734b859aa6a48 100644
--- a/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php
+++ b/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php
@@ -412,11 +412,6 @@ abstract class AbstractExpress extends \Magento\App\Action\Action
             if ($order) {
                 $this->_getCheckoutSession()->setLastOrderId($order->getId())
                     ->setLastRealOrderId($order->getIncrementId());
-                // as well a billing agreement can be created
-                $agreement = $this->_checkout->getBillingAgreement();
-                if ($agreement) {
-                    $this->_getCheckoutSession()->setLastBillingAgreementId($agreement->getId());
-                }
             }
 
             // recurring profiles may be created along with the order or without it
diff --git a/app/code/Magento/Paypal/Helper/Data.php b/app/code/Magento/Paypal/Helper/Data.php
index 145809949fc848a455da9997114372dd61bef325..cbc29ce28e3818f952c2ca6a5a2488748cd733f1 100644
--- a/app/code/Magento/Paypal/Helper/Data.php
+++ b/app/code/Magento/Paypal/Helper/Data.php
@@ -44,21 +44,29 @@ class Data extends \Magento\App\Helper\AbstractHelper
     protected $_coreData;
 
     /**
-     * @var \Magento\Sales\Model\Billing\AgreementFactory
+     * @var \Magento\Payment\Helper\Data
+     */
+    protected $_paymentData;
+
+    /**
+     * @var \Magento\Paypal\Model\Billing\AgreementFactory
      */
     protected $_agreementFactory;
 
     /**
      * @param \Magento\App\Helper\Context $context
      * @param \Magento\Core\Helper\Data $coreData
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
+     * @param \Magento\Payment\Helper\Data $paymentData
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
      */
     public function __construct(
         \Magento\App\Helper\Context $context,
         \Magento\Core\Helper\Data $coreData,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
+        \Magento\Payment\Helper\Data $paymentData,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
     ) {
         $this->_coreData = $coreData;
+        $this->_paymentData = $paymentData;
         $this->_agreementFactory = $agreementFactory;
         parent::__construct($context);
     }
@@ -83,6 +91,56 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return self::$_shouldAskToCreateBillingAgreement;
     }
 
+    /**
+     * Retrieve available billing agreement methods
+     *
+     * @param mixed $store
+     * @param \Magento\Sales\Model\Quote $quote
+     * @return array
+     */
+    public function getBillingAgreementMethods($store = null, $quote = null)
+    {
+        $result = array();
+        foreach ($this->_paymentData->getStoreMethods($store, $quote) as $method) {
+            if ($this->canManageBillingAgreements($method)) {
+                $result[] = $method;
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * Retrieve all billing agreement methods (code and label)
+     *
+     * @return array
+     */
+    public function getAllBillingAgreementMethods()
+    {
+        $result = array();
+        $interface = 'Magento\Paypal\Model\Billing\Agreement\MethodInterface';
+        foreach ($this->_paymentData->getPaymentMethods() as $code => $data) {
+            if (!isset($data['model'])) {
+                continue;
+            }
+            $method = $data['model'];
+            if (in_array($interface, class_implements($method))) {
+                $result[$code] = $data['title'];
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * Check whether payment method can manage billing agreements or not
+     *
+     * @param mixed $methodInstance
+     * @return bool
+     */
+    public function canManageBillingAgreements($methodInstance)
+    {
+        return ($methodInstance instanceof \Magento\Paypal\Model\Billing\Agreement\MethodInterface);
+    }
+
     /**
      * Return backend config for element like JSON
      *
diff --git a/app/code/Magento/Payment/Model/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php
similarity index 96%
rename from app/code/Magento/Payment/Model/Billing/AbstractAgreement.php
rename to app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php
index 1a608e82de51bff7f84c4646aaf98efbc269da0d..ad8f0d143360074a14dd783fe6982c54d88f13b4 100644
--- a/app/code/Magento/Payment/Model/Billing/AbstractAgreement.php
+++ b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php
@@ -18,18 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Payment
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Billing Agreement abstaract class
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Payment\Model\Billing;
+namespace Magento\Paypal\Model\Billing;
 
 abstract class AbstractAgreement extends \Magento\Core\Model\AbstractModel
 {
diff --git a/app/code/Magento/Sales/Model/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Billing/Agreement.php
similarity index 84%
rename from app/code/Magento/Sales/Model/Billing/Agreement.php
rename to app/code/Magento/Paypal/Model/Billing/Agreement.php
index 100068c20141b0cf046c2781d39a153aab12e269..e8c1ef949ff83563aca0a340706db8d3c1eb69fb 100644
--- a/app/code/Magento/Sales/Model/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Model/Billing/Agreement.php
@@ -18,37 +18,35 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Model\Billing;
+namespace Magento\Paypal\Model\Billing;
 
 /**
  * Billing Agreement abstract model
  *
- * @method \Magento\Sales\Model\Resource\Billing\Agreement _getResource()
- * @method \Magento\Sales\Model\Resource\Billing\Agreement getResource()
+ * @method \Magento\Paypal\Model\Resource\Billing\Agreement _getResource()
+ * @method \Magento\Paypal\Model\Resource\Billing\Agreement getResource()
  * @method int getCustomerId()
- * @method \Magento\Sales\Model\Billing\Agreement setCustomerId(int $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setCustomerId(int $value)
  * @method string getMethodCode()
- * @method \Magento\Sales\Model\Billing\Agreement setMethodCode(string $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setMethodCode(string $value)
  * @method string getReferenceId()
- * @method \Magento\Sales\Model\Billing\Agreement setReferenceId(string $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setReferenceId(string $value)
  * @method string getStatus()
- * @method \Magento\Sales\Model\Billing\Agreement setStatus(string $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setStatus(string $value)
  * @method string getCreatedAt()
- * @method \Magento\Sales\Model\Billing\Agreement setCreatedAt(string $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setCreatedAt(string $value)
  * @method string getUpdatedAt()
- * @method \Magento\Sales\Model\Billing\Agreement setUpdatedAt(string $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setUpdatedAt(string $value)
  * @method int getStoreId()
- * @method \Magento\Sales\Model\Billing\Agreement setStoreId(int $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setStoreId(int $value)
  * @method string getAgreementLabel()
- * @method \Magento\Sales\Model\Billing\Agreement setAgreementLabel(string $value)
+ * @method \Magento\Paypal\Model\Billing\Agreement setAgreementLabel(string $value)
  */
-class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
+class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement
 {
     const STATUS_ACTIVE     = 'active';
     const STATUS_CANCELED   = 'canceled';
@@ -61,7 +59,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
     protected $_relatedOrders = array();
 
     /**
-     * @var \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory
      */
     protected $_billingAgreementFactory;
 
@@ -74,7 +72,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Payment\Helper\Data $paymentData
-     * @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory
+     * @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory
      * @param \Magento\Core\Model\DateFactory $dateFactory
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
@@ -84,7 +82,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Payment\Helper\Data $paymentData,
-        \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory,
+        \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory,
         \Magento\Core\Model\DateFactory $dateFactory,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
@@ -100,7 +98,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
      */
     protected function _construct()
     {
-        $this->_init('Magento\Sales\Model\Resource\Billing\Agreement');
+        $this->_init('Magento\Paypal\Model\Resource\Billing\Agreement');
     }
 
     /**
@@ -165,7 +163,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
      * Get billing agreement details
      * Data from response is inside this object
      *
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     public function verifyToken()
     {
@@ -177,7 +175,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
     /**
      * Create billing agreement
      *
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     public function place()
     {
@@ -198,7 +196,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
     /**
      * Cancel billing agreement
      *
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     public function cancel()
     {
@@ -255,7 +253,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
      *  [method_code]           => string
      *
      * @param \Magento\Sales\Model\Order\Payment $payment
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     public function importOrderPayment(\Magento\Sales\Model\Order\Payment $payment)
     {
@@ -278,7 +276,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
      * Retrieve available customer Billing Agreements
      *
      * @param int $customerId
-     * @return \Magento\Sales\Model\Resource\Billing\Agreement\Collection
+     * @return \Magento\Paypal\Model\Resource\Billing\Agreement\Collection
      */
     public function getAvailableCustomerBillingAgreements($customerId)
     {
@@ -304,7 +302,7 @@ class Agreement extends \Magento\Payment\Model\Billing\AbstractAgreement
      * Add order relation to current billing agreement
      *
      * @param int|\Magento\Sales\Model\Order $orderId
-     * @return \Magento\Sales\Model\Billing\Agreement
+     * @return \Magento\Paypal\Model\Billing\Agreement
      */
     public function addOrderRelation($orderId)
     {
diff --git a/app/code/Magento/Payment/Model/Billing/Agreement/MethodInterface.php b/app/code/Magento/Paypal/Model/Billing/Agreement/MethodInterface.php
similarity index 58%
rename from app/code/Magento/Payment/Model/Billing/Agreement/MethodInterface.php
rename to app/code/Magento/Paypal/Model/Billing/Agreement/MethodInterface.php
index 4174a90915b099f20925cbb72a525b1cb5049ee7..496ad405c1cfe88893e19e5628f0f70030eced56 100644
--- a/app/code/Magento/Payment/Model/Billing/Agreement/MethodInterface.php
+++ b/app/code/Magento/Paypal/Model/Billing/Agreement/MethodInterface.php
@@ -18,46 +18,42 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Payment
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
  * Interface for payment methods that support billing agreements management
- *
- * @author Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Payment\Model\Billing\Agreement;
+namespace Magento\Paypal\Model\Billing\Agreement;
 
 interface MethodInterface
 {
     /**
      * Init billing agreement
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      */
-    public function initBillingAgreementToken(\Magento\Payment\Model\Billing\AbstractAgreement $agreement);
+    public function initBillingAgreementToken(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement);
 
     /**
      * Retrieve billing agreement details
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      */
-    public function getBillingAgreementTokenInfo(\Magento\Payment\Model\Billing\AbstractAgreement $agreement);
+    public function getBillingAgreementTokenInfo(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement);
 
     /**
      * Create billing agreement
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      */
-    public function placeBillingAgreement(\Magento\Payment\Model\Billing\AbstractAgreement $agreement);
+    public function placeBillingAgreement(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement);
 
     /**
      * Update billing agreement status
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      */
-    public function updateBillingAgreementStatus(\Magento\Payment\Model\Billing\AbstractAgreement $agreement);
+    public function updateBillingAgreementStatus(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement);
 }
diff --git a/app/code/Magento/Sales/Model/Billing/Agreement/OrdersUpdater.php b/app/code/Magento/Paypal/Model/Billing/Agreement/OrdersUpdater.php
similarity index 76%
rename from app/code/Magento/Sales/Model/Billing/Agreement/OrdersUpdater.php
rename to app/code/Magento/Paypal/Model/Billing/Agreement/OrdersUpdater.php
index 94e45f9af8e64440681dc098382eca6997bffcd2..acbe86a64b2c11dfb29dca24a0c18d600e92fb49 100644
--- a/app/code/Magento/Sales/Model/Billing/Agreement/OrdersUpdater.php
+++ b/app/code/Magento/Paypal/Model/Billing/Agreement/OrdersUpdater.php
@@ -18,16 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
- * Sales orders grid massaction items updater
+ * Orders grid massaction items updater
  */
-namespace Magento\Sales\Model\Billing\Agreement;
+namespace Magento\Paypal\Model\Billing\Agreement;
 
 class OrdersUpdater implements \Magento\Core\Model\Layout\Argument\UpdaterInterface
 {
@@ -36,14 +34,24 @@ class OrdersUpdater implements \Magento\Core\Model\Layout\Argument\UpdaterInterf
      */
     protected $_registryManager;
 
+    /**
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement
+     */
+    protected $_agreementResource;
+
     /**
      * @param \Magento\Core\Model\Registry $coreRegistry
+     * @param \Magento\Paypal\Model\Resource\Billing\Agreement $agreementResource
      * @param array $data
      * @throws \InvalidArgumentException
      */
-    public function __construct(\Magento\Core\Model\Registry $coreRegistry, array $data = array())
-    {
+    public function __construct(
+        \Magento\Core\Model\Registry $coreRegistry,
+        \Magento\Paypal\Model\Resource\Billing\Agreement $agreementResource,
+        array $data = array()
+    ) {
         $this->_registryManager = isset($data['registry']) ? $data['registry'] : $coreRegistry;
+        $this->_agreementResource = $agreementResource;
 
         if (false === ($this->_registryManager instanceof \Magento\Core\Model\Registry)) {
             throw new \InvalidArgumentException('registry object has to be an instance of \Magento\Core\Model\Registry');
@@ -66,7 +74,7 @@ class OrdersUpdater implements \Magento\Core\Model\Layout\Argument\UpdaterInterf
             throw new \DomainException('Undefined billing agreement object');
         }
 
-        $argument->addBillingAgreementsFilter($billingAgreement->getId());
+        $this->_agreementResource->addOrdersFilter($argument, $billingAgreement->getId());
         return $argument;
     }
 }
diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php
index 69ef88849e7efd4900d538a62d7e01240aca36fd..10f460e45bfc7b2a1f8d8398c462acbeffa89cfe 100644
--- a/app/code/Magento/Paypal/Model/Express.php
+++ b/app/code/Magento/Paypal/Model/Express.php
@@ -68,7 +68,6 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod
     protected $_canUseInternal              = false;
     protected $_canUseCheckout              = true;
     protected $_canFetchTransactionInfo     = true;
-    protected $_canCreateBillingAgreement   = true;
     protected $_canReviewPayment            = true;
 
     /**
@@ -519,9 +518,9 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod
     /**
      * Validate RP data
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function validateRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile)
+    public function validateRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile)
     {
         return $this->_pro->validateRecurringProfile($profile);
     }
@@ -529,10 +528,10 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod
     /**
      * Submit RP to the gateway
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      * @param \Magento\Payment\Model\Info $paymentInfo
      */
-    public function submitRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile,
+    public function submitRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile,
         \Magento\Payment\Model\Info $paymentInfo
     ) {
         $token = $paymentInfo->getAdditionalInformation(
@@ -564,9 +563,9 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod
     /**
      * Update RP data
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function updateRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile)
+    public function updateRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile)
     {
         return $this->_pro->updateRecurringProfile($profile);
     }
@@ -574,9 +573,9 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod
     /**
      * Manage status
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function updateRecurringProfileStatus(\Magento\Payment\Model\Recurring\Profile $profile)
+    public function updateRecurringProfileStatus(\Magento\RecurringProfile\Model\RecurringProfile $profile)
     {
         return $this->_pro->updateRecurringProfileStatus($profile);
     }
diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php
index f50b0ed184460abd22420bcd877dd753e8c3790b..485d103380f452381f0d6cfbedc042889daa4b63 100644
--- a/app/code/Magento/Paypal/Model/Express/Checkout.php
+++ b/app/code/Magento/Paypal/Model/Express/Checkout.php
@@ -127,7 +127,7 @@ class Checkout
     /**
      * Billing agreement that might be created during order placing
      *
-     * @var \Magento\Sales\Model\Billing\Agreement
+     * @var \Magento\Paypal\Model\Billing\Agreement
      */
     protected $_billingAgreement;
 
@@ -210,7 +210,7 @@ class Checkout
     protected $_serviceQuoteFactory;
 
     /**
-     * @var \Magento\Sales\Model\Billing\AgreementFactory
+     * @var \Magento\Paypal\Model\Billing\AgreementFactory
      */
     protected $_agreementFactory;
 
@@ -224,6 +224,11 @@ class Checkout
      */
     protected $_objectCopyService;
 
+    /**
+     * @var \Magento\Checkout\Model\Session
+     */
+    protected $_checkoutSession;
+
     /**
      * Set config, session and quote instances
      *
@@ -241,9 +246,10 @@ class Checkout
      * @param \Magento\Core\Model\Log\AdapterFactory $logFactory
      * @param \Magento\Checkout\Model\Type\OnepageFactory $onepageFactory
      * @param \Magento\Sales\Model\Service\QuoteFactory $serviceQuoteFactory
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
      * @param \Magento\Paypal\Model\Api\Type\Factory $apiTypeFactory
      * @param \Magento\Object\Copy $objectCopyService
+     * @param \Magento\Checkout\Model\Session $checkoutSession
      * @param array $params
      * @throws \Exception
      */
@@ -262,9 +268,10 @@ class Checkout
         \Magento\Core\Model\Log\AdapterFactory $logFactory,
         \Magento\Checkout\Model\Type\OnepageFactory $onepageFactory,
         \Magento\Sales\Model\Service\QuoteFactory $serviceQuoteFactory,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory,
         \Magento\Paypal\Model\Api\Type\Factory $apiTypeFactory,
         \Magento\Object\Copy $objectCopyService,
+        \Magento\Checkout\Model\Session $checkoutSession,
         $params = array()
     ) {
         $this->_customerData = $customerData;
@@ -284,6 +291,7 @@ class Checkout
         $this->_agreementFactory = $agreementFactory;
         $this->_apiTypeFactory = $apiTypeFactory;
         $this->_objectCopyService = $objectCopyService;
+        $this->_checkoutSession = $checkoutSession;
 
         if (isset($params['config']) && $params['config'] instanceof \Magento\Paypal\Model\Config) {
             $this->_config = $params['config'];
@@ -477,7 +485,7 @@ class Checkout
             foreach ($profiles as $profile) {
                 $profile->setMethodCode(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS);
                 if (!$profile->isValid()) {
-                    throw new \Magento\Core\Exception($profile->getValidationErrors(true, true));
+                    throw new \Magento\Core\Exception($profile->getValidationErrors());
                 }
             }
             $this->_api->addRecurringPaymentProfiles($profiles);
@@ -717,7 +725,6 @@ class Checkout
         if (!$order) {
             return;
         }
-        $this->_billingAgreement = $order->getPayment()->getBillingAgreement();
 
         // commence redirecting to finish payment, if paypal requires it
         if ($order->getPayment()->getAdditionalInformation(
@@ -780,7 +787,7 @@ class Checkout
     /**
      * Get created billing agreement
      *
-     * @return \Magento\Sales\Model\Billing\Agreement|null
+     * @return \Magento\Paypal\Model\Billing\Agreement|null
      */
     public function getBillingAgreement()
     {
diff --git a/app/code/Magento/Paypal/Model/Ipn.php b/app/code/Magento/Paypal/Model/Ipn.php
index 2e5354a7bdbe98e798a18bf4e066bfb3b3417e14..7b9e8ca4660a050c6f73d6b8af7e05d9d0a2f45b 100644
--- a/app/code/Magento/Paypal/Model/Ipn.php
+++ b/app/code/Magento/Paypal/Model/Ipn.php
@@ -44,7 +44,7 @@ class Ipn
     /**
      * Recurring profile instance
      *
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_recurringProfile;
 
@@ -90,15 +90,15 @@ class Ipn
     protected $_configFactory;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\ProfileFactory
+     * @var \Magento\RecurringProfile\Model\ProfileFactory
      */
-    protected $_profileFactory;
+    protected $_recurringProfileFactory;
 
     /**
      * @param \Magento\Sales\Model\OrderFactory $orderFactory
      * @param \Magento\App\ResponseInterface $responseHttp
      * @param \Magento\Paypal\Model\ConfigFactory $configFactory
-     * @param \Magento\Sales\Model\Recurring\ProfileFactory $profileFactory
+     * @param \Magento\RecurringProfile\Model\ProfileFactory $recurringProfileFactory
      * @param \Magento\Paypal\Model\Info $paypalInfo
      * @param \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory
      */
@@ -106,14 +106,14 @@ class Ipn
         \Magento\Sales\Model\OrderFactory $orderFactory,
         \Magento\App\ResponseInterface $responseHttp,
         \Magento\Paypal\Model\ConfigFactory $configFactory,
-        \Magento\Sales\Model\Recurring\ProfileFactory $profileFactory,
+        \Magento\RecurringProfile\Model\ProfileFactory $recurringProfileFactory,
         \Magento\Paypal\Model\Info $paypalInfo,
         \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory
     ) {
         $this->_orderFactory = $orderFactory;
         $this->_responseHttp = $responseHttp;
         $this->_configFactory = $configFactory;
-        $this->_profileFactory = $profileFactory;
+        $this->_recurringProfileFactory = $recurringProfileFactory;
         $this->_info = $paypalInfo;
         $this->_logAdapterFactory = $logAdapterFactory;
     }
@@ -141,7 +141,7 @@ class Ipn
      */
     public function processIpnRequest(array $request, \Zend_Http_Client_Adapter_Interface $httpAdapter = null)
     {
-        $this->_request   = $request;
+        $this->_request = $request;
         $this->_debugData = array('ipn' => $request);
         ksort($this->_debugData['ipn']);
 
@@ -213,7 +213,7 @@ class Ipn
             if (!$this->_order->getId()) {
                 $this->_debugData['exception'] = sprintf('Wrong order ID: "%s".', $id);
                 $this->_debug();
-                $this->_responseHttp->setHeader('HTTP/1.1','503 Service Unavailable')->sendResponse();
+                $this->_responseHttp->setHeader('HTTP/1.1', '503 Service Unavailable')->sendResponse();
                 exit;
             }
             // re-initialize config with the method code and store id
@@ -232,7 +232,7 @@ class Ipn
     /**
      * Load recurring profile
      *
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\Profile
      * @throws \Exception
      */
     protected function _getRecurringProfile()
@@ -240,7 +240,7 @@ class Ipn
         if (empty($this->_recurringProfile)) {
             // get proper recurring profile
             $internalReferenceId = $this->_request['rp_invoice_id'];
-            $this->_recurringProfile = $this->_profileFactory->create()
+            $this->_recurringProfile = $this->_recurringProfileFactory->create()
                 ->loadByInternalReferenceId($internalReferenceId);
             if (!$this->_recurringProfile->getId()) {
                 throw new \Exception(
@@ -275,7 +275,9 @@ class Ipn
             }
             if (strtolower($merchantEmail) != strtolower($receiverEmail)) {
                 throw new \Exception(sprintf(
-                    'The requested %s and configured %s merchant emails do not match.', $receiverEmail, $merchantEmail
+                    'The requested %s and configured %s merchant emails do not match.',
+                    $receiverEmail,
+                    $merchantEmail
                 ));
             }
         }
@@ -327,7 +329,12 @@ class Ipn
         /**
          *  Add IPN comment about registered dispute
          */
-        $message = __('IPN "%1". A dispute has been resolved and closed. %2 Transaction amount %3.', ucfirst($reasonCode), $notificationAmount, $reasonComment);
+        $message = __(
+            'IPN "%1". A dispute has been resolved and closed. %2 Transaction amount %3.',
+            ucfirst($reasonCode),
+            $notificationAmount,
+            $reasonComment
+        );
         $this->_order->addStatusHistoryComment($message)
             ->setIsCustomerNotified(false)
             ->save();
@@ -346,7 +353,13 @@ class Ipn
         /**
          *  Add IPN comment about registered dispute
          */
-        $message = __('IPN "%1". Case type "%2". Case ID "%3" %4', ucfirst($caseType), $caseTypeLabel, $caseId, $reasonComment);
+        $message = __(
+            'IPN "%1". Case type "%2". Case ID "%3" %4',
+            ucfirst($caseType),
+            $caseTypeLabel,
+            $caseId,
+            $reasonComment
+        );
         $this->_order->addStatusHistoryComment($message)
             ->setIsCustomerNotified(false)
             ->save();
@@ -362,9 +375,10 @@ class Ipn
         $notificationAmount = $this->_order
             ->getBaseCurrency()
             ->formatTxt($this->_request['mc_gross'] + $this->_request['mc_fee']);
-        $paymentStatus = $this->_filterPaymentStatus(isset($this->_request['payment_status'])
-            ? $this->_request['payment_status']
-            : null
+        $paymentStatus = $this->_filterPaymentStatus(
+            isset($this->_request['payment_status'])
+                ? $this->_request['payment_status']
+                : null
         );
         $orderStatus = ($paymentStatus == \Magento\Paypal\Model\Info::PAYMENTSTATUS_REVERSED)
             ? \Magento\Paypal\Model\Info::ORDER_STATUS_REVERSED
@@ -372,7 +386,13 @@ class Ipn
         /**
          * Change order status to PayPal Reversed/PayPal Cancelled Reversal if it is possible.
          */
-        $message = __('IPN "%1". %2 Transaction amount %3. Transaction ID: "%4"', $this->_request['payment_status'], $reasonComment, $notificationAmount, $this->_request['txn_id']);
+        $message = __(
+            'IPN "%1". %2 Transaction amount %3. Transaction ID: "%4"',
+            $this->_request['payment_status'],
+            $reasonComment,
+            $notificationAmount,
+            $this->_request['txn_id']
+        );
         $this->_order->setStatus($orderStatus);
         $this->_order->save();
         $this->_order->addStatusHistoryComment($message, $orderStatus)
@@ -414,7 +434,7 @@ class Ipn
                     $this->_registerMasspaymentsSuccess();
                     break;
 
-                case \Magento\Paypal\Model\Info::PAYMENTSTATUS_REVERSED:// break is intentionally omitted
+                case \Magento\Paypal\Model\Info::PAYMENTSTATUS_REVERSED: //break is intentionally omitted
                 case \Magento\Paypal\Model\Info::PAYMENTSTATUS_UNREVERSED:
                     $this->_registerPaymentReversal();
                     break;
@@ -449,63 +469,51 @@ class Ipn
         try {
             // handle payment_status
             $paymentStatus = $this->_filterPaymentStatus($this->_request['payment_status']);
+            if ($paymentStatus != \Magento\Paypal\Model\Info::PAYMENTSTATUS_COMPLETED) {
+                throw new \Exception("Cannot handle payment status '{$paymentStatus}'.");
+            }
+            // Register recurring payment notification, create and process order
+            $price = $this->getRequestData('mc_gross') - $this->getRequestData('tax')
+                - $this->getRequestData('shipping');
+            $productItemInfo = new \Magento\Object;
+            $type = trim($this->getRequestData('period_type'));
+            if ($type == 'Trial') {
+                $productItemInfo->setPaymentType(\Magento\RecurringProfile\Model\PaymentTypeInterface::TRIAL);
+            } elseif ($type == 'Regular') {
+                $productItemInfo->setPaymentType(\Magento\RecurringProfile\Model\PaymentTypeInterface::REGULAR);
+            }
+            $productItemInfo->setTaxAmount($this->getRequestData('tax'));
+            $productItemInfo->setShippingAmount($this->getRequestData('shipping'));
+            $productItemInfo->setPrice($price);
 
-            switch ($paymentStatus) {
-                // paid
-                case \Magento\Paypal\Model\Info::PAYMENTSTATUS_COMPLETED:
-                    $this->_registerRecurringProfilePaymentCapture();
-                    break;
+            $order = $this->_recurringProfile->createOrder($productItemInfo);
 
-                default:
-                    throw new \Exception("Cannot handle payment status '{$paymentStatus}'.");
+            $payment = $order->getPayment();
+            $payment->setTransactionId($this->getRequestData('txn_id'))
+                ->setCurrencyCode($this->getRequestData('mc_currency'))
+                ->setPreparedMessage($this->_createIpnComment(''))
+                ->setIsTransactionClosed(0);
+            $order->save();
+            $this->_recurringProfile->addOrderRelation($order->getId());
+            $payment->registerCaptureNotification($this->getRequestData('mc_gross'));
+            $order->save();
+
+            // notify customer
+            $invoice = $payment->getCreatedInvoice();
+            if ($invoice) {
+                $message = __('You notified customer about invoice #%1.', $invoice->getIncrementId());
+                $order->sendNewOrderEmail()->addStatusHistoryComment($message)
+                    ->setIsCustomerNotified(true)
+                    ->save();
             }
         } catch (\Magento\Core\Exception $e) {
-// TODO: add to payment profile comments
-//            $comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true);
-//            $comment->save();
+            //TODO: add to payment profile comments
+            //$comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true);
+            //$comment->save();
             throw $e;
         }
     }
 
-    /**
-     * Register recurring payment notification, create and process order
-     */
-    protected function _registerRecurringProfilePaymentCapture()
-    {
-        $price = $this->getRequestData('mc_gross') - $this->getRequestData('tax') -  $this->getRequestData('shipping');
-        $productItemInfo = new \Magento\Object;
-        $type = trim($this->getRequestData('period_type'));
-        if ($type == 'Trial') {
-            $productItemInfo->setPaymentType(\Magento\Sales\Model\Recurring\Profile::PAYMENT_TYPE_TRIAL);
-        } elseif ($type == 'Regular') {
-            $productItemInfo->setPaymentType(\Magento\Sales\Model\Recurring\Profile::PAYMENT_TYPE_REGULAR);
-        }
-        $productItemInfo->setTaxAmount($this->getRequestData('tax'));
-        $productItemInfo->setShippingAmount($this->getRequestData('shipping'));
-        $productItemInfo->setPrice($price);
-
-        $order = $this->_recurringProfile->createOrder($productItemInfo);
-
-        $payment = $order->getPayment();
-        $payment->setTransactionId($this->getRequestData('txn_id'))
-            ->setCurrencyCode($this->getRequestData('mc_currency'))
-            ->setPreparedMessage($this->_createIpnComment(''))
-            ->setIsTransactionClosed(0);
-        $order->save();
-        $this->_recurringProfile->addOrderRelation($order->getId());
-        $payment->registerCaptureNotification($this->getRequestData('mc_gross'));
-        $order->save();
-
-        // notify customer
-        $invoice = $payment->getCreatedInvoice();
-        if ($invoice) {
-            $message = __('You notified customer about invoice #%1.', $invoice->getIncrementId());
-            $order->sendNewOrderEmail()->addStatusHistoryComment($message)
-                ->setIsCustomerNotified(true)
-                ->save();
-        }
-    }
-
     /**
      * Process completed payment (either full or partial)
      */
@@ -528,11 +536,10 @@ class Ipn
         // notify customer
         $invoice = $payment->getCreatedInvoice();
         if ($invoice && !$this->_order->getEmailSent()) {
-            $this->_order->sendNewOrderEmail()->addStatusHistoryComment(
-                __('You notified customer about invoice #%1.', $invoice->getIncrementId())
-            )
-            ->setIsCustomerNotified(true)
-            ->save();
+            $this->_order->sendNewOrderEmail()
+                ->addStatusHistoryComment(__('You notified customer about invoice #%1.', $invoice->getIncrementId()))
+                ->setIsCustomerNotified(true)
+                ->save();
         }
     }
 
@@ -579,11 +586,11 @@ class Ipn
 
         // TODO: there is no way to close a capture right now
 
-        $creditmemo = $payment->getCreatedCreditmemo();
-        if ($creditmemo) {
-            $creditmemo->sendEmail();
+        $creditMemo = $payment->getCreatedCreditmemo();
+        if ($creditMemo) {
+            $creditMemo->sendEmail();
             $this->_order->addStatusHistoryComment(
-                __('You notified customer about creditmemo #%1.', $creditmemo->getIncrementId())
+                __('You notified customer about creditmemo #%1.', $creditMemo->getIncrementId())
             )->setIsCustomerNotified(true)->save();
         }
     }
diff --git a/app/code/Magento/Paypal/Model/Method/Agreement.php b/app/code/Magento/Paypal/Model/Method/Agreement.php
index ee4a9496cafe160fec8d34893be9e0974a50213f..efb05fde881170bbd0bad44ffdec22b3cff9461c 100644
--- a/app/code/Magento/Paypal/Model/Method/Agreement.php
+++ b/app/code/Magento/Paypal/Model/Method/Agreement.php
@@ -29,8 +29,8 @@
  */
 namespace Magento\Paypal\Model\Method;
 
-class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgreement
-    implements \Magento\Payment\Model\Billing\Agreement\MethodInterface
+class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement
+    implements \Magento\Paypal\Model\Billing\Agreement\MethodInterface
 {
     /**
      * Method code
@@ -82,7 +82,7 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
      * @param \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Paypal\Model\Method\ProTypeFactory $proTypeFactory
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
      * @param \Magento\UrlInterface $urlBuilder
      * @param \Magento\Paypal\Model\CartFactory $cartFactory
      * @param array $data
@@ -94,7 +94,7 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
         \Magento\Payment\Helper\Data $paymentData,
         \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig,
         \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Paypal\Model\Method\ProTypeFactory $proTypeFactory,
         \Magento\UrlInterface $urlBuilder,
@@ -142,10 +142,10 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
     /**
      * Init billing agreement
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      * @return \Magento\Paypal\Model\Method\Agreement
      */
-    public function initBillingAgreementToken(\Magento\Payment\Model\Billing\AbstractAgreement $agreement)
+    public function initBillingAgreementToken(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement)
     {
         $api = $this->_pro->getApi()
             ->setReturnUrl($agreement->getReturnUrl())
@@ -162,10 +162,10 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
     /**
      * Retrieve billing agreement customer details by token
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      * @return array
      */
-    public function getBillingAgreementTokenInfo(\Magento\Payment\Model\Billing\AbstractAgreement $agreement)
+    public function getBillingAgreementTokenInfo(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement)
     {
         $api = $this->_pro->getApi()
             ->setToken($agreement->getToken());
@@ -183,10 +183,10 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
     /**
      * Create billing agreement by token specified in request
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      * @return \Magento\Paypal\Model\Method\Agreement
      */
-    public function placeBillingAgreement(\Magento\Payment\Model\Billing\AbstractAgreement $agreement)
+    public function placeBillingAgreement(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement)
     {
         $api = $this->_pro->getApi()
             ->setToken($agreement->getToken());
@@ -198,11 +198,11 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
     /**
      * Update billing agreement status
      *
-     * @param \Magento\Payment\Model\Billing\AbstractAgreement $agreement
+     * @param \Magento\Paypal\Model\Billing\AbstractAgreement $agreement
      * @return \Magento\Paypal\Model\Method\Agreement
      * @throws \Exception|\Magento\Core\Exception
      */
-    public function updateBillingAgreementStatus(\Magento\Payment\Model\Billing\AbstractAgreement $agreement)
+    public function updateBillingAgreementStatus(\Magento\Paypal\Model\Billing\AbstractAgreement $agreement)
     {
         $targetStatus = $agreement->getStatus();
         $api = $this->_pro->getApi()
@@ -212,7 +212,7 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
             $api->callUpdateBillingAgreement();
         } catch (\Magento\Core\Exception $e) {
             // when BA was already canceled, just pretend that the operation succeeded
-            if (!(\Magento\Sales\Model\Billing\Agreement::STATUS_CANCELED == $targetStatus
+            if (!(\Magento\Paypal\Model\Billing\Agreement::STATUS_CANCELED == $targetStatus
                 && $api->getIsBillingAgreementAlreadyCancelled())) {
                 throw $e;
             }
@@ -341,10 +341,10 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre
     protected function _placeOrder(\Magento\Sales\Model\Order\Payment $payment, $amount)
     {
         $order = $payment->getOrder();
-        /** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */
+        /** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */
         $billingAgreement = $this->_agreementFactory->create()->load(
             $payment->getAdditionalInformation(
-                \Magento\Sales\Model\Payment\Method\Billing\AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID
+                \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID
             )
         );
 
diff --git a/app/code/Magento/Paypal/Model/Observer.php b/app/code/Magento/Paypal/Model/Observer.php
index 93cb6828a720396bc896a2a9e3ce1871b7d2adf3..260db1eb83189b90628aa653bb1192e400bb4beb 100644
--- a/app/code/Magento/Paypal/Model/Observer.php
+++ b/app/code/Magento/Paypal/Model/Observer.php
@@ -67,6 +67,21 @@ class Observer
      */
     protected $_view;
 
+    /**
+     * @var \Magento\AuthorizationInterface
+     */
+    protected $_authorization;
+
+    /**
+     * @var \Magento\Paypal\Model\Billing\AgreementFactory
+     */
+    protected $_agreementFactory;
+
+    /**
+     * @var \Magento\Checkout\Model\Session
+     */
+    protected $_checkoutSession;
+
     /**
      * @param \Magento\Core\Helper\Data $coreData
      * @param \Magento\Paypal\Helper\Hss $paypalHss
@@ -74,6 +89,9 @@ class Observer
      * @param \Magento\Logger $logger
      * @param Report\SettlementFactory $settlementFactory
      * @param \Magento\App\ViewInterface $view
+     * @param \Magento\AuthorizationInterface $authorization
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
+     * @param \Magento\Checkout\Model\Session $checkoutSession
      */
     public function __construct(
         \Magento\Core\Helper\Data $coreData,
@@ -81,7 +99,10 @@ class Observer
         \Magento\Core\Model\Registry $coreRegistry,
         \Magento\Logger $logger,
         \Magento\Paypal\Model\Report\SettlementFactory $settlementFactory,
-        \Magento\App\ViewInterface $view
+        \Magento\App\ViewInterface $view,
+        \Magento\AuthorizationInterface $authorization,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory,
+        \Magento\Checkout\Model\Session $checkoutSession
     ) {
         $this->_coreData = $coreData;
         $this->_paypalHss = $paypalHss;
@@ -89,6 +110,9 @@ class Observer
         $this->_logger = $logger;
         $this->_settlementFactory = $settlementFactory;
         $this->_view = $view;
+        $this->_authorization = $authorization;
+        $this->_agreementFactory = $agreementFactory;
+        $this->_checkoutSession = $checkoutSession;
     }
 
     /**
@@ -175,4 +199,79 @@ class Observer
 
         return $this;
     }
+
+    /**
+     * Block admin ability to use customer billing agreements
+     *
+     * @param \Magento\Event\Observer $observer
+     */
+    public function restrictAdminBillingAgreementUsage($observer)
+    {
+        $event = $observer->getEvent();
+        $methodInstance = $event->getMethodInstance();
+        if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement
+            && false == $this->_authorization->isAllowed('Magento_Paypal::use')
+        ) {
+            $event->getResult()->isAvailable = false;
+        }
+    }
+
+    /**
+     * @param \Magento\Event\Observer $observer
+     */
+    public function addBillingAgreementToSession(\Magento\Event\Observer $observer)
+    {
+        /** @var \Magento\Sales\Model\Order\Payment $orderPayment */
+        $orderPayment = $observer->getEvent()->getPayment();
+        $agreementCreated = false;
+        if ($orderPayment->getBillingAgreementData()) {
+            $order = $orderPayment->getOrder();
+            /** @var \Magento\Paypal\Model\Billing\Agreement $agreement */
+            $agreement = $this->_agreementFactory->create()->importOrderPayment($orderPayment);
+            if ($agreement->isValid()) {
+                $message = __('Created billing agreement #%1.', $agreement->getReferenceId());
+                $order->addRelatedObject($agreement);
+                $this->_checkoutSession->setLastBillingAgreementReferenceId($agreement->getReferenceId());
+                $agreementCreated = true;
+            } else {
+                $message = __('We couldn\'t create a billing agreement for this order.');
+            }
+            $comment = $order->addStatusHistoryComment($message);
+            $order->addRelatedObject($comment);
+        }
+        if (!$agreementCreated) {
+            $this->_checkoutSession->unsLastBillingAgreementReferenceId();
+        }
+    }
+
+    /**
+     * Add PayPal shortcut buttons
+     *
+     * @param \Magento\Event\Observer $observer
+     */
+    public function addPaypalShortcuts(\Magento\Event\Observer $observer)
+    {
+        /** @var \Magento\Catalog\Block\ShortcutButtons $shortcutButtons */
+        $shortcutButtons = $observer->getEvent()->getContainer();
+        // PayPal Express Checkout
+        $shortcut = $shortcutButtons->getLayout()->createBlock(
+            'Magento\Paypal\Block\Express\Shortcut',
+            '',
+            array('checkoutSession' => $observer->getEvent()->getCheckoutSession())
+        );
+        $shortcut->setIsInCatalogProduct($observer->getEvent()->getIsCatalogProduct())
+            ->setShowOrPosition($observer->getEvent()->getOrPosition())
+            ->setTemplate('express/shortcut.phtml');
+        $shortcutButtons->addShortcut($shortcut);
+        // PayPal Express Checkout Payflow Edition
+        $shortcut = $shortcutButtons->getLayout()->createBlock(
+            'Magento\Paypal\Block\PayflowExpress\Shortcut',
+            '',
+            array('checkoutSession' => $observer->getEvent()->getCheckoutSession())
+        );
+        $shortcut->setIsInCatalogProduct($observer->getEvent()->getIsCatalogProduct())
+            ->setShowOrPosition($observer->getEvent()->getOrPosition())
+            ->setTemplate('express/shortcut.phtml');
+        $shortcutButtons->addShortcut($shortcut);
+    }
 }
diff --git a/app/code/Magento/Paypal/Model/PayflowExpress.php b/app/code/Magento/Paypal/Model/PayflowExpress.php
index cceebc35964e8d9ff138d4a07576426073684309..b1aadf58dea121a2cf90ce50e7b3651ef201631c 100644
--- a/app/code/Magento/Paypal/Model/PayflowExpress.php
+++ b/app/code/Magento/Paypal/Model/PayflowExpress.php
@@ -28,7 +28,6 @@ class PayflowExpress extends \Magento\Paypal\Model\Express
 {
     protected $_code = \Magento\Paypal\Model\Config::METHOD_WPP_PE_EXPRESS;
     protected $_formBlockType = 'Magento\Paypal\Block\PayflowExpress\Form';
-    protected $_canCreateBillingAgreement = false;
     protected $_canManageRecurringProfiles = false;
 
     /**
diff --git a/app/code/Magento/Sales/Model/Payment/Method/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php
similarity index 87%
rename from app/code/Magento/Sales/Model/Payment/Method/Billing/AbstractAgreement.php
rename to app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php
index 9f2cdc05ca34bb6d42b9515e1c5e2863974e47da..e45d90e9fdeb6d29a691f2de8d1f22f189a9c566 100644
--- a/app/code/Magento/Sales/Model/Payment/Method/Billing/AbstractAgreement.php
+++ b/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php
@@ -18,16 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
- * Sales Billing Agreement Payment Method Abstract model
+ * Billing Agreement Payment Method Abstract model
  */
-namespace Magento\Sales\Model\Payment\Method\Billing;
+namespace Magento\Paypal\Model\Payment\Method\Billing;
 
 abstract class AbstractAgreement
     extends \Magento\Payment\Model\Method\AbstractMethod
@@ -38,8 +36,8 @@ abstract class AbstractAgreement
     const TRANSPORT_BILLING_AGREEMENT_ID = 'ba_agreement_id';
     const PAYMENT_INFO_REFERENCE_ID      = 'ba_reference_id';
 
-    protected $_infoBlockType = 'Magento\Sales\Block\Payment\Info\Billing\Agreement';
-    protected $_formBlockType = 'Magento\Sales\Block\Payment\Form\Billing\Agreement';
+    protected $_infoBlockType = 'Magento\Paypal\Block\Payment\Info\Billing\Agreement';
+    protected $_formBlockType = 'Magento\Paypal\Block\Payment\Form\Billing\Agreement';
 
     /**
      * Is method instance available
@@ -49,7 +47,7 @@ abstract class AbstractAgreement
     protected $_isAvailable = null;
 
     /**
-     * @var \Magento\Sales\Model\Billing\AgreementFactory
+     * @var \Magento\Paypal\Model\Billing\AgreementFactory
      */
     protected $_agreementFactory;
 
@@ -58,7 +56,7 @@ abstract class AbstractAgreement
      * @param \Magento\Payment\Helper\Data $paymentData
      * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig
      * @param \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
+     * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory
      * @param array $data
      */
     public function __construct(
@@ -66,7 +64,7 @@ abstract class AbstractAgreement
         \Magento\Payment\Helper\Data $paymentData,
         \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig,
         \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory,
+        \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory,
         array $data = array()
     ) {
         $this->_agreementFactory = $agreementFactory;
@@ -76,7 +74,7 @@ abstract class AbstractAgreement
     /**
      * Check whether method is available
      *
-     * @param \Magento\Sales\Model\Quote $quote
+     * @param \Magento\Paypal\Model\Quote $quote
      * @return bool
      */
     public function isAvailable($quote = null)
diff --git a/app/code/Magento/Paypal/Model/Pro.php b/app/code/Magento/Paypal/Model/Pro.php
index 157c19e0dec8ad1538575169ff8761991b737230..59cff81612fd10d1c08b59bf96964b567a5841e5 100644
--- a/app/code/Magento/Paypal/Model/Pro.php
+++ b/app/code/Magento/Paypal/Model/Pro.php
@@ -382,10 +382,10 @@ class Pro
     /**
      * Validate RP data
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      * @throws \Magento\Core\Exception
      */
-    public function validateRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile)
+    public function validateRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile)
     {
         $errors = array();
         if (strlen($profile->getSubscriberName()) > 32) { // up to 32 single-byte chars
@@ -407,11 +407,11 @@ class Pro
     /**
      * Submit RP to the gateway
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      * @param \Magento\Payment\Model\Info $paymentInfo
      * @throws \Magento\Core\Exception
      */
-    public function submitRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile,
+    public function submitRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile,
         \Magento\Payment\Model\Info $paymentInfo
     ) {
         $api = $this->getApi();
@@ -427,9 +427,9 @@ class Pro
         $api->callCreateRecurringPaymentsProfile();
         $profile->setReferenceId($api->getRecurringProfileId());
         if ($api->getIsProfileActive()) {
-            $profile->setState(\Magento\Sales\Model\Recurring\Profile::STATE_ACTIVE);
+            $profile->setState(\Magento\RecurringProfile\Model\States::ACTIVE);
         } elseif ($api->getIsProfilePending()) {
-            $profile->setState(\Magento\Sales\Model\Recurring\Profile::STATE_PENDING);
+            $profile->setState(\Magento\RecurringProfile\Model\States::PENDING);
         }
     }
 
@@ -450,9 +450,9 @@ class Pro
     /**
      * Update RP data
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function updateRecurringProfile(\Magento\Payment\Model\Recurring\Profile $profile)
+    public function updateRecurringProfile(\Magento\RecurringProfile\Model\RecurringProfile $profile)
     {
 
     }
@@ -460,22 +460,22 @@ class Pro
     /**
      * Manage status
      *
-     * @param \Magento\Payment\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\RecurringProfile $profile
      */
-    public function updateRecurringProfileStatus(\Magento\Payment\Model\Recurring\Profile $profile)
+    public function updateRecurringProfileStatus(\Magento\RecurringProfile\Model\RecurringProfile $profile)
     {
         $api = $this->getApi();
         $action = null;
         switch ($profile->getNewState()) {
-            case \Magento\Sales\Model\Recurring\Profile::STATE_CANCELED: $action = 'cancel'; break;
-            case \Magento\Sales\Model\Recurring\Profile::STATE_SUSPENDED: $action = 'suspend'; break;
-            case \Magento\Sales\Model\Recurring\Profile::STATE_ACTIVE: $action = 'activate'; break;
+            case \Magento\RecurringProfile\Model\States::CANCELED: $action = 'cancel'; break;
+            case \Magento\RecurringProfile\Model\States::SUSPENDED: $action = 'suspend'; break;
+            case \Magento\RecurringProfile\Model\States::ACTIVE: $action = 'activate'; break;
         }
         $state = $profile->getState();
         $api->setRecurringProfileId($profile->getReferenceId())
-            ->setIsAlreadyCanceled($state == \Magento\Sales\Model\Recurring\Profile::STATE_CANCELED)
-            ->setIsAlreadySuspended($state == \Magento\Sales\Model\Recurring\Profile::STATE_SUSPENDED)
-            ->setIsAlreadyActive($state == \Magento\Sales\Model\Recurring\Profile::STATE_ACTIVE)
+            ->setIsAlreadyCanceled($state == \Magento\RecurringProfile\Model\States::CANCELED)
+            ->setIsAlreadySuspended($state == \Magento\RecurringProfile\Model\States::SUSPENDED)
+            ->setIsAlreadyActive($state == \Magento\RecurringProfile\Model\States::ACTIVE)
             ->setAction($action)
             ->callManageRecurringPaymentsProfileStatus()
         ;
diff --git a/app/code/Magento/Sales/Model/Resource/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php
similarity index 60%
rename from app/code/Magento/Sales/Model/Resource/Billing/Agreement.php
rename to app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php
index 228f023a79015761cfd6a702be46b6bf6727fde5..e12df7c2fa51a3ef475b155f654c0da36c070f3b 100644
--- a/app/code/Magento/Sales/Model/Resource/Billing/Agreement.php
+++ b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,12 +25,8 @@
 
 /**
  * Billing agreement resource model
- *
- * @category    Magento
- * @package     Magento_Sales
- * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Model\Resource\Billing;
+namespace Magento\Paypal\Model\Resource\Billing;
 
 class Agreement extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
@@ -42,7 +36,7 @@ class Agreement extends \Magento\Core\Model\Resource\Db\AbstractDb
      */
     protected function _construct()
     {
-        $this->_init('sales_billing_agreement', 'agreement_id');
+        $this->_init('paypal_billing_agreement', 'agreement_id');
     }
 
     /**
@@ -50,16 +44,35 @@ class Agreement extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param int $agreementId
      * @param int $orderId
-     * @return \Magento\Sales\Model\Resource\Billing\Agreement
+     * @return \Magento\Paypal\Model\Resource\Billing\Agreement
      */
     public function addOrderRelation($agreementId, $orderId)
     {
         $this->_getWriteAdapter()->insert(
-            $this->getTable('sales_billing_agreement_order'), array(
+            $this->getTable('paypal_billing_agreement_order'), array(
                 'agreement_id'  => $agreementId,
                 'order_id'      => $orderId
             )
         );
         return $this;
     }
+
+    /**
+     * Add billing agreement filter on orders collection
+     *
+     * @param \Magento\Sales\Model\Resource\Order\Collection $orderCollection
+     * @param string|int|array $agreementIds
+     * @return $this
+     */
+    public function addOrdersFilter(\Magento\Sales\Model\Resource\Order\Collection $orderCollection, $agreementIds)
+    {
+        $agreementIds = (is_array($agreementIds)) ? $agreementIds : [$agreementIds];
+        $orderCollection->getSelect()
+            ->joinInner(
+                array('pbao' => $this->getTable('paypal_billing_agreement_order')),
+                'main_table.entity_id = pbao.order_id',
+                array())
+            ->where('pbao.agreement_id IN(?)', $agreementIds);
+        return $this;
+    }
 }
diff --git a/app/code/Magento/Sales/Model/Resource/Billing/Agreement/Collection.php b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php
similarity index 93%
rename from app/code/Magento/Sales/Model/Resource/Billing/Agreement/Collection.php
rename to app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php
index 7aadd53edfd222940d1cbebe09bdcae2496ee743..6d1dfa0836873c844d524790ea731fba33f68378 100644
--- a/app/code/Magento/Sales/Model/Resource/Billing/Agreement/Collection.php
+++ b/app/code/Magento/Paypal/Model/Resource/Billing/Agreement/Collection.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Billing agreements resource collection
  */
-namespace Magento\Sales\Model\Resource\Billing\Agreement;
+namespace Magento\Paypal\Model\Resource\Billing\Agreement;
 
 class Collection
     extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
@@ -77,13 +75,13 @@ class Collection
      */
     protected function _construct()
     {
-        $this->_init('Magento\Sales\Model\Billing\Agreement', 'Magento\Sales\Model\Resource\Billing\Agreement');
+        $this->_init('Magento\Paypal\Model\Billing\Agreement', 'Magento\Paypal\Model\Resource\Billing\Agreement');
     }
 
     /**
      * Add customer details(email, firstname, lastname) to select
      *
-     * @return \Magento\Sales\Model\Resource\Billing\Agreement\Collection
+     * @return \Magento\Paypal\Model\Resource\Billing\Agreement\Collection
      */
     public function addCustomerDetails()
     {
diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php
index 704a7cf08b0cddc6955ccafdc193f6a8bddfef3c..b6063a3dd38ac49bed5cb4a28ba46e132f7cbabf 100644
--- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php
+++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php
@@ -28,7 +28,7 @@ namespace Magento\Paypal\Model\System\Config\Backend;
 
 class Cron extends \Magento\Core\Model\Config\Value
 {
-    const CRON_STRING_PATH = 'crontab/jobs/paypal_fetch_settlement_reports/schedule/cron_expr';
+    const CRON_STRING_PATH = 'crontab/default/jobs/paypal_fetch_settlement_reports/schedule/cron_expr';
     const CRON_MODEL_PATH_INTERVAL = 'paypal/fetch_reports/schedule';
 
     /**
diff --git a/app/code/Magento/Paypal/etc/adminhtml/acl.xml b/app/code/Magento/Paypal/etc/adminhtml/acl.xml
index 26cc8f8af9983c999bb766acd7fead9db1657b17..85a17f856e9f395b1cfd88bd7f1dfc240728467d 100644
--- a/app/code/Magento/Paypal/etc/adminhtml/acl.xml
+++ b/app/code/Magento/Paypal/etc/adminhtml/acl.xml
@@ -44,6 +44,17 @@
                         </resource>
                     </resource>
                 </resource>
+                <resource id="Magento_Sales::sales">
+                    <resource id="Magento_Sales::sales_operation">
+                        <resource id="Magento_Paypal::billing_agreement"  title="Billing Agreements" sortOrder="60">
+                            <resource id="Magento_Paypal::billing_agreement_actions" title="Actions" sortOrder="10">
+                                <resource id="Magento_Paypal::billing_agreement_actions_view" title="View" sortOrder="5" />
+                                <resource id="Magento_Paypal::actions_manage" title="Manage" sortOrder="10" />
+                                <resource id="Magento_Paypal::use" title="Place Order Using Billing Agreements" sortOrder="15" />
+                            </resource>
+                        </resource>
+                    </resource>
+                </resource>
             </resource>
         </resources>
     </acl>
diff --git a/app/code/Magento/Paypal/etc/adminhtml/events.xml b/app/code/Magento/Paypal/etc/adminhtml/events.xml
new file mode 100644
index 0000000000000000000000000000000000000000..dabd70e4101c2fd926a245e4c8403e62ff318348
--- /dev/null
+++ b/app/code/Magento/Paypal/etc/adminhtml/events.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <event name="payment_method_is_active">
+        <observer name="sales_billing_agreement" instance="Magento\Paypal\Model\Observer" method="restrictAdminBillingAgreementUsage" />
+    </event>
+</config>
diff --git a/app/code/Magento/Paypal/etc/adminhtml/menu.xml b/app/code/Magento/Paypal/etc/adminhtml/menu.xml
index 5fe86288e6b861ad26382d00d7b11552fa52b004..41da34c80c3b2ecb9579f9fc9c8b71838afeda18 100644
--- a/app/code/Magento/Paypal/etc/adminhtml/menu.xml
+++ b/app/code/Magento/Paypal/etc/adminhtml/menu.xml
@@ -27,6 +27,7 @@
 -->
 <config>
     <menu>
-        <add id="Magento_Paypal::report_salesroot_paypal_settlement_reports" title="PayPal Settlement" module="Magento_Paypal" sortOrder="70" parent="Magento_Reports::report_salesroot" action="adminhtml/paypal_reports" resource="Magento_Paypal::paypal_settlement_reports"/>
+        <add id="Magento_Paypal::report_salesroot_paypal_settlement_reports" title="PayPal Settlement" module="Magento_Paypal" sortOrder="70" parent="Magento_Reports::report_salesroot" action="paypal/paypal_reports" resource="Magento_Paypal::paypal_settlement_reports"/>
+        <add id="Magento_Paypal::paypal_billing_agreement" title="Billing Agreements" module="Magento_Paypal" sortOrder="60" parent="Magento_Sales::sales_operation" action="paypal/billing_agreement" resource="Magento_Paypal::billing_agreement"/>
     </menu>
 </config>
diff --git a/app/code/Magento/Paypal/etc/adminhtml/routes.xml b/app/code/Magento/Paypal/etc/adminhtml/routes.xml
index 13fca14c023b59421f2cacc939ad04cab891ff21..d070a2fae94900bb535b88f4650ca65412ea5a75 100644
--- a/app/code/Magento/Paypal/etc/adminhtml/routes.xml
+++ b/app/code/Magento/Paypal/etc/adminhtml/routes.xml
@@ -25,7 +25,7 @@
 -->
 <config>
     <router id="admin">
-        <route id="adminhtml">
+        <route id="paypal" frontName="paypal">
             <module name="Magento_Paypal" before="Magento_Adminhtml" />
         </route>
     </router>
diff --git a/app/code/Magento/Paypal/etc/crontab.xml b/app/code/Magento/Paypal/etc/crontab.xml
index d42211c5a782f3d88a0b00eb964f954f9286cc28..1c17fdf864ea041b0cfac99897b39bc3a5aaac99 100644
--- a/app/code/Magento/Paypal/etc/crontab.xml
+++ b/app/code/Magento/Paypal/etc/crontab.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="paypal_fetch_settlement_reports" instance="Magento\Paypal\Model\Observer" method="fetchReports" />
+    <group id="default">
+        <job name="paypal_fetch_settlement_reports" instance="Magento\Paypal\Model\Observer" method="fetchReports" />
+    </group>
 </config>
diff --git a/app/code/Magento/Paypal/etc/events.xml b/app/code/Magento/Paypal/etc/events.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7044752d6d9b1a6d1d45a9d443fb09cc80aa87ec
--- /dev/null
+++ b/app/code/Magento/Paypal/etc/events.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <event name="sales_order_payment_place_end">
+        <observer name="paypal" instance="Magento\Paypal\Model\Observer" method="addBillingAgreementToSession" />
+    </event>
+</config>
diff --git a/app/code/Magento/Paypal/etc/frontend/events.xml b/app/code/Magento/Paypal/etc/frontend/events.xml
index e8468a3a39b4f8cbb8b7d25783c9cbf203d3cb71..09929d4ae391eeda4d28fe02d35b99bc48969d3e 100644
--- a/app/code/Magento/Paypal/etc/frontend/events.xml
+++ b/app/code/Magento/Paypal/etc/frontend/events.xml
@@ -30,4 +30,7 @@
     <event name="controller_action_postdispatch_checkout_onepage_saveOrder">
         <observer name="hss_save_order_onepage" instance="Magento\Paypal\Model\Observer" method="setResponseAfterSaveOrder" />
     </event>
+    <event name="shortcut_buttons_container">
+        <observer name="paypal_shortcuts" instance="Magento\Paypal\Model\Observer" method="addPaypalShortcuts" />
+    </event>
 </config>
diff --git a/app/code/Magento/Paypal/etc/frontend/page_types.xml b/app/code/Magento/Paypal/etc/frontend/page_types.xml
index 44dfffd644bf8350e84e93669ed0558a6963f37e..e5cfd5635f1c3bbc0380237bd53b10162a992167 100644
--- a/app/code/Magento/Paypal/etc/frontend/page_types.xml
+++ b/app/code/Magento/Paypal/etc/frontend/page_types.xml
@@ -24,6 +24,8 @@
  */
 -->
 <page_types>
+    <type id="paypal_billing_agreement_index" label="Billing Agreement"/>
+    <type id="paypal_billing_agreement_view" label="Billing Agreement View"/>
     <type id="paypal_express_review" label="PayPal Express Order Review Form"/>
     <type id="paypal_hostedpro_cancel" label="Paypal Hosted Pro Frame"/>
     <type id="paypal_payflow_cancelpayment" label="Paypal Payflow Cancel Payment"/>
diff --git a/app/code/Magento/Paypal/etc/module.xml b/app/code/Magento/Paypal/etc/module.xml
index 9e9cffd45e341bab4a02c5d22c079601dbbc7c8d..4a6524533f8917014d6945dc85572bff800f19e8 100755
--- a/app/code/Magento/Paypal/etc/module.xml
+++ b/app/code/Magento/Paypal/etc/module.xml
@@ -41,6 +41,7 @@
             <module name="Magento_Theme"/>
             <module name="Magento_Centinel"/>
             <module name="Magento_Catalog"/>
+            <module name="Magento_RecurringProfile"/>
         </depends>
     </module>
 </config>
diff --git a/app/code/Magento/Paypal/i18n/de_DE.csv b/app/code/Magento/Paypal/i18n/de_DE.csv
index 6a376dc6ed657093e5921daf185cf0810ecf8e8a..c10284950a9c4c168b773d4fd7e07342665b938e 100644
--- a/app/code/Magento/Paypal/i18n/de_DE.csv
+++ b/app/code/Magento/Paypal/i18n/de_DE.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- Bitte wählen Sie Rechnungsvereinbarung --"
 "-OR-","-oder-"
 "2-pixel perimeter around the header space.","2-pixel Umkreis um das Feld der Kopfzeile"
 "3D Secure","3D Secure Verfahren"
@@ -50,9 +51,18 @@
 "Auto","Automatisch"
 "AutoSweep","Selbstdurchlauf"
 "Available Balance","Verfügbares Guthaben"
+"Back to Billing Agreements","Zurück zu Rechnungsvereinbarungen"
 "Balance Manager Account Bonus","Guthaben-Manager Kontobonus"
 "Billing Address","Rechnungsadresse"
+"Billing Agreement","Rechnungsvereinbarung"
+"Billing Agreement # %s","Rechnungsvereinbarung # %s"
+"Billing Agreement #%s","Rechnungsvereinbarung #%s"
 "Billing Agreement Signup ","Anmeldung zur Rechnungsvereinbarung"
+"Billing Agreement View","Rechnungsvereinbarung Ansicht"
+"Billing Agreements","Rechnungsvereinbarungen"
+"Billing Agreement status is not set.","Abrechnungsvereinbarungsstatus ist nicht gesetzt."
+"Unable to save Billing Agreement:","Abrechnungsvereinbarung kann nicht gespeichert werden:"
+"Your billing agreement # is: %s.","Die Nummer Ihrer Zustimmung zur Abrechnung lautet: %s."
 "Bonus for first ACH Use","Bonus für erste ACH-Benutzung"
 "Buyer Credit Payment","Käuferkredit Zahlung"
 "Buyer\'s Tax ID","Steuernummer des Käufers"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","Länder Zahlungen gültig ab"
 "Country","Land"
 "Coupon Redemption","Coupon-Einlösung"
+"Created billing agreement #%s.","Rechnungsvereinbahrung #%s erstellt."
 "Credit","Guthaben"
 "Credit Card Settings","Kreditkarten-Einstellung"
 "Currency Conversion required to cover negative balance","Währungsumrechnung erforderlich, um negatives Saldo zu decken"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","Express Kaufabwicklung Einstellungen"
 "Express Checkout and Order have been canceled.","Express-Checkout und Bestellung wurden storniert."
 "Express Checkout has been canceled.","Express-Checkout storniert."
+"Failed to cancel the billing agreement.","Aufhebung von Billing Agreement fehlgeschlagen."
+"Failed to create billing agreement for this order.","Erstellen von Billing Agreement für diese Bestellung fehlgeschlagen."
 "Failed to fetch reports from '%s@%s'.","Abholung der Berichte von '%s@%s' fehlgeschlagen."
+"Failed to finish billing agreement wizard.","Abschließen von Billing Agreement Assistent fehlgeschlagen."
+"Failed to start billing agreement wizard.","Start von Billing Agreement Assistent fehlgeschlagen."
 "Fax","Fax"
 "Fee Amount","Gebühr Betrag"
 "Fee Debit or Credit","Gebühr Soll oder Haben"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","N/A. Nicht verfügbar"
 "Negative Balance","Negatives Guthaben"
 "Never","Niemals"
+"New Billing Agreement","Neue Abrechnungsvereinbarung"
 "No","Nein"
 "No Details matched","Keine Details stimmen überein"
 "No Details matched. International","Keines der Details stimmt überein. International"
@@ -313,6 +329,7 @@
 "Pending PayPal","PayPal ausstehend"
 "Phone","Telefon"
 "Place Order","Erteilen Sie den Auftrag"
+"Place Order Using Billing Agreements","Auftrag mithilfe von Rechnungsvereinbahrungen erteilen"
 "Please agree to all the terms and conditions before placing the order.","Bitte stimmen Sie den Allgemeinen Geschäftsbedingungen zu, bevor Sie die Bestellung aufgeben."
 "Please contact PayPal Customer Service.","Bitte benachrichtigen Sie den PayPal Kundenservice."
 "Please do not refresh the page until you complete payment.","Bitte die Seite nicht aktualisieren, bis Sie die Zahlung abgeschlossen haben."
@@ -393,6 +410,8 @@
 "Test Mode","Testmodus"
 "The background color for the checkout page around the header and payment form.","Die Hintergrundfarbe für die Checkout-Seite, um die Überschrift und Zahlungsart herum."
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","Die Hintergrundfarbe für die Kopfzeile der Abmeldeseite. Groβ- und Kleinschreibung sechs Buchstaben HTML hexadezimal farbcode in ASII."
+"The billing agreement ""%s"" has been canceled.","Die Rechnungsvereinbarung ""%s"" wurde annuliert."
+"The billing agreement ""%s"" has been created.","Die Rechnungsvereinbarung ""%s"" wurde erstellt."
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","Die Standardeinstellung für Kinder-Autorisationen in Ihrem Paypal-Konto ist 1. Für mehrfache Autorisationen kontaktieren Sie bitte PayPal und bitten Sie um Erweiterung."
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","Das Bild oben links auf der Checkout-Seite. Max. Größe 750 x 90 Pixel. <strong style=""color:red"">https</strong> wird dringend empfohlen."
 "The maximum number of child authorizations is reached.","Die maximal mögliche Anzahl an Kinder-Autorisationen ist erreicht."
@@ -403,6 +422,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","Die Zahlung steht noch aus, da sie an eine Email-Adresse versandt wurde, die weder registriert noch bestätigt ist."
 "The payment is pending while it is being reviewed by PayPal for risk.","Zahlung steht noch aus und wird von PayPal auf Risiken geprüft."
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","Die Zahlung wurde mit Kreditkarte getätigt. Damit der Händler Zahlungen erhalten kann, muss er sein Konto auf Business- oder Premiumstatus upgraden."
+"There are no billing agreements yet.","Es gibt noch keine Rechnungsvereinbahrungen."
 "There was an error processing your order. Please contact us or try again later.","Bei der Bearbeitung Ihrer Bestellung ist ein Fehler aufgetreten. Bitte kontaktieren Sie uns oder versuchen Sie es später noch einmal."
 "This feature needs be enabled first for the merchant account through PayPal technical support.","Diese Funktion muss zunächst  für das Händlerkonto vom Technischen Support von Paypal aktiviert werden."
 "This operation requires an existing transaction object.","Dieser Vorgang erfordert einen bestehenden Transaktionsgegenstand."
@@ -464,6 +484,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","Würden Sie gerne eine Rechnungsvereinbarung abschliessen, um zukünftige Käufe mit PayPal zu rationalisieren?"
 "Wrong Order ID (%s) specified.","Falsche Bestellnummer (%s) angegeben."
 "Wrong PayPal Express Checkout Token specified.","Falscher PayPal Express-Checkout Token eingegeben."
+"Wrong billing agreement ID specified.","Falsche Zahlungsvereinbarungs-ID angegeben."
 "Yes","Ja"
 "Yes. Matched Address and five-didgit ZIP","Ja. Adresse und fünfstellige Postleitzahl stimmen überein."
 "You cannot void a verification transaction","Sie können eine Prüfung nicht für ungültig erklären"
diff --git a/app/code/Magento/Paypal/i18n/en_US.csv b/app/code/Magento/Paypal/i18n/en_US.csv
index f01e1a3be161494a1e32cbd243628290a1160a8e..8cea21541ae012b85e8a4707bc9dd16ecc81a3b1 100644
--- a/app/code/Magento/Paypal/i18n/en_US.csv
+++ b/app/code/Magento/Paypal/i18n/en_US.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- Please Select Billing Agreement--"
 "-OR-","-OR-"
 "2-pixel perimeter around the header space.","2-pixel perimeter around the header space."
 "3D Secure","3D Secure"
@@ -50,9 +51,18 @@
 "Auto","Auto"
 "AutoSweep","AutoSweep"
 "Available Balance","Available Balance"
+"Back to Billing Agreements","Back to Billing Agreements"
 "Balance Manager Account Bonus","Balance Manager Account Bonus"
 "Billing Address","Billing Address"
+"Billing Agreement","Billing Agreement"
+"Billing Agreement # %s","Billing Agreement # %s"
+"Billing Agreement #%s","Billing Agreement #%s"
 "Billing Agreement Signup ","Billing Agreement Signup "
+"Billing Agreement View","Billing Agreement View"
+"Billing Agreements","Billing Agreements"
+"Billing Agreement status is not set.","Billing Agreement status is not set."
+"Unable to save Billing Agreement:","Unable to save Billing Agreement:"
+"Your billing agreement # is: %s.","Your billing agreement # is: %s."
 "Bonus for first ACH Use","Bonus for first ACH Use"
 "Buyer Credit Payment","Buyer Credit Payment"
 "Buyer\'s Tax ID","Buyer\'s Tax ID"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","Countries Payment Applicable From"
 "Country","Country"
 "Coupon Redemption","Coupon Redemption"
+"Created billing agreement #%s.","Created billing agreement #%s."
 "Credit","Credit"
 "Credit Card Settings","Credit Card Settings"
 "Currency Conversion required to cover negative balance","Currency Conversion required to cover negative balance"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","Express Checkout Settings"
 "Express Checkout and Order have been canceled.","Express Checkout and Order have been canceled."
 "Express Checkout has been canceled.","Express Checkout has been canceled."
+"Failed to cancel the billing agreement.","Failed to cancel the billing agreement."
+"Failed to create billing agreement for this order.","Failed to create billing agreement for this order."
 "Failed to fetch reports from '%s@%s'.","Failed to fetch reports from '%s@%s'."
+"Failed to finish billing agreement wizard.","Failed to finish billing agreement wizard."
+"Failed to start billing agreement wizard.","Failed to start billing agreement wizard."
 "Fax","Fax"
 "Fee Amount","Fee Amount"
 "Fee Debit or Credit","Fee Debit or Credit"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","N/A. Unavailable"
 "Negative Balance","Negative Balance"
 "Never","Never"
+"New Billing Agreement","New Billing Agreement"
 "No","No"
 "No Details matched","No Details matched"
 "No Details matched. International","No Details matched. International"
@@ -312,6 +328,7 @@
 "Pending PayPal","Pending PayPal"
 "Phone","Phone"
 "Place Order","Place Order"
+"Place Order Using Billing Agreements","Place Order Using Billing Agreements"
 "Please agree to all the terms and conditions before placing the order.","Please agree to all the terms and conditions before placing the order."
 "Please contact PayPal Customer Service.","Please contact PayPal Customer Service."
 "Please do not refresh the page until you complete payment.","Please do not refresh the page until you complete payment."
@@ -392,6 +409,8 @@
 "Test Mode","Test Mode"
 "The background color for the checkout page around the header and payment form.","The background color for the checkout page around the header and payment form."
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII."
+"The billing agreement ""%s"" has been canceled.","The billing agreement ""%s"" has been canceled."
+"The billing agreement ""%s"" has been created.","The billing agreement ""%s"" has been created."
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase."
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged."
 "The maximum number of child authorizations is reached.","The maximum number of child authorizations is reached."
@@ -402,6 +421,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","The payment is pending because it was made to an email address that is not yet registered or confirmed."
 "The payment is pending while it is being reviewed by PayPal for risk.","The payment is pending while it is being reviewed by PayPal for risk."
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status."
+"There are no billing agreements yet.","There are no billing agreements yet."
 "There was an error processing your order. Please contact us or try again later.","There was an error processing your order. Please contact us or try again later."
 "This feature needs be enabled first for the merchant account through PayPal technical support.","This feature needs be enabled first for the merchant account through PayPal technical support."
 "This operation requires an existing transaction object.","This operation requires an existing transaction object."
@@ -463,6 +483,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","Would you like to sign a billing agreement to streamline further purchases with PayPal?"
 "Wrong Order ID (%s) specified.","Wrong Order ID (%s) specified."
 "Wrong PayPal Express Checkout Token specified.","Wrong PayPal Express Checkout Token specified."
+"Wrong billing agreement ID specified.","Wrong billing agreement ID specified."
 "Yes","Yes"
 "Yes. Matched Address and five-didgit ZIP","Yes. Matched Address and five-didgit ZIP"
 "You cannot void a verification transaction","You cannot void a verification transaction"
diff --git a/app/code/Magento/Paypal/i18n/es_ES.csv b/app/code/Magento/Paypal/i18n/es_ES.csv
index 842818ce40a230dac3bed3630fa8f4970a5beacb..54e9caf5fc4302cd5d07baaf9b3cdd33d058578b 100644
--- a/app/code/Magento/Paypal/i18n/es_ES.csv
+++ b/app/code/Magento/Paypal/i18n/es_ES.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- Por favor, Seleccione el Acuerdo de Facturación--"
 "-OR-","-O-"
 "2-pixel perimeter around the header space.","Perímetro de 2 píxeles alrededor del espacio de cabera."
 "3D Secure","3D Seguro"
@@ -50,9 +51,18 @@
 "Auto","Auto"
 "AutoSweep","AutoBarrido"
 "Available Balance","Balance Disponible"
+"Back to Billing Agreements","Volver a los contratos de facturación"
 "Balance Manager Account Bonus","Bono de Cuenta de Gestor de Balance"
 "Billing Address","Dirección de facturación"
+"Billing Agreement","Acuerdo de facturación"
+"Billing Agreement # %s","Contrato de facturación # %s"
+"Billing Agreement #%s","Contrato de facturación # %s"
 "Billing Agreement Signup ","Firma de Acuerdo de Facturación"
+"Billing Agreement View","Ver contrato de facturación"
+"Billing Agreements","Contratos de facturación"
+"Billing Agreement status is not set.","No se ha establecido el estado del acuerdo de facturación."
+"Unable to save Billing Agreement:","No se puede guardar el Contrato de Facturación:"
+"Your billing agreement # is: %s.","Su número de acuerdo de facturación es: %s."
 "Bonus for first ACH Use","Bono por el primer Uso de ACH"
 "Buyer Credit Payment","Pago de Crédito de Comprador"
 "Buyer\'s Tax ID","Número de identificación social del contribuyente del comprador\es"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","Formulario Aplicable de Pago por Países"
 "Country","País"
 "Coupon Redemption","Reembolso de Cupón"
+"Created billing agreement #%s.","Crear contrato de facturación #%s."
 "Credit","Crédito"
 "Credit Card Settings","Configuración de la Tarjeta de Crédito"
 "Currency Conversion required to cover negative balance","Se requiere una Conversión de Divisas para cubrir el saldo negativo"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","Ajustes de Paso por Caja Express"
 "Express Checkout and Order have been canceled.","El Pedido y la Salida Express se han cancelado."
 "Express Checkout has been canceled.","La Salida Express se ha cancelado."
+"Failed to cancel the billing agreement.","No se ha podido cancelar el acuerdo de facturación"
+"Failed to create billing agreement for this order.","No se ha podido crear un acuerdo de facturación para este pedido."
 "Failed to fetch reports from '%s@%s'.","No se consiguió obtener los registros de '%s@%s'."
+"Failed to finish billing agreement wizard.","El asistente de acuerdos de facturación no ha podido finalizar."
+"Failed to start billing agreement wizard.","El asistente de acuerdos de facturación no ha podido iniciarse."
 "Fax","Fax"
 "Fee Amount","Importe de la Comisión"
 "Fee Debit or Credit","Comisión Débito o Crédito"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","No disponible. No disponible."
 "Negative Balance","No disponible. Saldo negativo"
 "Never","Nunca"
+"New Billing Agreement","Nuevo Acuerdo de Facturación"
 "No","No"
 "No Details matched","No ha habido coincidencias"
 "No Details matched. International","Los detalles no coinciden. Internacional"
@@ -313,6 +329,7 @@
 "Pending PayPal","Pendiente de pago en PayPal"
 "Phone","Teléfono"
 "Place Order","Hacer pedido"
+"Place Order Using Billing Agreements","Hacer el Pedido Utilizando los Acuerdos de Facturación"
 "Please agree to all the terms and conditions before placing the order.","Por favor, acepta todos los términos y condiciones antes de realizar el pedido."
 "Please contact PayPal Customer Service.","Por favor, póngase en contacto con el Servicio de Atención al Cliente de PayPal."
 "Please do not refresh the page until you complete payment.","No actualice la página hasta que complete el pago."
@@ -393,6 +410,8 @@
 "Test Mode","Modo de prueba"
 "The background color for the checkout page around the header and payment form.","El color de fondo de la página de reembolso de la cabecera y formulario de pago."
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","Color de fondo para la cabecera de la página de pago. Código ASCII de color hexadecimal HTML de seis caracteres sin diferencias mayúsculas o minúsculas."
+"The billing agreement ""%s"" has been canceled.","El acuerdo de facturación ""%s"" se ha cancelado."
+"The billing agreement ""%s"" has been created.","El acuerdo de facturación ""%s"" se ha creado."
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","El número de autorizaciones infantiles por defecto de su cuenta de PayPal es 1. Para tener autorizaciones múltiples, póngase en contacto con PayPal para solicitar un aumento."
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","Imagen en la parte superior izquierda de la página de pago. El tamaño máximo es 750x90 píxeles. Se recomienda encarecidamente el uso de <strong style=""color:red"">https</strong>."
 "The maximum number of child authorizations is reached.","Se ha alcanzado el número máximo de autorizaciones infantiles."
@@ -403,6 +422,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","El pago está pendiente porque se ha realizado a una dirección de mail que todavía no se ha registrado o confirmado."
 "The payment is pending while it is being reviewed by PayPal for risk.","El pago está pendiente, PayPal lo está revisando para asegurarse."
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","El pago se ha realizado mediante tarjeta de crédito. Para recibir los fondos el vendedor tiene que actualizar la cuenta a estado Business o Premier."
+"There are no billing agreements yet.","No hay acuerdos de facturación todavía."
 "There was an error processing your order. Please contact us or try again later.","Se produjo un error en el proceso de su pedido. Contacte con nosotros o inténtelo más tarde."
 "This feature needs be enabled first for the merchant account through PayPal technical support.","Esta característica necesita primero ser activada para la cuenta comercial a través del soporte técnico de PayPal."
 "This operation requires an existing transaction object.","Esta operación requiere de una transacción ya existente."
@@ -464,6 +484,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","¿Le gustaría firmar un contrato de facturación para agilizar sus futuras compras con PayPal?"
 "Wrong Order ID (%s) specified.","Se especificó un Identificador de Pedido Erróneo (%s)."
 "Wrong PayPal Express Checkout Token specified.","Símbolo especificado de Salida Express con Paypal incorrecto."
+"Wrong billing agreement ID specified.","La identificación del contrato de facturación es incorrecta."
 "Yes","Sí"
 "Yes. Matched Address and five-didgit ZIP","Sí. La Dirección y el Código Postal de cinco dígitos coinciden."
 "You cannot void a verification transaction","No se puede anular una operación de comprobación"
diff --git a/app/code/Magento/Paypal/i18n/fr_FR.csv b/app/code/Magento/Paypal/i18n/fr_FR.csv
index 8b7275750411c5eab4a1db409607b5de7f99f662..6eaf7201817d12535d75d6193d7d4970075ca068 100644
--- a/app/code/Magento/Paypal/i18n/fr_FR.csv
+++ b/app/code/Magento/Paypal/i18n/fr_FR.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- Veuillez sélectionner un accord de facturation--"
 "-OR-","-OU-"
 "2-pixel perimeter around the header space.","Un périmètre de deux pixels autour de l'espace du header."
 "3D Secure","3D Secure"
@@ -50,9 +51,18 @@
 "Auto","Automatique"
 "AutoSweep","Emporter automatiquement"
 "Available Balance","Solde disponible"
+"Back to Billing Agreements","Retour aux accords de facturation"
 "Balance Manager Account Bonus","Bonus de la balance du manager"
 "Billing Address","Adresse de facturation"
+"Billing Agreement","Accord de facturation"
+"Billing Agreement # %s","Accord de facturation # %s"
+"Billing Agreement #%s","Accord de facturation #%s"
 "Billing Agreement Signup ","Souscription aux accords de facturation"
+"Billing Agreement View","Voir l'accord de facturation"
+"Billing Agreements","Accords de facturation"
+"Billing Agreement status is not set.","Le statut du contrat de facturation n'est pas réglé."
+"Unable to save Billing Agreement:","Impossible d'enregistrer l'accord de facturation :"
+"Your billing agreement # is: %s.","Votre accord de facturation # est : %s."
 "Bonus for first ACH Use","Bonus pour première utilisation de l'ACH"
 "Buyer Credit Payment","Paiement acheteur"
 "Buyer\'s Tax ID","Identification fiscale de l'acheteur"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","Formulaire de pays disponibles"
 "Country","Pays"
 "Coupon Redemption","Annulations de coupons"
+"Created billing agreement #%s.","Créer un accord de paiement #%s"
 "Credit","Crédit"
 "Credit Card Settings","Réglages de la carte de crédit"
 "Currency Conversion required to cover negative balance","Conversion de monnaie nécessaire pour compenser balance négative"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","Réglages de la commande express"
 "Express Checkout and Order have been canceled.","Le contrôle express et la commande ont été annulés."
 "Express Checkout has been canceled.","Le contrôle express a été annulé."
+"Failed to cancel the billing agreement.","Échec lors de l'annulation de l'accord de facturation."
+"Failed to create billing agreement for this order.","Échec de la création de l'accord de facturation pour cette commande."
 "Failed to fetch reports from '%s@%s'.","Échec de récupération des rapports depuis '%s@%s'."
+"Failed to finish billing agreement wizard.","Impossible de terminer l'assistant d'accord de facturation."
+"Failed to start billing agreement wizard.","Impossible de démarrer l'assistant d'accord de facturation"
 "Fax","Fax"
 "Fee Amount","Montant des frais"
 "Fee Debit or Credit","Frais de débit ou crédit"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","N/A. Indisponible."
 "Negative Balance","Solde négatif"
 "Never","Jamais"
+"New Billing Agreement","Nouvel Accord de Facturation"
 "No","Non"
 "No Details matched","Pas de détails correspondants"
 "No Details matched. International","Pas de détail trouvé. International"
@@ -313,6 +329,7 @@
 "Pending PayPal","PayPal en attente"
 "Phone","Téléphone"
 "Place Order","Placer une commande"
+"Place Order Using Billing Agreements","Passer une commande en recourant aux accords de facturation"
 "Please agree to all the terms and conditions before placing the order.","Veuillez accepter toutes les conditions générales avant de passer la commande."
 "Please contact PayPal Customer Service.","Veuillez contacter le service clients de Paypal."
 "Please do not refresh the page until you complete payment.","Merci de ne pas actualiser cette page avant la finalisation du paiement."
@@ -393,6 +410,8 @@
 "Test Mode","Mode test."
 "The background color for the checkout page around the header and payment form.","Couleur de fond pour la page de paiement autour du haut de page et du formulaire de paiement."
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","La couleur de fond de l'entête de la page de paiement. Code HTML hexadécimal en ASCII de six caractères, non sensible à la case."
+"The billing agreement ""%s"" has been canceled.","L'accord de facturation ""%s"" a été annulé."
+"The billing agreement ""%s"" has been created.","L'accord de facturation ""%s"" a été créé."
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","Le nombre d'autorisations pour enfant sur votre compte Paypal est d'un enfant. Pour en autoriser davantage, veuillez contacter Paypal."
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","L'image en haut à gauche de la page de paiement. Taille maximum : 750 x 90 pixels. <strong style=""color:red"">https</strong> est fortement conseillé."
 "The maximum number of child authorizations is reached.","Le nombre maximum d'autorisations pour enfant est atteint."
@@ -403,6 +422,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","Le paiement est en attente car il a été fait vers une adresse qui n'est pas encore enregistrée ou confirmée."
 "The payment is pending while it is being reviewed by PayPal for risk.","Le paiement est en attente alors qu'il est actuellement examiné par PayPal pour le risque."
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","Le paiement a été effectué via carte de crédit. Afin de recevoir les fonds, le vendeur doit obtenir un compte Business ou Premier."
+"There are no billing agreements yet.","Il n'y a pas encore d'accord de facturation"
 "There was an error processing your order. Please contact us or try again later.","Il y a eu une erreur dans le traitement de votre commande. Veuillez nous contacter ou réessayez plus tard."
 "This feature needs be enabled first for the merchant account through PayPal technical support.","Cette fonctionnalité doit d'abord être activée pour le compte commercial via le support technique PayPal."
 "This operation requires an existing transaction object.","Cette opération nécessite un objet de transaction existant."
@@ -464,6 +484,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","Voulez-vous signer un accord de facturation afin de pouvoir continuer les paiements via Paypal ?"
 "Wrong Order ID (%s) specified.","Mauvais identifiant de la commande (%s)."
 "Wrong PayPal Express Checkout Token specified.","Mauvais code de vérification du paiement express via Paypal."
+"Wrong billing agreement ID specified.","Mauvais identifiant des accords de facturation spécifié."
 "Yes","Oui"
 "Yes. Matched Address and five-didgit ZIP","Oui. Adresse correspondante et ZIP à 5 chiffres"
 "You cannot void a verification transaction","Une transaction de vérification ne peut être refusée"
diff --git a/app/code/Magento/Paypal/i18n/nl_NL.csv b/app/code/Magento/Paypal/i18n/nl_NL.csv
index ab100416c4045ca32392ae3241697232bb9ed814..d55a5b82636886085c7d6f87794c60326bb513ea 100644
--- a/app/code/Magento/Paypal/i18n/nl_NL.csv
+++ b/app/code/Magento/Paypal/i18n/nl_NL.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- Selecteer a.u.b. rekeningovereenkomst --"
 "-OR-","-OF-"
 "2-pixel perimeter around the header space.","2-pixel omtrek om de top ruimte."
 "3D Secure","3D Secure"
@@ -50,9 +51,18 @@
 "Auto","Auto"
 "AutoSweep","AutomatischOpschonen"
 "Available Balance","Beschikbaar Balans"
+"Back to Billing Agreements","Terug naar Factureringsovereenkomsten"
 "Balance Manager Account Bonus","Balans Beheerder Account Bonus"
 "Billing Address","Facturatieadres"
+"Billing Agreement","Factuurovereenkomst"
+"Billing Agreement # %s","Factureringsovereenkomst # %s"
+"Billing Agreement #%s","Factureringsovereenkomst #%s"
 "Billing Agreement Signup ","Betalingsovereenkomst aanmelding"
+"Billing Agreement View","Factureringsovereenkomst Beeld"
+"Billing Agreements","Facturering Overeenkomsten"
+"Billing Agreement status is not set.","Betaalovereenkomst status is niet opgesteld."
+"Unable to save Billing Agreement:","Niet mogelijk om Betalingsovereenkomst op te slaan:"
+"Your billing agreement # is: %s.","Uw factureringsovereenkomst # is: %s."
 "Bonus for first ACH Use","Bonus voor eerste ACH gebruik"
 "Buyer Credit Payment","Koper krediet betaling"
 "Buyer\'s Tax ID","Kopers Belastings ID"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","Landen Waaruit Betaling van Toepassing"
 "Country","Land"
 "Coupon Redemption","Waardebon Inleveren"
+"Created billing agreement #%s.","Factuurovereenkomst #%s aangemaakt."
 "Credit","Krediet"
 "Credit Card Settings","Creditkaart Instellingen"
 "Currency Conversion required to cover negative balance","Valuta Conversie nodig om het negatieve balans te dekken"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","Versneld afrekenen instellingen"
 "Express Checkout and Order have been canceled.","Express Checkout en bestelling zijn geannuleerd."
 "Express Checkout has been canceled.","Express Checkout is geannuleerd."
+"Failed to cancel the billing agreement.","Is er niet in geslaagd de facturering overeenkomst te ontbinden."
+"Failed to create billing agreement for this order.","Niet in staat om een factuurovereenkomst voor deze bestelling te maken."
 "Failed to fetch reports from '%s@%s'.","Kon verslagen niet ophalen van '%s@%s'."
+"Failed to finish billing agreement wizard.","Niet in staat om de factuur-wizard overeenkomst af te maken"
+"Failed to start billing agreement wizard.","Niet in staat om de factuur-wizard overeenkomst te starten"
 "Fax","Fax"
 "Fee Amount","Kosten bedrag"
 "Fee Debit or Credit","Kosten betaalrekening of creditcard"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","n.v.t. Niet beschikbaar"
 "Negative Balance","Negatief Balans"
 "Never","Nooit"
+"New Billing Agreement","Nieuwe factuurovereenkomst"
 "No","Nee"
 "No Details matched","Geen Details kwamen overeen"
 "No Details matched. International","Geen Details kwamen overeen. Internationaal"
@@ -312,6 +328,7 @@
 "Pending PayPal","In afwachting van PayPal"
 "Phone","Telefoon"
 "Place Order","Bestelling plaatsen"
+"Place Order Using Billing Agreements","Plaats uw bestelling met behulp van Facturering overeenkomsten"
 "Please agree to all the terms and conditions before placing the order.","Ga alstublieft akkoord met alle voorwaarden voor het plaatsen van de bestelling."
 "Please contact PayPal Customer Service.","Neem alstublieft contact op met Paypal Klantenservice."
 "Please do not refresh the page until you complete payment.","Ververs alstublieft niet de pagina totdat de betaling is voltooid."
@@ -392,6 +409,8 @@
 "Test Mode","Test modus"
 "The background color for the checkout page around the header and payment form.","De achtergrondkleur voor de afrekenpagina rond de header en het betalingsformulier."
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","De achtergrondkleur voor de header van de afrekenpagina. Niet hoofdlettergevoelige zes-letterteken HTML hexadecimale kleurcode in ASCII."
+"The billing agreement ""%s"" has been canceled.","De afrekeningsovereenkomst ""%s"" is geannuleerd."
+"The billing agreement ""%s"" has been created.","De afrekeningsovereenkomst ""%s"" is aangemaakt."
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","Het standaard aantal kindmachtigingen in uw PayPal account is 1. Om meerdere machtigingen te doen, neem alstublieft contact op met PayPal om een verhoging aan te vragen."
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","De afbeelding linksboven op de afrekeningspagina. Maximale grootte is 750x90 pixels. <strong style=""color:red"">Https</strong> is ten sterkte aangeraden."
 "The maximum number of child authorizations is reached.","Het maximale aantal kindmachtigingen is bereikt."
@@ -402,6 +421,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","De betaling staat in de wacht omdat deze aangemaakt is met een emailadres dat nog niet geregistreerd of bevestigd is."
 "The payment is pending while it is being reviewed by PayPal for risk.","De betaling staat in de wacht, terwijl deze beoordeeld wordt op risico door PayPal."
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","De betaling werd gemaakt via creditcard. Om de gelden te ontvangen, moet de handelaar de account upgraden naar Business of Premier status."
+"There are no billing agreements yet.","Er zijn nog geen facturatieovereenkomsten."
 "There was an error processing your order. Please contact us or try again later.","Er heeft zich een fout voorgedaan bij het verwerken van uw bestelling. Neem alstublieft contact met ons op of probeer het later opnieuw."
 "This feature needs be enabled first for the merchant account through PayPal technical support.","Deze functie moet eerst worden ingeschakeld voor de merchant account via PayPal technische ondersteuning."
 "This operation requires an existing transaction object.","Deze operatie vereist een bestaand transactie object."
@@ -463,6 +483,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","Zou u graag een facturatieovereenkomst willen ondertekenen voor een betere integratie met PayPal?"
 "Wrong Order ID (%s) specified.","Verkeerde Bestelling ID (%s) gespecificeerd."
 "Wrong PayPal Express Checkout Token specified.","Verkeerde PayPal Express Checkout Token gekozen."
+"Wrong billing agreement ID specified.","Verkeerde factuur overeenkomst ID opgegeven."
 "Yes","Ja"
 "Yes. Matched Address and five-didgit ZIP","Ja. Het adres en de 5-cijferige ZIP code komen overeen"
 "You cannot void a verification transaction","U kunt een verificatie-transactie niet nietig verklaren"
diff --git a/app/code/Magento/Paypal/i18n/pt_BR.csv b/app/code/Magento/Paypal/i18n/pt_BR.csv
index aa7f79d0afa4a8e16daacba69768f44e08a77ddf..2b8cf17f49c6d7554b004fd59e1ee7bb75b7525a 100644
--- a/app/code/Magento/Paypal/i18n/pt_BR.csv
+++ b/app/code/Magento/Paypal/i18n/pt_BR.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- Por Favor, Escolha o Acordo de Cobrança--"
 "-OR-","-OU-"
 "2-pixel perimeter around the header space.","Perímetro de 2 pixeis em torno do espaço do cabeçalho."
 "3D Secure","3D Secure"
@@ -50,9 +51,18 @@
 "Auto","Auto"
 "AutoSweep","AutoVarredura"
 "Available Balance","Saldo Disponível"
+"Back to Billing Agreements","Voltar para Contratos de Faturamento"
 "Balance Manager Account Bonus","Conta de Gerente Bônus de Balanço"
 "Billing Address","Endereço de faturamento"
+"Billing Agreement","Contrato de faturamento"
+"Billing Agreement # %s","Contrato de Faturamento # %s"
+"Billing Agreement #%s","Contrato de Faturamento # %s"
 "Billing Agreement Signup ","Aceitação do Contrato de Faturamento"
+"Billing Agreement View","Visualização de Contrato de Faturamento"
+"Billing Agreements","Contratos de faturamento"
+"Billing Agreement status is not set.","Acordo de estado de Faturamento não está definido."
+"Unable to save Billing Agreement:","Não foi possível salvar Acordo de Cobrança:"
+"Your billing agreement # is: %s.","Seu acordo de faturamento # está: %s."
 "Bonus for first ACH Use","Bônus pelo primeiro uso do ACH"
 "Buyer Credit Payment","Pagamento de Crédito do Comprador"
 "Buyer\'s Tax ID","CPF do Comprador"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","Pagamento a Países Aplicável Desde"
 "Country","País"
 "Coupon Redemption","Resgate de Cupom"
+"Created billing agreement #%s.","Criado o contrato de faturamento nº %s."
 "Credit","Crédito"
 "Credit Card Settings","Configurações do Cartão de Crédito"
 "Currency Conversion required to cover negative balance","Necessária a Conversão de Moeda para cobrir saldo negativo"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","Configurações de Caixa Expresso"
 "Express Checkout and Order have been canceled.","Caixa Expresso e Ordem foram canceladas."
 "Express Checkout has been canceled.","Caixa Expresso foi cancelada."
+"Failed to cancel the billing agreement.","Falha ao cancelar o contrato de faturamento."
+"Failed to create billing agreement for this order.","Falha ao criar contrato de faturamento para este pedido."
 "Failed to fetch reports from '%s@%s'.","Falha ao buscar relatórios de ""%s@%s""."
+"Failed to finish billing agreement wizard.","Falha ao concluir wizard do contrato de faturamento."
+"Failed to start billing agreement wizard.","Falha ao iniciar wizard do contrato de faturamento."
 "Fax","Fax"
 "Fee Amount","Valor da Taxa"
 "Fee Debit or Credit","Taxa de Débito ou de Crédito"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","N/A. Indisponível"
 "Negative Balance","Balanço Negativo"
 "Never","Nunca"
+"New Billing Agreement","Novo Contrato de Faturamento"
 "No","Não"
 "No Details matched","Nenhuns Detalhes correspondem"
 "No Details matched. International","Nenhuns Detalhes correspondem. Internacional"
@@ -312,6 +328,7 @@
 "Pending PayPal","Pendência com PayPal"
 "Phone","Telefone"
 "Place Order","Colocar Ordem"
+"Place Order Using Billing Agreements","Faça o Pedido Usando Acordos de Faturamento"
 "Please agree to all the terms and conditions before placing the order.","Por favor concorde com todos os Termos e Condições antes de colocar a ordem."
 "Please contact PayPal Customer Service.","Entre em contato com o Atendimento ao Cliente PayPal."
 "Please do not refresh the page until you complete payment.","Por favor não atualize a página até concluir o pagamento."
@@ -392,6 +409,8 @@
 "Test Mode","Modo de Teste"
 "The background color for the checkout page around the header and payment form.","A cor de fundo para a página de compra à volta do cabeçalho e formulário de pagamento."
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","A cor de fundo para o cabeçalho da página de compra. Código de seis caracteres, sem diferença de minúsculas e maiúsculas, de cor hexadecimal HTML em ASCII."
+"The billing agreement ""%s"" has been canceled.","O contrato de faturamento ""%s"" foi cancelado."
+"The billing agreement ""%s"" has been created.","O contrato de faturamento ""%s"" foi criado."
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","O número padrão de autorizações de criança em sua conta PayPal é 1. Para fazer autorizações múltiplas entre em contato com PayPal para pedir um aumento."
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","A imagem no canto superior esquerdo da página de compra. Tamanho máximo é 750x90 pixels. <strong style=""color:red"">https</strong> é altamente recomendado."
 "The maximum number of child authorizations is reached.","O número máximo de autorizações de criança foi atingido."
@@ -402,6 +421,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","O pagamento está pendente porque foi feito para um endereço de e-mail que ainda não está registrado ou confirmado."
 "The payment is pending while it is being reviewed by PayPal for risk.","O pagamento está pendente enquanto ele está sendo revisado para o risco por PayPal."
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","O pagamento foi feito via cartão de crédito. A fim de receber fundos o comerciante deve atualizar sua conta para status Business ou Premier."
+"There are no billing agreements yet.","Ainda não existem acordos de faturamento."
 "There was an error processing your order. Please contact us or try again later.","Ocorreu um erro ao processar sua ordem. Entre em contato conosco ou tente novamente mais tarde."
 "This feature needs be enabled first for the merchant account through PayPal technical support.","Este recurso primeiro precisa ser ativado para a conta que aceita cartões de crédito através do suporte técnico PayPal ."
 "This operation requires an existing transaction object.","Esta operação requer um objeto existente de transação."
@@ -463,6 +483,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","Gostaria de assinar um acordo de faturamento para agilizar ainda mais compras posteriores com o PayPal?"
 "Wrong Order ID (%s) specified.","ID (%s) especificado da Ordem Errado ."
 "Wrong PayPal Express Checkout Token specified.","Token errado p/ Fechamento Expresso de Pedido pelo PayPal."
+"Wrong billing agreement ID specified.","ID de acordo de faturamento especificado errado."
 "Yes","Sim"
 "Yes. Matched Address and five-didgit ZIP","Sim. Endereço Correspondente e ZIP de cinco dígitos"
 "You cannot void a verification transaction","Não é possível anular uma transação de verificação"
diff --git a/app/code/Magento/Paypal/i18n/zh_CN.csv b/app/code/Magento/Paypal/i18n/zh_CN.csv
index e263d254469bd0e8f94510fba2655c5a436d87a0..3ead5d652b5d96b4732b18beeddcc755cc7ab449 100644
--- a/app/code/Magento/Paypal/i18n/zh_CN.csv
+++ b/app/code/Magento/Paypal/i18n/zh_CN.csv
@@ -1,3 +1,4 @@
+"-- Please Select Billing Agreement--","-- 请选择记账协议 --"
 "-OR-","-或-"
 "2-pixel perimeter around the header space.","头部空间周围2像素的边界"
 "3D Secure","3D 安全"
@@ -50,9 +51,18 @@
 "Auto","自动"
 "AutoSweep","自动清理"
 "Available Balance","可用余额"
+"Back to Billing Agreements","返回记账协议"
 "Balance Manager Account Bonus","余额管理器帐户点数"
 "Billing Address","账单地址"
+"Billing Agreement","记账协议"
+"Billing Agreement # %s","记账协议 # %s"
+"Billing Agreement #%s","记账协议#%s"
 "Billing Agreement Signup ","签署记账协议"
+"Billing Agreement View","记账协议视图"
+"Billing Agreements","记账协议"
+"Billing Agreement status is not set.","记账协议状态未设置。"
+"Unable to save Billing Agreement:","无法保存记账协议:"
+"Your billing agreement # is: %s.","您的账单编号为: %s"
 "Bonus for first ACH Use","首次使用ACH奖励"
 "Buyer Credit Payment","买家信用支付"
 "Buyer\'s Tax ID","买家的纳税人 ID"
@@ -77,6 +87,7 @@
 "Countries Payment Applicable From","各国支付可用情况表单"
 "Country","国家"
 "Coupon Redemption","代金券兑换"
+"Created billing agreement #%s.","创建记账协议 #%s。"
 "Credit","信用"
 "Credit Card Settings","信用卡设置"
 "Currency Conversion required to cover negative balance","货币转换需要考虑余额负值"
@@ -127,7 +138,11 @@
 "Express Checkout Settings","快速结账设置"
 "Express Checkout and Order have been canceled.","快速结账且订单已取消。"
 "Express Checkout has been canceled.","快速结账已被取消。"
+"Failed to cancel the billing agreement.","取消记账协议时出错。"
+"Failed to create billing agreement for this order.","为该订单创建记账协议时出错。"
 "Failed to fetch reports from '%s@%s'.","从 '%s@%s'获取报告失败。"
+"Failed to finish billing agreement wizard.","完成地记账协议向导时出错。"
+"Failed to start billing agreement wizard.","开始记账协议向导时出错。"
 "Fax","传真"
 "Fee Amount","费率"
 "Fee Debit or Credit","借记卡或信用卡费用"
@@ -231,6 +246,7 @@
 "N/A. Unavailable","N/A. 不可用"
 "Negative Balance","逆差"
 "Never","永不"
+"New Billing Agreement","新建记账协议"
 "No","否"
 "No Details matched","无匹配资料"
 "No Details matched. International","无匹配资料。国际化"
@@ -312,6 +328,7 @@
 "Pending PayPal","挂起的PayPal"
 "Phone","电话"
 "Place Order","下订单"
+"Place Order Using Billing Agreements","使用记账协议下单"
 "Please agree to all the terms and conditions before placing the order.","请在下订单前同意所有的条款和条件。"
 "Please contact PayPal Customer Service.","请联系PayPal客服。"
 "Please do not refresh the page until you complete payment.","请不要刷新该页面,直到付款完成。"
@@ -392,6 +409,8 @@
 "Test Mode","测试模式"
 "The background color for the checkout page around the header and payment form.","付款页面上头部和支付表单周围的背景色。"
 "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","付款页面上头部的背景色。请用ASCII码方式输入大小写敏感的六位代表HTML十六进制颜色代码的字符。"
+"The billing agreement ""%s"" has been canceled.","该记账协议 ""%s"" 已被取消。"
+"The billing agreement ""%s"" has been created.","该记账协议 ""%s"" 已被创建。"
 "The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase.","您PayPal帐户中授权子帐户的默认数量为1。如果要获得更多授权,请联系PayPal增加数量。"
 "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","付款页面左上角的图像,最大尺寸为750x90像素。 强烈建议使用<strong style=""color:red"">https</strong>地址。"
 "The maximum number of child authorizations is reached.","授权子帐户的最大数量已达到。"
@@ -402,6 +421,7 @@
 "The payment is pending because it was made to an email address that is not yet registered or confirmed.","支付被挂起,因为支付使用了一个未经确认的电子邮件地址。"
 "The payment is pending while it is being reviewed by PayPal for risk.","支付被挂起,因为正在由PayPal进行风险评估。"
 "The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.","支付是通过信用卡进行的。为了收到资金,银行必须将帐户升级为商业或白金状态。"
+"There are no billing agreements yet.","尚无记账协议。"
 "There was an error processing your order. Please contact us or try again later.","处理您的订单时遇到了错误。请联系我们,或稍后再试。"
 "This feature needs be enabled first for the merchant account through PayPal technical support.","要使用商家账户,必须先通过 PayPal 技术支持启用该功能。"
 "This operation requires an existing transaction object.","该操作需要一个现有的交易目标。"
@@ -463,6 +483,7 @@
 "Would you like to sign a billing agreement to streamline further purchases with PayPal?","您是否想要通过PayPal签署记账协议并简化后续的付款?"
 "Wrong Order ID (%s) specified.","所指定的订单ID(%s)有误。"
 "Wrong PayPal Express Checkout Token specified.","所指定的PayPal快速结账令牌有误。"
+"Wrong billing agreement ID specified.","指定的记账协议ID有误。"
 "Yes","是"
 "Yes. Matched Address and five-didgit ZIP","是的,匹配地址与五位邮编"
 "You cannot void a verification transaction","您无法将验证交易作废"
diff --git a/app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php b/app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php
index 6109fcb6ec61bcde902dd331c140a597a0b1dc8a..c6fd0993e44c6588196a48520a4cce81049585c7 100644
--- a/app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php
+++ b/app/code/Magento/Paypal/sql/paypal_setup/install-1.6.0.0.php
@@ -32,6 +32,85 @@ $installer = $this;
  */
 $installer->startSetup();
 
+/**
+ * Create table 'paypal_billing_agreement'
+ */
+$table = $installer->getConnection()
+    ->newTable($installer->getTable('paypal_billing_agreement'))
+    ->addColumn('agreement_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'identity'  => true,
+        'unsigned'  => true,
+        'nullable'  => false,
+        'primary'   => true,
+    ), 'Agreement Id')
+    ->addColumn('customer_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+    ), 'Customer Id')
+    ->addColumn('method_code', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
+        'nullable'  => false,
+    ), 'Method Code')
+    ->addColumn('reference_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
+        'nullable'  => false,
+    ), 'Reference Id')
+    ->addColumn('status', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
+        'nullable'  => false,
+    ), 'Status')
+    ->addColumn('created_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
+        'nullable'  => false,
+    ), 'Created At')
+    ->addColumn('updated_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
+    ), 'Updated At')
+    ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Store Id')
+    ->addColumn('agreement_label', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array(
+    ), 'Agreement Label')
+    ->addIndex($installer->getIdxName('paypal_billing_agreement', array('customer_id')),
+        array('customer_id'))
+    ->addIndex($installer->getIdxName('paypal_billing_agreement', array('store_id')),
+        array('store_id'))
+    ->addForeignKey($installer->getFkName('paypal_billing_agreement', 'customer_id', 'customer_entity', 'entity_id'),
+        'customer_id', $installer->getTable('customer_entity'), 'entity_id',
+        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->addForeignKey($installer->getFkName('paypal_billing_agreement', 'store_id', 'core_store', 'store_id'),
+        'store_id', $installer->getTable('core_store'), 'store_id',
+        \Magento\DB\Ddl\Table::ACTION_SET_NULL, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->setComment('Sales Billing Agreement');
+$installer->getConnection()->createTable($table);
+
+/**
+ * Create table 'paypal_billing_agreement_order'
+ */
+$table = $installer->getConnection()
+    ->newTable($installer->getTable('paypal_billing_agreement_order'))
+    ->addColumn('agreement_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+        'primary'   => true,
+    ), 'Agreement Id')
+    ->addColumn('order_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+        'primary'   => true,
+    ), 'Order Id')
+    ->addIndex($installer->getIdxName('paypal_billing_agreement_order', array('order_id')),
+        array('order_id'))
+    ->addForeignKey(
+        $installer->getFkName(
+            'paypal_billing_agreement_order',
+            'agreement_id',
+            'paypal_billing_agreement',
+            'agreement_id'
+        ),
+        'agreement_id', $installer->getTable('paypal_billing_agreement'), 'agreement_id',
+        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->addForeignKey($installer->getFkName('paypal_billing_agreement_order', 'order_id', 'sales_flat_order', 'entity_id'),
+        'order_id', $installer->getTable('sales_flat_order'), 'entity_id',
+        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->setComment('Sales Billing Agreement Order');
+$installer->getConnection()->createTable($table);
+
 /**
  * Create table 'paypal_settlement_report'
  */
diff --git a/app/code/Magento/Sales/view/adminhtml/billing/agreement/form.phtml b/app/code/Magento/Paypal/view/adminhtml/billing/agreement/form.phtml
similarity index 96%
rename from app/code/Magento/Sales/view/adminhtml/billing/agreement/form.phtml
rename to app/code/Magento/Paypal/view/adminhtml/billing/agreement/form.phtml
index 80abde08dfc966866046c95f89b37cdb7d1dcd6c..2566d22c9330a9ebf090dcc43f7925b82b7a14f5 100644
--- a/app/code/Magento/Sales/view/adminhtml/billing/agreement/form.phtml
+++ b/app/code/Magento/Paypal/view/adminhtml/billing/agreement/form.phtml
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    design
- * @package     default_default
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
diff --git a/app/code/Magento/Sales/view/adminhtml/billing/agreement/view/form.phtml b/app/code/Magento/Paypal/view/adminhtml/billing/agreement/view/form.phtml
similarity index 94%
rename from app/code/Magento/Sales/view/adminhtml/billing/agreement/view/form.phtml
rename to app/code/Magento/Paypal/view/adminhtml/billing/agreement/view/form.phtml
index 7091f25ab0db2422630cc0bdb025ba91bfe78111..27c5f3f23d83c6b20f44606b9cd7bb96c4cf7e52 100644
--- a/app/code/Magento/Sales/view/adminhtml/billing/agreement/view/form.phtml
+++ b/app/code/Magento/Paypal/view/adminhtml/billing/agreement/view/form.phtml
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    design
- * @package     default_default
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
diff --git a/app/code/Magento/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml b/app/code/Magento/Paypal/view/adminhtml/billing/agreement/view/tab/info.phtml
similarity index 97%
rename from app/code/Magento/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml
rename to app/code/Magento/Paypal/view/adminhtml/billing/agreement/view/tab/info.phtml
index 787fc94e9220b738c97f7f79ec4633672c3ded18..0aeda336681a4bb8b3c9bc422ac8bef746474964 100644
--- a/app/code/Magento/Sales/view/adminhtml/billing/agreement/view/tab/info.phtml
+++ b/app/code/Magento/Paypal/view/adminhtml/billing/agreement/view/tab/info.phtml
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    design
- * @package     default_default
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
diff --git a/app/code/Magento/Paypal/view/adminhtml/layout/customer_index_edit.xml b/app/code/Magento/Paypal/view/adminhtml/layout/customer_index_edit.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f95b994b5e6930de071c8d52c9ea0321e6723848
--- /dev/null
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/customer_index_edit.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <referenceBlock name="customer_edit_tabs">
+        <action method="addTab">
+            <argument name="name" xsi:type="string">customer_edit_tab_agreements</argument>
+            <argument name="block" xsi:type="string">Magento\Paypal\Block\Adminhtml\Customer\Edit\Tab\Agreement</argument>
+        </action>
+    </referenceBlock>
+</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/catalogsearch_result_index.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_customergrid.xml
similarity index 88%
rename from app/code/Magento/Paypal/view/frontend/layout/catalogsearch_result_index.xml
rename to app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_customergrid.xml
index 313d109b31dc36da303702293b30e8e734317499..0a1f0fb0b4f181b83982e44128dd3536c5abd7d9 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/catalogsearch_result_index.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_customergrid.xml
@@ -24,5 +24,5 @@
  */
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
+    <block class="Magento\Paypal\Block\Adminhtml\Customer\Edit\Tab\Agreement" name="customer.billing.agreement.grid" output="1"/>
 </layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/catalogsearch_advanced_result.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_grid.xml
similarity index 89%
rename from app/code/Magento/Paypal/view/frontend/layout/catalogsearch_advanced_result.xml
rename to app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_grid.xml
index 313d109b31dc36da303702293b30e8e734317499..3246dafdbab9a73d7dcafbfaff130b2004ecbee4 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/catalogsearch_advanced_result.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_grid.xml
@@ -24,5 +24,5 @@
  */
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
+    <block class="Magento\Paypal\Block\Adminhtml\Billing\Agreement\Grid" name="paypal.billing.agreement.grid" output="1"/>
 </layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_index.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_index.xml
similarity index 89%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_index.xml
rename to app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_index.xml
index 47b24fc46693ed7ad08827c3a5ec266697cce4f7..25966126293b8ee340662f7ae2a54a049f061557 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_index.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_index.xml
@@ -25,6 +25,6 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Adminhtml\Recurring\Profile" name="sales.recurring.profile.grid.container"/>
+        <block class="Magento\Paypal\Block\Adminhtml\Billing\Agreement" name="paypal.billing.agreement.grid.container"/>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_ordersgrid.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml
similarity index 94%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_ordersgrid.xml
rename to app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml
index 7c46929633b23bf5e1d18c31687668d40dc6b7d7..fb4f7a97c05c4403f3b533ae63c3981f2bf208f0 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_ordersgrid.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_ordersgrid.xml
@@ -28,7 +28,7 @@
     <referenceBlock name="sales.order.grid">
         <arguments>
             <argument name="dataSource" xsi:type="object">
-                <updater>Magento\Sales\Model\Billing\Agreement\OrdersUpdater</updater>
+                <updater>Magento\Paypal\Model\Billing\Agreement\OrdersUpdater</updater>
             </argument>
             <argument name="grid_url" xsi:type="url" path="*/*/ordersgrid"/>
         </arguments>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_view.xml b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml
similarity index 79%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_view.xml
rename to app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml
index 5dbbb2b7d59961ebd61fbbe54afd029c6f3c3001..d6d7aea7ccd92d81e35fc54386e21bd3fbbd3a33 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_view.xml
+++ b/app/code/Magento/Paypal/view/adminhtml/layout/paypal_billing_agreement_view.xml
@@ -28,7 +28,7 @@
     <referenceBlock name="sales.order.grid">
         <arguments>
             <argument name="dataSource" xsi:type="object">
-                <updater>Magento\Sales\Model\Billing\Agreement\OrdersUpdater</updater>
+                <updater>Magento\Paypal\Model\Billing\Agreement\OrdersUpdater</updater>
             </argument>
             <argument name="grid_url" xsi:type="url" path="*/*/ordersgrid"/>
         </arguments>
@@ -36,15 +36,15 @@
     <remove name="sales.order.grid.export"/>
     <remove name="sales.order.grid.massaction"/>
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Adminhtml\Billing\Agreement\View" name="sales.billing.agreement.view"/>
+        <block class="Magento\Paypal\Block\Adminhtml\Billing\Agreement\View" name="paypal.billing.agreement.view"/>
     </referenceContainer>
     <referenceContainer name="left">
-        <block class="Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tabs" name="sales.billing.agreement.tabs">
+        <block class="Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tabs" name="paypal.billing.agreement.tabs">
             <action method="addTab">
                 <argument name="name" xsi:type="string">billing_agreement_info</argument>
-                <argument name="block" xsi:type="string">Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab\Info</argument>
+                <argument name="block" xsi:type="string">Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab\Info</argument>
             </action>
-            <block class="Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab\Orders" name="sales_order.grid.container"/>
+            <block class="Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab\Orders" name="sales_order.grid.container"/>
             <action method="addTab">
                 <argument name="name" xsi:type="string">billing_agreement_orders</argument>
                 <argument name="block" xsi:type="string">sales_order.grid.container</argument>
diff --git a/app/code/Magento/Sales/view/adminhtml/payment/form/billing/agreement.phtml b/app/code/Magento/Paypal/view/adminhtml/payment/form/billing/agreement.phtml
similarity index 93%
rename from app/code/Magento/Sales/view/adminhtml/payment/form/billing/agreement.phtml
rename to app/code/Magento/Paypal/view/adminhtml/payment/form/billing/agreement.phtml
index 08f51da2b05e7cbbfebd46b7e3cabccb5951cafe..72c1fa5082ec468684b2d96a28346f54e3f14b53 100644
--- a/app/code/Magento/Sales/view/adminhtml/payment/form/billing/agreement.phtml
+++ b/app/code/Magento/Paypal/view/adminhtml/payment/form/billing/agreement.phtml
@@ -18,13 +18,11 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    design
- * @package     default_default
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Payment\Form\Billing\Agreement */?>
+<?php /* @var $this \Magento\Paypal\Block\Payment\Form\Billing\Agreement */?>
 <?php $_code=$this->getMethodCode() ?>
 <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
     <li>
diff --git a/app/code/Magento/Sales/view/frontend/billing/agreement/view.phtml b/app/code/Magento/Paypal/view/frontend/billing/agreement/view.phtml
similarity index 98%
rename from app/code/Magento/Sales/view/frontend/billing/agreement/view.phtml
rename to app/code/Magento/Paypal/view/frontend/billing/agreement/view.phtml
index 7531bcd64b6c00e1b3856168b33f71a33c9bb2e9..35d85beaad66cde0ad07c9329bfae8067d1b0f2c 100644
--- a/app/code/Magento/Sales/view/frontend/billing/agreement/view.phtml
+++ b/app/code/Magento/Paypal/view/frontend/billing/agreement/view.phtml
@@ -23,7 +23,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Billing\Agreement\View */ ?>
+<?php /* @var $this \Magento\Paypal\Block\Billing\Agreement\View */ ?>
 <div class="block billing agreements">
     <div class="title">
         <strong><?php echo __('Billing Agreement # %1', $this->escapeHtml($this->getReferenceId())) ?></strong>
@@ -99,4 +99,4 @@
             </div>
         </div>
     </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/app/code/Magento/Sales/view/frontend/billing/agreements.phtml b/app/code/Magento/Paypal/view/frontend/billing/agreements.phtml
similarity index 98%
rename from app/code/Magento/Sales/view/frontend/billing/agreements.phtml
rename to app/code/Magento/Paypal/view/frontend/billing/agreements.phtml
index 1611ca416dd4e9b329aa92a8a03a40a49ced0e7a..cac5faca8fa9906b5efaacbf40443f78d9059933 100644
--- a/app/code/Magento/Sales/view/frontend/billing/agreements.phtml
+++ b/app/code/Magento/Paypal/view/frontend/billing/agreements.phtml
@@ -22,7 +22,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Billing\Agreements */ ?>
+<?php /* @var $this \Magento\Paypal\Block\Billing\Agreements */ ?>
 <div class="block billing agreements">
     <?php $billingAgreements = $this->getBillingAgreements(); ?>
     <?php if (count($billingAgreements) > 0): ?>
diff --git a/app/code/Magento/Paypal/view/frontend/checkout/onepage/success/billing_agreement.phtml b/app/code/Magento/Paypal/view/frontend/checkout/onepage/success/billing_agreement.phtml
new file mode 100644
index 0000000000000000000000000000000000000000..0ff348e20ca8fa70dafac31ce400a4438b1bdf10
--- /dev/null
+++ b/app/code/Magento/Paypal/view/frontend/checkout/onepage/success/billing_agreement.phtml
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+?>
+<?php /* @var $this \Magento\Paypal\Block\Checkout\Onepage\Success\BillingAgreement */ ?>
+<p><?php echo __('Your billing agreement # is: %1.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml b/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml
deleted file mode 100644
index 6abd619074b566ca44569315eb93c7e74a2ebdd3..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <referenceBlock name="product.tooltip">
-        <container name="product.info.addtocart.paypal.wrapper" label="PayPal Express Checkout Shortcut Wrapper"
-                   htmlTag="div">
-            <block class="Magento\Paypal\Block\Express\Shortcut" name="product.info.addtocart.paypal"
-                   template="express/shortcut.phtml" cacheable="false">
-                <action method="setIsInCatalogProduct">
-                    <argument name="value" xsi:type="string">1</argument>
-                </action>
-                <action method="setShowOrPosition">
-                    <argument name="value" xsi:type="string">after</argument>
-                </action>
-            </block>
-        </container>
-        <container name="product.info.addtocart.payflow.wrapper"
-                   label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="div">
-            <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="product.info.addtocart.payflow"
-                   template="express/shortcut.phtml" cacheable="false">
-                <action method="setIsInCatalogProduct">
-                    <argument name="value" xsi:type="string">1</argument>
-                </action>
-                <action method="setShowOrPosition">
-                    <argument name="value" xsi:type="string">after</argument>
-                </action>
-            </block>
-        </container>
-    </referenceBlock>
-</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/Paypal/view/frontend/layout/catalog_category_view.xml
index 93954b747f8a3d117982bae79c5a924c4f1c0f95..8ffeb3397cbf944ae755965cae2b7743fa693fa7 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/catalog_category_view.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/catalog_category_view.xml
@@ -24,7 +24,6 @@
  */
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
     <referenceContainer name="right">
         <block class="Magento\Paypal\Block\Logo" name="paypal.partner.right.logo" template="partner/logo.phtml"/>
     </referenceContainer>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml
deleted file mode 100644
index df80c2c2a454141be3ee0eef992f76496c02d397..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <referenceBlock name="product.info.addtocart">
-        <container name="product.info.addtocart.paypal.wrapper" label="PayPal Express Checkout Shortcut Wrapper">
-            <block class="Magento\Paypal\Block\Express\Shortcut" name="product.info.addtocart.paypal"
-                   template="express/shortcut.phtml">
-                <action method="setIsInCatalogProduct">
-                    <argument name="value" xsi:type="string">1</argument>
-                </action>
-            </block>
-        </container>
-        <container name="product.info.addtocart.payflow.wrapper"
-                   label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="p"
-                   htmlClass="paypal-logo">
-            <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="product.info.addtocart.payflow"
-                   template="express/shortcut.phtml">
-                <action method="setIsInCatalogProduct">
-                    <argument name="value" xsi:type="string">1</argument>
-                </action>
-            </block>
-        </container>
-    </referenceBlock>
-    <update handle="SHORTCUT_popup"/>
-    <referenceContainer name="right">
-        <block class="Magento\Paypal\Block\Logo" name="paypal.partner.right.logo" template="partner/logo.phtml">
-            <!--action method="setLogoType">
-                <argument name="value" xsi:type="string">wePrefer_150x60</argument>
-            </action-->
-        </block>
-    </referenceContainer>
-</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml
deleted file mode 100644
index 406bf753fa84bf1675cd50aeb52123798daf1727..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <referenceContainer name="checkout.cart.top_methods">
-        <block class="Magento\Paypal\Block\Express\Shortcut" name="checkout.cart.methods.paypal_express.top" before="-"
-               template="express/shortcut.phtml" cacheable="false">
-            <action method="setIsQuoteAllowed">
-                <argument name="value" xsi:type="string">1</argument>
-            </action>
-        </block>
-        <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="checkout.cart.methods.payflow_express.top"
-               before="-" template="express/shortcut.phtml" cacheable="false">
-            <action method="setIsQuoteAllowed">
-                <argument name="value" xsi:type="string">1</argument>
-            </action>
-        </block>
-    </referenceContainer>
-    <referenceContainer name="checkout.cart.methods">
-        <block class="Magento\Paypal\Block\Express\Shortcut" name="checkout.cart.methods.paypal_express.bottom"
-               before="-" template="express/shortcut.phtml" cacheable="false">
-            <action method="setIsQuoteAllowed">
-                <argument name="value" xsi:type="string">1</argument>
-            </action>
-        </block>
-        <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="checkout.cart.methods.payflow_express.bottom"
-               before="-" template="express/shortcut.phtml" cacheable="false">
-            <action method="setIsQuoteAllowed">
-                <argument name="value" xsi:type="string">1</argument>
-            </action>
-        </block>
-    </referenceContainer>
-    <update handle="SHORTCUT_popup"/>
-</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_success.xml b/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_success.xml
index 313d109b31dc36da303702293b30e8e734317499..7795d20aff15e922753599b7f824cbbfc9cbaec0 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_success.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_success.xml
@@ -24,5 +24,7 @@
  */
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
+    <referenceContainer name="order.success.additional.info">
+        <block class="Magento\Paypal\Block\Checkout\Onepage\Success\BillingAgreement" name="onepage.success.billing_agreement" template="checkout/onepage/success/billing_agreement.phtml"/>
+    </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/customer_account.xml b/app/code/Magento/Paypal/view/frontend/layout/customer_account.xml
new file mode 100644
index 0000000000000000000000000000000000000000..884dfa61a88627150a39eb92e6284764dc5b7e8e
--- /dev/null
+++ b/app/code/Magento/Paypal/view/frontend/layout/customer_account.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <referenceBlock name="customer_account_navigation">
+        <block class="Magento\View\Element\Html\Link\Current" name="customer-account-navigation-billing-agreements-link">
+            <arguments>
+                <argument name="path" xsi:type="string">paypal/billing_agreement</argument>
+                <argument name="label" xsi:type="string">Billing Agreements</argument>
+            </arguments>
+        </block>
+    </referenceBlock>
+</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/default.xml b/app/code/Magento/Paypal/view/frontend/layout/default.xml
deleted file mode 100644
index c5d6aeafa3752a78a181cddc9c42bbd1f547e66b..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/default.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <referenceContainer name="topCart.extra_actions">
-        <block class="Magento\Paypal\Block\Express\Shortcut" name="paypal.partner.top_cart.shortcut"
-               template="express/shortcut.phtml" cacheable="false"/>
-        <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="payflow.partner.top_cart.shortcut"
-               template="express/shortcut.phtml" cacheable="false"/>
-    </referenceContainer>
-    <referenceContainer name="cart_sidebar.extra_actions">
-        <block class="Magento\Paypal\Block\Express\Shortcut" name="paypal.partner.cart_sidebar.shortcut"
-               template="express/shortcut.phtml" cacheable="false"/>
-        <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="payflow.partner.cart_sidebar.shortcut"
-               template="express/shortcut.phtml" cacheable="false"/>
-    </referenceContainer>
-</layout>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_billing_agreement_index.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_billing_agreement_index.xml
similarity index 87%
rename from app/code/Magento/Sales/view/frontend/layout/sales_billing_agreement_index.xml
rename to app/code/Magento/Paypal/view/frontend/layout/paypal_billing_agreement_index.xml
index 53ae82c291ed8aac4894f7e7269e01773e6f9bdc..b2390bc3ab6b2aa47106bd27d433d8e5301c2539 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_billing_agreement_index.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_billing_agreement_index.xml
@@ -26,6 +26,6 @@
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <update handle="customer_account"/>
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Billing\Agreements" name="customer.account.billing.agreement" template="billing/agreements.phtml" cacheable="false"/>
+        <block class="Magento\Paypal\Block\Billing\Agreements" name="customer.account.billing.agreement" template="billing/agreements.phtml" cacheable="false"/>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_billing_agreement_view.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_billing_agreement_view.xml
similarity index 86%
rename from app/code/Magento/Sales/view/frontend/layout/sales_billing_agreement_view.xml
rename to app/code/Magento/Paypal/view/frontend/layout/paypal_billing_agreement_view.xml
index f5bcc48c0ffcb4a7b6099fcf43ac6d7c2df432b9..62eebc08ef863141b5580c38ff892e1447d54b82 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_billing_agreement_view.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_billing_agreement_view.xml
@@ -26,6 +26,6 @@
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <update handle="customer_account"/>
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Billing\Agreement\View" name="customer.account.billing.agreement" template="billing/agreement/view.phtml" cacheable="false"/>
+        <block class="Magento\Paypal\Block\Billing\Agreement\View" name="customer.account.billing.agreement" template="billing/agreement/view.phtml" cacheable="false"/>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml
index d9bb4cf14d20dda6729e0f696af1a25f265dda35..0cfaa741736354be25618f5b2606130f13f3f3b6 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml
@@ -45,7 +45,7 @@
                        as="totals" template="onepage/review/totals.phtml" cacheable="false"/>
             </block>
             <block class="Magento\Checkout\Block\Agreements" name="paypal.express.review.details.agreements"
-                   as="agreements" template="onepage/agreements.phtml"/>
+                   as="agreements" template="agreements.phtml"/>
         </block>
     </referenceContainer>
     <block class="Magento\View\Element\Template" name="additional.product.info" template="Magento_Core::template.phtml"/>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml
index 5cdaf6ca42ce7a04aed5080c39b15d635ecdf6e6..0b195afe9d8906c3c085a23d2681e96e87fa459f 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml
@@ -43,7 +43,7 @@
                        as="totals" template="onepage/review/totals.phtml" cacheable="false"/>
             </block>
             <block class="Magento\Checkout\Block\Agreements" name="paypal.express.review.details.agreements"
-                   as="agreements" template="onepage/agreements.phtml"/>
+                   as="agreements" template="agreements.phtml"/>
         </block>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/review_product_list.xml b/app/code/Magento/Paypal/view/frontend/layout/review_product_list.xml
deleted file mode 100644
index 313d109b31dc36da303702293b30e8e734317499..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/review_product_list.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
-</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/tag_customer_view.xml b/app/code/Magento/Paypal/view/frontend/layout/tag_customer_view.xml
deleted file mode 100644
index 313d109b31dc36da303702293b30e8e734317499..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/tag_customer_view.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
-</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/tag_product_list.xml b/app/code/Magento/Paypal/view/frontend/layout/tag_product_list.xml
deleted file mode 100644
index 313d109b31dc36da303702293b30e8e734317499..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/tag_product_list.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
-</layout>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/Paypal/view/frontend/layout/wishlist_index_index.xml
deleted file mode 100644
index 313d109b31dc36da303702293b30e8e734317499..0000000000000000000000000000000000000000
--- a/app/code/Magento/Paypal/view/frontend/layout/wishlist_index_index.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
-</layout>
diff --git a/app/code/Magento/Sales/view/frontend/payment/form/billing/agreement.phtml b/app/code/Magento/Paypal/view/frontend/payment/form/billing/agreement.phtml
similarity index 94%
rename from app/code/Magento/Sales/view/frontend/payment/form/billing/agreement.phtml
rename to app/code/Magento/Paypal/view/frontend/payment/form/billing/agreement.phtml
index 35b7c95f8c73dcf54c843773ec51e32b16539208..e0ee151a77c25d22a88350b88c428c3e20a2e25a 100644
--- a/app/code/Magento/Sales/view/frontend/payment/form/billing/agreement.phtml
+++ b/app/code/Magento/Paypal/view/frontend/payment/form/billing/agreement.phtml
@@ -18,12 +18,11 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    design
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Payment\Form\Billing\Agreement */?>
+<?php /* @var $this \Magento\Paypal\Block\Payment\Form\Billing\Agreement */?>
 <?php $_code=$this->getMethodCode() ?>
 <div class="field items required" id="payment_form_<?php echo $_code ?>" style="display:none;">
     <label for="<?php echo $_code ?>_ba_agreement_id" class="label"><span><?php echo __('Billing Agreement') ?></span></label>
diff --git a/app/code/Magento/Paypal/view/frontend/payment/redirect.phtml b/app/code/Magento/Paypal/view/frontend/payment/redirect.phtml
index c37636582633c0ef486d002a712720b6176bc086..65da4e5f0f082f0f9ee14c190fe9e537d4a3b67b 100644
--- a/app/code/Magento/Paypal/view/frontend/payment/redirect.phtml
+++ b/app/code/Magento/Paypal/view/frontend/payment/redirect.phtml
@@ -30,8 +30,9 @@
  */
 ?>
 <div class="paypal choice field items" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
-    <p><?php echo $this->getRedirectMessage() ?></p>
-    <?php if ($code = $this->getCreateBACode()): ?>
+    <p><?php echo $this->getRedirectMessage(); ?></p>
+    <?php $code = $this->getBillingAgreementCode(); ?>
+    <?php if ($code): ?>
         <input type="checkbox" id="<?php echo $code ?>" value="1" name="payment[<?php echo $code ?>]" class="checkbox">
         <label for="<?php echo $code ?>" class="label">
             <span><?php echo __('Sign a billing agreement to streamline further purchases with PayPal.') ?></span>
diff --git a/app/code/Magento/Persistent/etc/crontab.xml b/app/code/Magento/Persistent/etc/crontab.xml
index 97d50080af9e893f62b0bc9d0c6d482bcefee5bc..92c0bf3b6dd5d39774662e5e694bea9dfb88c82b 100644
--- a/app/code/Magento/Persistent/etc/crontab.xml
+++ b/app/code/Magento/Persistent/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="persistent_clear_expired" instance="Magento\Persistent\Model\Observer" method="clearExpiredCronJob">
-        <schedule>0 0 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="persistent_clear_expired" instance="Magento\Persistent\Model\Observer" method="clearExpiredCronJob">
+            <schedule>0 0 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/ProductAlert/Controller/Add.php b/app/code/Magento/ProductAlert/Controller/Add.php
index 507a4c36449e8d49975cd93f36d260e3fc6e8f28..8cbc5f6714ab7b6330578d0c0dfa4d49abca64dd 100644
--- a/app/code/Magento/ProductAlert/Controller/Add.php
+++ b/app/code/Magento/ProductAlert/Controller/Add.php
@@ -163,6 +163,6 @@ class Add extends \Magento\App\Action\Action
         }
         $currentStore = $this->_storeManager->getStore();
         return strpos($url, $currentStore->getBaseUrl()) === 0
-            || strpos($url, $currentStore->getBaseUrl($currentStore::URL_TYPE_LINK, true)) === 0;
+            || strpos($url, $currentStore->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK, true)) === 0;
     }
 }
diff --git a/app/code/Magento/ProductAlert/etc/crontab.xml b/app/code/Magento/ProductAlert/etc/crontab.xml
index 6bbdb9d116d68c63dfa6039eb3f66481496ba523..09322ed50ac21b53f0c2b9c292f13bbc694a6196 100644
--- a/app/code/Magento/ProductAlert/etc/crontab.xml
+++ b/app/code/Magento/ProductAlert/etc/crontab.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="catalog_product_alert" instance="Magento\ProductAlert\Model\Observer" method="process" />
+    <group id="default">
+        <job name="catalog_product_alert" instance="Magento\ProductAlert\Model\Observer" method="process" />
+    </group>
 </config>
diff --git a/app/code/Magento/Rating/Model/Resource/Rating.php b/app/code/Magento/Rating/Model/Resource/Rating.php
index c7c5297022b32af2e339ae61085d69a0e95d83a3..adb4c3688559dc2fa026a44f0390b1050e83586a 100644
--- a/app/code/Magento/Rating/Model/Resource/Rating.php
+++ b/app/code/Magento/Rating/Model/Resource/Rating.php
@@ -112,7 +112,7 @@ class Rating extends \Magento\Core\Model\Resource\Db\AbstractDb
         $adapter    = $this->_getReadAdapter();
 
         $table      = $this->getMainTable();
-        $storeId    = (int)$this->_storeManager->getStore()->getId();
+        $storeId    = (int)$this->_storeManager->getStore(\Magento\Core\Model\Store::ADMIN_CODE)->getId();
         $select     = parent::_getLoadSelect($field, $value, $object);
         $codeExpr   = $adapter->getIfNullSql('title.value', "{$table}.rating_code");
 
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php
similarity index 84%
rename from app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php
index d589742d0d7a63d64fcf5d02a0c66589633e4803..c9cfa3a844e6ff8e9c198e8b6f4d33f3784972ac 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php
@@ -25,12 +25,11 @@
 /**
  * Adminhtml customer recurring profiles tab
  */
-namespace Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring;
+namespace Magento\RecurringProfile\Block\Adminhtml\Customer\Edit\Tab;
 
 use Magento\Customer\Controller\Adminhtml\Index as CustomerController;
-
-class Profile
-    extends \Magento\Sales\Block\Adminhtml\Recurring\Profile\Grid
+class RecurringProfile
+    extends \Magento\RecurringProfile\Block\Adminhtml\Profile\Grid
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
     /**
@@ -49,8 +48,9 @@ class Profile
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Backend\Helper\Data $backendHelper
      * @param \Magento\Payment\Helper\Data $paymentData
-     * @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection
-     * @param \Magento\Sales\Model\Recurring\ProfileFactory $recurringProfile
+     * @param \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory $profileCollection
+     * @param \Magento\RecurringProfile\Model\States $recurringStates
+     * @param \Magento\RecurringProfile\Block\Fields $fields
      * @param \Magento\Core\Model\Registry $coreRegistry
      * @param array $data
      */
@@ -58,8 +58,9 @@ class Profile
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Backend\Helper\Data $backendHelper,
         \Magento\Payment\Helper\Data $paymentData,
-        \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection,
-        \Magento\Sales\Model\Recurring\ProfileFactory $recurringProfile,
+        \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory $profileCollection,
+        \Magento\RecurringProfile\Model\States $recurringStates,
+        \Magento\RecurringProfile\Block\Fields $fields,
         \Magento\Core\Model\Registry $coreRegistry,
         array $data = array()
     ) {
@@ -80,7 +81,8 @@ class Profile
             $backendHelper,
             $paymentData,
             $profileCollection,
-            $recurringProfile,
+            $recurringStates,
+            $fields,
             $data
         );
     }
@@ -138,7 +140,7 @@ class Profile
     /**
      * Prepare collection for grid
      *
-     * @return \Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring\Profile
+     * @return $this
      */
     protected function _prepareCollection()
     {
@@ -174,6 +176,6 @@ class Profile
      */
     public function getGridUrl()
     {
-        return $this->getUrl('sales/recurring_profile/customerGrid', array('_current' => true));
+        return $this->getUrl('sales/recurringProfile/customerGrid', array('_current' => true));
     }
 }
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile.php
similarity index 86%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile.php
index e8ec81bda1eb4c4c2f37bb49f87195f433be0c46..63651ef36b51f8c3d41285f66dfcf8446eb02f08 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Adminhtml sales orders block
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring;
+namespace Magento\RecurringProfile\Block\Adminhtml;
 
 class Profile extends \Magento\Backend\Block\Widget\Grid\Container
 {
@@ -36,8 +34,8 @@ class Profile extends \Magento\Backend\Block\Widget\Grid\Container
      *
      * @var string
      */
-    protected $_blockGroup = 'Magento_Sales';
-    protected $_controller = 'adminhtml_recurring_profile';
+    protected $_blockGroup = 'Magento_RecurringProfile';
+    protected $_controller = 'adminhtml_profile';
 
     /**
      * Set header text and remove "add" btn
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/Edit/Form.php
similarity index 67%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/Edit/Form.php
index 60029ca34a2a18f85d84d28a07b4d0bbf93751ae..d73ab020245422664d871caeb46416b7e49325a9 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Edit/Form.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/Edit/Form.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -28,7 +26,7 @@
  * Recurring profile editing form
  * Can work in scope of product edit form
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile\Edit;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile\Edit;
 
 class Form extends \Magento\Backend\Block\AbstractBlock
 {
@@ -49,9 +47,9 @@ class Form extends \Magento\Backend\Block\AbstractBlock
     /**
      * Recurring profile instance used for getting labels and options
      *
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Block\Fields
      */
-    protected $_profile;
+    protected $_recurringProfileFields;
 
     /**
      * @var \Magento\Catalog\Model\Product
@@ -64,25 +62,28 @@ class Form extends \Magento\Backend\Block\AbstractBlock
     protected $_formFactory;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\PeriodUnits
      */
-    protected $_recurringProfile;
+    protected $_periodUnits;
 
     /**
      * @param \Magento\Backend\Block\Context $context
      * @param \Magento\Data\FormFactory $formFactory
-     * @param \Magento\Sales\Model\Recurring\Profile $recurringProfile
+     * @param \Magento\RecurringProfile\Block\Fields $recurringProfileFields
+     * @param \Magento\RecurringProfile\Model\PeriodUnits $periodUnits
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Context $context,
         \Magento\Data\FormFactory $formFactory,
-        \Magento\Sales\Model\Recurring\Profile $recurringProfile,
+        \Magento\RecurringProfile\Block\Fields $recurringProfileFields,
+        \Magento\RecurringProfile\Model\PeriodUnits $periodUnits,
         array $data = array()
     ) {
         $this->_formFactory = $formFactory;
-        $this->_profile = $recurringProfile;
+        $this->_recurringProfileFields = $recurringProfileFields;
         parent::__construct($context, $data);
+        $this->_periodUnits = $periodUnits;
     }
 
     /**
@@ -154,49 +155,75 @@ class Form extends \Magento\Backend\Block\AbstractBlock
         $noYes = array(__('No'), __('Yes'));
 
         // schedule
-        $schedule = $form->addFieldset('schedule_fieldset', array(
-            'legend' => __('Schedule'),
-            'disabled'  => $this->_isReadOnly
-        ));
-        $schedule->addField('start_date_is_editable', 'select', array(
-            'name'    => 'start_date_is_editable',
-            'label'   => __('Customer Can Define Start Date'),
-            'comment' => __('Select whether buyer can define the date when billing for the profile begins.'),
-            'options' => $noYes,
-            'disabled' => $this->_isReadOnly
-        ));
+        $schedule = $form->addFieldset(
+            'schedule_fieldset',
+            array(
+                'legend' => __('Schedule'),
+                'disabled' => $this->_isReadOnly
+            )
+        );
+        $schedule->addField(
+            'start_date_is_editable',
+            'select',
+            array(
+                'name' => 'start_date_is_editable',
+                'label' => __('Customer Can Define Start Date'),
+                'comment' => __('Select whether buyer can define the date when billing for the profile begins.'),
+                'options' => $noYes,
+                'disabled' => $this->_isReadOnly
+            )
+        );
         $this->_addField($schedule, 'schedule_description');
         $this->_addField($schedule, 'suspension_threshold');
         $this->_addField($schedule, 'bill_failed_later', array('options' => $noYes), 'select');
 
         // billing
-        $billing = $form->addFieldset('billing_fieldset', array(
-            'legend' => __('Billing'),
-            'disabled'  => $this->_isReadOnly
-        ));
-        $this->_addField($billing, 'period_unit', array(
-            'options' => $this->_getPeriodUnitOptions(__('-- Please Select --')),
-        ), 'select');
+        $billing = $form->addFieldset(
+            'billing_fieldset',
+            array(
+                'legend' => __('Billing'),
+                'disabled' => $this->_isReadOnly
+            )
+        );
+        $this->_addField(
+            $billing,
+            'period_unit',
+            array(
+                'options' => $this->_getPeriodUnitOptions(__('-- Please Select --')),
+            ),
+            'select'
+        );
         $this->_addField($billing, 'period_frequency');
         $this->_addField($billing, 'period_max_cycles');
 
         // trial
-        $trial = $form->addFieldset('trial_fieldset', array(
-            'legend' => __('Trial Period'),
-            'disabled'  => $this->_isReadOnly
-        ));
-        $this->_addField($trial, 'trial_period_unit', array(
-            'options' => $this->_getPeriodUnitOptions(__('-- Not Selected --')),
-        ), 'select');
+        $trial = $form->addFieldset(
+            'trial_fieldset',
+            array(
+                'legend' => __('Trial Period'),
+                'disabled' => $this->_isReadOnly
+            )
+        );
+        $this->_addField(
+            $trial,
+            'trial_period_unit',
+            array(
+                'options' => $this->_getPeriodUnitOptions(__('-- Not Selected --')),
+            ),
+            'select'
+        );
         $this->_addField($trial, 'trial_period_frequency');
         $this->_addField($trial, 'trial_period_max_cycles');
         $this->_addField($trial, 'trial_billing_amount');
 
         // initial fees
-        $initial = $form->addFieldset('initial_fieldset', array(
-            'legend' => __('Initial Fees'),
-            'disabled'  => $this->_isReadOnly
-        ));
+        $initial = $form->addFieldset(
+            'initial_fieldset',
+            array(
+                'legend' => __('Initial Fees'),
+                'disabled' => $this->_isReadOnly
+            )
+        );
         $this->_addField($initial, 'init_amount');
         $this->_addField($initial, 'init_may_fail', array('options' => $noYes), 'select');
 
@@ -215,12 +242,15 @@ class Form extends \Magento\Backend\Block\AbstractBlock
      */
     protected function _addField($formOrFieldset, $elementName, $options = array(), $type = 'text')
     {
-        $options = array_merge($options, array(
-            'name'     => $elementName,
-            'label'    => $this->_profile->getFieldLabel($elementName),
-            'note'     => $this->_profile->getFieldComment($elementName),
-            'disabled' => $this->_isReadOnly,
-        ));
+        $options = array_merge(
+            $options,
+            array(
+                'name' => $elementName,
+                'label' => $this->_recurringProfileFields->getFieldLabel($elementName),
+                'note' => $this->_recurringProfileFields->getFieldComment($elementName),
+                'disabled' => $this->_isReadOnly,
+            )
+        );
         if (in_array($elementName, array('period_unit', 'period_frequency'))) {
             $options['required'] = true;
         }
@@ -235,8 +265,9 @@ class Form extends \Magento\Backend\Block\AbstractBlock
      */
     protected function _getPeriodUnitOptions($emptyLabel)
     {
-        return array_merge(array('' => $emptyLabel),
-            $this->_profile->getAllPeriodUnits()
+        return array_merge(
+            array('' => $emptyLabel),
+            $this->_periodUnits->toOptionArray()
         );
     }
 
@@ -244,7 +275,7 @@ class Form extends \Magento\Backend\Block\AbstractBlock
      * Set readonly flag
      *
      * @param boolean $isReadonly
-     * @return \Magento\Sales\Block\Adminhtml\Recurring\Profile\Edit\Form
+     * @return \Magento\RecurringProfile\Block\Adminhtml\Profile\Edit\Form
      */
     public function setIsReadonly($isReadonly)
     {
@@ -256,6 +287,7 @@ class Form extends \Magento\Backend\Block\AbstractBlock
      * Get readonly flag
      *
      * @return boolean
+     * @SuppressWarnings(PHPMD.BooleanGetMethodName)
      */
     public function getIsReadonly()
     {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/Grid.php
similarity index 74%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/Grid.php
index 7847b9ceb92b046687159e963a4c7d07d2cd2837..b6293e7edea905c25d030c9a18ad5c6351388e29 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/Grid.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Recurring profiles grid
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile;
 
 class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 {
@@ -42,41 +40,49 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     protected $_paymentData = null;
 
     /**
-     * @var \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory
+     * @var \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory
      */
     protected $_profileCollection;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\ProfileFactory
+     * @var \Magento\RecurringProfile\Model\States
      */
-    protected $_recurringProfile;
+    protected $recurringStates;
+
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
 
     /**
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Backend\Helper\Data $backendHelper
      * @param \Magento\Payment\Helper\Data $paymentData
-     * @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection
-     * @param \Magento\Sales\Model\Recurring\ProfileFactory $recurringProfile
+     * @param \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory $profileCollection
+     * @param \Magento\RecurringProfile\Model\States $recurringStates
+     * @param \Magento\RecurringProfile\Block\Fields $fields
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Backend\Helper\Data $backendHelper,
         \Magento\Payment\Helper\Data $paymentData,
-        \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection,
-        \Magento\Sales\Model\Recurring\ProfileFactory $recurringProfile,
+        \Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory $profileCollection,
+        \Magento\RecurringProfile\Model\States $recurringStates,
+        \Magento\RecurringProfile\Block\Fields $fields,
         array $data = array()
     ) {
         $this->_paymentData = $paymentData;
         $this->_profileCollection = $profileCollection;
-        $this->_recurringProfile = $recurringProfile;
+        $this->recurringStates = $recurringStates;
         parent::__construct($context, $backendHelper, $data);
+        $this->_fields = $fields;
     }
 
     protected function _construct()
     {
         parent::_construct();
-        $this->setId('sales_recurring_profile_grid');
+        $this->setId('recurring_profile_grid');
         $this->setUseAjax(true);
         $this->setSaveParametersInSession(true);
     }
@@ -99,14 +105,12 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     /**
      * Prepare grid columns
      *
-     * @return \Magento\Sales\Block\Adminhtml\Recurring\Profile\Grid
+     * @return \Magento\RecurringProfile\Block\Adminhtml\Profile\Grid
      */
     protected function _prepareColumns()
     {
-        $profile = $this->_recurringProfile->create();
-
         $this->addColumn('reference_id', array(
-            'header' => $profile->getFieldLabel('reference_id'),
+            'header' => $this->_fields->getFieldLabel('reference_id'),
             'index' => 'reference_id',
             'html_decorators' => array('nobr'),
             'width' => 1,
@@ -123,16 +127,16 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         }
 
         $this->addColumn('state', array(
-            'header' => $profile->getFieldLabel('state'),
+            'header' => $this->_fields->getFieldLabel('state'),
             'index' => 'state',
             'type'  => 'options',
-            'options' => $profile->getAllStates(),
+            'options' => $this->recurringStates->toOptionArray(),
             'html_decorators' => array('nobr'),
             'width' => 1,
         ));
 
         $this->addColumn('created_at', array(
-            'header' => $profile->getFieldLabel('created_at'),
+            'header' => $this->_fields->getFieldLabel('created_at'),
             'index' => 'created_at',
             'type' => 'datetime',
             'html_decorators' => array('nobr'),
@@ -140,7 +144,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
         ));
 
         $this->addColumn('updated_at', array(
-            'header' => $profile->getFieldLabel('updated_at'),
+            'header' => $this->_fields->getFieldLabel('updated_at'),
             'index' => 'updated_at',
             'type' => 'datetime',
             'html_decorators' => array('nobr'),
@@ -152,14 +156,14 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
             $methods[$method->getCode()] = $method->getTitle();
         }
         $this->addColumn('method_code', array(
-            'header'  => $profile->getFieldLabel('method_code'),
+            'header'  => $this->_fields->getFieldLabel('method_code'),
             'index'   => 'method_code',
             'type'    => 'options',
             'options' => $methods,
         ));
 
         $this->addColumn('schedule_description', array(
-            'header' => $profile->getFieldLabel('schedule_description'),
+            'header' => $this->_fields->getFieldLabel('schedule_description'),
             'index' => 'schedule_description',
         ));
 
@@ -174,7 +178,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
      */
     public function getRowUrl($row)
     {
-        return $this->getUrl('sales/recurring_profile/view', array('profile' => $row->getId()));
+        return $this->getUrl('sales/recurringProfile/view', array('profile' => $row->getId()));
     }
 
     /**
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View.php
similarity index 94%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View.php
index 8661059a14ad71264cd19d8873bdaaf84cff4be8..36688fae546dfcc6c6002656a58295a661ac6876 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Recurring profile view page
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile;
 
 class View extends \Magento\Backend\Block\Widget\Container
 {
@@ -55,7 +53,7 @@ class View extends \Magento\Backend\Block\Widget\Container
     /**
      * Create buttons
      * TODO: implement ACL restrictions
-     * @return \Magento\Sales\Block\Adminhtml\Recurring\Profile\View
+     * @return \Magento\RecurringProfile\Block\Adminhtml\Profile\View
      */
     protected function _prepareLayout()
     {
@@ -114,7 +112,7 @@ class View extends \Magento\Backend\Block\Widget\Container
     /**
      * Set title and a hack for tabs container
      *
-     * @return \Magento\Sales\Block\Adminhtml\Recurring\Profile\View
+     * @return \Magento\RecurringProfile\Block\Adminhtml\Profile\View
      */
     protected function _beforeToHtml()
     {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Getawayinfo.php
similarity index 82%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Getawayinfo.php
index f4b2aa53f8665eb8715adeb36434008d1f881242..899745b4ebd8bf8eb4169486b06bc892c87f4472 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Getawayinfo.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Getawayinfo.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -31,7 +29,7 @@
  * @package    Magento_Sales
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile\View;
 
 class Getawayinfo extends \Magento\Backend\Block\Widget
 {
@@ -42,18 +40,26 @@ class Getawayinfo extends \Magento\Backend\Block\Widget
      */
     protected $_coreRegistry = null;
 
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
     /**
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\RecurringProfile\Block\Fields $fields
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
+        \Magento\RecurringProfile\Block\Fields $fields,
         array $data = array()
     ) {
         $this->_coreRegistry = $registry;
         parent::__construct($context, $data);
+        $this->_fields = $fields;
     }
 
     /**
@@ -65,8 +71,8 @@ class Getawayinfo extends \Magento\Backend\Block\Widget
     {
         $recurringProfile = $this->_coreRegistry->registry('current_recurring_profile');
         $information = array();
-        foreach ($recurringProfile->getData() as $kay => $value) {
-            $information[$recurringProfile->getFieldLabel($kay)] = $value;
+        foreach ($recurringProfile->getData() as $key => $value) {
+            $information[$this->_fields->getFieldLabel($key)] = $value;
         }
         return $information;
     }
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Info.php
similarity index 81%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Info.php
index 340fe705ae06596aa83bb4907680f8f5756a77c4..1b7a164e85e4dd1857d3d6fa347617e8091622ab 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Info.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Info.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -31,7 +29,7 @@
  * @package    Magento_Sales
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile\View;
 
 class Info extends \Magento\Backend\Block\Widget
 {
@@ -42,18 +40,26 @@ class Info extends \Magento\Backend\Block\Widget
      */
     protected $_coreRegistry = null;
 
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
     /**
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\RecurringProfile\Block\Fields $fields
      * @param array $data
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
+        \Magento\RecurringProfile\Block\Fields $fields,
         array $data = array()
     ) {
         $this->_coreRegistry = $registry;
         parent::__construct($context, $data);
+        $this->_fields = $fields;
     }
 
     /**
@@ -65,8 +71,8 @@ class Info extends \Magento\Backend\Block\Widget
     {
         $recurringProfile = $this->_coreRegistry->registry('current_recurring_profile');
         $information = array();
-        foreach ($recurringProfile->getData() as $kay => $value) {
-            $information[$recurringProfile->getFieldLabel($kay)] = $value;
+        foreach ($recurringProfile->getData() as $key => $value) {
+            $information[$this->_fields->getFieldLabel($key)] = $value;
         }
         return $information;
     }
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Items.php
similarity index 92%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Items.php
index 2fcff2a187c97f3096c78b02ce6ae3f96ab6de76..b5446ef52e75f010e288f7cc91f53659027b5c9c 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Items.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Items.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -31,7 +29,7 @@
  * @package    Magento_Sales
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile\View;
 
 class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems
 {
@@ -49,7 +47,7 @@ class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems
     /**
      * Return current recurring profile
      *
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\Profile
      */
     public function _getRecurringProfile()
     {
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Tab/Info.php
similarity index 92%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Tab/Info.php
index 374ce44376e3949af392788684bc5e990c818a51..7aa3d29b2f955f9c6b386b85227ac610484a3911 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Info.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Tab/Info.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Recurring profile information tab
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab;
 
 class Info
     extends \Magento\Backend\Block\Widget
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Tab/Orders.php
similarity index 96%
rename from app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php
rename to app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Tab/Orders.php
index 7b41c64d2b99ebbbef3ab417d4f8fa977a9d905f..2123c842fa43ce4fcc410bbc878c4be934dd14bb 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php
+++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Profile/View/Tab/Orders.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Recurring profile orders grid
  */
-namespace Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab;
+namespace Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab;
 
 class Orders
     extends \Magento\Backend\Block\Widget\Grid\Extended
@@ -86,7 +84,7 @@ class Orders
     /**
      * Prepare grid collection object
      *
-     * @return \Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Orders
+     * @return \Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Orders
      */
     protected function _prepareCollection()
     {
@@ -101,7 +99,7 @@ class Orders
      *
      * TODO: fix up this mess
      *
-     * @return \Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Orders
+     * @return \Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Orders
      */
     protected function _prepareColumns()
     {
diff --git a/app/code/Magento/Payment/Block/Catalog/Product/View/Profile.php b/app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php
similarity index 87%
rename from app/code/Magento/Payment/Block/Catalog/Product/View/Profile.php
rename to app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php
index 832e4b14579db900acf79937f5b743c06b9cc63c..b21bc0e32e82dd08bf8348674c70f2eeda184de2 100644
--- a/app/code/Magento/Payment/Block/Catalog/Product/View/Profile.php
+++ b/app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php
@@ -25,14 +25,14 @@
 /**
  * Recurring profile info/options product view block
  */
-namespace Magento\Payment\Block\Catalog\Product\View;
+namespace Magento\RecurringProfile\Block\Catalog\Product\View;
 
 class Profile extends \Magento\View\Element\Template
 {
     /**
      * Recurring profile instance
      *
-     * @var \Magento\Payment\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\RecurringProfile
      */
     protected $_profile = false;
 
@@ -43,24 +43,23 @@ class Profile extends \Magento\View\Element\Template
      */
     protected $_registry = null;
 
-
     /**
      * Recurring profile factory
      *
-     * @var \Magento\Payment\Model\Recurring\ProfileFactory
+     * @var \Magento\RecurringProfile\Model\RecurringProfileFactory
      */
     protected $_profileFactory;
 
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
-     * @param \Magento\Payment\Model\Recurring\ProfileFactory $profileFactory
+     * @param \Magento\RecurringProfile\Model\RecurringProfileFactory $profileFactory
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
-        \Magento\Payment\Model\Recurring\ProfileFactory $profileFactory,
+        \Magento\RecurringProfile\Model\RecurringProfileFactory $profileFactory,
         array $data = array()
     ) {
         parent::__construct($context, $data);
@@ -97,19 +96,20 @@ class Profile extends \Magento\View\Element\Template
             $calendar = $this->getLayout()
                 ->createBlock('Magento\View\Element\Html\Date')
                 ->setId('recurring_start_date')
-                ->setName(\Magento\Payment\Model\Recurring\Profile::BUY_REQUEST_START_DATETIME)
+                ->setName(\Magento\RecurringProfile\Model\RecurringProfile::BUY_REQUEST_START_DATETIME)
                 ->setClass('datetime-picker input-text')
                 ->setImage($this->getViewFileUrl('Magento_Core::calendar.gif'))
                 ->setDateFormat($this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT))
                 ->setTimeFormat($this->_locale->getTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT));
             return $calendar->getHtml();
         }
+        return '';
     }
 
     /**
      * Determine current product and initialize its recurring profile model
      *
-     * @return \Magento\Payment\Block\Catalog\Product\View\Profile
+     * @return \Magento\RecurringProfile\Block\Catalog\Product\View\Profile
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/RecurringProfile/Block/Fields.php b/app/code/Magento/RecurringProfile/Block/Fields.php
new file mode 100644
index 0000000000000000000000000000000000000000..69e8c40a459cb7834e28a675bd4c5185d4f1d44a
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/Block/Fields.php
@@ -0,0 +1,144 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\RecurringProfile\Block;
+
+/**
+ * Recurring profile fields block
+ *
+ * @TODO: this is temporary solution, revise it during recurring profile-related blocks movement
+ */
+class Fields extends \Magento\Backend\Block\AbstractBlock
+{
+    /**
+     * Getter for field label
+     *
+     * @param string $field
+     * @return string|null
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+     */
+    public function getFieldLabel($field)
+    {
+        switch ($field) {
+            case 'order_item_id':
+                return __('Purchased Item');
+            case 'state':
+                return __('Profile State');
+            case 'created_at':
+                return __('Created');
+            case 'updated_at':
+                return __('Updated');
+            case 'subscriber_name':
+                return __('Subscriber Name');
+            case 'start_datetime':
+                return __('Start Date');
+            case 'internal_reference_id':
+                return __('Internal Reference ID');
+            case 'schedule_description':
+                return __('Schedule Description');
+            case 'suspension_threshold':
+                return __('Maximum Payment Failures');
+            case 'bill_failed_later':
+                return __('Auto Bill on Next Cycle');
+            case 'period_unit':
+                return __('Billing Period Unit');
+            case 'period_frequency':
+                return __('Billing Frequency');
+            case 'period_max_cycles':
+                return __('Maximum Billing Cycles');
+            case 'billing_amount':
+                return __('Billing Amount');
+            case 'trial_period_unit':
+                return __('Trial Billing Period Unit');
+            case 'trial_period_frequency':
+                return __('Trial Billing Frequency');
+            case 'trial_period_max_cycles':
+                return __('Maximum Trial Billing Cycles');
+            case 'trial_billing_amount':
+                return __('Trial Billing Amount');
+            case 'currency_code':
+                return __('Currency');
+            case 'shipping_amount':
+                return __('Shipping Amount');
+            case 'tax_amount':
+                return __('Tax Amount');
+            case 'init_amount':
+                return __('Initial Fee');
+            case 'init_may_fail':
+                return __('Allow Initial Fee Failure');
+            case 'method_code':
+                return __('Payment Method');
+            case 'reference_id':
+                return __('Payment Reference ID');
+        }
+    }
+
+    /**
+     * Getter for field comments
+     *
+     * @param string $field
+     * @return string|null
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+     */
+    public function getFieldComment($field)
+    {
+        switch ($field) {
+            case 'order_item_id':
+                return __('Original order item that recurring payment profile corresponds to');
+            case 'subscriber_name':
+                return __(
+                    'Full name of the person receiving the product or service paid for by the recurring payment.'
+                );
+            case 'start_datetime':
+                return __('This is the date when billing for the profile begins.');
+            case 'schedule_description':
+                return __(
+                    'Enter a short description of the recurring payment. '
+                        . 'By default, this description will match the product name.'
+                );
+            case 'suspension_threshold':
+                return __(
+                    'This is the number of scheduled payments '
+                        . 'that can fail before the profile is automatically suspended.'
+                );
+            case 'bill_failed_later':
+                return __(
+                    'Use this to automatically bill the outstanding balance amount in the next billing cycle '
+                        . '(if there were failed payments).'
+                );
+            case 'period_unit':
+                return __('This is the unit for billing during the subscription period.');
+            case 'period_frequency':
+                return __('This is the number of billing periods that make up one billing cycle.');
+            case 'period_max_cycles':
+                return __('This is the number of billing cycles for the payment period.');
+            case 'init_amount':
+                return __('The initial, non-recurring payment amount is due immediately when the profile is created.');
+            case 'init_may_fail':
+                return __(
+                    'This sets whether to suspend the payment profile if the initial fee fails or, '
+                        . 'instead, add it to the outstanding balance.'
+                );
+        }
+    }
+}
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/Grid.php b/app/code/Magento/RecurringProfile/Block/Profile/Grid.php
similarity index 79%
rename from app/code/Magento/Sales/Block/Recurring/Profile/Grid.php
rename to app/code/Magento/RecurringProfile/Block/Profile/Grid.php
index af49a62aaecb556b922780d3df7a4dff8d5f25c2..523e11699789be9a676d5b64b9ee1cde6a6b1065 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/Grid.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/Grid.php
@@ -18,18 +18,16 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile;
+namespace Magento\RecurringProfile\Block\Profile;
 
 /**
  * Recurring profile view grid
  */
-class Grid extends \Magento\Sales\Block\Recurring\Profiles
+class Grid extends \Magento\RecurringProfile\Block\Profiles
 {
     /**
      * @var \Magento\Core\Model\Registry
@@ -37,32 +35,40 @@ class Grid extends \Magento\Sales\Block\Recurring\Profiles
     protected $_registry;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_recurringProfile;
 
     /**
      * Profiles collection
      *
-     * @var \Magento\Sales\Model\Resource\Recurring\Profile\Collection
+     * @var \Magento\RecurringProfile\Model\Resource\Profile\Collection
      */
     protected $_profiles = null;
 
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
     /**
      * @param \Magento\View\Element\Template\Context $context
-     * @param \Magento\Sales\Model\Recurring\Profile $profile
+     * @param \Magento\RecurringProfile\Model\Profile $recurringProfile
      * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\RecurringProfile\Block\Fields $fields
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
-        \Magento\Sales\Model\Recurring\Profile $profile,
+        \Magento\RecurringProfile\Model\Profile $recurringProfile,
         \Magento\Core\Model\Registry $registry,
+        \Magento\RecurringProfile\Block\Fields $fields,
         array $data = array()
     ) {
-        $this->_recurringProfile = $profile;
+        $this->_recurringProfile = $recurringProfile;
         $this->_registry = $registry;
         parent::__construct($context, $data);
+        $this->_fields = $fields;
         $this->_isScopePrivate = true;
     }
 
@@ -96,30 +102,30 @@ class Grid extends \Magento\Sales\Block\Recurring\Profiles
         $this->setGridColumns(array(
             new \Magento\Object(array(
                 'index' => 'reference_id',
-                'title' => $this->_recurringProfile->getFieldLabel('reference_id'),
+                'title' => $this->_fields->getFieldLabel('reference_id'),
                 'is_nobr' => true,
                 'width' => 1,
             )),
             new \Magento\Object(array(
                 'index' => 'state',
-                'title' => $this->_recurringProfile->getFieldLabel('state'),
+                'title' => $this->_fields->getFieldLabel('state'),
             )),
             new \Magento\Object(array(
                 'index' => 'created_at',
-                'title' => $this->_recurringProfile->getFieldLabel('created_at'),
+                'title' => $this->_fields->getFieldLabel('created_at'),
                 'is_nobr' => true,
                 'width' => 1,
                 'is_amount' => true,
             )),
             new \Magento\Object(array(
                 'index' => 'updated_at',
-                'title' => $this->_recurringProfile->getFieldLabel('updated_at'),
+                'title' => $this->_fields->getFieldLabel('updated_at'),
                 'is_nobr' => true,
                 'width' => 1,
             )),
             new \Magento\Object(array(
                 'index' => 'method_code',
-                'title' => $this->_recurringProfile->getFieldLabel('method_code'),
+                'title' => $this->_fields->getFieldLabel('method_code'),
                 'is_nobr' => true,
                 'width' => 1,
             )),
@@ -128,11 +134,11 @@ class Grid extends \Magento\Sales\Block\Recurring\Profiles
         $profiles = array();
         $store = $this->_storeManager->getStore();
         foreach ($this->_profiles as $profile) {
-            $profile->setStore($store)->setLocale($this->_locale);
+            $profile->setStore($store);
             $profiles[] = new \Magento\Object(array(
                 'reference_id' => $profile->getReferenceId(),
                 'reference_id_link_url' => $this->getUrl(
-                    'sales/recurring_profile/view/',
+                    'sales/recurringProfile/view/',
                     array('profile' => $profile->getId())
                 ),
                 'state'       => $profile->renderData('state'),
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/Related/Orders/Grid.php b/app/code/Magento/RecurringProfile/Block/Profile/Related/Orders/Grid.php
similarity index 95%
rename from app/code/Magento/Sales/Block/Recurring/Profile/Related/Orders/Grid.php
rename to app/code/Magento/RecurringProfile/Block/Profile/Related/Orders/Grid.php
index 73ea983ea6ae51910eba24725cad704c39c7f924..7e8566318da2a7e63c61ac4d75032c82a8d9134d 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/Related/Orders/Grid.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/Related/Orders/Grid.php
@@ -18,18 +18,16 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\Related\Orders;
+namespace Magento\RecurringProfile\Block\Profile\Related\Orders;
 
 /**
  * Recurring profile related orders grid
  */
-class Grid extends \Magento\Sales\Block\Recurring\Profile\View
+class Grid extends \Magento\RecurringProfile\Block\Profile\View
 {
     /**
      * @var \Magento\Sales\Model\Resource\Order\Collection
@@ -78,7 +76,7 @@ class Grid extends \Magento\Sales\Block\Recurring\Profile\View
             $this->_relatedOrders = $this->_orderCollection
                 ->addFieldToSelect($fieldsToSelect)
                 ->addFieldToFilter('customer_id', $this->_registry->registry('current_customer')->getId())
-                ->addRecurringProfilesFilter($this->_profile->getId())
+                ->addRecurringProfilesFilter($this->_recurringProfile->getId())
                 ->setOrder('entity_id', 'desc');
         }
     }
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View.php b/app/code/Magento/RecurringProfile/Block/Profile/View.php
similarity index 87%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View.php
index 9cd76f5972a779be286ec01b2d721de2acf2deb3..0183fa3b3a9fd9e5b8c916990291083be4e94d2b 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,14 +25,14 @@
 /**
  * Recurring profile view
  */
-namespace Magento\Sales\Block\Recurring\Profile;
+namespace Magento\RecurringProfile\Block\Profile;
 
 class View extends \Magento\View\Element\Template
 {
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
-    protected $_profile = null;
+    protected $_recurringProfile = null;
 
     /**
      * Whether the block should be used to render $_info
@@ -133,10 +131,8 @@ class View extends \Magento\View\Element\Template
      */
     protected function _prepareLayout()
     {
-        $this->_profile = $this->_registry->registry('current_recurring_profile')
-            ->setStore($this->_storeManager->getStore())
-            ->setLocale($this->_locale)
-        ;
+        $this->_recurringProfile = $this->_registry->registry('current_recurring_profile')
+            ->setStore($this->_storeManager->getStore());
         return parent::_prepareLayout();
     }
 
@@ -147,7 +143,7 @@ class View extends \Magento\View\Element\Template
      */
     protected function _toHtml()
     {
-        if (!$this->_profile || $this->_shouldRenderInfo && !$this->_info) {
+        if (!$this->_recurringProfile || $this->_shouldRenderInfo && !$this->_info) {
             return '';
         }
 
@@ -159,7 +155,10 @@ class View extends \Magento\View\Element\Template
                     continue;
                 }
                 $block->setViewUrl(
-                    $this->getUrl("*/*/{$block->getViewAction()}", array('profile' => $this->_profile->getId()))
+                    $this->getUrl(
+                        "*/*/{$block->getViewAction()}",
+                        array('profile' => $this->_recurringProfile->getId())
+                    )
                 );
             }
         }
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View/Address.php b/app/code/Magento/RecurringProfile/Block/Profile/View/Address.php
similarity index 88%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View/Address.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View/Address.php
index 69ef9f8c7795b240bb5d4c372ae06655aa857f7e..165f9ecb850f31ad81e704381549d94a02a87ab9 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View/Address.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View/Address.php
@@ -18,18 +18,16 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
  * Recurring profile address view
  */
-class Address extends \Magento\Sales\Block\Recurring\Profile\View
+class Address extends \Magento\RecurringProfile\Block\Profile\View
 {
     /**
      * @param \Magento\View\Element\Template\Context $context
@@ -58,7 +56,7 @@ class Address extends \Magento\Sales\Block\Recurring\Profile\View
 
         $this->_shouldRenderInfo = true;
         if ('shipping' == $this->getAddressType()) {
-            if ('1' == $this->_profile->getInfoValue('order_item_info', 'is_virtual')) {
+            if ('1' == $this->_recurringProfile->getInfoValue('order_item_info', 'is_virtual')) {
                 $this->getParentBlock()->unsetChild('sales.recurring.profile.view.shipping');
                 return;
             }
@@ -67,7 +65,7 @@ class Address extends \Magento\Sales\Block\Recurring\Profile\View
             $key = 'billing_address_info';
         }
         $this->setIsAddress(true);
-        $address = $this->_addressFactory->create(array('data' => $this->_profile->getData($key)));
+        $address = $this->_addressFactory->create(array('data' => $this->_recurringProfile->getData($key)));
         $this->_addInfo(array(
             'value' => preg_replace('/\\n{2,}/', "\n", $address->format('text')),
         ));
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View/Data.php b/app/code/Magento/RecurringProfile/Block/Profile/View/Data.php
similarity index 72%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View/Data.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View/Data.php
index 6e0825453d78273ec03fc5953e2746a68685d738..e8616a26bb6ad1a4d5c6e7450706e0ad63901be1 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View/Data.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View/Data.php
@@ -18,18 +18,16 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
  * Recurring profile view data
  */
-class Data extends \Magento\Sales\Block\Recurring\Profile\View
+class Data extends \Magento\RecurringProfile\Block\Profile\View
 {
     /**
      * Prepare profile data
@@ -40,36 +38,36 @@ class Data extends \Magento\Sales\Block\Recurring\Profile\View
     {
         parent::_prepareLayout();
         $this->addData(array(
-            'reference_id' => $this->_profile->getReferenceId(),
-            'can_cancel'   => $this->_profile->canCancel(),
+            'reference_id' => $this->_recurringProfile->getReferenceId(),
+            'can_cancel'   => $this->_recurringProfile->canCancel(),
             'cancel_url'   => $this->getUrl(
                 '*/*/updateState',
                 array(
-                    'profile' => $this->_profile->getId(),
+                    'profile' => $this->_recurringProfile->getId(),
                     'action' => 'cancel'
                 )
             ),
-            'can_suspend'  => $this->_profile->canSuspend(),
+            'can_suspend'  => $this->_recurringProfile->canSuspend(),
             'suspend_url'  => $this->getUrl(
                 '*/*/updateState',
                 array(
-                    'profile' => $this->_profile->getId(),
+                    'profile' => $this->_recurringProfile->getId(),
                     'action' => 'suspend'
                 )
             ),
-            'can_activate' => $this->_profile->canActivate(),
+            'can_activate' => $this->_recurringProfile->canActivate(),
             'activate_url' => $this->getUrl(
                 '*/*/updateState',
                 array(
-                    'profile' => $this->_profile->getId(),
+                    'profile' => $this->_recurringProfile->getId(),
                     'action' => 'activate'
                 )
             ),
-            'can_update'   => $this->_profile->canFetchUpdate(),
+            'can_update'   => $this->_recurringProfile->canFetchUpdate(),
             'update_url'   => $this->getUrl(
                 '*/*/updateProfile',
                 array(
-                    'profile' => $this->_profile->getId()
+                    'profile' => $this->_recurringProfile->getId()
                 )
             ),
             'back_url'     => $this->getUrl('*/*/'),
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View/Fees.php b/app/code/Magento/RecurringProfile/Block/Profile/View/Fees.php
similarity index 77%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View/Fees.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View/Fees.php
index e54c77dd926811f25e6fc1118d5c4e8164bfa1b7..bd800dfef399044d116c210f7ab7beba7c7d9580 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View/Fees.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View/Fees.php
@@ -18,38 +18,44 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
  * Recurring profile view fees
  */
-class Fees extends \Magento\Sales\Block\Recurring\Profile\View
+class Fees extends \Magento\RecurringProfile\Block\Profile\View
 {
     /**
      * @var \Magento\Core\Helper\Data
      */
     protected $_coreHelper;
 
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
     /**
      * @param \Magento\View\Element\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Core\Helper\Data $coreHelper
+     * @param \Magento\RecurringProfile\Block\Fields $fields
      * @param array $data
      */
     public function __construct(
         \Magento\View\Element\Template\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Core\Helper\Data $coreHelper,
+        \Magento\RecurringProfile\Block\Fields $fields,
         array $data = array()
     ) {
         $this->_coreHelper = $coreHelper;
         parent::__construct($context, $registry, $data);
+        $this->_fields = $fields;
     }
 
     /**
@@ -63,15 +69,15 @@ class Fees extends \Magento\Sales\Block\Recurring\Profile\View
 
         $this->_shouldRenderInfo = true;
         $this->_addInfo(array(
-            'label' => $this->_profile->getFieldLabel('currency_code'),
-            'value' => $this->_profile->getCurrencyCode()
+            'label' => $this->_fields->getFieldLabel('currency_code'),
+            'value' => $this->_recurringProfile->getCurrencyCode()
         ));
         $params = array('init_amount', 'trial_billing_amount', 'billing_amount', 'tax_amount', 'shipping_amount');
         foreach ($params as $key) {
-            $value = $this->_profile->getData($key);
+            $value = $this->_recurringProfile->getData($key);
             if ($value) {
                 $this->_addInfo(array(
-                    'label' => $this->_profile->getFieldLabel($key),
+                    'label' => $this->_fields->getFieldLabel($key),
                     'value' => $this->_coreHelper->formatCurrency($value, false),
                     'is_amount' => true,
                 ));
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View/Item.php b/app/code/Magento/RecurringProfile/Block/Profile/View/Item.php
similarity index 89%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View/Item.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View/Item.php
index 982706563caf45ebce26bd57016ca51d97b4c077..3162e01be2ed50b2e8dc4573f0e6c6445689b609 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View/Item.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View/Item.php
@@ -18,18 +18,16 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
  * Recurring profile view item
  */
-class Item extends \Magento\Sales\Block\Recurring\Profile\View
+class Item extends \Magento\RecurringProfile\Block\Profile\View
 {
     /**
      * @var \Magento\Catalog\Model\Product\Option
@@ -76,13 +74,13 @@ class Item extends \Magento\Sales\Block\Recurring\Profile\View
             'sku' => __('SKU'),
             'qty' => __('Quantity'),
         ) as $itemKey => $label) {
-            $value = $this->_profile->getInfoValue($key, $itemKey);
+            $value = $this->_recurringProfile->getInfoValue($key, $itemKey);
             if ($value) {
                 $this->_addInfo(array('label' => $label, 'value' => $value,));
             }
         }
 
-        $request = $this->_profile->getInfoValue($key, 'info_buyRequest');
+        $request = $this->_recurringProfile->getInfoValue($key, 'info_buyRequest');
         if (empty($request)) {
             return;
         }
@@ -94,7 +92,7 @@ class Item extends \Magento\Sales\Block\Recurring\Profile\View
 
         $options = $this->_option->getCollection()
             ->addIdsToFilter(array_keys($request['options']))
-            ->addTitleToResult($this->_profile->getInfoValue($key, 'store_id'))
+            ->addTitleToResult($this->_recurringProfile->getInfoValue($key, 'store_id'))
             ->addValuesToResult();
 
         foreach ($options as $option) {
@@ -113,7 +111,7 @@ class Item extends \Magento\Sales\Block\Recurring\Profile\View
                 $skipHtmlEscaping = true;
 
                 $downloadParams = array(
-                    'id'  => $this->_profile->getId(),
+                    'id'  => $this->_recurringProfile->getId(),
                     'option_id' => $option->getId(),
                     'key' => $request['options'][$option->getId()]['secret_key']
                 );
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View/Reference.php b/app/code/Magento/RecurringProfile/Block/Profile/View/Reference.php
similarity index 59%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View/Reference.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View/Reference.php
index f690d94f2e72bd6ddda59d085f8e02e9dff839b8..90a94a18c8281a795b00e1c3c1b7b886cadb2e28 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View/Reference.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View/Reference.php
@@ -18,19 +18,38 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
  * Recurring profile view reference
  */
-class Reference extends \Magento\Sales\Block\Recurring\Profile\View
+class Reference extends \Magento\RecurringProfile\Block\Profile\View
 {
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
+    /**
+     * @param \Magento\View\Element\Template\Context $context
+     * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\RecurringProfile\Block\Fields $fields
+     * @param array $data
+     */
+    public function __construct(
+        \Magento\View\Element\Template\Context $context,
+        \Magento\Core\Model\Registry $registry,
+        \Magento\RecurringProfile\Block\Fields $fields,
+        array $data = array()
+    ) {
+        parent::__construct($context, $registry, $data);
+        $this->_fields = $fields;
+    }
+
     /**
      * Prepare reference info
      *
@@ -43,8 +62,8 @@ class Reference extends \Magento\Sales\Block\Recurring\Profile\View
         $this->_shouldRenderInfo = true;
         foreach (array('method_code', 'reference_id', 'schedule_description', 'state') as $key) {
             $this->_addInfo(array(
-                'label' => $this->_profile->getFieldLabel($key),
-                'value' => $this->_profile->renderData($key),
+                'label' => $this->_fields->getFieldLabel($key),
+                'value' => $this->_recurringProfile->renderData($key),
             ));
         }
     }
diff --git a/app/code/Magento/Sales/Block/Recurring/Profile/View/Schedule.php b/app/code/Magento/RecurringProfile/Block/Profile/View/Schedule.php
similarity index 60%
rename from app/code/Magento/Sales/Block/Recurring/Profile/View/Schedule.php
rename to app/code/Magento/RecurringProfile/Block/Profile/View/Schedule.php
index c5b44a0b7e33aa2954df1ed5e46c7c0e1e9dc6cb..18d0c76e3787af6c5661915ecbdad3020ed287cf 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profile/View/Schedule.php
+++ b/app/code/Magento/RecurringProfile/Block/Profile/View/Schedule.php
@@ -18,19 +18,38 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
  * Recurring profile view schedule
  */
-class Schedule extends \Magento\Sales\Block\Recurring\Profile\View
+class Schedule extends \Magento\RecurringProfile\Block\Profile\View
 {
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
+    /**
+     * @param \Magento\View\Element\Template\Context $context
+     * @param \Magento\Core\Model\Registry $registry
+     * @param \Magento\RecurringProfile\Block\Fields $fields
+     * @param array $data
+     */
+    public function __construct(
+        \Magento\View\Element\Template\Context $context,
+        \Magento\Core\Model\Registry $registry,
+        \Magento\RecurringProfile\Block\Fields $fields,
+        array $data = array()
+    ) {
+        parent::__construct($context, $registry, $data);
+        $this->_fields = $fields;
+    }
+
     /**
      * Prepare schedule info
      *
@@ -43,12 +62,12 @@ class Schedule extends \Magento\Sales\Block\Recurring\Profile\View
         $this->_shouldRenderInfo = true;
         foreach (array('start_datetime', 'suspension_threshold') as $key) {
             $this->_addInfo(array(
-                'label' => $this->_profile->getFieldLabel($key),
-                'value' => $this->_profile->renderData($key),
+                'label' => $this->_fields->getFieldLabel($key),
+                'value' => $this->_recurringProfile->renderData($key),
             ));
         }
 
-        foreach ($this->_profile->exportScheduleInfo() as $info) {
+        foreach ($this->_recurringProfile->exportScheduleInfo() as $info) {
             $this->_addInfo(array(
                 'label' => $info->getTitle(),
                 'value' => $info->getSchedule(),
diff --git a/app/code/Magento/Sales/Block/Recurring/Profiles.php b/app/code/Magento/RecurringProfile/Block/Profiles.php
similarity index 91%
rename from app/code/Magento/Sales/Block/Recurring/Profiles.php
rename to app/code/Magento/RecurringProfile/Block/Profiles.php
index 39d2dcacdf3de114c5de561cbbf0365a417ea458..166f735187c26900713d7e5c487943f213468c5d 100644
--- a/app/code/Magento/Sales/Block/Recurring/Profiles.php
+++ b/app/code/Magento/RecurringProfile/Block/Profiles.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,7 +25,7 @@
 /**
  * Recurring profiles listing
  */
-namespace Magento\Sales\Block\Recurring;
+namespace Magento\RecurringProfile\Block;
 
 class Profiles extends \Magento\View\Element\Template
 {
@@ -47,7 +45,7 @@ class Profiles extends \Magento\View\Element\Template
     /**
      * Set back Url
      *
-     * @return \Magento\Sales\Block\Recurring\Profiles
+     * @return \Magento\RecurringProfile\Block\Profiles
      */
     protected function _beforeToHtml()
     {
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php
similarity index 93%
rename from app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php
index e3b936978d1c36c89f2adcd26a60fc42b0b18bab..bbbd032e54a14ab3d6ea0427a79ec03e6a71eb5e 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php
@@ -27,13 +27,13 @@
  *
  * TODO: implement ACL restrictions
  */
-namespace Magento\Sales\Controller\Adminhtml\Recurring;
+namespace Magento\RecurringProfile\Controller\Adminhtml;
 
 use Magento\App\Action\NotFoundException;
 use Magento\Core\Exception as CoreException;
 use Magento\Customer\Controller\Adminhtml\Index as CustomerController;
 
-class Profile extends \Magento\Backend\App\Action
+class RecurringProfile extends \Magento\Backend\App\Action
 {
     /**#@+
      * Request parameter keys
@@ -93,7 +93,7 @@ class Profile extends \Magento\Backend\App\Action
     {
         $this->_title->add(__('Recurring Billing Profiles'));
         $this->_view->loadLayout();
-        $this->_setActiveMenu('Magento_Sales::sales_recurring_profile');
+        $this->_setActiveMenu('Magento_RecurringProfile::recurring_profile');
         $this->_view->renderLayout();
     }
 
@@ -106,7 +106,7 @@ class Profile extends \Magento\Backend\App\Action
             $this->_title->add(__('Recurring Billing Profiles'));
             $profile = $this->_initProfile();
             $this->_view->loadLayout();
-            $this->_setActiveMenu('Magento_Sales::sales_recurring_profile');
+            $this->_setActiveMenu('Magento_RecurringProfile::recurring_profile');
             $this->_title->add(__('Profile #%1', $profile->getReferenceId()));
             $this->_view->renderLayout();
             return;
@@ -216,7 +216,7 @@ class Profile extends \Magento\Backend\App\Action
     }
 
     /**
-     * Customer billing agreements ajax action
+     * Customer grid ajax action
      *
      */
     public function customerGridAction()
@@ -234,13 +234,12 @@ class Profile extends \Magento\Backend\App\Action
     /**
      * Load/set profile
      *
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\Profile
      * @throws \Magento\Core\Exception
      */
     protected function _initProfile()
     {
-        /** @var \Magento\Sales\Model\Recurring\Profile $profile */
-        $profile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile')
+        $profile = $this->_objectManager->create('Magento\RecurringProfile\Model\Profile')
             ->load($this->getRequest()->getParam(self::PARAM_PROFILE));
         if (!$profile->getId()) {
             throw new CoreException(__('The profile you specified does not exist.'));
diff --git a/app/code/Magento/Sales/Controller/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Controller/RecurringProfile.php
similarity index 91%
rename from app/code/Magento/Sales/Controller/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Controller/RecurringProfile.php
index 621dd5de02fbaaea2031a24693299154b47f1773..1c228392c92bca034a1ece9af1249972b736253d 100644
--- a/app/code/Magento/Sales/Controller/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Controller/RecurringProfile.php
@@ -18,8 +18,6 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,12 +25,11 @@
 /**
  * Recurring profiles view/management controller
  */
-namespace Magento\Sales\Controller\Recurring;
+namespace Magento\RecurringProfile\Controller;
 
-use Magento\App\Action\NotFoundException;
 use Magento\App\RequestInterface;
 
-class Profile extends \Magento\App\Action\Action
+class RecurringProfile extends \Magento\App\Action\Action
 {
     /**
      *
@@ -180,10 +177,6 @@ class Profile extends \Magento\App\Action\Action
             $this->_title->add(__('Profile #%1', $profile->getReferenceId()));
             $this->_view->loadLayout();
             $this->_view->getLayout()->initMessages();
-            $navigationBlock = $this->_view->getLayout()->getBlock('customer_account_navigation');
-            if ($navigationBlock) {
-                $navigationBlock->setActive('sales/recurring_profile/');
-            }
             $this->_view->renderLayout();
             return;
         } catch (\Magento\Core\Exception $e) {
@@ -197,12 +190,12 @@ class Profile extends \Magento\App\Action\Action
     /**
      * Instantiate current profile and put it into registry
      *
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\Profile
      * @throws \Magento\Core\Exception
      */
     protected function _initProfile()
     {
-        $profile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile')
+        $profile = $this->_objectManager->create('Magento\RecurringProfile\Model\Profile')
             ->load($this->getRequest()->getParam('profile'));
         if (!$profile->getId()) {
             throw new \Magento\Core\Exception(__('We can\'t find the profile you specified.'));
diff --git a/app/code/Magento/RecurringProfile/Model/Observer.php b/app/code/Magento/RecurringProfile/Model/Observer.php
new file mode 100644
index 0000000000000000000000000000000000000000..c4c253d20ebb1e24f355a05390722fa49c1852b6
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/Model/Observer.php
@@ -0,0 +1,160 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\RecurringProfile\Model;
+
+/**
+ * Recurring profile observer
+ */
+class Observer
+{
+    /**
+     * Locale model
+     *
+     * @var \Magento\Core\Model\LocaleInterface
+     */
+    protected $_locale;
+
+    /**
+     * Store manager
+     *
+     * @var \Magento\Core\Model\StoreManagerInterface
+     */
+    protected $_storeManager;
+
+    /**
+     * Recurring profile factory
+     *
+     * @var \Magento\RecurringProfile\Model\RecurringProfileFactory
+     */
+    protected $_profileFactory;
+
+    /**
+     * @var \Magento\View\Element\BlockFactory
+     */
+    protected $_blockFactory;
+
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
+    /**
+     * @param \Magento\Core\Model\LocaleInterface $locale
+     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param \Magento\RecurringProfile\Model\RecurringProfileFactory $profileFactory
+     * @param \Magento\View\Element\BlockFactory $blockFactory
+     * @param \Magento\RecurringProfile\Block\Fields $fields
+     */
+    public function __construct(
+        \Magento\Core\Model\LocaleInterface $locale,
+        \Magento\Core\Model\StoreManagerInterface $storeManager,
+        \Magento\RecurringProfile\Model\RecurringProfileFactory $profileFactory,
+        \Magento\View\Element\BlockFactory $blockFactory,
+        \Magento\RecurringProfile\Block\Fields $fields
+    ) {
+        $this->_locale = $locale;
+        $this->_storeManager = $storeManager;
+        $this->_profileFactory = $profileFactory;
+        $this->_blockFactory = $blockFactory;
+        $this->_fields = $fields;
+    }
+
+    /**
+     * Collect buy request and set it as custom option
+     *
+     * Also sets the collected information and schedule as informational static options
+     *
+     * @param \Magento\Event\Observer $observer
+     */
+    public function prepareProductRecurringProfileOptions($observer)
+    {
+        $product = $observer->getEvent()->getProduct();
+        $buyRequest = $observer->getEvent()->getBuyRequest();
+
+        if (!$product->isRecurring()) {
+            return;
+        }
+
+        /** @var \Magento\RecurringProfile\Model\RecurringProfile $profile */
+        $profile = $this->_profileFactory->create(['locale' => $this->_locale]);
+        $profile->setStore($this->_storeManager->getStore())
+            ->importBuyRequest($buyRequest)
+            ->importProduct($product);
+        if (!$profile) {
+            return;
+        }
+
+        // add the start datetime as product custom option
+        $product->addCustomOption(\Magento\RecurringProfile\Model\RecurringProfile::PRODUCT_OPTIONS_KEY,
+            serialize(array('start_datetime' => $profile->getStartDatetime()))
+        );
+
+        // duplicate as 'additional_options' to render with the product statically
+        $infoOptions = array(array(
+            'label' => $this->_fields->getFieldLabel('start_datetime'),
+            'value' => $profile->exportStartDatetime(),
+        ));
+
+        foreach ($profile->exportScheduleInfo() as $info) {
+            $infoOptions[] = array(
+                'label' => $info->getTitle(),
+                'value' => $info->getSchedule(),
+            );
+        }
+        $product->addCustomOption('additional_options', serialize($infoOptions));
+    }
+
+    /**
+     * Add the recurring profile form when editing a product
+     *
+     * @param \Magento\Event\Observer $observer
+     */
+    public function addFieldsToProductEditForm($observer)
+    {
+        // replace the element of recurring payment profile field with a form
+        $profileElement = $observer->getEvent()->getProductElement();
+        $product = $observer->getEvent()->getProduct();
+
+        /** @var $formBlock \Magento\RecurringProfile\Block\Adminhtml\Profile\Edit\Form */
+        $formBlock = $this->_blockFactory->createBlock('Magento\RecurringProfile\Block\Adminhtml\Profile\Edit\Form');
+        $formBlock->setNameInLayout('adminhtml_recurring_profile_edit_form');
+        $formBlock->setParentElement($profileElement);
+        $formBlock->setProductEntity($product);
+        $output = $formBlock->toHtml();
+
+        // make the profile element dependent on is_recurring
+        /** @var $dependencies \Magento\Backend\Block\Widget\Form\Element\Dependence */
+        $dependencies = $this->_blockFactory->createBlock('Magento\Backend\Block\Widget\Form\Element\Dependence');
+        $dependencies->setNameInLayout('adminhtml_recurring_profile_edit_form_dependence');
+        $dependencies->addFieldMap('is_recurring', 'product[is_recurring]');
+        $dependencies->addFieldMap($profileElement->getHtmlId(), $profileElement->getName());
+        $dependencies->addFieldDependence($profileElement->getName(), 'product[is_recurring]', '1');
+        $dependencies->addConfigOptions(array('levels_up' => 2));
+
+        $output .= $dependencies->toHtml();
+
+        $observer->getEvent()->getResult()->output = $output;
+    }
+}
diff --git a/app/code/Magento/RecurringProfile/Model/PaymentTypeInterface.php b/app/code/Magento/RecurringProfile/Model/PaymentTypeInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..c53f7b8ac192495191fccccddd3a927194fa3639
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/Model/PaymentTypeInterface.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\RecurringProfile\Model;
+
+interface PaymentTypeInterface
+{
+    /**
+     * @var string
+     */
+    const REGULAR = 'regular';
+
+    /**
+     * @var string
+     */
+    const TRIAL = 'trial';
+
+    /**
+     * @var string
+     */
+    const INITIAL = 'initial';
+}
\ No newline at end of file
diff --git a/app/code/Magento/RecurringProfile/Model/PeriodUnits.php b/app/code/Magento/RecurringProfile/Model/PeriodUnits.php
new file mode 100644
index 0000000000000000000000000000000000000000..c2ff91f065312cf33a277eea1f88356fba0bcb7f
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/Model/PeriodUnits.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\RecurringProfile\Model;
+
+use Magento\Core\Model\Option;
+
+class PeriodUnits implements Option\ArrayInterface
+{
+    const DAY = 'day';
+    const WEEK = 'week';
+    const SEMI_MONTH = 'semi_month';
+    const MONTH = 'month';
+    const YEAR = 'year';
+
+    /**
+     * @return array
+     */
+    public function toOptionArray()
+    {
+        return [
+            self::DAY => __('Day'),
+            self::WEEK => __('Week'),
+            self::SEMI_MONTH => __('Two Weeks'),
+            self::MONTH => __('Month'),
+            self::YEAR => __('Year'),
+        ];
+    }
+}
diff --git a/app/code/Magento/Sales/Model/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Model/Profile.php
similarity index 72%
rename from app/code/Magento/Sales/Model/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Model/Profile.php
index b6ccc00ad3bbdce8bf370e9178a7f72d397e5927..c9088be385f57335abb15be806f0acd791761489 100644
--- a/app/code/Magento/Sales/Model/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Model/Profile.php
@@ -18,112 +18,85 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\RecurringProfile\Model;
 
 /**
  * Sales implementation of recurring payment profiles
  * Implements saving and managing profiles
  *
- * @method \Magento\Sales\Model\Resource\Recurring\Profile _getResource()
- * @method \Magento\Sales\Model\Resource\Recurring\Profile getResource()
+ * @method \Magento\RecurringProfile\Model\Resource\Profile _getResource()
+ * @method \Magento\RecurringProfile\Model\Resource\Profile getResource()
  * @method string getState()
- * @method \Magento\Sales\Model\Recurring\Profile setState(string $value)
+ * @method Profile setState(string $value)
  * @method int getCustomerId()
- * @method \Magento\Sales\Model\Recurring\Profile setCustomerId(int $value)
+ * @method Profile setCustomerId(int $value)
  * @method int getStoreId()
- * @method \Magento\Sales\Model\Recurring\Profile setStoreId(int $value)
+ * @method Profile setStoreId(int $value)
  * @method string getMethodCode()
- * @method \Magento\Sales\Model\Recurring\Profile setMethodCode(string $value)
+ * @method Profile setMethodCode(string $value)
  * @method string getCreatedAt()
- * @method \Magento\Sales\Model\Recurring\Profile setCreatedAt(string $value)
+ * @method Profile setCreatedAt(string $value)
  * @method string getUpdatedAt()
- * @method \Magento\Sales\Model\Recurring\Profile setUpdatedAt(string $value)
+ * @method Profile setUpdatedAt(string $value)
  * @method string getReferenceId()
- * @method \Magento\Sales\Model\Recurring\Profile setReferenceId(string $value)
+ * @method Profile setReferenceId(string $value)
  * @method string getSubscriberName()
- * @method \Magento\Sales\Model\Recurring\Profile setSubscriberName(string $value)
+ * @method Profile setSubscriberName(string $value)
  * @method string getStartDatetime()
- * @method \Magento\Sales\Model\Recurring\Profile setStartDatetime(string $value)
+ * @method Profile setStartDatetime(string $value)
  * @method string getInternalReferenceId()
- * @method \Magento\Sales\Model\Recurring\Profile setInternalReferenceId(string $value)
+ * @method Profile setInternalReferenceId(string $value)
  * @method string getScheduleDescription()
- * @method \Magento\Sales\Model\Recurring\Profile setScheduleDescription(string $value)
+ * @method Profile setScheduleDescription(string $value)
  * @method int getSuspensionThreshold()
- * @method \Magento\Sales\Model\Recurring\Profile setSuspensionThreshold(int $value)
+ * @method Profile setSuspensionThreshold(int $value)
  * @method int getBillFailedLater()
- * @method \Magento\Sales\Model\Recurring\Profile setBillFailedLater(int $value)
+ * @method Profile setBillFailedLater(int $value)
  * @method string getPeriodUnit()
- * @method \Magento\Sales\Model\Recurring\Profile setPeriodUnit(string $value)
+ * @method Profile setPeriodUnit(string $value)
  * @method int getPeriodFrequency()
- * @method \Magento\Sales\Model\Recurring\Profile setPeriodFrequency(int $value)
+ * @method Profile setPeriodFrequency(int $value)
  * @method int getPeriodMaxCycles()
- * @method \Magento\Sales\Model\Recurring\Profile setPeriodMaxCycles(int $value)
+ * @method Profile setPeriodMaxCycles(int $value)
  * @method float getBillingAmount()
- * @method \Magento\Sales\Model\Recurring\Profile setBillingAmount(float $value)
+ * @method Profile setBillingAmount(float $value)
  * @method string getTrialPeriodUnit()
- * @method \Magento\Sales\Model\Recurring\Profile setTrialPeriodUnit(string $value)
+ * @method Profile setTrialPeriodUnit(string $value)
  * @method int getTrialPeriodFrequency()
- * @method \Magento\Sales\Model\Recurring\Profile setTrialPeriodFrequency(int $value)
+ * @method Profile setTrialPeriodFrequency(int $value)
  * @method int getTrialPeriodMaxCycles()
- * @method \Magento\Sales\Model\Recurring\Profile setTrialPeriodMaxCycles(int $value)
+ * @method Profile setTrialPeriodMaxCycles(int $value)
  * @method float getTrialBillingAmount()
- * @method \Magento\Sales\Model\Recurring\Profile setTrialBillingAmount(float $value)
+ * @method Profile setTrialBillingAmount(float $value)
  * @method string getCurrencyCode()
- * @method \Magento\Sales\Model\Recurring\Profile setCurrencyCode(string $value)
+ * @method Profile setCurrencyCode(string $value)
  * @method float getShippingAmount()
- * @method \Magento\Sales\Model\Recurring\Profile setShippingAmount(float $value)
+ * @method Profile setShippingAmount(float $value)
  * @method float getTaxAmount()
- * @method \Magento\Sales\Model\Recurring\Profile setTaxAmount(float $value)
+ * @method Profile setTaxAmount(float $value)
  * @method float getInitAmount()
- * @method \Magento\Sales\Model\Recurring\Profile setInitAmount(float $value)
+ * @method Profile setInitAmount(float $value)
  * @method int getInitMayFail()
- * @method \Magento\Sales\Model\Recurring\Profile setInitMayFail(int $value)
+ * @method Profile setInitMayFail(int $value)
  * @method string getOrderInfo()
- * @method \Magento\Sales\Model\Recurring\Profile setOrderInfo(string $value)
+ * @method Profile setOrderInfo(string $value)
  * @method string getOrderItemInfo()
- * @method \Magento\Sales\Model\Recurring\Profile setOrderItemInfo(string $value)
+ * @method Profile setOrderItemInfo(string $value)
  * @method string getBillingAddressInfo()
- * @method \Magento\Sales\Model\Recurring\Profile setBillingAddressInfo(string $value)
+ * @method Profile setBillingAddressInfo(string $value)
  * @method string getShippingAddressInfo()
- * @method \Magento\Sales\Model\Recurring\Profile setShippingAddressInfo(string $value)
+ * @method Profile setShippingAddressInfo(string $value)
  * @method string getProfileVendorInfo()
- * @method \Magento\Sales\Model\Recurring\Profile setProfileVendorInfo(string $value)
+ * @method Profile setProfileVendorInfo(string $value)
  * @method string getAdditionalInfo()
- * @method \Magento\Sales\Model\Recurring\Profile setAdditionalInfo(string $value)
- *
- * @category    Magento
- * @package     Magento_Sales
- * @author      Magento Core Team <core@magentocommerce.com>
+ * @method Profile setAdditionalInfo(string $value)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
-namespace Magento\Sales\Model\Recurring;
-
-class Profile extends \Magento\Payment\Model\Recurring\Profile
+class Profile extends \Magento\RecurringProfile\Model\RecurringProfile
 {
-    /**
-     * Available states
-     *
-     * @var string
-     */
-    const STATE_UNKNOWN   = 'unknown';
-    const STATE_PENDING   = 'pending';
-    const STATE_ACTIVE    = 'active';
-    const STATE_SUSPENDED = 'suspended';
-    const STATE_CANCELED  = 'canceled';
-    const STATE_EXPIRED   = 'expired';
-
-    /**
-     * Payment types
-     *
-     * @var string
-     */
-    const PAYMENT_TYPE_REGULAR   = 'regular';
-    const PAYMENT_TYPE_TRIAL     = 'trial';
-    const PAYMENT_TYPE_INITIAL   = 'initial';
-
     /**
      * Allowed actions matrix
      *
@@ -156,28 +129,42 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     protected $mathRandom;
 
+    /**
+     * @var States
+     */
+    protected $states;
+
     /**
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Payment\Helper\Data $paymentData
+     * @param PeriodUnits $periodUnits
+     * @param \Magento\RecurringProfile\Block\Fields $fields
+     * @param \Magento\Core\Model\LocaleInterface $locale
      * @param \Magento\Sales\Model\OrderFactory $orderFactory
      * @param \Magento\Sales\Model\Order\AddressFactory $addressFactory
      * @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory
      * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory
      * @param \Magento\Math\Random $mathRandom
+     * @param States $states
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
+     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Payment\Helper\Data $paymentData,
+        \Magento\RecurringProfile\Model\PeriodUnits $periodUnits,
+        \Magento\RecurringProfile\Block\Fields $fields,
+        \Magento\Core\Model\LocaleInterface $locale,
         \Magento\Sales\Model\OrderFactory $orderFactory,
         \Magento\Sales\Model\Order\AddressFactory $addressFactory,
         \Magento\Sales\Model\Order\PaymentFactory $paymentFactory,
         \Magento\Sales\Model\Order\ItemFactory $orderItemFactory,
         \Magento\Math\Random $mathRandom,
+        States $states,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
         array $data = array()
@@ -187,7 +174,18 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         $this->_paymentFactory = $paymentFactory;
         $this->_orderItemFactory = $orderItemFactory;
         $this->mathRandom = $mathRandom;
-        parent::__construct($context, $registry, $paymentData, $resource, $resourceCollection, $data);
+        $this->states = $states;
+        parent::__construct(
+            $context,
+            $registry,
+            $paymentData,
+            $periodUnits,
+            $fields,
+            $locale,
+            $resource,
+            $resourceCollection,
+            $data
+        );
     }
 
     /**
@@ -226,11 +224,10 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     public function activate()
     {
-        $this->_checkWorkflow(self::STATE_ACTIVE, false);
-        $this->setNewState(self::STATE_ACTIVE);
+        $this->_checkWorkflow(States::ACTIVE, false);
+        $this->setNewState(States::ACTIVE);
         $this->getMethodInstance()->updateRecurringProfileStatus($this);
-        $this->setState(self::STATE_ACTIVE)
-            ->save();
+        $this->setState(States::ACTIVE)->save();
     }
 
     /**
@@ -240,7 +237,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     public function canActivate()
     {
-        return $this->_checkWorkflow(self::STATE_ACTIVE);
+        return $this->_checkWorkflow(States::ACTIVE);
     }
 
     /**
@@ -248,11 +245,10 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     public function suspend()
     {
-        $this->_checkWorkflow(self::STATE_SUSPENDED, false);
-        $this->setNewState(self::STATE_SUSPENDED);
+        $this->_checkWorkflow(States::SUSPENDED, false);
+        $this->setNewState(States::SUSPENDED);
         $this->getMethodInstance()->updateRecurringProfileStatus($this);
-        $this->setState(self::STATE_SUSPENDED)
-            ->save();
+        $this->setState(States::SUSPENDED)->save();
     }
 
     /**
@@ -262,7 +258,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     public function canSuspend()
     {
-        return $this->_checkWorkflow(self::STATE_SUSPENDED);
+        return $this->_checkWorkflow(States::SUSPENDED);
     }
 
     /**
@@ -270,11 +266,10 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     public function cancel()
     {
-        $this->_checkWorkflow(self::STATE_CANCELED, false);
-        $this->setNewState(self::STATE_CANCELED);
+        $this->_checkWorkflow(States::CANCELED, false);
+        $this->setNewState(States::CANCELED);
         $this->getMethodInstance()->updateRecurringProfileStatus($this);
-        $this->setState(self::STATE_CANCELED)
-            ->save();
+        $this->setState(States::CANCELED)->save();
     }
 
     /**
@@ -284,7 +279,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     public function canCancel()
     {
-        return $this->_checkWorkflow(self::STATE_CANCELED);
+        return $this->_checkWorkflow(States::CANCELED);
     }
 
     public function fetchUpdate()
@@ -293,15 +288,15 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         $this->getMethodInstance()->getRecurringProfileDetails($this->getReferenceId(), $result);
 
         if ($result->getIsProfileActive()) {
-            $this->setState(self::STATE_ACTIVE);
+            $this->setState(States::ACTIVE);
         } elseif ($result->getIsProfilePending()) {
-            $this->setState(self::STATE_PENDING);
+            $this->setState(States::PENDING);
         } elseif ($result->getIsProfileCanceled()) {
-            $this->setState(self::STATE_CANCELED);
+            $this->setState(States::CANCELED);
         } elseif ($result->getIsProfileSuspended()) {
-            $this->setState(self::STATE_SUSPENDED);
+            $this->setState(States::SUSPENDED);
         } elseif ($result->getIsProfileExpired()) {
-            $this->setState(self::STATE_EXPIRED);
+            $this->setState(States::EXPIRED);
         }
     }
 
@@ -354,7 +349,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         $payment = $this->_paymentFactory->create()
             ->setMethod($this->getMethodCode());
 
-        $transferDataKays = array(
+        $transferDataKeys = array(
             'store_id',             'store_name',           'customer_id',          'customer_email',
             'customer_firstname',   'customer_lastname',    'customer_middlename',  'customer_prefix',
             'customer_suffix',      'customer_taxvat',      'customer_gender',      'customer_is_guest',
@@ -365,7 +360,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         );
 
         $orderInfo = $this->getOrderInfo();
-        foreach ($transferDataKays as $key) {
+        foreach ($transferDataKeys as $key) {
             if (isset($orderInfo[$key])) {
                 $order->setData($key, $orderInfo[$key]);
             } elseif (isset($shippingInfo[$key])) {
@@ -410,7 +405,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         parent::isValid();
 
         // state
-        if (!in_array($this->getState(), $this->getAllStates(false), true)) {
+        if (!array_key_exists($this->getState(), $this->states->toOptionArray())) {
             $this->_errors['state'][] = __('Wrong state: "%1"', $this->getState());
         }
 
@@ -421,7 +416,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      * Import quote information to the profile
      *
      * @param \Magento\Sales\Model\Quote $quote
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return Profile
      */
     public function importQuote(\Magento\Sales\Model\Quote $quote)
     {
@@ -455,7 +450,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      * Import quote item information to the profile
      *
      * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return Profile
      */
     public function importQuoteItem(\Magento\Sales\Model\Quote\Item\AbstractItem $item)
     {
@@ -464,8 +459,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         // TODO: make it abstract from amounts
         $this->setBillingAmount($item->getBaseRowTotal())
             ->setTaxAmount($item->getBaseTaxAmount())
-            ->setShippingAmount($item->getBaseShippingAmount())
-        ;
+            ->setShippingAmount($item->getBaseShippingAmount());
         if (!$this->getScheduleDescription()) {
             $this->setScheduleDescription($item->getName());
         }
@@ -483,84 +477,6 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         return $this->_filterValues();
     }
 
-    /**
-     * Getter for sales-related field labels
-     *
-     * @param string $field
-     * @return string|null
-     */
-    public function getFieldLabel($field)
-    {
-        switch ($field) {
-            case 'order_item_id':
-                return __('Purchased Item');
-            case 'state':
-                return __('Profile State');
-            case 'created_at':
-                return __('Created');
-            case 'updated_at':
-                return __('Updated');
-            default:
-                return parent::getFieldLabel($field);
-        }
-    }
-
-    /**
-     * Getter for sales-related field comments
-     *
-     * @param string $field
-     * @return string|null
-     */
-    public function getFieldComment($field)
-    {
-        switch ($field) {
-            case 'order_item_id':
-                return __('Original order item that recurring payment profile corresponds to');
-            default:
-                return parent::getFieldComment($field);
-        }
-    }
-
-    /**
-     * Getter for all available states
-     *
-     * @param bool $withLabels
-     * @return array
-     */
-    public function getAllStates($withLabels = true)
-    {
-        $states = array(self::STATE_UNKNOWN, self::STATE_PENDING, self::STATE_ACTIVE,
-            self::STATE_SUSPENDED, self::STATE_CANCELED, self::STATE_EXPIRED,
-        );
-        if ($withLabels) {
-            $result = array();
-            foreach ($states as $state) {
-                $result[$state] = $this->getStateLabel($state);
-            }
-            return $result;
-        }
-        return $states;
-    }
-
-    /**
-     * Get state label based on the code
-     *
-     * @param string $state
-     * @return string
-     */
-    public function getStateLabel($state)
-    {
-        switch ($state) {
-            case self::STATE_UNKNOWN:   return __('Not Initialized');
-            case self::STATE_PENDING:   return __('Pending');
-            case self::STATE_ACTIVE:    return __('Active');
-            case self::STATE_SUSPENDED: return __('Suspended');
-            case self::STATE_CANCELED:  return __('Canceled');
-            case self::STATE_EXPIRED:   return __('Expired');
-            default: return $state;
-        }
-    }
-
     /**
      * Render state as label
      *
@@ -572,7 +488,8 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         $value = $this->_getData($key);
         switch ($key) {
             case 'state':
-                return $this->getStateLabel($value);
+                $states = $this->states->toOptionArray();
+                return $states[$value];
         }
         return parent::renderData($key);
     }
@@ -609,20 +526,20 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      */
     protected function _construct()
     {
-        $this->_init('Magento\Sales\Model\Resource\Recurring\Profile');
+        $this->_init('Magento\RecurringProfile\Model\Resource\Profile');
     }
 
     /**
      * Automatically set "unknown" state if not defined
      *
-     * @return \Magento\Payment\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\RecurringProfile
      */
     protected function _filterValues()
     {
         $result = parent::_filterValues();
 
         if (!$this->getState()) {
-            $this->setState(self::STATE_UNKNOWN);
+            $this->setState(States::UNKNOWN);
         }
 
         return $result;
@@ -635,12 +552,12 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
     {
         if (null === $this->_workflow) {
             $this->_workflow = array(
-                'unknown'   => array('pending', 'active', 'suspended', 'canceled'),
-                'pending'   => array('active', 'canceled'),
-                'active'    => array('suspended', 'canceled'),
+                'unknown' => array('pending', 'active', 'suspended', 'canceled'),
+                'pending' => array('active', 'canceled'),
+                'active' => array('suspended', 'canceled'),
                 'suspended' => array('active', 'canceled'),
-                'canceled'  => array(),
-                'expired'   => array(),
+                'canceled' => array(),
+                'expired' => array(),
             );
         }
     }
@@ -674,7 +591,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
     public function getChildOrderIds()
     {
         $ids = $this->_getResource()->getChildOrderIds($this);
-        if (empty($ids)){
+        if (empty($ids)) {
             $ids[] = '-1';
         }
         return $ids;
@@ -684,7 +601,7 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
      * Add order relation to recurring profile
      *
      * @param int $orderId
-     * @return \Magento\Sales\Model\Recurring\Profile
+     * @return Profile
      */
     public function addOrderRelation($orderId)
     {
@@ -707,11 +624,11 @@ class Profile extends \Magento\Payment\Model\Recurring\Profile
         }
 
         switch ($paymentType) {
-            case self::PAYMENT_TYPE_REGULAR:
+            case PaymentTypeInterface::REGULAR:
                 return $this->_getRegularItem($itemInfo);
-            case self::PAYMENT_TYPE_TRIAL:
+            case PaymentTypeInterface::TRIAL:
                 return $this->_getTrialItem($itemInfo);
-            case self::PAYMENT_TYPE_INITIAL:
+            case PaymentTypeInterface::INITIAL:
                 return $this->_getInitialItem($itemInfo);
             default:
                 new \Exception("Invalid recurring profile payment type '{$paymentType}'.");
diff --git a/app/code/Magento/Payment/Model/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Model/RecurringProfile.php
similarity index 63%
rename from app/code/Magento/Payment/Model/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Model/RecurringProfile.php
index 1b637b5766581d0249fa3773305737981e25da86..4c482f9df3b04744cd918cb8641027dd4af24a61 100644
--- a/app/code/Magento/Payment/Model/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Model/RecurringProfile.php
@@ -18,19 +18,17 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Payment
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\RecurringProfile\Model;
 
 /**
  * Recurring payment profile
  * Extends from \Magento\Core\Abstract for a reason: to make descendants have its own resource
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
-namespace Magento\Payment\Model\Recurring;
-
-class Profile extends \Magento\Core\Model\AbstractModel
+class RecurringProfile extends \Magento\Core\Model\AbstractModel
 {
     /**
      * Constants for passing data through catalog
@@ -40,17 +38,6 @@ class Profile extends \Magento\Core\Model\AbstractModel
     const BUY_REQUEST_START_DATETIME = 'recurring_profile_start_datetime';
     const PRODUCT_OPTIONS_KEY = 'recurring_profile_options';
 
-    /**
-     * Period units
-     *
-     * @var string
-     */
-    const PERIOD_UNIT_DAY = 'day';
-    const PERIOD_UNIT_WEEK = 'week';
-    const PERIOD_UNIT_SEMI_MONTH = 'semi_month';
-    const PERIOD_UNIT_MONTH = 'month';
-    const PERIOD_UNIT_YEAR = 'year';
-
     /**
      * Errors collected during validation
      *
@@ -64,13 +51,6 @@ class Profile extends \Magento\Core\Model\AbstractModel
      */
     protected $_methodInstance = null;
 
-    /**
-     * Locale instance used for importing/exporting data
-     *
-     * @var \Magento\Core\Model\LocaleInterface
-     */
-    protected $_locale = null;
-
     /**
      * Store instance used by locale or method instance
      *
@@ -92,10 +72,28 @@ class Profile extends \Magento\Core\Model\AbstractModel
      */
     protected $_paymentData = null;
 
+    /**
+     * @var \Magento\RecurringProfile\Model\PeriodUnits
+     */
+    protected $_periodUnits;
+
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fields;
+
+    /**
+     * @var \Magento\Core\Model\LocaleInterface
+     */
+    protected $_locale;
+
     /**
      * @param \Magento\Core\Model\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Payment\Helper\Data $paymentData
+     * @param PeriodUnits $periodUnits
+     * @param \Magento\RecurringProfile\Block\Fields $fields
+     * @param \Magento\Core\Model\LocaleInterface $locale
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
      * @param array $data
@@ -104,12 +102,18 @@ class Profile extends \Magento\Core\Model\AbstractModel
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
         \Magento\Payment\Helper\Data $paymentData,
+        \Magento\RecurringProfile\Model\PeriodUnits $periodUnits,
+        \Magento\RecurringProfile\Block\Fields $fields,
+        \Magento\Core\Model\LocaleInterface $locale,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
         array $data = array()
     ) {
         $this->_paymentData = $paymentData;
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
+        $this->_periodUnits = $periodUnits;
+        $this->_fields = $fields;
+        $this->_locale = $locale;
     }
 
     /**
@@ -117,6 +121,8 @@ class Profile extends \Magento\Core\Model\AbstractModel
      * Returns true if valid.
      *
      * @return bool
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+     * @SuppressWarnings(PHPMD.NPathComplexity)
      */
     public function isValid()
     {
@@ -134,7 +140,9 @@ class Profile extends \Magento\Core\Model\AbstractModel
         }
 
         // period unit and frequency
-        if (!$this->getPeriodUnit() || !in_array($this->getPeriodUnit(), $this->getAllPeriodUnits(false), true)) {
+        if (!$this->getPeriodUnit()
+            || !in_array($this->getPeriodUnit(), array_keys($this->_periodUnits->toOptionArray()), true)
+        ) {
             $this->_errors['period_unit'][] = __('The billing period unit is not defined or wrong.');
         }
         if ($this->getPeriodFrequency() && !$this->_validatePeriodFrequency('period_unit', 'period_frequency')) {
@@ -143,11 +151,12 @@ class Profile extends \Magento\Core\Model\AbstractModel
 
         // trial period unit, trial frequency, trial period max cycles, trial billing amount
         if ($this->getTrialPeriodUnit()) {
-            if (!in_array($this->getTrialPeriodUnit(), $this->getAllPeriodUnits(false), true)) {
+            if (!in_array($this->getTrialPeriodUnit(), array_keys($this->_periodUnits->toOptionArray()), true)) {
                 $this->_errors['trial_period_unit'][] = __('The trial billing period unit is wrong.');
             }
             if (!$this->getTrialPeriodFrequency()
-                || !$this->_validatePeriodFrequency('trial_period_unit', 'trial_period_frequency')) {
+                || !$this->_validatePeriodFrequency('trial_period_unit', 'trial_period_frequency')
+            ) {
                 $this->_errors['trial_period_frequency'][] = __('The trial period frequency is wrong.');
             }
             if (!$this->getTrialPeriodMaxCycles()) {
@@ -164,7 +173,7 @@ class Profile extends \Magento\Core\Model\AbstractModel
         }
         foreach (array('trial_billing_abount', 'shipping_amount', 'tax_amount', 'init_amount') as $key) {
             if ($this->hasData($key) && 0 >= $this->getData($key)) {
-                $this->_errors[$key][] = __('The wrong %1 is specified.', $this->getFieldLabel($key));
+                $this->_errors[$key][] = __('The wrong %1 is specified.', $this->_fields->getFieldLabel($key));
             }
         }
 
@@ -191,23 +200,19 @@ class Profile extends \Magento\Core\Model\AbstractModel
     /**
      * Getter for errors that may appear after validation
      *
-     * @param bool $isGrouped
-     * @param bool $asMessage
      * @return array
      * @throws \Magento\Core\Exception
      */
-    public function getValidationErrors($isGrouped = true, $asMessage = false)
+    public function getValidationErrors()
     {
-        if ($isGrouped && $this->_errors) {
+        if ($this->_errors) {
             $result = array();
             foreach ($this->_errors as $row) {
                 $result[] = implode(' ', $row);
             }
-            if ($asMessage) {
-                throw new \Magento\Core\Exception(__("The payment profile is invalid:\n%1.",
-                    implode("\n", $result)));
-            }
-            return $result;
+            throw new \Magento\Core\Exception(
+                __("The payment profile is invalid:\n%1.", implode("\n", $result))
+            );
         }
         return $this->_errors;
     }
@@ -216,7 +221,7 @@ class Profile extends \Magento\Core\Model\AbstractModel
      * Setter for payment method instance
      *
      * @param \Magento\Payment\Model\Method\AbstractMethod $object
-     * @return \Magento\Payment\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\RecurringProfile
      * @throws \Exception
      */
     public function setMethodInstance(\Magento\Payment\Model\Method\AbstractMethod $object)
@@ -234,14 +239,17 @@ class Profile extends \Magento\Core\Model\AbstractModel
      * Then filter data
      *
      * @param \Magento\Object $buyRequest
-     * @return \Magento\Payment\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\RecurringProfile
      * @throws \Magento\Core\Exception
+     * @throws \Exception
      */
     public function importBuyRequest(\Magento\Object $buyRequest)
     {
         $startDate = $buyRequest->getData(self::BUY_REQUEST_START_DATETIME);
         if ($startDate) {
-            $this->_ensureLocaleAndStore();
+            if (!$this->_locale || !$this->_store) {
+                throw new \Exception('Locale and store instances must be set for this operation.');
+            }
             $dateFormat = $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT);
             $localeCode = $this->_locale->getLocaleCode();
             if (!\Zend_Date::isDate($startDate, $dateFormat, $localeCode)) {
@@ -259,7 +267,7 @@ class Profile extends \Magento\Core\Model\AbstractModel
      * Returns false if it cannot be imported
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @return \Magento\Payment\Model\Recurring\Profile|false
+     * @return \Magento\RecurringProfile\Model\RecurringProfile|false
      */
     public function importProduct(\Magento\Catalog\Model\Product $product)
     {
@@ -299,14 +307,14 @@ class Profile extends \Magento\Core\Model\AbstractModel
     {
         $result = array(
             new \Magento\Object(array(
-                'title'    => __('Billing Period'),
+                'title' => __('Billing Period'),
                 'schedule' => $this->_renderSchedule('period_unit', 'period_frequency', 'period_max_cycles'),
             ))
         );
         $trial = $this->_renderSchedule('trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles');
         if ($trial) {
             $result[] = new \Magento\Object(array(
-                'title'    => __('Trial Period'),
+                'title' => __('Trial Period'),
                 'schedule' => $trial,
             ));
         }
@@ -317,9 +325,9 @@ class Profile extends \Magento\Core\Model\AbstractModel
      * Determine nearest possible profile start date
      *
      * @param \Zend_Date $minAllowed
-     * @return \Magento\Payment\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\RecurringProfile
      */
-    public function setNearestStartDatetime(\Zend_Date $minAllowed = null)
+    protected function setNearestStartDatetime(\Zend_Date $minAllowed = null)
     {
         // TODO: implement proper logic with invoking payment method instance
         $date = $minAllowed;
@@ -333,41 +341,25 @@ class Profile extends \Magento\Core\Model\AbstractModel
     /**
      * Convert the start datetime (if set) to proper locale/timezone and return
      *
-     * @param bool $asString
-     * @return \Zend_Date|string
+     * @return string
      */
-    public function exportStartDatetime($asString = true)
+    public function exportStartDatetime()
     {
         $datetime = $this->getStartDatetime();
         if (!$datetime || !$this->_locale || !$this->_store) {
-            return;
+            return '';
         }
         $date = $this->_locale->storeDate($this->_store, strtotime($datetime), true);
-        if ($asString) {
-            return $date->toString(
-                $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)
-            );
-        }
-        return $date;
-    }
-
-    /**
-     * Locale instance setter
-     *
-     * @param \Magento\Core\Model\LocaleInterface $locale
-     * @return \Magento\Payment\Model\Recurring\Profile
-     */
-    public function setLocale(\Magento\Core\Model\LocaleInterface $locale)
-    {
-        $this->_locale = $locale;
-        return $this;
+        return $date->toString(
+            $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)
+        );
     }
 
     /**
      * Store instance setter
      *
      * @param \Magento\Core\Model\Store $store
-     * @return \Magento\Payment\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\RecurringProfile
      */
     public function setStore(\Magento\Core\Model\Store $store)
     {
@@ -375,146 +367,6 @@ class Profile extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
-    /**
-     * Getter for available period units
-     *
-     * @param bool $withLabels
-     * @return array
-     */
-    public function getAllPeriodUnits($withLabels = true)
-    {
-        $units = array(
-            self::PERIOD_UNIT_DAY,
-            self::PERIOD_UNIT_WEEK,
-            self::PERIOD_UNIT_SEMI_MONTH,
-            self::PERIOD_UNIT_MONTH,
-            self::PERIOD_UNIT_YEAR
-        );
-
-        if ($withLabels) {
-            $result = array();
-            foreach ($units as $unit) {
-                $result[$unit] = $this->getPeriodUnitLabel($unit);
-            }
-            return $result;
-        }
-        return $units;
-    }
-
-    /**
-     * Render label for specified period unit
-     *
-     * @param string $unit
-     * @return string
-     */
-    public function getPeriodUnitLabel($unit)
-    {
-        switch ($unit) {
-            case self::PERIOD_UNIT_DAY:
-                return __('Day');
-            case self::PERIOD_UNIT_WEEK:
-                return __('Week');
-            case self::PERIOD_UNIT_SEMI_MONTH:
-                return __('Two Weeks');
-            case self::PERIOD_UNIT_MONTH:
-                return __('Month');
-            case self::PERIOD_UNIT_YEAR:
-                return __('Year');
-        }
-        return $unit;
-    }
-
-    /**
-     * Getter for field label
-     *
-     * @param string $field
-     * @return string|null
-     */
-    public function getFieldLabel($field)
-    {
-        switch ($field) {
-            case 'subscriber_name':
-                return __('Subscriber Name');
-            case 'start_datetime':
-                return __('Start Date');
-            case 'internal_reference_id':
-                return __('Internal Reference ID');
-            case 'schedule_description':
-                return __('Schedule Description');
-            case 'suspension_threshold':
-                return __('Maximum Payment Failures');
-            case 'bill_failed_later':
-                return __('Auto Bill on Next Cycle');
-            case 'period_unit':
-                return __('Billing Period Unit');
-            case 'period_frequency':
-                return __('Billing Frequency');
-            case 'period_max_cycles':
-                return __('Maximum Billing Cycles');
-            case 'billing_amount':
-                return __('Billing Amount');
-            case 'trial_period_unit':
-                return __('Trial Billing Period Unit');
-            case 'trial_period_frequency':
-                return __('Trial Billing Frequency');
-            case 'trial_period_max_cycles':
-                return __('Maximum Trial Billing Cycles');
-            case 'trial_billing_amount':
-                return __('Trial Billing Amount');
-            case 'currency_code':
-                return __('Currency');
-            case 'shipping_amount':
-                return __('Shipping Amount');
-            case 'tax_amount':
-                return __('Tax Amount');
-            case 'init_amount':
-                return __('Initial Fee');
-            case 'init_may_fail':
-                return __('Allow Initial Fee Failure');
-            case 'method_code':
-                return __('Payment Method');
-            case 'reference_id':
-                return __('Payment Reference ID');
-        }
-    }
-
-    /**
-     * Getter for field comments
-     *
-     * @param string $field
-     * @return string|null
-     */
-    public function getFieldComment($field)
-    {
-        switch ($field) {
-            case 'subscriber_name':
-                return __('Full name of the person receiving the product or service '
-                    . 'paid for by the recurring payment.');
-            case 'start_datetime':
-                return __('This is the date when billing for the profile begins.');
-            case 'schedule_description':
-                return __('Enter a short description of the recurring payment. '
-                    . 'By default, this description will match the product name.');
-            case 'suspension_threshold':
-                return __('This is the number of scheduled payments '
-                    . 'that can fail before the profile is automatically suspended.');
-            case 'bill_failed_later':
-                return __('Use this to automatically bill the outstanding balance amount in the next billing cycle '
-                    . '(if there were failed payments).');
-            case 'period_unit':
-                return __('This is the unit for billing during the subscription period.');
-            case 'period_frequency':
-                return __('This is the number of billing periods that make up one billing cycle.');
-            case 'period_max_cycles':
-                return __('This is the number of billing cycles for the payment period.');
-            case 'init_amount':
-                return __('The initial, non-recurring payment amount is due immediately when the profile is created.');
-            case 'init_may_fail':
-                return __('This sets whether to suspend the payment profile if the initial fee fails or, '
-                    . 'instead, add it to the outstanding balance.');
-        }
-    }
-
     /**
      * Transform some specific data for output
      *
@@ -526,7 +378,7 @@ class Profile extends \Magento\Core\Model\AbstractModel
         $value = $this->_getData($key);
         switch ($key) {
             case 'period_unit':
-                return $this->getPeriodUnitLabel($value);
+                return $this->_periodUnits->toOptionArray()[$value];
             case 'method_code':
                 if (!$this->_paymentMethods) {
                     $this->_paymentMethods = $this->_paymentData->getPaymentMethodList(false);
@@ -536,7 +388,7 @@ class Profile extends \Magento\Core\Model\AbstractModel
                 }
                 break;
             case 'start_datetime':
-                return $this->exportStartDatetime(true);
+                return $this->exportStartDatetime();
         }
         return $value;
     }
@@ -544,7 +396,8 @@ class Profile extends \Magento\Core\Model\AbstractModel
     /**
      * Filter self data to make sure it can be validated properly
      *
-     * @return \Magento\Payment\Model\Recurring\Profile
+     * @return \Magento\RecurringProfile\Model\RecurringProfile
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      */
     protected function _filterValues()
     {
@@ -556,9 +409,18 @@ class Profile extends \Magento\Core\Model\AbstractModel
         }
 
         // unset redundant values, if empty
-        foreach (array('schedule_description',
-            'suspension_threshold', 'bill_failed_later', 'period_frequency', 'period_max_cycles', 'reference_id',
-            'trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles', 'init_may_fail') as $key) {
+        foreach (array(
+                     'schedule_description',
+                     'suspension_threshold',
+                     'bill_failed_later',
+                     'period_frequency',
+                     'period_max_cycles',
+                     'reference_id',
+                     'trial_period_unit',
+                     'trial_period_frequency',
+                     'trial_period_max_cycles',
+                     'init_may_fail'
+                 ) as $key) {
             if ($this->hasData($key) && (!$this->getData($key) || '0' == $this->getData($key))) {
                 $this->unsetData($key);
             }
@@ -566,7 +428,12 @@ class Profile extends \Magento\Core\Model\AbstractModel
 
         // cast amounts
         foreach (array(
-            'billing_amount', 'trial_billing_amount', 'shipping_amount', 'tax_amount', 'init_amount') as $key) {
+                     'billing_amount',
+                     'trial_billing_amount',
+                     'shipping_amount',
+                     'tax_amount',
+                     'init_amount'
+                 ) as $key) {
             if ($this->hasData($key)) {
                 if (!$this->getData($key) || 0 == $this->getData($key)) {
                     $this->unsetData($key);
@@ -587,18 +454,6 @@ class Profile extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
-    /**
-     * Check that locale and store instances are set
-     *
-     * @throws \Exception
-     */
-    protected function _ensureLocaleAndStore()
-    {
-        if (!$this->_locale || !$this->_store) {
-            throw new \Exception('Locale and store instances must be set for this operation.');
-        }
-    }
-
     /**
      * Return payment method instance
      *
@@ -622,10 +477,7 @@ class Profile extends \Magento\Core\Model\AbstractModel
      */
     protected function _validatePeriodFrequency($unitKey, $frequencyKey)
     {
-        if ($this->getData($unitKey) == self::PERIOD_UNIT_SEMI_MONTH && $this->getData($frequencyKey) != 1) {
-            return false;
-        }
-        return true;
+        return !($this->getData($unitKey) == PeriodUnits::SEMI_MONTH && $this->getData($frequencyKey) != 1);
     }
 
     /**
@@ -636,24 +488,13 @@ class Profile extends \Magento\Core\Model\AbstractModel
     protected function _validateBeforeSave()
     {
         if (!$this->isValid()) {
-            throw new \Magento\Core\Exception($this->getValidationErrors(true, true));
+            throw new \Magento\Core\Exception($this->getValidationErrors());
         }
         if (!$this->getInternalReferenceId()) {
             throw new \Magento\Core\Exception(__('An internal reference ID is required to save the payment profile.'));
         }
     }
 
-    /**
-     * Validate before saving
-     *
-     * @return \Magento\Payment\Model\Recurring\Profile
-     */
-    protected function _beforeSave()
-    {
-        $this->_validateBeforeSave();
-        return parent::_beforeSave();
-    }
-
     /**
      * Generate explanations for specified schedule parameters
      *
@@ -673,10 +514,10 @@ class Profile extends \Magento\Core\Model\AbstractModel
         if (!$period || !$frequency) {
             return $result;
         }
-        if (self::PERIOD_UNIT_SEMI_MONTH == $period) {
+        if (PeriodUnits::SEMI_MONTH == $period) {
             $frequency = '';
         }
-        $result[] = __('%1 %2 cycle.', $frequency, $this->getPeriodUnitLabel($period));
+        $result[] = __('%1 %2 cycle.', $frequency, $this->_periodUnits->toOptionArray()[$period]);
 
         $cycles = (int)$this->_getData($cyclesKey);
         if ($cycles) {
diff --git a/app/code/Magento/Sales/Model/Resource/Recurring/Profile.php b/app/code/Magento/RecurringProfile/Model/Resource/Profile.php
similarity index 74%
rename from app/code/Magento/Sales/Model/Resource/Recurring/Profile.php
rename to app/code/Magento/RecurringProfile/Model/Resource/Profile.php
index 37a685a1cc1fd70476d60f0115c5854afa04c8a2..fa8e1007969ca0a4414a2dd1ccf00af7a406234d 100644
--- a/app/code/Magento/Sales/Model/Resource/Recurring/Profile.php
+++ b/app/code/Magento/RecurringProfile/Model/Resource/Profile.php
@@ -18,22 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\RecurringProfile\Model\Resource;
 
 /**
  * Recurring payment profiles resource model
- *
- * @category    Magento
- * @package     Magento_Sales
- * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Model\Resource\Recurring;
-
 class Profile extends \Magento\Sales\Model\Resource\AbstractResource
 {
     /**
@@ -42,12 +34,11 @@ class Profile extends \Magento\Sales\Model\Resource\AbstractResource
      */
     protected function _construct()
     {
-        $this->_init('sales_recurring_profile', 'profile_id');
+        $this->_init('recurring_profile', 'profile_id');
 
         $this->_serializableFields = array(
-            'profile_vendor_info'    => array(null, array()),
+            'profile_vendor_info' => array(null, array()),
             'additional_info' => array(null, array()),
-
             'order_info' => array(null, array()),
             'order_item_info' => array(null, array()),
             'billing_address_info' => array(null, array()),
@@ -65,11 +56,12 @@ class Profile extends \Magento\Sales\Model\Resource\AbstractResource
     public function getChildOrderIds($object)
     {
         $adapter = $this->_getReadAdapter();
-        $bind    = array(':profile_id' => $object->getId());
-        $select  = $adapter->select()
+        $bind = array(':profile_id' => $object->getId());
+        $select = $adapter->select()
             ->from(
-                array('main_table' => $this->getTable('sales_recurring_profile_order')),
-                array('order_id'))
+                array('main_table' => $this->getTable('recurring_profile_order')),
+                array('order_id')
+            )
             ->where('profile_id=:profile_id');
 
         return $adapter->fetchCol($select, $bind);
@@ -80,14 +72,15 @@ class Profile extends \Magento\Sales\Model\Resource\AbstractResource
      *
      * @param int $recurringProfileId
      * @param int $orderId
-     * @return \Magento\Sales\Model\Resource\Recurring\Profile
+     * @return $this
      */
     public function addOrderRelation($recurringProfileId, $orderId)
     {
         $this->_getWriteAdapter()->insert(
-            $this->getTable('sales_recurring_profile_order'), array(
+            $this->getTable('recurring_profile_order'),
+            array(
                 'profile_id' => $recurringProfileId,
-                'order_id'   => $orderId
+                'order_id' => $orderId
             )
         );
         return $this;
diff --git a/app/code/Magento/Sales/Model/Resource/Recurring/Profile/Collection.php b/app/code/Magento/RecurringProfile/Model/Resource/Profile/Collection.php
similarity index 72%
rename from app/code/Magento/Sales/Model/Resource/Recurring/Profile/Collection.php
rename to app/code/Magento/RecurringProfile/Model/Resource/Profile/Collection.php
index 6b3fa2d995fc517f7313d7c281501043f52ba6aa..e5cf06e1a2cbc8544ef2f446d866d0776b7bf401 100644
--- a/app/code/Magento/Sales/Model/Resource/Recurring/Profile/Collection.php
+++ b/app/code/Magento/RecurringProfile/Model/Resource/Profile/Collection.php
@@ -18,22 +18,14 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\RecurringProfile\Model\Resource\Profile;
 
 /**
  * Recurring profile collection
- *
- * @category    Magento
- * @package     Magento_Sales
- * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sales\Model\Resource\Recurring\Profile;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -41,14 +33,14 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @var string
      */
-    protected $_eventPrefix    = 'sales_recurring_profile_collection';
+    protected $_eventPrefix = 'recurring_profile_collection';
 
     /**
      * Event object
      *
      * @var string
      */
-    protected $_eventObject    = 'recurring_profile_collection';
+    protected $_eventObject = 'recurring_profile_collection';
 
     /**
      * Entity initialization
@@ -56,6 +48,6 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      */
     protected function _construct()
     {
-        $this->_init('Magento\Sales\Model\Recurring\Profile', 'Magento\Sales\Model\Resource\Recurring\Profile');
+        $this->_init('Magento\RecurringProfile\Model\Profile', 'Magento\RecurringProfile\Model\Resource\Profile');
     }
 }
diff --git a/app/code/Magento/RecurringProfile/Model/States.php b/app/code/Magento/RecurringProfile/Model/States.php
new file mode 100644
index 0000000000000000000000000000000000000000..6e71f25ef3021ecf1cf8c7fb79687392caa91842
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/Model/States.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\RecurringProfile\Model;
+
+use Magento\Core\Model\Option\ArrayInterface;
+
+class States implements ArrayInterface
+{
+    /**
+     * @var string
+     */
+    const UNKNOWN = 'unknown';
+    const PENDING = 'pending';
+    const ACTIVE = 'active';
+    const SUSPENDED = 'suspended';
+    const CANCELED = 'canceled';
+    const EXPIRED = 'expired';
+
+    /**
+     * @return array
+     */
+    public function toOptionArray()
+    {
+        return array(
+            self::UNKNOWN => __('Not Initialized'),
+            self::PENDING => __('Pending'),
+            self::ACTIVE => __('Active'),
+            self::SUSPENDED => __('Suspended'),
+            self::CANCELED => __('Canceled'),
+            self::EXPIRED => __('Expired'),
+        );
+    }
+}
diff --git a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.10-1.6.0.11.php b/app/code/Magento/RecurringProfile/data/recurringprofile_setup/data-install-1.0.0.0.php
similarity index 85%
rename from app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.10-1.6.0.11.php
rename to app/code/Magento/RecurringProfile/data/recurringprofile_setup/data-install-1.0.0.0.php
index b541e66a49a2e612c8fbf8d55ec0963502a708c6..4d77f9e23a0cbc0499611873341c01da96573be0 100644
--- a/app/code/Magento/Sales/data/sales_setup/data-upgrade-1.6.0.10-1.6.0.11.php
+++ b/app/code/Magento/RecurringProfile/data/recurringprofile_setup/data-install-1.0.0.0.php
@@ -18,14 +18,10 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 /** @var $this \Magento\Catalog\Model\Resource\Setup */
-
 $entityTypeId = $this->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
 $attributeSetId = $this->getAttributeSetId($entityTypeId, 'Default');
 
@@ -36,3 +32,11 @@ $this->updateAttributeGroup($entityTypeId, $attributeSetId, $groupName, 'tab_gro
 
 $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'is_recurring');
 $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'recurring_profile');
+
+$connection = $this->getConnection();
+$adminRuleTable = $this->getTable('admin_rule');
+$connection->update(
+    $adminRuleTable,
+    array('resource_id' => 'Magento_RecurringProfile::recurring_profile'),
+    array('resource_id = ?' => 'Magento_Sales::recurring_profile')
+);
diff --git a/app/code/Magento/RecurringProfile/etc/adminhtml/acl.xml b/app/code/Magento/RecurringProfile/etc/adminhtml/acl.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a950354652056931c3373cdc2bf5d3b8da5a0224
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/adminhtml/acl.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <acl>
+        <resources>
+            <resource id="Magento_Adminhtml::admin">
+                <resource id="Magento_Sales::sales" title="Sales" sortOrder="20">
+                    <resource id="Magento_Sales::sales_operation" title="Operations" sortOrder="10">
+                        <resource id="Magento_RecurringProfile::recurring_profile" title="Recurring Profiles" sortOrder="80" />
+                    </resource>
+                </resource>
+            </resource>
+        </resources>
+    </acl>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/adminhtml/events.xml b/app/code/Magento/RecurringProfile/etc/adminhtml/events.xml
new file mode 100644
index 0000000000000000000000000000000000000000..eaabd53aa50e6863e522d0cba53f509fb30f88f0
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/adminhtml/events.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <event name="catalog_product_edit_form_render_recurring">
+        <observer name="payment" instance="Magento\RecurringProfile\Model\Observer" method="addFieldsToProductEditForm" />
+    </event>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/adminhtml/menu.xml b/app/code/Magento/RecurringProfile/etc/adminhtml/menu.xml
new file mode 100644
index 0000000000000000000000000000000000000000..24b0d22f59fc50d044cefd7b4fcdf4eb18342f5b
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/adminhtml/menu.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <menu>
+        <add id="Magento_RecurringProfile::recurring_profile" title="Recurring Billing"
+             module="Magento_RecurringProfile" sortOrder="80" parent="Magento_Sales::sales_operation"
+             action="sales/recurringProfile" resource="Magento_RecurringProfile::recurring_profile"/>
+    </menu>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/adminhtml/routes.xml b/app/code/Magento/RecurringProfile/etc/adminhtml/routes.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c7d1b2c67ee83565bc013e4669f3a0267d7e1a51
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/adminhtml/routes.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <router id="admin">
+        <route id="sales" frontName="sales">
+            <module name="Magento_RecurringProfile" before="Magento_Adminhtml" />
+        </route>
+    </router>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/catalog_attributes.xml b/app/code/Magento/RecurringProfile/etc/catalog_attributes.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a74b0aa6a459e1315607544e4858c17cd6a04708
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/catalog_attributes.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <group name="sales_quote_item">
+        <attribute name="is_recurring"/>
+        <attribute name="recurring_profile"/>
+    </group>
+    <group name="unassignable">
+        <attribute name="recurring_profileinit_may_fail" />
+    </group>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/di.xml b/app/code/Magento/RecurringProfile/etc/di.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b335e08e2994d07405bacfb7da44353d1f250903
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/di.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <type name="Magento\Module\Updater\SetupFactory">
+        <param name="resourceTypes">
+            <array>
+                <item key="recurringprofile_setup"><value>Magento\Catalog\Model\Resource\Setup</value></item>
+            </array>
+        </param>
+    </type>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/fieldset.xml b/app/code/Magento/RecurringProfile/etc/fieldset.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4682201e027e7026a47df605516c372199edf4db
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/fieldset.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="../../../../../lib/Magento/Object/etc/fieldset.xsd">
+    <scope id="global">
+        <fieldset id="sales_convert_quote_item">
+            <field name="is_recurring">
+                <aspect name="to_order_item" />
+            </field>
+        </fieldset>
+    </scope>
+</config>
diff --git a/app/code/Magento/Payment/etc/frontend/events.xml b/app/code/Magento/RecurringProfile/etc/frontend/events.xml
similarity index 86%
rename from app/code/Magento/Payment/etc/frontend/events.xml
rename to app/code/Magento/RecurringProfile/etc/frontend/events.xml
index 1c4dc4116eed8353c2159b6f985e206385c8e25e..78d849fb7c7ff148958ba3354e212307c4624a4e 100644
--- a/app/code/Magento/Payment/etc/frontend/events.xml
+++ b/app/code/Magento/RecurringProfile/etc/frontend/events.xml
@@ -25,6 +25,6 @@
 -->
 <config>
     <event name="catalog_product_type_prepare_cart_options">
-        <observer name="payment_recurring_profile_prepare_options" instance="Magento\Payment\Model\Observer" method="prepareProductRecurringProfileOptions" />
+        <observer name="recurring_profile_prepare_options" instance="Magento\RecurringProfile\Model\Observer" method="prepareProductRecurringProfileOptions" />
     </event>
 </config>
diff --git a/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_failure.xml b/app/code/Magento/RecurringProfile/etc/frontend/routes.xml
similarity index 84%
rename from app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_failure.xml
rename to app/code/Magento/RecurringProfile/etc/frontend/routes.xml
index 313d109b31dc36da303702293b30e8e734317499..ee8a3da6ede1d91368ad22b4025c834e080c29d7 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_failure.xml
+++ b/app/code/Magento/RecurringProfile/etc/frontend/routes.xml
@@ -23,6 +23,10 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 -->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
-</layout>
+<config>
+    <router id="standard">
+        <route id="sales" frontName="sales">
+            <module name="Magento_RecurringProfile" />
+        </route>
+    </router>
+</config>
diff --git a/app/code/Magento/RecurringProfile/etc/module.xml b/app/code/Magento/RecurringProfile/etc/module.xml
new file mode 100644
index 0000000000000000000000000000000000000000..bce35e7e3443af843f3472b40d5bbc5477cc98d5
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/etc/module.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<config>
+    <module name="Magento_RecurringProfile" version="1.0.0.0" active="true">
+        <sequence>
+            <module name="Magento_Sales"/>
+            <module name="Magento_User"/>
+        </sequence>
+        <depends>
+            <module name="Magento_Backend"/>
+            <module name="Magento_Core"/>
+            <module name="Magento_Catalog"/>
+            <module name="Magento_Customer"/>
+            <module name="Magento_Payment"/>
+            <module name="Magento_Sales"/>
+            <module name="Magento_Theme"/>
+        </depends>
+    </module>
+</config>
diff --git a/app/code/Magento/RecurringProfile/sql/recurringprofile_setup/install-1.0.0.0.php b/app/code/Magento/RecurringProfile/sql/recurringprofile_setup/install-1.0.0.0.php
new file mode 100644
index 0000000000000000000000000000000000000000..99f2888ba95997eb1e7e129b8fde4dcfd27ed5ab
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/sql/recurringprofile_setup/install-1.0.0.0.php
@@ -0,0 +1,197 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+/** @var $this \Magento\Catalog\Model\Resource\Setup */
+$this->startSetup();
+
+/**
+ * Create table 'recurring_profile'
+ */
+$table = $this->getConnection()
+    ->newTable($this->getTable('recurring_profile'))
+    ->addColumn('profile_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'identity'  => true,
+        'unsigned'  => true,
+        'nullable'  => false,
+        'primary'   => true,
+    ), 'Profile Id')
+    ->addColumn('state', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
+        'nullable'  => false,
+    ), 'State')
+    ->addColumn('customer_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'unsigned'  => true,
+    ), 'Customer Id')
+    ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Store Id')
+    ->addColumn('method_code', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
+        'nullable'  => false,
+    ), 'Method Code')
+    ->addColumn('created_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
+        'nullable'  => false,
+    ), 'Created At')
+    ->addColumn('updated_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
+    ), 'Updated At')
+    ->addColumn('reference_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
+    ), 'Reference Id')
+    ->addColumn('subscriber_name', \Magento\DB\Ddl\Table::TYPE_TEXT, 150, array(
+    ), 'Subscriber Name')
+    ->addColumn('start_datetime', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
+        'nullable'  => false,
+    ), 'Start Datetime')
+    ->addColumn('internal_reference_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 42, array(
+        'nullable'  => false,
+    ), 'Internal Reference Id')
+    ->addColumn('schedule_description', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array(
+        'nullable'  => false,
+    ), 'Schedule Description')
+    ->addColumn('suspension_threshold', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Suspension Threshold')
+    ->addColumn('bill_failed_later', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+        'default'   => '0',
+    ), 'Bill Failed Later')
+    ->addColumn('period_unit', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
+        'nullable'  => false,
+    ), 'Period Unit')
+    ->addColumn('period_frequency', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Period Frequency')
+    ->addColumn('period_max_cycles', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Period Max Cycles')
+    ->addColumn('billing_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
+        'nullable'  => false,
+        'default'   => '0.0000',
+    ), 'Billing Amount')
+    ->addColumn('trial_period_unit', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
+    ), 'Trial Period Unit')
+    ->addColumn('trial_period_frequency', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Trial Period Frequency')
+    ->addColumn('trial_period_max_cycles', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+    ), 'Trial Period Max Cycles')
+    ->addColumn('trial_billing_amount', \Magento\DB\Ddl\Table::TYPE_TEXT, null, array(
+    ), 'Trial Billing Amount')
+    ->addColumn('currency_code', \Magento\DB\Ddl\Table::TYPE_TEXT, 3, array(
+        'nullable'  => false,
+    ), 'Currency Code')
+    ->addColumn('shipping_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
+    ), 'Shipping Amount')
+    ->addColumn('tax_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
+    ), 'Tax Amount')
+    ->addColumn('init_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
+    ), 'Init Amount')
+    ->addColumn('init_may_fail', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+        'default'   => '0',
+    ), 'Init May Fail')
+    ->addColumn('order_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
+        'nullable'  => false,
+    ), 'Order Info')
+    ->addColumn('order_item_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
+        'nullable'  => false,
+    ), 'Order Item Info')
+    ->addColumn('billing_address_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
+        'nullable'  => false,
+    ), 'Billing Address Info')
+    ->addColumn('shipping_address_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
+    ), 'Shipping Address Info')
+    ->addColumn('profile_vendor_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
+    ), 'Profile Vendor Info')
+    ->addColumn('additional_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
+    ), 'Additional Info')
+    ->addIndex(
+        $this->getIdxName(
+            'recurring_profile',
+            array('internal_reference_id'),
+            \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
+        ),
+        array('internal_reference_id'), array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE))
+    ->addIndex($this->getIdxName('recurring_profile', array('customer_id')),
+        array('customer_id'))
+    ->addIndex($this->getIdxName('recurring_profile', array('store_id')),
+        array('store_id'))
+    ->addForeignKey($this->getFkName('recurring_profile', 'customer_id', 'customer_entity', 'entity_id'),
+        'customer_id', $this->getTable('customer_entity'), 'entity_id',
+        \Magento\DB\Ddl\Table::ACTION_SET_NULL, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->addForeignKey($this->getFkName('recurring_profile', 'store_id', 'core_store', 'store_id'),
+        'store_id', $this->getTable('core_store'), 'store_id',
+        \Magento\DB\Ddl\Table::ACTION_SET_NULL, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->setComment('Sales Recurring Profile');
+$this->getConnection()->createTable($table);
+
+/**
+ * Create table 'recurring_profile_order'
+ */
+$table = $this->getConnection()
+    ->newTable($this->getTable('recurring_profile_order'))
+    ->addColumn('link_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'identity'  => true,
+        'unsigned'  => true,
+        'nullable'  => false,
+        'primary'   => true,
+    ), 'Link Id')
+    ->addColumn('profile_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+        'default'   => '0',
+    ), 'Profile Id')
+    ->addColumn('order_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
+        'unsigned'  => true,
+        'nullable'  => false,
+        'default'   => '0',
+    ), 'Order Id')
+    ->addIndex(
+        $this->getIdxName(
+            'recurring_profile_order',
+            array('profile_id', 'order_id'),
+            \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
+        ),
+        array('profile_id', 'order_id'), array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE))
+    ->addIndex($this->getIdxName('recurring_profile_order', array('order_id')),
+        array('order_id'))
+    ->addForeignKey(
+        $this->getFkName(
+            'recurring_profile_order',
+            'order_id',
+            'sales_flat_order',
+            'entity_id'
+        ),
+        'order_id', $this->getTable('sales_flat_order'), 'entity_id',
+        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->addForeignKey(
+        $this->getFkName(
+            'recurring_profile_order',
+            'profile_id',
+            'recurring_profile',
+            'profile_id'
+        ),
+        'profile_id', $this->getTable('recurring_profile'), 'profile_id',
+        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
+    ->setComment('Sales Recurring Profile Order');
+$this->getConnection()->createTable($table);
diff --git a/app/code/Magento/Paypal/view/frontend/layout/catalog_product_compare_index.xml b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_customergrid.xml
similarity index 87%
rename from app/code/Magento/Paypal/view/frontend/layout/catalog_product_compare_index.xml
rename to app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_customergrid.xml
index 313d109b31dc36da303702293b30e8e734317499..6f67d9bc026f3855e27f3cba851a4cfeee708dfa 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/catalog_product_compare_index.xml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_customergrid.xml
@@ -24,5 +24,5 @@
  */
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <update handle="SHORTCUT_popup"/>
+    <block class="Magento\RecurringProfile\Block\Adminhtml\Customer\Edit\Tab\RecurringProfile" name="customer.recurring.profile.grid" output="1"/>
 </layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_grid.xml b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_grid.xml
similarity index 89%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_grid.xml
rename to app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_grid.xml
index 7faf76a2d20e9c2209a225af4d791377df5b5511..fff2ba16bcc212dfb3621cc65a8a4ff3a0e43b2d 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_grid.xml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_grid.xml
@@ -25,5 +25,5 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <remove name="root"/>
-    <block class="Magento\Sales\Block\Adminhtml\Recurring\Profile\Grid" name="sales.recurring.profile.grid" output="1"/>
+    <block class="Magento\RecurringProfile\Block\Profile\Grid" name="sales.recurring.profile.grid" output="1"/>
 </layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_index.xml b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_index.xml
similarity index 90%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_index.xml
rename to app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_index.xml
index 1102a5d08f8264b61aa4b803bd4c6382b5987871..e151611cf12eeb76785f0d2913be11ddc59de154 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_index.xml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_index.xml
@@ -25,6 +25,6 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Adminhtml\Billing\Agreement" name="sales.billing.agreement.grid.container"/>
+        <block class="Magento\RecurringProfile\Block\Adminhtml\Profile" name="sales.recurring.profile.grid.container"/>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_orders.xml b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_orders.xml
similarity index 88%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_orders.xml
rename to app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_orders.xml
index 696a9f4abea39655eabc63feb70610f93f1d550b..8800b89b034deb44e3d5ad91dda660b64c1a364d 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_orders.xml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_orders.xml
@@ -25,5 +25,5 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <remove name="root"/>
-    <block class="Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Orders" name="sales.recurring.profile.tab.orders" output="1"/>
+    <block class="Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Orders" name="sales.recurring.profile.tab.orders" output="1"/>
 </layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_view.xml b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_view.xml
similarity index 75%
rename from app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_view.xml
rename to app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_view.xml
index 5a48cb7fe104c321dab712ab63b52a3c9a5bec7f..7b8c200fe91393c29e2a1a30ec010d1c5c16af84 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_view.xml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/layout/sales_recurringprofile_view.xml
@@ -25,7 +25,7 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Adminhtml\Recurring\Profile\View" name="sales.recurring.profile.view" template="Magento_Backend::widget/view/container.phtml">
+        <block class="Magento\RecurringProfile\Block\Adminhtml\Profile\View" name="sales.recurring.profile.view" template="Magento_Backend::widget/view/container.phtml">
             <action method="setDestElementId">
                 <argument name="value" xsi:type="string">sales_recurring_profile_view</argument>
             </action>
@@ -42,14 +42,14 @@
             <action method="setId">
                 <argument name="value" xsi:type="string">sales_recurring_profile_view_tabs</argument>
             </action>
-            <block class="Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Info" as="info_tab" name="sales.recurring.profile.tab.info" template="recurring/profile/view.phtml">
-                <block class="Magento\Sales\Block\Recurring\Profile\View\Reference" name="sales.recurring.profile.view.general" as="general" group="info_blocks_row_1">
+            <block class="Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Info" as="info_tab" name="sales.recurring.profile.tab.info" template="recurring/profile/view.phtml">
+                <block class="Magento\RecurringProfile\Block\Profile\View\Reference" name="sales.recurring.profile.view.general" as="general" group="info_blocks_row_1">
                     <arguments>
                         <argument name="view_column" xsi:type="string">1</argument>
                         <argument translate="true" name="view_label" xsi:type="string">Reference</argument>
                     </arguments>
                 </block>
-                <block class="Magento\Sales\Block\Recurring\Profile\View\Item" name="sales.recurring.profile.view.item" as="item" group="info_blocks_row_1">
+                <block class="Magento\RecurringProfile\Block\Profile\View\Item" name="sales.recurring.profile.view.item" as="item" group="info_blocks_row_1">
                     <action method="setViewColumn">
                         <argument name="value" xsi:type="string">2</argument>
                     </action>
@@ -57,7 +57,7 @@
                         <argument translate="true" name="value" xsi:type="string">Purchased Item</argument>
                     </action>
                 </block>
-                <block class="Magento\Sales\Block\Recurring\Profile\View\Schedule" name="sales.recurring.profile.view.schedule" as="profile" group="info_blocks_row_2">
+                <block class="Magento\RecurringProfile\Block\Profile\View\Schedule" name="sales.recurring.profile.view.schedule" as="profile" group="info_blocks_row_2">
                     <action method="setViewColumn">
                         <argument name="value" xsi:type="string">1</argument>
                     </action>
@@ -65,7 +65,7 @@
                         <argument translate="true" name="value" xsi:type="string">Profile Schedule</argument>
                     </action>
                 </block>
-                <block class="Magento\Sales\Block\Recurring\Profile\View\Fees" name="sales.recurring.profile.view.fees" as="fees" group="info_blocks_row_2">
+                <block class="Magento\RecurringProfile\Block\Profile\View\Fees" name="sales.recurring.profile.view.fees" as="fees" group="info_blocks_row_2">
                     <action method="setViewColumn">
                         <argument name="value" xsi:type="string">2</argument>
                     </action>
@@ -73,7 +73,7 @@
                         <argument translate="true" name="value" xsi:type="string">Profile Payments</argument>
                     </action>
                 </block>
-                <block class="Magento\Sales\Block\Recurring\Profile\View\Address" name="sales.recurring.profile.view.billing" as="billing_address" group="info_blocks_row_3">
+                <block class="Magento\RecurringProfile\Block\Profile\View\Address" name="sales.recurring.profile.view.billing" as="billing_address" group="info_blocks_row_3">
                     <action method="setViewColumn">
                         <argument name="value" xsi:type="string">1</argument>
                     </action>
@@ -81,7 +81,7 @@
                         <argument translate="true" name="value" xsi:type="string">Billing Address</argument>
                     </action>
                 </block>
-                <block class="Magento\Sales\Block\Recurring\Profile\View\Address" name="sales.recurring.profile.view.shipping" as="shipping_address" group="info_blocks_row_3">
+                <block class="Magento\RecurringProfile\Block\Profile\View\Address" name="sales.recurring.profile.view.shipping" as="shipping_address" group="info_blocks_row_3">
                     <action method="setAddressType">
                         <argument name="value" xsi:type="string">shipping</argument>
                     </action>
@@ -93,7 +93,7 @@
                     </action>
                 </block>
             </block>
-            <block class="Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Orders" as="orders_tab" name="sales.recurring.profile.tab.orders"/>
+            <block class="Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Orders" as="orders_tab" name="sales.recurring.profile.tab.orders"/>
             <action method="addTab">
                 <argument name="name" xsi:type="string">recurring_profile_info</argument>
                 <argument name="block" xsi:type="string">info_tab</argument>
diff --git a/app/code/Magento/Sales/view/adminhtml/recurring/profile/view.phtml b/app/code/Magento/RecurringProfile/view/adminhtml/recurring/profile/view.phtml
similarity index 95%
rename from app/code/Magento/Sales/view/adminhtml/recurring/profile/view.phtml
rename to app/code/Magento/RecurringProfile/view/adminhtml/recurring/profile/view.phtml
index eb5fc56dd2dc035190c6017da20a0f5283a43aa8..c18b728649e28b867578519ff803ae8cd26c4a03 100644
--- a/app/code/Magento/Sales/view/adminhtml/recurring/profile/view.phtml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/recurring/profile/view.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Info */ ?>
+<?php /* @var $this \Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Info */ ?>
 
 <?php $layout = $this->getLayout(); ?>
 <?php for ($i = 1; $i <= 5; $i++):?>
diff --git a/app/code/Magento/Sales/view/adminhtml/recurring/profile/view/info.phtml b/app/code/Magento/RecurringProfile/view/adminhtml/recurring/profile/view/info.phtml
similarity index 95%
rename from app/code/Magento/Sales/view/adminhtml/recurring/profile/view/info.phtml
rename to app/code/Magento/RecurringProfile/view/adminhtml/recurring/profile/view/info.phtml
index e70c0c2f8f5166b799883e72a09f5e9d463327f1..afc81dd5336064b4088812f58aa3a24ff9130bf1 100644
--- a/app/code/Magento/Sales/view/adminhtml/recurring/profile/view/info.phtml
+++ b/app/code/Magento/RecurringProfile/view/adminhtml/recurring/profile/view/info.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Recurring\Profile\View */?>
+<?php /* @var $this \Magento\RecurringProfile\Block\Adminhtml\Profile\View */ ?>
 <?php if ($this->getIsAddress()):?>
 
 <?php foreach ($this->getRenderedInfo() as $row):?>
diff --git a/app/code/Magento/Payment/view/frontend/catalog/product/view/profile/options.phtml b/app/code/Magento/RecurringProfile/view/frontend/catalog/product/view/profile/options.phtml
similarity index 82%
rename from app/code/Magento/Payment/view/frontend/catalog/product/view/profile/options.phtml
rename to app/code/Magento/RecurringProfile/view/frontend/catalog/product/view/profile/options.phtml
index 2fef6b8e5ba44a536b8e9ea4ca347773bb83a20b..5e049f4802a1a27d052195144042465b2e5a83ac 100644
--- a/app/code/Magento/Payment/view/frontend/catalog/product/view/profile/options.phtml
+++ b/app/code/Magento/RecurringProfile/view/frontend/catalog/product/view/profile/options.phtml
@@ -23,14 +23,12 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php
-/**
- * @see \Magento\Payment\Block\Catalog\Product\View\Profile
- */
-?>
+<?php /* @var $this \Magento\RecurringProfile\Block\Catalog\Product\View\Profile */ ?>
 <?php if ($dateHtml = $this->getDateHtml()): ?>
 <dl class="payment product options">
-    <dt class="title"><label for="<?php echo $this->getDateHtmlId() ?>"><?php echo __('Recurring Profile Start Date') ?></label></dt>
+    <dt class="title">
+        <label for="<?php echo $this->getDateHtmlId() ?>"><?php echo __('Recurring Profile Start Date') ?></label>
+    </dt>
     <dd class="content"><?php echo $dateHtml ?></dd>
 </dl>
 <?php endif; ?>
diff --git a/app/code/Magento/Payment/view/frontend/catalog/product/view/profile/schedule.phtml b/app/code/Magento/RecurringProfile/view/frontend/catalog/product/view/profile/schedule.phtml
similarity index 95%
rename from app/code/Magento/Payment/view/frontend/catalog/product/view/profile/schedule.phtml
rename to app/code/Magento/RecurringProfile/view/frontend/catalog/product/view/profile/schedule.phtml
index 3937f5cca535982b5c3a95f9dd0a05469803f2eb..314602619f93a0a8fd814aed85225bdbeadbd9d1 100644
--- a/app/code/Magento/Payment/view/frontend/catalog/product/view/profile/schedule.phtml
+++ b/app/code/Magento/RecurringProfile/view/frontend/catalog/product/view/profile/schedule.phtml
@@ -25,7 +25,7 @@
 ?>
 <?php
 /**
- * @see \Magento\Payment\Block\Catalog\Product\View\Profile
+ * @see \Magento\RecurringProfile\Block\Catalog\Product\View\Profile
  */
 ?>
 <dl class="payment product schedule">
diff --git a/app/code/Magento/Payment/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/RecurringProfile/view/frontend/layout/catalog_product_view.xml
similarity index 75%
rename from app/code/Magento/Payment/view/frontend/layout/catalog_product_view.xml
rename to app/code/Magento/RecurringProfile/view/frontend/layout/catalog_product_view.xml
index 92ddb7ec7a776dee4dc023c8cc9c190e60973e55..4a8635b5d329bee4939a1e143cfb29437fbaa7a7 100644
--- a/app/code/Magento/Payment/view/frontend/layout/catalog_product_view.xml
+++ b/app/code/Magento/RecurringProfile/view/frontend/layout/catalog_product_view.xml
@@ -25,13 +25,13 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceBlock name="product.info.main">
-        <block class="Magento\Payment\Block\Catalog\Product\View\Profile" name="product.info.additional.recurring.schedule" as="recurring_info" template="catalog/product/view/profile/schedule.phtml" group="detailed_info">
+        <block class="Magento\RecurringProfile\Block\Catalog\Product\View\Profile" name="product.info.additional.recurring.schedule" as="recurring_info" template="catalog/product/view/profile/schedule.phtml" group="detailed_info">
             <action method="setTitle">
                 <argument translate="true" name="value" xsi:type="string">Recurring Profile</argument>
             </action>
         </block>
     </referenceBlock>
     <referenceBlock name="product.info.options.wrapper">
-        <block class="Magento\Payment\Block\Catalog\Product\View\Profile" name="product.info.options.recurring" as="recurring_options" template="catalog/product/view/profile/options.phtml"/>
+        <block class="Magento\RecurringProfile\Block\Catalog\Product\View\Profile" name="product.info.options.recurring" as="recurring_options" template="catalog/product/view/profile/options.phtml"/>
     </referenceBlock>
 </layout>
diff --git a/app/code/Magento/RecurringProfile/view/frontend/layout/customer_account.xml b/app/code/Magento/RecurringProfile/view/frontend/layout/customer_account.xml
new file mode 100644
index 0000000000000000000000000000000000000000..32b86bff421eeb91cda7bb1f97e97d64bfe030f4
--- /dev/null
+++ b/app/code/Magento/RecurringProfile/view/frontend/layout/customer_account.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+-->
+<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <referenceBlock name="customer_account_navigation">
+        <block class="Magento\View\Element\Html\Link\Current" name="customer-account-navigation-recurring-profiles-link">
+            <arguments>
+                <argument name="path" xsi:type="string">sales/recurringProfile</argument>
+                <argument name="label" xsi:type="string">Recurring Profiles</argument>
+            </arguments>
+        </block>
+    </referenceBlock>
+</layout>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_index.xml b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_index.xml
similarity index 82%
rename from app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_index.xml
rename to app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_index.xml
index 75c7affb14ecb8d5877bfa53201236116d476aa0..176db195c0a1d28b26e41624d72040a9d5a7c3ed 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_index.xml
+++ b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_index.xml
@@ -26,8 +26,8 @@
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <update handle="customer_account"/>
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Recurring\Profiles" name="sales.recurring.profiles" template="recurring/profiles.phtml" cacheable="false">
-            <block class="Magento\Sales\Block\Recurring\Profile\Grid" name="sales.recurring.profiles.grid" as="grid" template="recurring/grid.phtml" cacheable="false">
+        <block class="Magento\RecurringProfile\Block\Profiles" name="sales.recurring.profiles" template="recurring/profiles.phtml" cacheable="false">
+            <block class="Magento\RecurringProfile\Block\Profile\Grid" name="sales.recurring.profiles.grid" as="grid" template="recurring/grid.phtml" cacheable="false">
                 <action method="setEmptyGridMessage">
                     <argument translate="true" name="value" xsi:type="string">There are no recurring profiles yet.</argument>
                 </action>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_orders.xml b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_orders.xml
similarity index 89%
rename from app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_orders.xml
rename to app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_orders.xml
index a63210bbccd87be0a469de3d730da7ba91551e80..5d34f0b6c1aa17602bd39439d347da6806a2a53a 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_orders.xml
+++ b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_orders.xml
@@ -25,14 +25,14 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <update handle="customer_account"/>
-    <update handle="sales_recurring_profile_view__tabs"/>
+    <update handle="sales_recurringprofile_view__tabs"/>
     <referenceBlock name="sales.recurring.profile.view.tab.orders">
         <action method="setIsViewCurrent">
             <argument name="v" xsi:type="string">1</argument>
         </action>
     </referenceBlock>
     <referenceBlock name="sales.recurring.profile.view">
-        <block class="Magento\Sales\Block\Recurring\Profile\Related\Orders\Grid" name="sales.recurring.profile.view.orders" as="table" template="recurring/grid.phtml" cacheable="false">
+        <block class="Magento\RecurringProfile\Block\Profile\Related\Orders\Grid" name="sales.recurring.profile.view.orders" as="table" template="recurring/grid.phtml" cacheable="false">
             <action method="setViewLabel">
                 <argument translate="true" name="value" xsi:type="string">Orders Based on This Profile</argument>
             </action>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_view.xml b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_view.xml
similarity index 72%
rename from app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_view.xml
rename to app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_view.xml
index d2380b840c494873fd2a320929a2d5fa869e9bc5..6eae86511526c17ce497d81a596e9f0e81d3f9f3 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_view.xml
+++ b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_view.xml
@@ -25,14 +25,14 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <update handle="customer_account"/>
-    <update handle="sales_recurring_profile_view__tabs"/>
+    <update handle="sales_recurringprofile_view__tabs"/>
     <referenceBlock name="sales.recurring.profile.view.tab.profile">
         <action method="setIsViewCurrent">
             <argument name="v" xsi:type="string">1</argument>
         </action>
     </referenceBlock>
     <referenceBlock name="sales.recurring.profile.view">
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Schedule" name="sales.recurring.profile.view.general" as="general" template="recurring/profile/view/info.phtml" group="info_blocks_row_1">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Schedule" name="sales.recurring.profile.view.general" as="general" template="recurring/profile/view/info.phtml" group="info_blocks_row_1">
             <action method="setViewColumn">
                 <argument name="value" xsi:type="string">1</argument>
             </action>
@@ -40,7 +40,7 @@
                 <argument translate="true" name="value" xsi:type="string">Reference</argument>
             </action>
         </block>
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Item" name="sales.recurring.profile.view.item" as="item" template="recurring/profile/view/info.phtml" group="info_blocks_row_1">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Item" name="sales.recurring.profile.view.item" as="item" template="recurring/profile/view/info.phtml" group="info_blocks_row_1">
             <action method="setViewColumn">
                 <argument name="value" xsi:type="string">2</argument>
             </action>
@@ -48,7 +48,7 @@
                 <argument translate="true" name="value" xsi:type="string">Purchased Item</argument>
             </action>
         </block>
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Schedule" name="sales.recurring.profile.view.schedule" as="profile" template="recurring/profile/view/info.phtml" group="info_blocks_row_2">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Schedule" name="sales.recurring.profile.view.schedule" as="profile" template="recurring/profile/view/info.phtml" group="info_blocks_row_2">
             <action method="setViewColumn">
                 <argument name="value" xsi:type="string">1</argument>
             </action>
@@ -56,7 +56,7 @@
                 <argument translate="true" name="value" xsi:type="string">Profile Schedule</argument>
             </action>
         </block>
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Fees" name="sales.recurring.profile.view.fees" as="fees" template="recurring/profile/view/info.phtml" group="info_blocks_row_2">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Fees" name="sales.recurring.profile.view.fees" as="fees" template="recurring/profile/view/info.phtml" group="info_blocks_row_2">
             <action method="setViewColumn">
                 <argument name="value" xsi:type="string">2</argument>
             </action>
@@ -64,7 +64,7 @@
                 <argument translate="true" name="value" xsi:type="string">Profile Payments</argument>
             </action>
         </block>
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Address" name="sales.recurring.profile.view.billing" as="billing_address" template="recurring/profile/view/info.phtml" group="info_blocks_row_3">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Address" name="sales.recurring.profile.view.billing" as="billing_address" template="recurring/profile/view/info.phtml" group="info_blocks_row_3">
             <action method="setViewColumn">
                 <argument name="value" xsi:type="string">1</argument>
             </action>
@@ -72,7 +72,7 @@
                 <argument translate="true" name="value" xsi:type="string">Billing Address</argument>
             </action>
         </block>
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Address" name="sales.recurring.profile.view.shipping" as="shipping_address" template="recurring/profile/view/info.phtml" group="info_blocks_row_3">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Address" name="sales.recurring.profile.view.shipping" as="shipping_address" template="recurring/profile/view/info.phtml" group="info_blocks_row_3">
             <action method="setAddressType">
                 <argument name="value" xsi:type="string">shipping</argument>
             </action>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_view__tabs.xml b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_view__tabs.xml
similarity index 62%
rename from app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_view__tabs.xml
rename to app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_view__tabs.xml
index ed652359a68e7680bfa044c9b98274f2c8b7d24f..74ef662684ad0f778c87ec0df0c247c4deef38a3 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_recurring_profile_view__tabs.xml
+++ b/app/code/Magento/RecurringProfile/view/frontend/layout/sales_recurringprofile_view__tabs.xml
@@ -30,7 +30,7 @@
         </action>
     </referenceBlock>
     <referenceContainer name="content">
-        <block class="Magento\Sales\Block\Recurring\Profile\View\Data" name="sales.recurring.profile.view" template="recurring/profile/view.phtml">
+        <block class="Magento\RecurringProfile\Block\Profile\View\Data" name="sales.recurring.profile.view" template="recurring/profile/view.phtml">
             <action method="setShouldPrepareInfoTabs">
                 <argument name="value" xsi:type="string">1</argument>
             </action>
@@ -42,19 +42,6 @@
                     <argument name="value" xsi:type="string">view</argument>
                 </action>
             </block>
-            <!-- not implemented
-            <block class="Magento\View\Element\Text" as="history" name="sales.recurring.profile.view.tab.history">
-                <action method="addToParentGroup">
-                    <argument name="value" xsi:type="string">info_tabs</argument>
-                </action>
-                <action method="setViewLabel" translate="value">
-                    <argument name="value" xsi:type="string">History</argument>
-                </action>
-                <action method="setViewAction">
-                    <argument name="value" xsi:type="string">history</argument>
-                </action>
-            </block>
-            -->
             <block class="Magento\View\Element\Text" as="related_orders" name="sales.recurring.profile.view.tab.orders" group="info_tabs">
                 <action method="setViewLabel">
                     <argument translate="true" name="value" xsi:type="string">Related Orders</argument>
@@ -63,19 +50,6 @@
                     <argument name="value" xsi:type="string">orders</argument>
                 </action>
             </block>
-            <!-- not implemented
-            <block class="Magento\View\Element\Text" as="vendor_info" name="sales.recurring.profile.view.tab.vendor">
-                <action method="addToParentGroup">
-                    <argument name="value" xsi:type="string">info_tabs</argument>
-                </action>
-                <action method="setViewLabel" translate="value">
-                    <argument name="value" xsi:type="string">Gateway Information</argument>
-                </action>
-                <action method="setViewAction">
-                    <argument name="value" xsi:type="string">vendor</argument>
-                </action>
-            </block>
-            -->
         </block>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Sales/view/frontend/recurring/grid.phtml b/app/code/Magento/RecurringProfile/view/frontend/recurring/grid.phtml
similarity index 100%
rename from app/code/Magento/Sales/view/frontend/recurring/grid.phtml
rename to app/code/Magento/RecurringProfile/view/frontend/recurring/grid.phtml
diff --git a/app/code/Magento/Sales/view/frontend/recurring/profile/view.phtml b/app/code/Magento/RecurringProfile/view/frontend/recurring/profile/view.phtml
similarity index 98%
rename from app/code/Magento/Sales/view/frontend/recurring/profile/view.phtml
rename to app/code/Magento/RecurringProfile/view/frontend/recurring/profile/view.phtml
index 1fdf1adb99a4c20f9fa8cc83a91379ece5605845..4bd04fc34784fa936c2ce2f8cb453c112d8ba15e 100644
--- a/app/code/Magento/Sales/view/frontend/recurring/profile/view.phtml
+++ b/app/code/Magento/RecurringProfile/view/frontend/recurring/profile/view.phtml
@@ -24,7 +24,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Recurring\Profile\View */ ?>
+<?php /* @var $this \Magento\RecurringProfile\Block\Profile\View */ ?>
 
 <div class="order recurring details">
     <div class="actions">
diff --git a/app/code/Magento/Sales/view/frontend/recurring/profile/view/info.phtml b/app/code/Magento/RecurringProfile/view/frontend/recurring/profile/view/info.phtml
similarity index 95%
rename from app/code/Magento/Sales/view/frontend/recurring/profile/view/info.phtml
rename to app/code/Magento/RecurringProfile/view/frontend/recurring/profile/view/info.phtml
index 944ff0a1b82d5c8be6883d8fbdc40b19c56d5d79..3877695a035ffcae7467b8ec2a68194bcb574385 100644
--- a/app/code/Magento/Sales/view/frontend/recurring/profile/view/info.phtml
+++ b/app/code/Magento/RecurringProfile/view/frontend/recurring/profile/view/info.phtml
@@ -23,7 +23,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Recurring\Profile\View */ ?>
+<?php /* @var $this \Magento\RecurringProfile\Block\Profile\View */ ?>
 <?php if ($this->getIsAddress()): ?>
 
     <?php foreach ($this->getRenderedInfo() as $row): ?>
diff --git a/app/code/Magento/Sales/view/frontend/recurring/profiles.phtml b/app/code/Magento/RecurringProfile/view/frontend/recurring/profiles.phtml
similarity index 94%
rename from app/code/Magento/Sales/view/frontend/recurring/profiles.phtml
rename to app/code/Magento/RecurringProfile/view/frontend/recurring/profiles.phtml
index 6f17bb4d1bcfc4423d2270560e9d171f6c80d9fb..18c42b4a3b78c1c4ee6a903f88dd97f64e16b8e9 100644
--- a/app/code/Magento/Sales/view/frontend/recurring/profiles.phtml
+++ b/app/code/Magento/RecurringProfile/view/frontend/recurring/profiles.phtml
@@ -23,7 +23,7 @@
  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  */
 ?>
-<?php /* @var $this \Magento\Sales\Block\Recurring\Profiles */ ?>
+<?php /* @var $this \Magento\RecurringProfile\Block\Profiles */ ?>
 <div class="block recurring profiles">
     <?php echo $this->getChildHtml('grid')?>
     <div class="actions">
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php
index a3f0fc364827817a67a6087c2a2f18f425edebc1..686b0a902cce107e1c20a0bede923676486fc5e3 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php
@@ -58,6 +58,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      *
      * @param string $fieldId
      * @param bool $visibility
+     *
      * @return void
      */
     public function setFieldVisibility($fieldId, $visibility)
@@ -85,7 +86,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      *
      * @param string $fieldId Field id
      * @param mixed $option Field option name
-     * @param mixed $value Field option value
+     * @param mixed|null $value Field option value
      *
      * @return void
      */
@@ -120,7 +121,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Add fieldset with general report fields
      *
-     * @return \Magento\Reports\Block\Adminhtml\Filter\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php
index c9ec1cc0f009a39981e261b61cb62afc4ae49c10..7e59e14fad93e9ed7a4421a9d4a72681abc69f8a 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php
@@ -95,7 +95,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
     /**
      * Apply sorting and filtering to collection
      *
-     * @return \Magento\Backend\Block\Widget\Grid|\Magento\Reports\Block\Adminhtml\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
@@ -199,8 +199,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
     /**
      * Set filter values
      *
-     * @param string $data
-     * @return \Magento\Backend\Block\Widget\Grid|\Magento\Reports\Block\Adminhtml\Grid
+     * @param array $data
+     * @return $this
      */
     protected function _setFilterValues($data)
     {
@@ -214,6 +214,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
      * Set visibility of store switcher
      *
      * @param bool $visible
+     *
      * @return void
      */
     public function setStoreSwitcherVisibility($visible=true)
@@ -245,6 +246,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
      * Set visibility of date filter
      *
      * @param bool $visible
+     *
      * @return void
      */
     public function setDateFilterVisibility($visible=true)
@@ -307,6 +309,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
      *
      * @param string $name
      * @param string $value
+     *
      * @return void
      */
     public function setFilter($name, $value)
@@ -336,6 +339,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
      * Set sub-report rows count
      *
      * @param int $size
+     *
      * @return void
      */
     public function setSubReportSize($size)
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
index 081037061d1e2e5ba764a3c02bf3ff3e3f749b51..6a588ee4c5df09be7beb967a47e950579d586be5 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
@@ -108,7 +108,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * @return string;
+     * @return string
      */
     public function getResourceCollectionName()
     {
@@ -152,7 +152,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
      *
      * @param string $columnId
      * @param array $column
-     * @return \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
+     * @return $this
      */
     public function addColumn($columnId, $column)
     {
@@ -281,7 +281,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * @return int
+     * @return array
      */
     public function getCountTotals()
     {
@@ -329,7 +329,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * @param mixed $storeIds
+     * @param array $storeIds
      *
      * @return $this
      */
@@ -340,7 +340,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * @return string
+     * @return string|\Magento\Directory\Model\Currency $currencyCode
      */
     public function getCurrentCurrencyCode()
     {
@@ -356,7 +356,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
      * Get currency rate (base to given currency)
      *
      * @param string|\Magento\Directory\Model\Currency $toCurrency
-     * @return double
+     * @return float
      */
     public function getRate($toCurrency)
     {
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php
index 8a5c0d7309130352d7124edf486a93a26eccbfac..d5ef95b2735a8b8a8e311b1feaa6de35a1d4f436 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php
@@ -33,12 +33,16 @@ namespace Magento\Reports\Block\Adminhtml\Grid;
 class Shopcart extends \Magento\Backend\Block\Widget\Grid\Extended
 {
     /**
-     * stores current currency code
+     * Stores current currency code
+     *
+     * @var array
      */
     protected $_currentCurrencyCode = null;
 
     /**
-     * ids of current stores
+     * Ids of current stores
+     *
+     * @var array
      */
     protected $_storeIds            = array();
 
@@ -74,7 +78,7 @@ class Shopcart extends \Magento\Backend\Block\Widget\Grid\Extended
      * Get currency rate (base to given currency)
      *
      * @param string|\Magento\Directory\Model\Currency $toCurrency
-     * @return double
+     * @return float
      */
     public function getRate($toCurrency)
     {
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php
index 5c981c4f46f0d181ece7d3b309e773f883f3ec39..ef61f0cdb0aae336cd3dd5b6b9e86093d902a736 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php
@@ -150,6 +150,4 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 
         return parent::_prepareColumns();
     }
-
 }
-
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php
index 38079c1675dff358bb8d19fbe91f7e6fc1825d55..f19577793e11aff910cf025478c599dd8c48ff55 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php
@@ -43,5 +43,4 @@ class Customer extends \Magento\Backend\Block\Widget\Grid\Container
         parent::_construct();
         $this->_removeButton('add');
     }
-
 }
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php
index ef5d9ee3ad54b3f8a552de97dcd85f97aeefc148..7d3b989736dc519537c083e195332a9ea303cdb1 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php
@@ -86,7 +86,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
      */
     protected function _prepareColumns()
     {
-
         $this->addColumn('nickname', array(
             'header'    =>__('Customer'),
             'width'     =>'100px',
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php
index 58b1202817bf264715ab0150fe13e4ea39b4092f..eae39e7ce403b4a84bc0e5a722c1e9662a6e2fb4 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php
@@ -163,7 +163,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
     /**
      * Preparing collection.  Filter canceled statuses for orders in taxes
      *
-     * @return \Magento\Reports\Block\Adminhtml\Sales\Tax\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
index 51daaf028a0c09090a46cbaad5708f43cff802de..8e8d018ce747c72cc16c28885b9b81b0c64ecc43 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
@@ -87,6 +87,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
     }
 
     /**
+     * @param array $column
+     *
      * @return $this
      */
     protected function _addColumnFilterToCollection($column)
@@ -208,6 +210,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
     }
 
     /**
+     * @param \Magento\Object $row
+     *
      * @return string
      */
     public function getRowUrl($row)
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php
index 59f8759abdf9b4878a57812d8b4403abbd48ee14..290de7252095a990c6b318addc5e34c19cb8b35f 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php
@@ -135,5 +135,4 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
 
         return parent::_prepareColumns();
     }
-
 }
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
index 40ce896921dc4b76c2e5c7fa6eea7a6417d2e349..70500865ddf1ee87dfe69168918710346ae4d874 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
@@ -133,6 +133,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
     }
 
     /**
+     * @param \Magento\Object $row
+     *
      * @return string
      */
     public function getRowUrl($row)
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php
index 75170a8c4ce821563464802eda6d0a2bb76f5383..5b970f459f93d1b30ec87a37e8d08c23df23fcfd 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php
@@ -33,32 +33,32 @@ namespace Magento\Reports\Block\Adminhtml;
 class Wishlist extends \Magento\Backend\Block\Template
 {
     /**
-     * @var
+     * @var int
      */
     public $wishlists_count;
 
     /**
-     * @var
+     * @var int
      */
     public $items_bought;
 
     /**
-     * @var
+     * @var int
      */
     public $shared_count;
 
     /**
-     * @var
+     * @var int
      */
     public $referrals_count;
 
     /**
-     * @var
+     * @var int
      */
     public $conversions_count;
 
     /**
-     * @var
+     * @var int
      */
     public $customer_with_wishlist;
 
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php
index 95933e10043072982c225676eeab119cff8d8e41..601bc91b85f0cf99920b9b8237e8714d77ae9a21 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php
@@ -65,11 +65,10 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     }
 
     /**
-     * @return $this|\Magento\Backend\Block\Widget\Grid
+     * @return $this
      */
     protected function _prepareCollection()
     {
-
         $collection = $this->_productsFactory->create()
             ->addAttributeToSelect('entity_id')
             ->addAttributeToSelect('name')
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php
index 8c06aa8153a621a8e6d14110dabbab4d115a6801..ab78ce3bbba4223cd3b4d003e43b7c978d26bdf8 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php
@@ -84,7 +84,7 @@ abstract class AbstractReport extends \Magento\Backend\App\Action
     /**
      * Add report breadcrumbs
      *
-     * @return \Magento\Reports\Controller\Adminhtml\Report\AbstractReport
+     * @return $this
      */
     public function _initAction()
     {
@@ -97,7 +97,7 @@ abstract class AbstractReport extends \Magento\Backend\App\Action
      * Report action init operations
      *
      * @param array|\Magento\Object $blocks
-     * @return \Magento\Reports\Controller\Adminhtml\Report\AbstractReport
+     * @return $this
      */
     public function _initReportAction($blocks)
     {
@@ -134,7 +134,7 @@ abstract class AbstractReport extends \Magento\Backend\App\Action
      *
      * @param string $flagCode
      * @param string $refreshCode
-     * @return \Magento\Reports\Controller\Adminhtml\Report\AbstractReport
+     * @return $this
      */
     protected function _showLastExecutionTime($flagCode, $refreshCode)
     {
diff --git a/app/code/Magento/Reports/Model/DateFactory.php b/app/code/Magento/Reports/Model/DateFactory.php
index dfc0dedb47cf12c40861854bb0b46f9ab6f5f8b2..8c0169980603f22e3ef394eaaf79347c0e6d557e 100644
--- a/app/code/Magento/Reports/Model/DateFactory.php
+++ b/app/code/Magento/Reports/Model/DateFactory.php
@@ -38,4 +38,4 @@ class DateFactory
         return new \Zend_Date($date, $part, $locale);
     }
 
-} 
\ No newline at end of file
+} 
diff --git a/app/code/Magento/Reports/Model/Event/Observer.php b/app/code/Magento/Reports/Model/Event/Observer.php
index ba157a7c30e209146c3b30de54b91300e47eb131..9d3e861f69fdae70a4a91e123244fc29707834aa 100644
--- a/app/code/Magento/Reports/Model/Event/Observer.php
+++ b/app/code/Magento/Reports/Model/Event/Observer.php
@@ -60,6 +60,14 @@ class Observer
      */
     protected $_logVisitor;
 
+    /**
+     * @param \Magento\Core\Model\StoreManagerInterface $storeManager
+     * @param \Magento\Reports\Model\EventFactory $event
+     * @param \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory
+     * @param \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory
+     * @param \Magento\Customer\Model\Session $customerSession
+     * @param \Magento\Log\Model\Visitor $logVisitor
+     */
     public function __construct(
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Reports\Model\EventFactory $event,
@@ -76,7 +84,7 @@ class Observer
         $this->_logVisitor = $logVisitor;
     }
     /**
-     * Abstract Event obeserver logic
+     * Abstract Event observer logic
      *
      * Save event
      *
@@ -84,7 +92,7 @@ class Observer
      * @param int $objectId
      * @param int $subjectId
      * @param int $subtype
-     * @return \Magento\Reports\Model\Event\Observer
+     * @return $this
      */
     protected function _event($eventTypeId, $objectId, $subjectId = null, $subtype = 0)
     {
diff --git a/app/code/Magento/Reports/Model/Item.php b/app/code/Magento/Reports/Model/Item.php
index b7a12dd95aabdb116bbac6810855ce5c36a0cd86..9086d418d5db313140c692a70a2b5f377723aad4 100644
--- a/app/code/Magento/Reports/Model/Item.php
+++ b/app/code/Magento/Reports/Model/Item.php
@@ -27,10 +27,14 @@ namespace Magento\Reports\Model;
 
 class Item extends \Magento\Object
 {
-    /** @var bool */
+    /**
+     * @var bool
+     */
     protected $_isEmpty  = false;
 
-    /** @var array */
+    /**
+     * @var array
+     */
     protected $_children = array();
 
     /**
@@ -74,7 +78,7 @@ class Item extends \Magento\Object
     /**
      * Set children
      *
-     * @param $children
+     * @param array $children
      * @return $this
      */
     public function setChildren($children)
diff --git a/app/code/Magento/Reports/Model/Plugin/Log.php b/app/code/Magento/Reports/Model/Plugin/Log.php
index 1d8f77b0e786a7d9a1196c141dfbaa847fcba192..cf92bbb705c8c0f1b7f056d993887fce53196d44 100644
--- a/app/code/Magento/Reports/Model/Plugin/Log.php
+++ b/app/code/Magento/Reports/Model/Plugin/Log.php
@@ -60,10 +60,10 @@ class Log
     /**
      * Clean events by old visitors after plugin for clean method
      *
-     * @see Global Log Clean Settings
-     *
      * @param \Magento\Log\Model\Resource\Log $logResourceModel
      * @return \Magento\Log\Model\Resource\Log
+     *
+     * @see Global Log Clean Settings
      */
     public function afterClean($logResourceModel)
     {
diff --git a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php
index c5246434b7635eba2841d8d63ef62c6f3d8e573e..ebc069145d52cf656b5fa245f52f4aea3f11a8c7 100644
--- a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php
+++ b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php
@@ -106,7 +106,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel
     /**
      * Prepare customer/visitor, store data before save
      *
-     * @return \Magento\Reports\Model\Product\Index\AbstractIndex
+     * @return $this
      */
     protected function _beforeSave()
     {
diff --git a/app/code/Magento/Reports/Model/Resource/HelperFactory.php b/app/code/Magento/Reports/Model/Resource/HelperFactory.php
index 95210042bb54321502cfdcc51afa75062a9cd5f4..0aa82a327c3c36bb9b64cdf2dde11887663ddc2c 100644
--- a/app/code/Magento/Reports/Model/Resource/HelperFactory.php
+++ b/app/code/Magento/Reports/Model/Resource/HelperFactory.php
@@ -34,4 +34,4 @@ class HelperFactory extends \Magento\Core\Model\Resource\HelperFactory
      * @var string
      */
     protected $_moduleName = 'Magento_Reports';
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Reports/Model/Resource/HelperInterface.php b/app/code/Magento/Reports/Model/Resource/HelperInterface.php
index 0729ee7da037b896abbc6efb1e39971d17f8c148..d48f3168591c5a3ceae978aa93be37c6807efa93 100644
--- a/app/code/Magento/Reports/Model/Resource/HelperInterface.php
+++ b/app/code/Magento/Reports/Model/Resource/HelperInterface.php
@@ -36,7 +36,7 @@ interface HelperInterface
      *
      * @param string $mainTable
      * @param array $data
-     * $param mixed $matchFields
+     * @param mixed $matchFields
      * @return string
      */
     public function mergeVisitorProductIndex($mainTable, $data, $matchFields);
diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php
index 2d23d1878fd34b1c173cc93132d26c207e1cbae6..1bf8d45b10b77c1f8ee4a5fb3109a6f59a4ecf5d 100644
--- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php
@@ -150,7 +150,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection
      * @param mixed $customStart
      * @param mixed $customEnd
      * @param int $isFilter
-     * @return \Magento\Reports\Model\Resource\Order\Collection
+     * @return $this
      */
     public function prepareSummary($range, $customStart, $customEnd, $isFilter = 0)
     {
@@ -456,7 +456,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection
     /**
      * Add item count expression
      *
-     * @return \Magento\Reports\Model\Resource\Order\Collection
+     * @return $this
      */
     public function addItemCountExpr()
     {
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php
index 27e1e15bdb5e4f89ea71617ed388c040018ffdf4..57f8ce31b471b00c5a885eec26ff74111939b1b2 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php
@@ -60,7 +60,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     protected $_productEntityTypeId;
 
     /**
-     * select count
+     * Select count
      *
      * @var int
      */
@@ -169,7 +169,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Set product entity id
      *
-     * @param $entityId
+     * @param string $entityId
      * @return $this
      */
     public function setProductEntityId($entityId)
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php
index 4ae66cb46255174279652c075b0aa2bd729ad6d9..ba0a113f955d1df77f5b8864e8e71b2889295974 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php
@@ -121,6 +121,8 @@ abstract class AbstractCollection
 
     /**
      * Retrieve Product Index table name
+     *
+     * @return string
      */
     abstract protected function _getTableName();
 
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php
index 1e46772307f9a3d41390cf5a148c0e6971c42f54..24b542ebb49f54f7ca76b205eb5c62fedc7e623f 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php
@@ -36,7 +36,7 @@ namespace Magento\Reports\Model\Resource\Product\Sold\Collection;
 
 class Initial extends \Magento\Reports\Model\Resource\Report\Collection
 {
-    /*
+    /**
      * Report sub-collection class name
      *
      * @var string
diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php
index 1308c8143723575dad88bd6404eff64e7a45352e..628f679e3f3db965de1640b22f7741db405c740e 100644
--- a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php
@@ -68,6 +68,16 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection
      */
     protected $_customerResource;
 
+    /**
+     * @param \Magento\Core\Model\EntityFactory $entityFactory
+     * @param \Magento\Logger $logger
+     * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
+     * @param \Magento\Event\ManagerInterface $eventManager
+     * @param \Magento\Catalog\Model\Resource\Product\Collection $productResource
+     * @param \Magento\Customer\Model\Resource\Customer $customerResource
+     * @param null $connection
+     * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
+     */
     public function __construct(
         \Magento\Core\Model\EntityFactory $entityFactory,
         \Magento\Logger $logger,
diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
index 9f209b021953e0bea96cb701aaed678221665770..a85ffdfb5b80d2eb3779d6c92eaaa57e10b5d3f5 100644
--- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
+++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
@@ -355,8 +355,8 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Check range dates and transforms it to strings
      *
-     * @param mixed $dateFrom
-     * @param mixed $dateTo
+     * @param mixed &$dateFrom
+     * @param mixed &$dateTo
      * @return $this
      */
     protected function _checkDates(&$dateFrom, &$dateTo)
diff --git a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php
index ddeeff7e8df376ae269ea90524b111b826487874..7681a60016fcd5b2518a06dfb2c8cb9ddeaa5274 100644
--- a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php
@@ -85,7 +85,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set wishlist table name
      *
      * @param string $value
-     * @return \Magento\Reports\Model\Resource\Wishlist\Collection
+     * @return $this
      */
     public function setWishlistTable($value)
     {
diff --git a/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_default_without_children.xml b/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_default_without_children.xml
index 8034b3110782e0ffd860ed7b3397ef825be77815..f6520102091c392e3035cc0571d9cbd31b59e22f 100644
--- a/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_default_without_children.xml
+++ b/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_default_without_children.xml
@@ -26,6 +26,6 @@
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <remove name="right.reports.product.viewed"/>
     <referenceContainer name="right">
-        <block class="Magento\Reports\Block\Product\Viewed" before="right.permanent.callout" name="left.reports.product.viewed" template="product_viewed.phtml"/>
+        <block class="Magento\Reports\Block\Product\Viewed" name="left.reports.product.viewed" template="product_viewed.phtml"/>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_layered_without_children.xml b/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_layered_without_children.xml
index 8034b3110782e0ffd860ed7b3397ef825be77815..f6520102091c392e3035cc0571d9cbd31b59e22f 100644
--- a/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_layered_without_children.xml
+++ b/app/code/Magento/Reports/view/frontend/layout/catalog_category_view_type_layered_without_children.xml
@@ -26,6 +26,6 @@
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <remove name="right.reports.product.viewed"/>
     <referenceContainer name="right">
-        <block class="Magento\Reports\Block\Product\Viewed" before="right.permanent.callout" name="left.reports.product.viewed" template="product_viewed.phtml"/>
+        <block class="Magento\Reports\Block\Product\Viewed" name="left.reports.product.viewed" template="product_viewed.phtml"/>
     </referenceContainer>
 </layout>
diff --git a/app/code/Magento/Reports/view/frontend/widget/compared/column/compared_default_list.phtml b/app/code/Magento/Reports/view/frontend/widget/compared/column/compared_default_list.phtml
index 33c2d571384be750f713c3d5c159acec3bee798d..127cea3304f281e8e06443fb797e60209f466181 100644
--- a/app/code/Magento/Reports/view/frontend/widget/compared/column/compared_default_list.phtml
+++ b/app/code/Magento/Reports/view/frontend/widget/compared/column/compared_default_list.phtml
@@ -69,7 +69,7 @@ if ($exist = $this->getRecentlyComparedProducts()) {
                     <div class="actions">
                         <?php if ($_product->getTypeInstance()->hasRequiredOptions($_product)): ?>
                             <button class="action tocart"
-                                    data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_product) ?>'}}"
+                                    data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_product) ?>"}}'
                                     type="button" title="<?php echo __('Add to Cart') ?>">
                                 <span><?php echo __('Add to Cart') ?></span>
                             </button>
diff --git a/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_grid.phtml b/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_grid.phtml
index e840d9f54c83aaedea1ae6e3f2d5618fe8c40162..e12debd170adfd06f83be321432aa604d8d9965d 100644
--- a/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_grid.phtml
+++ b/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_grid.phtml
@@ -80,7 +80,7 @@ if ($exist = $this->getRecentlyComparedProducts()) {
                                             <?php if($_item->isSaleable()): ?>
                                                 <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
                                                     <button class="action tocart"
-                                                            data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>'}}"
+                                                            data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}'
                                                             type="button" title="<?php echo __('Add to Cart') ?>">
                                                         <span><?php echo __('Add to Cart') ?></span>
                                                     </button>
@@ -135,4 +135,4 @@ if ($exist = $this->getRecentlyComparedProducts()) {
             </ol>
         </div>
     </div>
-<?php endif;?>
\ No newline at end of file
+<?php endif;?>
diff --git a/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_list.phtml b/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_list.phtml
index cf2d934b134775863fa168e92d856048d8235754..e01262465c84baeaf56a8ecb3805bb8ddab76120 100644
--- a/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_list.phtml
+++ b/app/code/Magento/Reports/view/frontend/widget/compared/content/compared_list.phtml
@@ -80,7 +80,7 @@ if ($exist = $this->getRecentlyComparedProducts()) {
                                             <?php if($_item->isSaleable()): ?>
                                                 <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
                                                     <button class="action tocart"
-                                                            data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>'}}"
+                                                            data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}'
                                                             type="button" title="<?php echo __('Add to Cart') ?>">
                                                         <span><?php echo __('Add to Cart') ?></span>
                                                     </button>
diff --git a/app/code/Magento/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml b/app/code/Magento/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml
index 1b50f80a3f5973593c3b8a14acf3e234355c8f4b..8feffe3ca6195c7f349bbc251ea827223a194a0d 100644
--- a/app/code/Magento/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml
+++ b/app/code/Magento/Reports/view/frontend/widget/viewed/column/viewed_default_list.phtml
@@ -77,7 +77,7 @@ if ($exist = $this->getRecentlyViewedProducts()) {
                             <div class="primary">
                                 <?php if ($_product->getTypeInstance()->hasRequiredOptions($_item)): ?>
                                     <button class="action tocart"
-                                            data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>
+                                            data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}'
                                                             type="button" title="<?php echo __('Add to Cart') ?>">
                                     <span><?php echo __('Add to Cart') ?></span>
                                 <?php else: ?>
diff --git a/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml b/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml
index 151add3d1fcbbeebdb14fd23298a59751670283a..17c125779c2c1d8bec72eb03e01374af8d5a5c48 100644
--- a/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml
+++ b/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_grid.phtml
@@ -81,7 +81,7 @@ if ($exist = $this->getRecentlyViewedProducts()) {
                                         <div class="primary">
                                             <?php if($_item->isSaleable()): ?>
                                                 <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
-                                                    <button class="action tocart" data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>'}}" type="button" title="<?php echo __('Add to Cart') ?>">
+                                                    <button class="action tocart" data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}' type="button" title="<?php echo __('Add to Cart') ?>">
                                                         <span><?php echo __('Add to Cart') ?></span>
                                                     </button>
                                                 <?php else: ?>
diff --git a/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_list.phtml b/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_list.phtml
index bdd10e82d43b67b865183b170d8e36d717c4848d..25c94ef7690e0ac12de6dbc19a93e46f1e816ecb 100644
--- a/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_list.phtml
+++ b/app/code/Magento/Reports/view/frontend/widget/viewed/content/viewed_list.phtml
@@ -83,7 +83,7 @@ if ($exist = $this->getRecentlyViewedProducts()) {
                                             <?php if($_item->isSaleable()): ?>
                                                 <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?>
                                                     <button class="action tocart"
-                                                            data-mage-init="{redirectUrl: {url: '<?php echo $this->getAddToCartUrl($_item) ?>
+                                                            data-mage-init='{"redirectUrl": {"url": "<?php echo $this->getAddToCartUrl($_item) ?>"}}'
                                                             type="button" title="<?php echo __('Add to Cart') ?>">
                                                         <span><?php echo __('Add to Cart') ?></span>
                                                     </button>
diff --git a/app/code/Magento/Review/Block/Adminhtml/Add.php b/app/code/Magento/Review/Block/Adminhtml/Add.php
index 7bcf2e85007b763b6ef483774bf27cfe1de861ef..8c344cf11e01042f0d67082891420633c8f4e252 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Add.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Add.php
@@ -35,6 +35,11 @@ namespace Magento\Review\Block\Adminhtml;
  */
 class Add extends \Magento\Backend\Block\Widget\Form\Container
 {
+    /**
+     * Initialize add review
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -119,6 +124,8 @@ class Add extends \Magento\Backend\Block\Widget\Form\Container
     }
 
     /**
+     * Get add new review header text
+     *
      * @return string
      */
     public function getHeaderText()
diff --git a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php
index 35371248f652b2e14ad0e54db4a868273234834d..fa58391274b67b4de5221a7d968b72432788d201 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Block\Adminhtml\Add;
 
 /**
  * Adminhtml add product review form
@@ -31,9 +32,6 @@
  * @package    Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Review\Block\Adminhtml\Add;
-
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
     /**
@@ -44,6 +42,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     protected $_reviewData = null;
 
     /**
+     * Core system store model
+     *
      * @var \Magento\Core\Model\System\Store
      */
     protected $_systemStore;
@@ -70,6 +70,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
+     * Prepare add review form
+     *
      * @return void
      */
     protected function _prepareForm()
diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit.php b/app/code/Magento/Review/Block/Adminhtml/Edit.php
index 23ff1302b99a17fa6baba52d32d6e5696eb273b7..be6711f6ac05bad2c20db41344e76a5d0bd4e192 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Edit.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Edit.php
@@ -46,6 +46,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
     protected $_coreRegistry = null;
 
     /**
+     * Review model factory
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
@@ -70,6 +72,11 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         parent::__construct($context, $data);
     }
 
+    /**
+     * Initialize edit review
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -214,6 +221,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
     }
 
     /**
+     * Get edit review header text
+     *
      * @return string
      */
     public function getHeaderText()
diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
index e429057dabfb460a88517f6a242e3fe7037234d4..1e0d62c72c704ec764d0faba134d92d6467c5045 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
@@ -39,16 +39,22 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     protected $_reviewData = null;
 
     /**
+     * Customer model factory
+     *
      * @var \Magento\Customer\Model\CustomerFactory
      */
     protected $_customerFactory;
 
     /**
+     * Catalog product factory
+     *
      * @var \Magento\Catalog\Model\ProductFactory
      */
     protected $_productFactory;
 
     /**
+     * Core system store model
+     *
      * @var \Magento\Core\Model\System\Store
      */
     protected $_systemStore;
@@ -81,6 +87,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
+     * Prepare edit review form
+     *
      * @return $this
      */
     protected function _prepareForm()
@@ -118,12 +126,10 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
                 $this->escapeHtml($customer->getFirstname()),
                 $this->escapeHtml($customer->getLastname()),
                 $this->escapeHtml($customer->getEmail()));
+        } elseif ($review->getStoreId() == \Magento\Core\Model\Store::DEFAULT_STORE_ID) {
+            $customerText = __('Administrator');
         } else {
-            if (is_null($review->getCustomerId())) {
-                $customerText = __('Guest');
-            } elseif ($review->getCustomerId() == 0) {
-                $customerText = __('Administrator');
-            }
+            $customerText = __('Guest');
         }
 
         $fieldset->addField('customer', 'note', array(
diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Grid.php
index a954bc7dfa9493097ef9a809f7f7791f3fb49d29..5ac101ef5dde088842f963e041386d001ef162f4 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Grid.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Grid.php
@@ -63,11 +63,15 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
     protected $_coreRegistry = null;
 
     /**
+     * Review collection model factory
+     *
      * @var \Magento\Review\Model\Resource\Review\Product\CollectionFactory
      */
     protected $_productsFactory;
 
     /**
+     * Review model factory
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
@@ -102,6 +106,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
 
     /**
      * Initialize grid
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php b/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php
index 8d8721e2e5979e3acbcc58e17a3b4265e9fbe15e..845bac209462a0241f73039151dc474f66d8eb5f 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php
@@ -36,6 +36,8 @@ namespace Magento\Review\Block\Adminhtml\Grid\Filter;
 class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
 {
     /**
+     * Get grid options
+     *
      * @return array
      */
     protected function _getOptions()
@@ -49,6 +51,8 @@ class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
     }
 
     /**
+     * Get condition
+     *
      * @return int
      */
     public function getCondition()
diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php b/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php
index 67ebcececcc40520d7ccd600cc2bbff51d8d5a0a..c388348416565b253a506f33e452f9865bcca682 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php
@@ -36,20 +36,19 @@ namespace Magento\Review\Block\Adminhtml\Grid\Renderer;
 class Type extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
     /**
+     * Render review type
+     *
+     * @param \Magento\Object $row
      * @return string
      */
     public function render(\Magento\Object $row)
     {
-
-        if (is_null($row->getCustomerId())) {
-            if ($row->getStoreId() == \Magento\Core\Model\Store::DEFAULT_STORE_ID) {
-                return __('Administrator');
-            } else {
-                return __('Guest');
-            }
-        } elseif ($row->getCustomerId() > 0) {
+        if ($row->getCustomerId()) {
             return __('Customer');
         }
-//		return ($row->getCustomerId() ? __('Customer') : __('Guest'));
+        if ($row->getStoreId() == \Magento\Core\Model\Store::DEFAULT_STORE_ID) {
+            return __('Administrator');
+        }
+        return __('Guest');
     }
 }// Class \Magento\Review\Block\Adminhtml\Grid\Renderer\Type END
diff --git a/app/code/Magento/Review/Block/Adminhtml/Main.php b/app/code/Magento/Review/Block/Adminhtml/Main.php
index 003152defcaf45348ef4c01a50c95086e8adb260..f8933abeac87fd6b0f50db2dbd4807fed494961d 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Main.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Main.php
@@ -39,11 +39,15 @@ class Main extends \Magento\Backend\Block\Widget\Grid\Container
     protected $_coreRegistry = null;
 
     /**
+     * Customer model factory
+     *
      * @var \Magento\Customer\Model\CustomerFactory
      */
     protected $_customerFactory;
 
     /**
+     * Catalog product model factory
+     *
      * @var \Magento\Catalog\Model\ProductFactory
      */
     protected $_productFactory;
@@ -68,6 +72,11 @@ class Main extends \Magento\Backend\Block\Widget\Grid\Container
         parent::__construct($context, $data);
     }
 
+    /**
+     * Initialize add new review
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->_addButtonLabel = __('Add New Review');
diff --git a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php
index 8cda7a1478d53298f4d3034244f1ed1c2539eff6..7d5f69624dd28dbddd6123aea8487d8ef130725b 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php
@@ -23,19 +23,18 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Block\Adminhtml\Product;
 
 /**
  * Adminhtml product grid block
  *
- * @category   Magento
- * @package    Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Block\Adminhtml\Product;
-
 class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
 {
     /**
+     * Website collection
+     *
      * @var \Magento\Core\Model\Resource\Website\CollectionFactory
      */
     protected $_websitesFactory;
@@ -83,6 +82,11 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
         );
     }
 
+    /**
+     * Initialize review
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -91,6 +95,8 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
     }
 
     /**
+     * Prepare product review grid
+     *
      * @return void
      */
     protected function _prepareColumns()
@@ -158,6 +164,8 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
     }
 
     /**
+     * Get catalog product grid url
+     *
      * @return string
      */
     public function getGridUrl()
@@ -166,6 +174,9 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
     }
 
     /**
+     * Get catalog product row url
+     *
+     * @param \Magento\Object $row
      * @return string
      */
     public function getRowUrl($row)
@@ -174,6 +185,8 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
     }
 
     /**
+     * Prepare mass action
+     *
      * @return $this
      */
     protected function _prepareMassaction()
diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php
index db12de01600d88feacc52213f2e72776bc1ca9cf..a96a1ef279637307c369549c36bebc4d1cd5a3ee 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php
@@ -36,11 +36,15 @@ use Magento\Rating\Model\Resource\Rating\Option\Vote\Collection as VoteCollectio
 class Detailed extends \Magento\Backend\Block\Template
 {
     /**
+     * Vote collection
+     *
      * @var VoteCollection
      */
     protected $_voteCollection = false;
 
     /**
+     * Rating detail template name
+     *
      * @var string
      */
     protected $_template = 'Magento_Rating::rating/detailed.phtml';
@@ -53,11 +57,15 @@ class Detailed extends \Magento\Backend\Block\Template
     protected $_coreRegistry = null;
 
     /**
+     * Rating resource model
+     *
      * @var \Magento\Rating\Model\Resource\Rating\CollectionFactory
      */
     protected $_ratingsFactory;
 
     /**
+     * Rating resource option model
+     *
      * @var \Magento\Rating\Model\Resource\Rating\Option\Vote\CollectionFactory
      */
     protected $_votesFactory;
@@ -82,6 +90,11 @@ class Detailed extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * Initialize review data
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -92,6 +105,8 @@ class Detailed extends \Magento\Backend\Block\Template
     }
 
     /**
+     * Get collection of ratings
+     *
      * @return RatingCollection
      */
     public function getRating()
@@ -145,6 +160,8 @@ class Detailed extends \Magento\Backend\Block\Template
     }
 
     /**
+     * Set independent mode
+     *
      * @return $this
      */
     public function setIndependentMode()
@@ -154,6 +171,8 @@ class Detailed extends \Magento\Backend\Block\Template
     }
 
     /**
+     * Indicator of whether or not a rating is selected
+     *
      * @param Option $option
      * @param Rating $rating
      * @return bool
diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php
index 11abe14d21f447c5286ec4e17db9cf955d86e03f..7e3830e1cdaedfa53cd504ebdb98ecd5573a7180 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php
@@ -34,6 +34,8 @@ use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection;
 class Summary extends \Magento\Backend\Block\Template
 {
     /**
+     * Rating summary template name
+     *
      * @var string
      */
     protected $_template = 'Magento_Rating::rating/stars/summary.phtml';
@@ -46,11 +48,15 @@ class Summary extends \Magento\Backend\Block\Template
     protected $_coreRegistry = null;
 
     /**
+     * Rating resource option model
+     *
      * @var \Magento\Rating\Model\Resource\Rating\Option\Vote\CollectionFactory
      */
     protected $_votesFactory;
 
     /**
+     * Rating model
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
@@ -75,6 +81,11 @@ class Summary extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * Initialize review data
+     *
+     * @return void
+     */
     protected function _construct()
     {
         if ($this->_coreRegistry->registry('review_data')) {
@@ -83,6 +94,8 @@ class Summary extends \Magento\Backend\Block\Template
     }
 
     /**
+     * Get collection of ratings
+     *
      * @return RatingCollection
      */
     public function getRating()
@@ -98,6 +111,8 @@ class Summary extends \Magento\Backend\Block\Template
     }
 
     /**
+     * Get rating summary
+     *
      * @return string
      */
     public function getRatingSummary()
diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php
index e2a46d8c5b729782063ed98b638184a645e8212a..4b53de6a2c40e8e7a7e4ba195a14e43358d92e99 100644
--- a/app/code/Magento/Review/Block/Customer/ListCustomer.php
+++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php
@@ -42,6 +42,8 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard
     protected $_collection;
 
     /**
+     * Review resource model
+     *
      * @var \Magento\Review\Model\Resource\Review\Product\CollectionFactory
      */
     protected $_collectionFactory;
@@ -66,6 +68,8 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard
     }
 
     /**
+     * Initialize review collection
+     *
      * @return $this
      */
     protected function _initCollection()
@@ -167,6 +171,8 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard
     }
 
     /**
+     * Add review summary
+     *
      * @return \Magento\View\Element\AbstractBlock
      */
     protected function _beforeToHtml()
diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php
index c2d11019f5c73325ec88bcb390b1c6a5dbad58f5..f7721415f54990d78cca9591bac807b49b84b596 100644
--- a/app/code/Magento/Review/Block/Customer/Recent.php
+++ b/app/code/Magento/Review/Block/Customer/Recent.php
@@ -34,6 +34,8 @@ use Magento\Review\Model\Resource\Review\Product\Collection;
 class Recent extends \Magento\View\Element\Template
 {
     /**
+     * Customer list template name
+     *
      * @var string
      */
     protected $_template = 'customer/list.phtml';
@@ -46,11 +48,14 @@ class Recent extends \Magento\View\Element\Template
     protected $_collection;
 
     /**
+     * Review resource model
+     *
      * @var \Magento\Review\Model\Resource\Review\Product\CollectionFactory
      */
     protected $_collectionFactory;
 
     /**
+     * Customer session model
      * @var \Magento\Customer\Model\Session
      */
     protected $_customerSession;
@@ -94,6 +99,7 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Initialize review collection
      * @return $this
      */
     protected function _initCollection()
@@ -110,6 +116,8 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Get number of reviews
+     *
      * @return int
      */
     public function count()
@@ -118,6 +126,7 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Initialize and return collection of reviews
      * @return Collection
      */
     protected function _getCollection()
@@ -129,6 +138,8 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Return collection of reviews
+     *
      * @return Collection
      */
     public function getCollection()
@@ -137,6 +148,8 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Return review customer view url
+     *
      * @return string
      */
     public function getReviewLink()
@@ -145,6 +158,8 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Return catalog product view url
+     *
      * @return string
      */
     public function getProductLink()
@@ -153,6 +168,9 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Format review date
+     *
+     * @param string $date
      * @return string
      */
     public function dateFormat($date)
@@ -161,6 +179,8 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Return review customer url
+     *
      * @return string
      */
     public function getAllReviewsUrl()
@@ -169,6 +189,9 @@ class Recent extends \Magento\View\Element\Template
     }
 
     /**
+     * Return review customer view url for a specific customer/review
+     *
+     * @param int $id
      * @return string
      */
     public function getReviewUrl($id)
diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php
index b41a95cb478962a90bebe834e265dba127e3154a..d23751758e20837ae94b5dad2949101e88dc9b17 100644
--- a/app/code/Magento/Review/Block/Customer/View.php
+++ b/app/code/Magento/Review/Block/Customer/View.php
@@ -23,6 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Block\Customer;
+
+use Magento\Catalog\Model\Product as Product;
+use Magento\Rating\Model\Resource\Rating\Option\Vote\Collection as VoteCollection;
+use Magento\Review\Model\Review as Review;
 
 /**
  * Customer Review detailed view block
@@ -31,38 +36,46 @@
  * @package    Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Review\Block\Customer;
-
-use Magento\Catalog\Model\Product as Product;
-use Magento\Rating\Model\Rating\Option\Vote\Collection as VoteCollection;
-use Magento\Review\Model\Review as Review;
-
 class View extends \Magento\Catalog\Block\Product\AbstractProduct
 {
+    /**
+     * Customer view template name
+     *
+     * @var string
+     */
     protected $_template = 'customer/view.phtml';
 
     /**
+     * Catalog product model
+     *
      * @var \Magento\Catalog\Model\ProductFactory
      */
     protected $_productFactory;
 
     /**
+     * Review model
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
 
     /**
+     * Rating option model
+     *
      * @var \Magento\Rating\Model\Rating\Option\VoteFactory
      */
     protected $_voteFactory;
 
     /**
+     * Rating model
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
 
     /**
+     * Customer session model
+     *
      * @var \Magento\Customer\Model\Session
      */
     protected $_customerSession;
@@ -133,7 +146,11 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
         $this->_isScopePrivate = true;
     }
 
-
+    /**
+     * Initialize review id
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -141,11 +158,13 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
     }
 
     /**
+     * Get product data
+     *
      * @return Product
      */
     public function getProductData()
     {
-        if( $this->getReviewId() && !$this->getProductCacheData() ) {
+        if ($this->getReviewId() && !$this->getProductCacheData()) {
             $product = $this->_productFactory->create()
                 ->setStoreId($this->_storeManager->getStore()->getId())
                 ->load($this->getReviewData()->getEntityPkValue());
@@ -155,17 +174,21 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
     }
 
     /**
+     * Get review data
+     *
      * @return Review
      */
     public function getReviewData()
     {
-        if( $this->getReviewId() && !$this->getReviewCachedData() ) {
+        if ($this->getReviewId() && !$this->getReviewCachedData()) {
             $this->setReviewCachedData($this->_reviewFactory->create()->load($this->getReviewId()));
         }
         return $this->getReviewCachedData();
     }
 
     /**
+     * Return review customer url
+     *
      * @return string
      */
     public function getBackUrl()
@@ -174,11 +197,13 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
     }
 
     /**
+     * Get review rating collection
+     *
      * @return VoteCollection
      */
     public function getRating()
     {
-        if( !$this->getRatingCollection() ) {
+        if (!$this->getRatingCollection()) {
             $ratingCollection = $this->_voteFactory->create()
                 ->getResourceCollection()
                 ->setReviewFilter($this->getReviewId())
@@ -193,28 +218,35 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
     }
 
     /**
+     * Get rating summary
+     *
      * @return array
      */
     public function getRatingSummary()
     {
-        if( !$this->getRatingSummaryCache() ) {
+        if (!$this->getRatingSummaryCache()) {
             $this->setRatingSummaryCache($this->_ratingFactory->create()->getEntitySummary($this->getProductData()->getId()));
         }
         return $this->getRatingSummaryCache();
     }
 
     /**
+     * Get total reviews
+     *
      * @return int
      */
     public function getTotalReviews()
     {
-        if( !$this->getTotalReviewsCache() ) {
+        if (!$this->getTotalReviewsCache()) {
             $this->setTotalReviewsCache($this->_reviewFactory->create()->getTotalReviews($this->getProductData()->getId()), false, $this->_storeManager->getStore()->getId());
         }
         return $this->getTotalReviewsCache();
     }
 
     /**
+     * Get formatted date
+     *
+     * @param string $date
      * @return string
      */
     public function dateFormat($date)
diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php
index 10ab8e13a75dd6af647550503562d004bc46ffdf..ef710cba1bd843a9a66e4dabe7182e1b44655602 100644
--- a/app/code/Magento/Review/Block/Form.php
+++ b/app/code/Magento/Review/Block/Form.php
@@ -23,6 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Block;
+
+use Magento\Catalog\Model\Product;
+use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection;
 
 /**
  * Review form block
@@ -31,11 +35,6 @@
  * @package    Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Block;
-
-use Magento\Catalog\Model\Product;
-use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection;
-
 class Form extends \Magento\View\Element\Template
 {
     /**
@@ -46,31 +45,43 @@ class Form extends \Magento\View\Element\Template
     protected $_reviewData = null;
 
     /**
+     * Customer session model
+     *
      * @var \Magento\Customer\Model\Session
      */
     protected $_customerSession;
 
     /**
+     * Catalog product model
+     *
      * @var \Magento\Catalog\Model\ProductFactory
      */
     protected $_productFactory;
 
     /**
+     * Rating model
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
 
     /**
+     * Review session model
+     *
      * @var \Magento\Review\Model\Session
      */
     protected $_reviewSession;
 
     /**
+     * Core helper data
+     *
      * @var \Magento\Core\Helper\Data
      */
     protected $_coreData;
 
     /**
+     * Message manager interface
+     *
      * @var \Magento\Message\ManagerInterface
      */
     protected $messageManager;
@@ -108,6 +119,11 @@ class Form extends \Magento\View\Element\Template
         $this->_isScopePrivate = true;
     }
 
+    /**
+     * Initialize review form
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -143,6 +159,8 @@ class Form extends \Magento\View\Element\Template
     }
 
     /**
+     * Get product info
+     *
      * @return Product
      */
     public function getProductInfo()
@@ -152,6 +170,8 @@ class Form extends \Magento\View\Element\Template
     }
 
     /**
+     * Get review product post action
+     *
      * @return string
      */
     public function getAction()
@@ -161,6 +181,8 @@ class Form extends \Magento\View\Element\Template
     }
 
     /**
+     * Get collection of ratings
+     *
      * @return RatingCollection
      */
     public function getRatings()
diff --git a/app/code/Magento/Review/Block/Helper.php b/app/code/Magento/Review/Block/Helper.php
index 98c04a9a85a1cae1667014416d78c2c3c2b8c88f..49d38474f6e8099c3b03b022cc790915dbcf8eef 100644
--- a/app/code/Magento/Review/Block/Helper.php
+++ b/app/code/Magento/Review/Block/Helper.php
@@ -38,6 +38,8 @@ use Magento\Catalog\Model\Product;
 class Helper extends \Magento\View\Element\Template
 {
     /**
+     * Array of available template name
+     *
      * @var array
      */
     protected $_availableTemplates = array(
@@ -46,6 +48,8 @@ class Helper extends \Magento\View\Element\Template
     );
 
     /**
+     * Review model factory
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
@@ -65,6 +69,8 @@ class Helper extends \Magento\View\Element\Template
     }
 
     /**
+     * Get review summary html
+     *
      * @param Product $product
      * @param string $templateType
      * @param bool $displayIfNoReviews
@@ -89,6 +95,8 @@ class Helper extends \Magento\View\Element\Template
     }
 
     /**
+     * Get ratings summary
+     *
      * @return string
      */
     public function getRatingSummary()
@@ -97,6 +105,8 @@ class Helper extends \Magento\View\Element\Template
     }
 
     /**
+     * Get count of reviews
+     *
      * @return int
      */
     public function getReviewsCount()
@@ -105,6 +115,8 @@ class Helper extends \Magento\View\Element\Template
     }
 
     /**
+     * Get review product list url
+     *
      * @return string
      */
     public function getReviewsUrl()
diff --git a/app/code/Magento/Review/Block/Product/View.php b/app/code/Magento/Review/Block/Product/View.php
index 93c8ed0d785801460c545be40da3ab59545ad39e..f6af37fd442c58ae9f09f88cb50f7b8315457a68 100644
--- a/app/code/Magento/Review/Block/Product/View.php
+++ b/app/code/Magento/Review/Block/Product/View.php
@@ -37,11 +37,15 @@ use Magento\Review\Model\Resource\Review\Collection as ReviewCollection;
 class View extends \Magento\Catalog\Block\Product\View
 {
     /**
+     * Review collection
+     *
      * @var ReviewCollection
      */
     protected $_reviewsCollection;
 
     /**
+     * Review resource model
+     *
      * @var \Magento\Review\Model\Resource\Review\CollectionFactory
      */
     protected $_reviewsColFactory;
@@ -136,7 +140,7 @@ class View extends \Magento\Catalog\Block\Product\View
      * Reviews collection count will be jerked here
      *
      * @param \Magento\Catalog\Model\Product $product
-     * @param string $templateType
+     * @param bool $templateType
      * @param bool $displayIfNoReviews
      * @return string
      */
@@ -157,6 +161,8 @@ class View extends \Magento\Catalog\Block\Product\View
     }
 
     /**
+     * Get collection of reviews
+     *
      * @return ReviewCollection
      */
     public function getReviewsCollection()
@@ -174,7 +180,7 @@ class View extends \Magento\Catalog\Block\Product\View
     /**
      * Force product view page behave like without options
      *
-     * @return false
+     * @return bool
      */
     public function hasOptions()
     {
diff --git a/app/code/Magento/Review/Block/Product/View/ListView.php b/app/code/Magento/Review/Block/Product/View/ListView.php
index a7f419253c757ac0c7ef0f620d2eece3626eaed6..b0334eddc494ff13647dfedbb428a91786985f12 100644
--- a/app/code/Magento/Review/Block/Product/View/ListView.php
+++ b/app/code/Magento/Review/Block/Product/View/ListView.php
@@ -35,11 +35,14 @@ namespace Magento\Review\Block\Product\View;
 class ListView extends \Magento\Review\Block\Product\View
 {
     /**
+     * Unused class property
      * @var false
      */
     protected $_forceHasOptions = false;
 
     /**
+     * Get product id
+     *
      * @return int
      */
     public function getProductId()
@@ -48,6 +51,8 @@ class ListView extends \Magento\Review\Block\Product\View
     }
 
     /**
+     * Prepare product review list toolbar
+     *
      * @return $this
      */
     protected function _prepareLayout()
@@ -63,6 +68,8 @@ class ListView extends \Magento\Review\Block\Product\View
     }
 
     /**
+     * Add rate votes
+     *
      * @return $this
      */
     protected function _beforeToHtml()
@@ -74,6 +81,9 @@ class ListView extends \Magento\Review\Block\Product\View
     }
 
     /**
+     * Return review url
+     *
+     * @param int $id
      * @return string
      */
     public function getReviewUrl($id)
diff --git a/app/code/Magento/Review/Block/Product/View/Other.php b/app/code/Magento/Review/Block/Product/View/Other.php
index e4e6d04c2384da2ae138717e8718251903af2949..e3051b6e9d01f08acdc04b1608f311cda09925ad 100644
--- a/app/code/Magento/Review/Block/Product/View/Other.php
+++ b/app/code/Magento/Review/Block/Product/View/Other.php
@@ -32,6 +32,7 @@ namespace Magento\Review\Block\Product\View;
 class Other extends \Magento\View\Element\Template
 {
     /**
+     * Core model registry
      * @var \Magento\Core\Model\Registry
      */
     protected $_registry;
@@ -51,6 +52,8 @@ class Other extends \Magento\View\Element\Template
     }
 
     /**
+     * Get product object
+     *
      * @return \Magento\Catalog\Model\Product
      */
     public function getProduct()
diff --git a/app/code/Magento/Review/Block/View.php b/app/code/Magento/Review/Block/View.php
index 080ecb97caf57b204e38c7e28e17345fe10b9039..38d493b8cc7d6cfd1a78090a35c27b412a03e374 100644
--- a/app/code/Magento/Review/Block/View.php
+++ b/app/code/Magento/Review/Block/View.php
@@ -23,35 +23,39 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Block;
 
 /**
  * Review detailed view block
  *
- * @category   Magento
- * @package    Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Review\Block;
-
 class View extends \Magento\Catalog\Block\Product\AbstractProduct
 {
     /**
+     * View template name
+     *
      * @var string
      */
     protected $_template = 'view.phtml';
 
     /**
+     * Rating option model
+     *
      * @var \Magento\Rating\Model\Rating\Option\VoteFactory
      */
     protected $_voteFactory;
 
     /**
+     * Rating model factory
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
 
     /**
+     * Review model
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
@@ -151,7 +155,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
      */
     public function getRating()
     {
-        if( !$this->getRatingCollection() ) {
+        if (!$this->getRatingCollection()) {
             $ratingCollection = $this->_voteFactory->create()
                 ->getResourceCollection()
                 ->setReviewFilter($this->getReviewId())
@@ -170,7 +174,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
      */
     public function getRatingSummary()
     {
-        if( !$this->getRatingSummaryCache() ) {
+        if (!$this->getRatingSummaryCache()) {
             $this->setRatingSummaryCache(
                 $this->_ratingFactory->create()->getEntitySummary($this->getProductData()->getId())
             );
@@ -185,7 +189,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct
      */
     public function getTotalReviews()
     {
-        if( !$this->getTotalReviewsCache() ) {
+        if (!$this->getTotalReviewsCache()) {
             $this->setTotalReviewsCache(
                 $this->_reviewFactory->create()->getTotalReviews(
                     $this->getProductData()->getId(), false, $this->_storeManager->getStore()->getId()
diff --git a/app/code/Magento/Review/Controller/Customer.php b/app/code/Magento/Review/Controller/Customer.php
index 6b557555a7d8ca329e1433977a91279274125759..c96378ee875c439aeba1da953622c7e065927397 100644
--- a/app/code/Magento/Review/Controller/Customer.php
+++ b/app/code/Magento/Review/Controller/Customer.php
@@ -23,23 +23,21 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Controller;
+
+use Magento\App\Action\NotFoundException;
+use Magento\App\RequestInterface;
 
 /**
  * Customer reviews controller
  *
- * @category    Magento
- * @package     Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Review\Controller;
-
-use Magento\App\Action\NotFoundException;
-use Magento\App\RequestInterface;
-
 class Customer extends \Magento\App\Action\Action
 {
     /**
+     * Customer session model
+     *
      * @var \Magento\Customer\Model\Session
      */
     protected $_customerSession;
@@ -71,6 +69,8 @@ class Customer extends \Magento\App\Action\Action
     }
 
     /**
+     * Render my product reviews
+     *
      * @return void
      */
     public function indexAction()
@@ -91,6 +91,8 @@ class Customer extends \Magento\App\Action\Action
     }
 
     /**
+     * Render review details
+     *
      * @return void
      */
     public function viewAction()
diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php
index a90661fa3e9db952b77e5b4a629ab0bde3b5bf99..918239e399ccf7585d265c211e8bdeb0fadfb302 100644
--- a/app/code/Magento/Review/Controller/Product.php
+++ b/app/code/Magento/Review/Controller/Product.php
@@ -23,20 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Controller;
+
+use Magento\App\RequestInterface;
+use Magento\Catalog\Model\Product as CatalogProduct;
+use Magento\Review\Model\Review;
 
 /**
  * Review controller
  *
- * @category   Magento
- * @package    Magento_Review
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Controller;
-
-use Magento\App\Action\NotFoundException;
-use Magento\App\RequestInterface;
-use Magento\Review\Model\Review;
-
 class Product extends \Magento\App\Action\Action
 {
     /**
@@ -47,56 +44,78 @@ class Product extends \Magento\App\Action\Action
     protected $_coreRegistry = null;
 
     /**
+     * Customer session model
+     *
      * @var \Magento\Customer\Model\Session
      */
     protected $_customerSession;
 
     /**
-     * @var \Magento\Review\Model\Session
+     * Generic session
+     *
+     * @var \Magento\Session\Generic
      */
     protected $_reviewSession;
 
     /**
+     * Catalog catgory model
+     *
      * @var \Magento\Catalog\Model\CategoryFactory
      */
     protected $_categoryFactory;
 
     /**
+     * Logger
+     *
      * @var \Magento\Logger
      */
     protected $_logger;
 
     /**
+     * Catalog product model
+     *
      * @var \Magento\Catalog\Model\ProductFactory
      */
     protected $_productFactory;
 
     /**
+     * Review model
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
 
     /**
+     * Rating model
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
 
     /**
+     * Core session model
+     *
      * @var \Magento\Core\Model\Session
      */
     protected $_session;
 
     /**
+     * Catalog design model
+     *
      * @var \Magento\Catalog\Model\Design
      */
     protected $_catalogDesign;
 
     /**
+     * Core model store manager interface
+     *
      * @var \Magento\Core\Model\StoreManagerInterface
      */
     protected $_storeManager;
 
     /**
+     * Core form key validator
+     *
      * @var \Magento\Core\App\Action\FormKeyValidator
      */
     protected $_formKeyValidator;
@@ -179,7 +198,7 @@ class Product extends \Magento\App\Action\Action
     /**
      * Initialize and check product
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return CatalogProduct
      */
     protected function _initProduct()
     {
@@ -216,7 +235,7 @@ class Product extends \Magento\App\Action\Action
      * Return false if product was not loaded or has incorrect status.
      *
      * @param int $productId
-     * @return bool|\Magento\Catalog\Model\Product
+     * @return bool|CatalogProduct
      */
     protected function _loadProduct($productId)
     {
@@ -227,7 +246,7 @@ class Product extends \Magento\App\Action\Action
         $product = $this->_productFactory->create()
             ->setStoreId($this->_storeManager->getStore()->getId())
             ->load($productId);
-        /* @var $product \Magento\Catalog\Model\Product */
+        /* @var $product CatalogProduct */
         if (!$product->getId() || !$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
             return false;
         }
@@ -401,6 +420,7 @@ class Product extends \Magento\App\Action\Action
     /**
      * Load specific layout handles by product type id
      *
+     * @param Product $product
      * @return void
      */
     protected function _initProductLayout($product)
diff --git a/app/code/Magento/Review/Helper/Action/Pager.php b/app/code/Magento/Review/Helper/Action/Pager.php
index 94321d412917b2b8bc46ab1004fe7e50f43c1f5f..5587e7a301ddbd598408057f187143f3ab34c80c 100644
--- a/app/code/Magento/Review/Helper/Action/Pager.php
+++ b/app/code/Magento/Review/Helper/Action/Pager.php
@@ -23,29 +23,36 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Helper\Action;
+
+use Magento\Core\Exception;
 
 /**
  * Action pager helper for iterating over search results
  *
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Helper\Action;
-
 class Pager extends \Magento\App\Helper\AbstractHelper
 {
     const STORAGE_PREFIX = 'search_result_ids';
 
     /**
+     * Storage id
+     *
      * @var int
      */
     protected $_storageId = null;
 
     /**
+     * Array of items
+     *
      * @var array
      */
     protected $_items = null;
 
     /**
+     * Backend session model
+     *
      * @var \Magento\Backend\Model\Session
      */
     protected $_backendSession;
@@ -65,7 +72,7 @@ class Pager extends \Magento\App\Helper\AbstractHelper
     /**
      * Set storage id
      *
-     * @param $storageId
+     * @param int $storageId
      * @return void
      */
     public function setStorageId($storageId)
@@ -132,6 +139,7 @@ class Pager extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
+     * Return item position based on passed in value
      *
      * @param mixed $value
      * @return int|bool
@@ -146,11 +154,12 @@ class Pager extends \Magento\App\Helper\AbstractHelper
      * Get storage key
      *
      * @return string
+     * @throws Exception
      */
     protected function _getStorageKey()
     {
         if (!$this->_storageId) {
-            throw new \Magento\Core\Exception(__('Storage key was not set'));
+            throw new Exception(__('Storage key was not set'));
         }
 
         return self::STORAGE_PREFIX . $this->_storageId;
diff --git a/app/code/Magento/Review/Helper/Data.php b/app/code/Magento/Review/Helper/Data.php
index d3345aac876bf9cecdf77be665287f2a96950e5c..a6bec2f19745e57c263ab244b958928d54abb7cd 100644
--- a/app/code/Magento/Review/Helper/Data.php
+++ b/app/code/Magento/Review/Helper/Data.php
@@ -48,6 +48,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     protected $_coreStoreConfig;
 
     /**
+     * Escaper
+     *
      * @var \Magento\Escaper
      */
     protected $_escaper;
@@ -71,6 +73,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
+     * Get review detail
+     *
      * @param string $origDetail
      * @return string
      */
@@ -80,7 +84,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
-     * getDetailHtml return short detail info in HTML
+     * Return short detail info in HTML
+     *
      * @param string $origDetail Full detail info
      * @return string
      */
@@ -90,6 +95,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
+     * Return an indicator of whether or not guest is allowed to write
+     *
      * @return bool
      */
     public function getIsGuestAllowToWrite()
diff --git a/app/code/Magento/Review/Model/Observer.php b/app/code/Magento/Review/Model/Observer.php
index 0fcc416bb37d913722b294e3e0686093c7e81406..71afd15a39f15a9604b61d3b903aca7845563f71 100644
--- a/app/code/Magento/Review/Model/Observer.php
+++ b/app/code/Magento/Review/Model/Observer.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Review\Model;
 
 /**
  * Review Observer Model
@@ -32,16 +32,18 @@
  * @package    Magento_Review
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Model;
-
 class Observer
 {
     /**
+     * Review model
+     *
      * @var \Magento\Review\Model\ReviewFactory
      */
     protected $_reviewFactory;
 
     /**
+     * Review resource model
+     *
      * @var \Magento\Review\Model\Resource\Review
      */
     protected $_resourceReview;
@@ -61,7 +63,7 @@ class Observer
      * Add review summary info for tagged product collection
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Review\Model\Observer
+     * @return $this
      */
     public function tagProductCollectionLoadAfter(\Magento\Event\Observer $observer)
     {
@@ -75,7 +77,7 @@ class Observer
      * Cleanup product reviews after product delete
      *
      * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Review\Model\Observer
+     * @return  $this
      */
     public function processProductAfterDeleteEvent(\Magento\Event\Observer $observer)
     {
@@ -91,7 +93,7 @@ class Observer
      * Append review summary before rendering html
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Review\Model\Observer
+     * @return $this
      */
     public function catalogBlockProductCollectionBeforeToHtml(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php
index a738d34a5134dd4189ac1f6a44034a2cbc79d294..db0f70b1ead35f9cd0d30aeff55abe08f8661ca7 100644
--- a/app/code/Magento/Review/Model/Resource/Review.php
+++ b/app/code/Magento/Review/Model/Resource/Review.php
@@ -86,21 +86,29 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb
     private $_deleteCache   = array();
 
     /**
+     * Core date model
+     *
      * @var \Magento\Core\Model\Date
      */
     protected $_date;
 
     /**
+     * Core model store manager interface
+     *
      * @var \Magento\Core\Model\StoreManagerInterface
      */
     protected $_storeManager;
 
     /**
+     * Rating model
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
 
     /**
+     * Rating resource model
+     *
      * @var \Magento\Rating\Model\Resource\Rating\Option
      */
     protected $_ratingOptions;
@@ -130,6 +138,7 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main table. Define other tables name
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -213,7 +222,6 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb
             $adapter->insert($this->_reviewDetailTable, $detail);
         }
 
-
         /**
          * save stores
          */
@@ -470,7 +478,7 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Better to call this method in transaction, because operation performed on two separated tables
      *
      * @param int $productId
-     * @return \Magento\Review\Model\Resource\Review
+     * @return $this
      */
     public function deleteReviewsByProductId($productId)
     {
diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php
index 0ccbe91e17361d042d5b2afab4f64aa42606d53f..06fb2fab8e7aa283f87762da9efad864f43b9849 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Collection.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php
@@ -23,17 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Review\Model\Resource\Review;
 
 
 /**
  * Review collection resource model
  *
- * @category    Magento
- * @package     Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Model\Resource\Review;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -85,11 +82,15 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     protected $_reviewData = null;
 
     /**
+     * Rating option model
+     *
      * @var \Magento\Rating\Model\Rating\Option\VoteFactory
      */
     protected $_voteFactory;
 
     /**
+     * Core model store manager interface
+     *
      * @var \Magento\Core\Model\StoreManagerInterface
      */
     protected $_storeManager;
@@ -126,6 +127,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Define module
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -138,7 +140,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     * init select
+     * Initialize select
      *
      * @return $this
      */
@@ -153,6 +155,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
+     * Add customer filter
+     *
      * @param int|string $customerId
      * @return $this
      */
diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php
index 0ddcd16cb2a72ad6d8f71fbd5a0ea775a4c464c0..f7211458a52ba1356b92b5a0f96a178082047958 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php
@@ -30,8 +30,6 @@ use \Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
 /**
  * Review Product Collection
  *
- * @category    Magento
- * @package     Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
 class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
@@ -65,11 +63,15 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     protected $_storesIds           = array();
 
     /**
+     * Rating model
+     *
      * @var \Magento\Rating\Model\RatingFactory
      */
     protected $_ratingFactory;
 
     /**
+     * Rating option vote model
+     *
      * @var \Magento\Rating\Model\Rating\Option\VoteFactory
      */
     protected $_voteFactory;
@@ -149,6 +151,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
 
     /**
      * Define module
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -159,7 +163,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     }
 
     /**
-     * init select
+     * Initialize select
      *
      * @return $this
      */
@@ -225,7 +229,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
     /**
      * Applies all store filters in one place to prevent multiple joins in select
      *
-     * @param null|Zend_Db_Select $select
+     * @param null|\Zend_Db_Select $select
      * @return $this
      */
     protected function _applyStoresFilterToSelect(\Zend_Db_Select $select = null)
diff --git a/app/code/Magento/Review/Model/Resource/Review/Status.php b/app/code/Magento/Review/Model/Resource/Review/Status.php
index c90410369a8911d142a6f86a5021063e163684e4..5bfe3da3854678d515771305c38add18d0710636 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Status.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Status.php
@@ -23,23 +23,20 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Review\Model\Resource\Review;
 
 /**
  * Review status resource model
  *
- * @category    Magento
- * @package     Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Model\Resource\Review;
-
 class Status extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
 
     /**
      * Resource status model initialization
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Review/Model/Resource/Review/Summary.php b/app/code/Magento/Review/Model/Resource/Review/Summary.php
index 97ddf61f1eaa9b9591c55ae4daf64f8316efc20c..407b6207b890a24d0734abccadb2df624c40c4a0 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Summary.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Summary.php
@@ -30,8 +30,6 @@ use Magento\Core\Model\AbstractModel;
 /**
  * Review summary resource model
  *
- * @category    Magento
- * @package     Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
 class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb
@@ -39,6 +37,7 @@ class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define module
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -61,10 +60,10 @@ class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb
     }
 
     /**
-     * Reaggregate all data by rating summary
+     * Re-aggregate all data by rating summary
      *
      * @param array $summary
-     * @return \Magento\Review\Model\Resource\Review\Summary
+     * @return $this
      */
     public function reAggregate($summary)
     {
diff --git a/app/code/Magento/Review/Model/Resource/Review/Summary/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Summary/Collection.php
index e6f5fa35cc01fe581d6a7efaddc84d460807c099..b15abc100c7eb996fd4364e1274e540755cda6b8 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Summary/Collection.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Summary/Collection.php
@@ -23,20 +23,18 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Review\Model\Resource\Review\Summary;
 
 /**
  * Review summery collection
  *
- * @category    Magento
- * @package     Magento_Review
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Review\Model\Resource\Review\Summary;
-
 class Collection extends \Magento\Data\Collection\Db
 {
     /**
+     * Summary table name
+     *
      * @var string
      */
     protected $_summaryTable;
@@ -68,7 +66,7 @@ class Collection extends \Magento\Data\Collection\Db
      *
      * @param int|string $entityId
      * @param int $entityType
-     * @return \Magento\Review\Model\Resource\Review\Summary\Collection
+     * @return $this
      */
     public function addEntityFilter($entityId, $entityType = 1)
     {
@@ -81,7 +79,7 @@ class Collection extends \Magento\Data\Collection\Db
      * Add store filter
      *
      * @param int $storeId
-     * @return \Magento\Review\Model\Resource\Review\Summary\Collection
+     * @return $this
      */
     public function addStoreFilter($storeId)
     {
diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php
index 2ce301b60d6cd26424ef46251223f0629fa8158f..1fe17a541aa682654ad17ca90a35eb20b0d6fb0a 100644
--- a/app/code/Magento/Review/Model/Review.php
+++ b/app/code/Magento/Review/Model/Review.php
@@ -57,7 +57,6 @@ class Review extends \Magento\Core\Model\AbstractModel
 
     /**
      * Review entity codes
-     *
      */
     const ENTITY_PRODUCT_CODE   = 'product';
     const ENTITY_CUSTOMER_CODE  = 'customer';
@@ -68,36 +67,50 @@ class Review extends \Magento\Core\Model\AbstractModel
     const STATUS_NOT_APPROVED   = 3;
 
     /**
+     * Review product collection factory
+     *
      * @var \Magento\Review\Model\Resource\Review\Product\CollectionFactory
      */
     protected $_productFactory;
 
     /**
+     * Review status collection factory
+     *
      * @var \Magento\Review\Model\Resource\Review\Status\CollectionFactory
      */
     protected $_statusFactory;
 
     /**
+     * Review model summary factory
+     *
      * @var \Magento\Review\Model\Review\SummaryFactory
      */
     protected $_summaryFactory;
 
     /**
+     * Review model summary factory
+     *
      * @var \Magento\Review\Model\Review\SummaryFactory
      */
     protected $_summaryModFactory;
 
     /**
+     * Review model summary
+     *
      * @var \Magento\Review\Model\Review\Summary
      */
     protected $_reviewSummary;
 
     /**
+     * Core model store manager interface
+     *
      * @var \Magento\Core\Model\StoreManagerInterface
      */
     protected $_storeManager;
 
     /**
+     * Url interface
+     *
      * @var \Magento\UrlInterface
      */
     protected $_urlModel;
@@ -140,12 +153,19 @@ class Review extends \Magento\Core\Model\AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * Initialization
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Review\Model\Resource\Review');
     }
 
     /**
+     * Get product collection
+     *
      * @return ProductCollection
      */
     public function getProductCollection()
@@ -154,6 +174,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get status collection
+     *
      * @return StatusCollection
      */
     public function getStatusCollection()
@@ -162,8 +184,10 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get total reviews
+     *
      * @param int $entityPkValue
-     * @param bool approvedOnly
+     * @param bool $approvedOnly
      * @param int $storeId
      * @return int
      */
@@ -173,6 +197,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Aggregate reviews
+     *
      * @return $this
      */
     public function aggregate()
@@ -182,6 +208,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get entity summary
+     *
      * @param Product $product
      * @param int $storeId
      * @return void
@@ -197,6 +225,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get pending status
+     *
      * @return int
      */
     public function getPendingStatus()
@@ -205,6 +235,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get review product view url
+     *
      * @return string
      */
     public function getReviewUrl()
@@ -213,6 +245,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Validate review summary fields
+     *
      * @return bool|string[]
      */
     public function validate()
@@ -282,6 +316,8 @@ class Review extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Validate user before delete
+     *
      * @return $this
      */
     protected function _beforeDelete()
diff --git a/app/code/Magento/Review/Model/Review/Summary.php b/app/code/Magento/Review/Model/Review/Summary.php
index 9ce693020bfa394ef9e7f5cf3f9a407486797016..ea8ad61347bc06f7cd827cd9371f9ab27b9d0e7b 100644
--- a/app/code/Magento/Review/Model/Review/Summary.php
+++ b/app/code/Magento/Review/Model/Review/Summary.php
@@ -48,6 +48,8 @@ class Summary extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get entity primary key value
+     *
      * @return int
      */
     public function getEntityPkValue()
@@ -56,6 +58,8 @@ class Summary extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get rating summary data
+     *
      * @return string
      */
     public function getRatingSummary()
@@ -64,6 +68,8 @@ class Summary extends \Magento\Core\Model\AbstractModel
     }
 
     /**
+     * Get count of reviews
+     *
      * @return int
      */
     public function getReviewsCount()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php b/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php
index 1d327903838853bcd977101efe1acac978455e11..574338520cf63dd9e2f78a1238561054a90d1a23 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Reorder/Renderer/Action.php
@@ -51,16 +51,16 @@ class Action
      */
     protected $_salesReorder = null;
 
-    /**
-     * @param \Magento\Backend\Block\Context $context
-     * @param \Magento\Sales\Helper\Reorder $salesReorder
-     * @param array $data
+    /**
+     * @param \Magento\Backend\Block\Context $context
+     * @param \Magento\Sales\Helper\Reorder $salesReorder
+     * @param array $data
      */
-    public function __construct(
-        \Magento\Backend\Block\Context $context,
-        \Magento\Sales\Helper\Reorder $salesReorder,
-        array $data = array()
-    ) {
+    public function __construct(
+        \Magento\Backend\Block\Context $context,
+        \Magento\Sales\Helper\Reorder $salesReorder,
+        array $data = array()
+    ) {
         $this->_salesReorder = $salesReorder;
         parent::__construct($context, $data);
     }
diff --git a/app/code/Magento/Sales/Controller/Download.php b/app/code/Magento/Sales/Controller/Download.php
index bd55866e0de2457443f74743012c226b6b12423f..f4d2789fe87305686b90432ecc1507891d4f834f 100644
--- a/app/code/Magento/Sales/Controller/Download.php
+++ b/app/code/Magento/Sales/Controller/Download.php
@@ -144,7 +144,7 @@ class Download extends \Magento\App\Action\Action
      */
     public function downloadProfileCustomOptionAction()
     {
-        $recurringProfile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile')
+        $recurringProfile = $this->_objectManager->create('Magento\RecurringProfile\Model\Profile')
             ->load($this->getRequest()->getParam('id'));
 
         if (!$recurringProfile->getId()) {
diff --git a/app/code/Magento/Sales/Model/Observer/Backend/RecurringProfile/FormRenderer.php b/app/code/Magento/Sales/Model/Observer/Backend/RecurringProfile/FormRenderer.php
deleted file mode 100644
index 1ae6da972cefa751c540c3a4e2d2c673e4792681..0000000000000000000000000000000000000000
--- a/app/code/Magento/Sales/Model/Observer/Backend/RecurringProfile/FormRenderer.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-namespace Magento\Sales\Model\Observer\Backend\RecurringProfile;
-
-class FormRenderer
-{
-    /**
-     * @var \Magento\View\Element\BlockFactory
-     */
-    protected $_blockFactory;
-
-    /**
-     * @param \Magento\View\Element\BlockFactory $blockFactory
-     */
-    public function __construct(\Magento\View\Element\BlockFactory $blockFactory)
-    {
-        $this->_blockFactory = $blockFactory;
-    }
-
-    /**
-     * Add the recurring profile form when editing a product
-     *
-     * @param \Magento\Event\Observer $observer
-     */
-    public function render($observer)
-    {
-        // replace the element of recurring payment profile field with a form
-        $profileElement = $observer->getEvent()->getProductElement();
-        $product = $observer->getEvent()->getProduct();
-
-        /** @var $formBlock \Magento\Sales\Block\Adminhtml\Recurring\Profile\Edit\Form */
-        $formBlock = $this->_blockFactory->createBlock('Magento\Sales\Block\Adminhtml\Recurring\Profile\Edit\Form');
-        $formBlock->setNameInLayout('adminhtml_recurring_profile_edit_form');
-        $formBlock->setParentElement($profileElement);
-        $formBlock->setProductEntity($product);
-        $output = $formBlock->toHtml();
-
-        // make the profile element dependent on is_recurring
-        /** @var $dependencies \Magento\Backend\Block\Widget\Form\Element\Dependence */
-        $dependencies = $this->_blockFactory->createBlock('Magento\Backend\Block\Widget\Form\Element\Dependence');
-        $dependencies->setNameInLayout('adminhtml_recurring_profile_edit_form_dependence');
-        $dependencies->addFieldMap('is_recurring', 'product[is_recurring]');
-        $dependencies->addFieldMap($profileElement->getHtmlId(), $profileElement->getName());
-        $dependencies->addFieldDependence($profileElement->getName(), 'product[is_recurring]', '1');
-        $dependencies->addConfigOptions(array('levels_up' => 2));
-
-        $output .= $dependencies->toHtml();
-
-        $observer->getEvent()->getResult()->output = $output;
-    }
-}
diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php
index bf2d901e42611ff68dc3f8512597d1a9bbc949ab..2f71b7ffd85a69d63b5bb474949a52acf2b888d4 100644
--- a/app/code/Magento/Sales/Model/Order.php
+++ b/app/code/Magento/Sales/Model/Order.php
@@ -187,8 +187,6 @@
  * @method \Magento\Sales\Model\Order setGiftMessageId(int $value)
  * @method int getPaymentAuthExpiration()
  * @method \Magento\Sales\Model\Order setPaymentAuthExpiration(int $value)
- * @method int getPaypalIpnCustomerNotified()
- * @method \Magento\Sales\Model\Order setPaypalIpnCustomerNotified(int $value)
  * @method int getQuoteAddressId()
  * @method \Magento\Sales\Model\Order setQuoteAddressId(int $value)
  * @method int getQuoteId()
diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php
index 8bbddead84e65c4a9862e63265ff8fbeda10967f..35685edb6518fd046a84a54d133c3b8b67f84482 100644
--- a/app/code/Magento/Sales/Model/Order/Payment.php
+++ b/app/code/Magento/Sales/Model/Order/Payment.php
@@ -154,13 +154,6 @@ class Payment extends \Magento\Payment\Model\Info
      */
     protected $_order;
 
-    /**
-     * Billing agreement instance that may be created during payment processing
-     *
-     * @var \Magento\Sales\Model\Billing\Agreement
-     */
-    protected $_billingAgreement = null;
-
     /**
      * Whether can void
      * @var string
@@ -199,11 +192,6 @@ class Payment extends \Magento\Payment\Model\Info
      */
     protected $_transactionCollectionFactory;
 
-    /**
-     * @var \Magento\Sales\Model\Billing\AgreementFactory
-     */
-    protected $_agreementFactory;
-
     /**
      * @var \Magento\Core\Model\StoreManagerInterface
      */
@@ -217,7 +205,6 @@ class Payment extends \Magento\Payment\Model\Info
      * @param \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory
      * @param \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory
      * @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory
-     * @param \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
@@ -231,7 +218,6 @@ class Payment extends \Magento\Payment\Model\Info
         \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory,
         \Magento\Sales\Model\Order\Payment\TransactionFactory $transactionFactory,
         \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $transactionCollectionFactory,
-        \Magento\Sales\Model\Billing\AgreementFactory $agreementFactory,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
@@ -240,7 +226,6 @@ class Payment extends \Magento\Payment\Model\Info
         $this->_serviceOrderFactory = $serviceOrderFactory;
         $this->_transactionFactory = $transactionFactory;
         $this->_transactionCollectionFactory = $transactionCollectionFactory;
-        $this->_agreementFactory = $agreementFactory;
         $this->_storeManager = $storeManager;
         parent::__construct($context, $registry, $paymentData, $encryptor, $resource, $resourceCollection, $data);
     }
@@ -374,8 +359,6 @@ class Payment extends \Magento\Payment\Model\Info
             }
         }
 
-        $this->_createBillingAgreement();
-
         $orderIsNotified = null;
         if ($stateObject->getState() && $stateObject->getStatus()) {
             $orderState      = $stateObject->getState();
@@ -1304,16 +1287,6 @@ class Payment extends \Magento\Payment\Model\Info
         return $this;
     }
 
-    /**
-     * Get the billing agreement, if any
-     *
-     * @return \Magento\Sales\Model\Billing\Agreement|null
-     */
-    public function getBillingAgreement()
-    {
-        return $this->_billingAgreement;
-    }
-
     /**
      * Totals updater utility method
      * Updates self totals by keys in data array('key' => $delta)
@@ -1550,27 +1523,6 @@ class Payment extends \Magento\Payment\Model\Info
         return $this;
     }
 
-    /**
-     * Generate billing agreement object if there is billing agreement data
-     * Adds it to order as related object
-     */
-    protected function _createBillingAgreement()
-    {
-        if ($this->getBillingAgreementData()) {
-            $order = $this->getOrder();
-            $agreement = $this->_agreementFactory->create()->importOrderPayment($this);
-            if ($agreement->isValid()) {
-                $message = __('Created billing agreement #%1.', $agreement->getReferenceId());
-                $order->addRelatedObject($agreement);
-                $this->_billingAgreement = $agreement;
-            } else {
-                $message = __('We couldn\'t create a billing agreement for this order.');
-            }
-            $comment = $order->addStatusHistoryComment($message);
-            $order->addRelatedObject($comment);
-        }
-    }
-
     /**
      * Additional transaction info setter
      *
diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php
index eb5e561234b089af2bfae82d7412beda47c4a729..d93d1bca627b66c0370ee73492e9b90b0c285d78 100644
--- a/app/code/Magento/Sales/Model/Quote.php
+++ b/app/code/Magento/Sales/Model/Quote.php
@@ -275,7 +275,7 @@ class Quote extends \Magento\Core\Model\AbstractModel
     protected $_quotePaymentCollectionFactory;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\ProfileFactory
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_recurringProfileFactory;
 
@@ -302,7 +302,7 @@ class Quote extends \Magento\Core\Model\AbstractModel
      * @param \Magento\Catalog\Model\ProductFactory $productFactory
      * @param \Magento\Sales\Model\Quote\PaymentFactory $quotePaymentFactory
      * @param \Magento\Sales\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory
-     * @param \Magento\Sales\Model\Recurring\ProfileFactory $recurringProfileFactory
+     * @param \Magento\RecurringProfile\Model\ProfileFactory $recurringProfileFactory
      * @param \Magento\Object\Copy $objectCopyService
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
@@ -326,7 +326,7 @@ class Quote extends \Magento\Core\Model\AbstractModel
         \Magento\Catalog\Model\ProductFactory $productFactory,
         \Magento\Sales\Model\Quote\PaymentFactory $quotePaymentFactory,
         \Magento\Sales\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory,
-        \Magento\Sales\Model\Recurring\ProfileFactory $recurringProfileFactory,
+        \Magento\RecurringProfile\Model\ProfileFactory $recurringProfileFactory,
         \Magento\Object\Copy $objectCopyService,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
diff --git a/app/code/Magento/Sales/Model/Quote/Payment.php b/app/code/Magento/Sales/Model/Quote/Payment.php
index 29f79bb2f29c840bfeb9db80a205554d20712e8f..e52182069252730bd106142027a5f24fa7904ff8 100644
--- a/app/code/Magento/Sales/Model/Quote/Payment.php
+++ b/app/code/Magento/Sales/Model/Quote/Payment.php
@@ -51,12 +51,6 @@
  * @method \Magento\Sales\Model\Quote\Payment setCcSsStartMonth(int $value)
  * @method int getCcSsStartYear()
  * @method \Magento\Sales\Model\Quote\Payment setCcSsStartYear(int $value)
- * @method string getPaypalCorrelationId()
- * @method \Magento\Sales\Model\Quote\Payment setPaypalCorrelationId(string $value)
- * @method string getPaypalPayerId()
- * @method \Magento\Sales\Model\Quote\Payment setPaypalPayerId(string $value)
- * @method string getPaypalPayerStatus()
- * @method \Magento\Sales\Model\Quote\Payment setPaypalPayerStatus(string $value)
  * @method string getPoNumber()
  * @method \Magento\Sales\Model\Quote\Payment setPoNumber(string $value)
  * @method string getAdditionalData()
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Collection.php b/app/code/Magento/Sales/Model/Resource/Order/Collection.php
index e15769f46baa7cd59016434942d96244ff1fb6b1..699d699cc84833ac5e8603ec1483366a5904daa8 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Collection.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Collection.php
@@ -230,24 +230,6 @@ class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollec
         return $this;
     }
 
-    /**
-     * Add filter by specified billing agreements
-     *
-     * @param int|array $agreements
-     * @return \Magento\Sales\Model\Resource\Order\Collection
-     */
-    public function addBillingAgreementsFilter($agreements)
-    {
-        $agreements = (is_array($agreements)) ? $agreements : array($agreements);
-        $this->getSelect()
-            ->joinInner(
-                array('sbao' => $this->getTable('sales_billing_agreement_order')),
-                'main_table.entity_id = sbao.order_id',
-                array())
-            ->where('sbao.agreement_id IN(?)', $agreements);
-        return $this;
-    }
-
     /**
      * Add filter by specified recurring profile id(s)
      *
@@ -259,7 +241,7 @@ class Collection extends \Magento\Sales\Model\Resource\Collection\AbstractCollec
         $ids = (is_array($ids)) ? $ids : array($ids);
         $this->getSelect()
             ->joinInner(
-                array('srpo' => $this->getTable('sales_recurring_profile_order')),
+                array('srpo' => $this->getTable('recurring_profile_order')),
                 'main_table.entity_id = srpo.order_id',
                 array())
             ->where('srpo.profile_id IN(?)', $ids);
diff --git a/app/code/Magento/Sales/Model/Service/Quote.php b/app/code/Magento/Sales/Model/Service/Quote.php
index ea3ed433c6360edd03da5c53172abfd59317aac0..9f71b42a1728bacf97ffd5ac18abd5073e35e304 100644
--- a/app/code/Magento/Sales/Model/Service/Quote.php
+++ b/app/code/Magento/Sales/Model/Service/Quote.php
@@ -365,7 +365,7 @@ class Quote
         $profiles = $this->_quote->prepareRecurringPaymentProfiles();
         foreach ($profiles as $profile) {
             if (!$profile->isValid()) {
-                throw new \Magento\Core\Exception($profile->getValidationErrors(true, true));
+                throw new \Magento\Core\Exception($profile->getValidationErrors());
             }
             $profile->submit();
         }
diff --git a/app/code/Magento/Sales/etc/adminhtml/acl.xml b/app/code/Magento/Sales/etc/adminhtml/acl.xml
index 0687d6c6ccbc1afc7292718df3a0432b81c5c03f..b51c3f575f9945ddab3eaab2ba4c217ce8cfd342 100644
--- a/app/code/Magento/Sales/etc/adminhtml/acl.xml
+++ b/app/code/Magento/Sales/etc/adminhtml/acl.xml
@@ -53,17 +53,9 @@
                         <resource id="Magento_Sales::sales_invoice"   title="Invoices" sortOrder="20" />
                         <resource id="Magento_Sales::shipment"   title="Shipments" sortOrder="30" />
                         <resource id="Magento_Sales::sales_creditmemo"  title="Credit Memos" sortOrder="40" />
-                        <resource id="Magento_Sales::billing_agreement"  title="Billing Agreements" sortOrder="60">
-                            <resource id="Magento_Sales::billing_agreement_actions" title="Actions" sortOrder="10">
-                                <resource id="Magento_Sales::billing_agreement_actions_view" title="View" sortOrder="5" />
-                                <resource id="Magento_Sales::actions_manage" title="Manage" sortOrder="10" />
-                                <resource id="Magento_Sales::use" title="Place Order Using Billing Agreements" sortOrder="15" />
-                            </resource>
-                        </resource>
                         <resource id="Magento_Sales::transactions"   title="Transactions" sortOrder="70">
                             <resource id="Magento_Sales::transactions_fetch" title="Fetch" sortOrder="10" />
                         </resource>
-                        <resource id="Magento_Sales::recurring_profile"   title="Recurring Profiles" sortOrder="80" />
                     </resource>
                 </resource>
                 <resource id="Magento_Adminhtml::stores">
diff --git a/app/code/Magento/Sales/etc/adminhtml/events.xml b/app/code/Magento/Sales/etc/adminhtml/events.xml
index 2d836681f75344390adad4ef3cf7108ea7ee59d0..7b8070b6dff32068bd5821a306bb78ef9bc45f1c 100644
--- a/app/code/Magento/Sales/etc/adminhtml/events.xml
+++ b/app/code/Magento/Sales/etc/adminhtml/events.xml
@@ -39,12 +39,6 @@
     <event name="catalog_product_status_update">
         <observer name="sales_quote" instance="Magento\Sales\Model\Observer\Backend\CatalogProductQuote" method="catalogProductStatusUpdate" />
     </event>
-    <event name="catalog_product_edit_form_render_recurring">
-        <observer name="payment" instance="Magento\Sales\Model\Observer\Backend\RecurringProfile\FormRenderer" method="render" />
-    </event>
-    <event name="payment_method_is_active">
-        <observer name="sales_billing_agreement" instance="Magento\Sales\Model\Observer\Backend\BillingAgreement" method="dispatch" />
-    </event>
     <event name="customer_save_after">
         <observer name="customer" instance="Magento\Sales\Model\Observer\Backend\CustomerQuote" method="dispatch" />
     </event>
diff --git a/app/code/Magento/Sales/etc/adminhtml/menu.xml b/app/code/Magento/Sales/etc/adminhtml/menu.xml
index 877dbb1088874b8aea08d960561c700f4a31862b..61c9f96391e1f876c429da9b8a667cd87f46254f 100644
--- a/app/code/Magento/Sales/etc/adminhtml/menu.xml
+++ b/app/code/Magento/Sales/etc/adminhtml/menu.xml
@@ -34,8 +34,6 @@
         <add id="Magento_Sales::sales_shipment" title="Shipments" module="Magento_Sales" sortOrder="30" parent="Magento_Sales::sales_operation" action="sales/shipment" resource="Magento_Sales::shipment"/>
         <add id="Magento_Sales::sales_creditmemo" title="Credit Memos" module="Magento_Sales" sortOrder="40" parent="Magento_Sales::sales_operation" action="sales/creditmemo" resource="Magento_Sales::sales_creditmemo"/>
         <add id="Magento_Sales::sales_transactions" title="Transactions" module="Magento_Sales" sortOrder="70" parent="Magento_Sales::sales_operation" action="sales/transactions" resource="Magento_Sales::transactions"/>
-        <add id="Magento_Sales::sales_recurring_profile" title="Recurring Billing" module="Magento_Sales" sortOrder="80" parent="Magento_Sales::sales_operation" action="sales/recurring_profile" resource="Magento_Sales::recurring_profile"/>
-        <add id="Magento_Sales::sales_billing_agreement" title="Billing Agreements" module="Magento_Sales" sortOrder="60" parent="Magento_Sales::sales_operation" action="sales/billing_agreement" resource="Magento_Sales::billing_agreement"/>
         <add id="Magento_Sales::system_order_statuses" title="Order Status" module="Magento_Sales" sortOrder="40" parent="Magento_Backend::stores_settings" action="sales/order_status" resource="Magento_Sales::order_statuses"/>
     </menu>
 </config>
diff --git a/app/code/Magento/Sales/etc/catalog_attributes.xml b/app/code/Magento/Sales/etc/catalog_attributes.xml
index 883b9b73f8bbda8963aebfc20fa1d5805781619e..50b011543b8638a5e95bc9ae5ee7718163fddd7f 100644
--- a/app/code/Magento/Sales/etc/catalog_attributes.xml
+++ b/app/code/Magento/Sales/etc/catalog_attributes.xml
@@ -41,8 +41,6 @@
         <attribute name="special_to_date"/>
         <attribute name="special_price"/>
         <attribute name="cost"/>
-        <attribute name="is_recurring"/>
-        <attribute name="recurring_profile"/>
         <attribute name="gift_message_available"/>
         <attribute name="msrp_enabled"/>
         <attribute name="msrp"/>
diff --git a/app/code/Magento/Sales/etc/crontab.xml b/app/code/Magento/Sales/etc/crontab.xml
index 167c6178e524573bcc28444123d636fafe5d0318..597ef3fcb1c24cb30c068d628f36a0a955982216 100644
--- a/app/code/Magento/Sales/etc/crontab.xml
+++ b/app/code/Magento/Sales/etc/crontab.xml
@@ -24,22 +24,24 @@
  */
 -->
 <config>
-    <job name="sales_clean_quotes" instance="Magento\Sales\Model\Observer" method="cleanExpiredQuotes">
-        <schedule>0 0 * * *</schedule>
-    </job>
-    <job name="aggregate_sales_report_order_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportOrderData">
-        <schedule>0 0 * * *</schedule>
-    </job>
-    <job name="aggregate_sales_report_shipment_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportShipmentData">
-        <schedule>0 0 * * *</schedule>
-    </job>
-    <job name="aggregate_sales_report_invoiced_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportInvoicedData">
-        <schedule>0 0 * * *</schedule>
-    </job>
-    <job name="aggregate_sales_report_refunded_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportRefundedData">
-        <schedule>0 0 * * *</schedule>
-    </job>
-    <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportBestsellersData">
-        <schedule>0 0 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="sales_clean_quotes" instance="Magento\Sales\Model\Observer" method="cleanExpiredQuotes">
+            <schedule>0 0 * * *</schedule>
+        </job>
+        <job name="aggregate_sales_report_order_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportOrderData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+        <job name="aggregate_sales_report_shipment_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportShipmentData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+        <job name="aggregate_sales_report_invoiced_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportInvoicedData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+        <job name="aggregate_sales_report_refunded_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportRefundedData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+        <job name="aggregate_sales_report_bestsellers_data" instance="Magento\Sales\Model\Observer" method="aggregateSalesReportBestsellersData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Sales/etc/fieldset.xml b/app/code/Magento/Sales/etc/fieldset.xml
index ad429d6df6bd2440dc396538599716eeb4ccaad0..878e5c67a2c3be22d875713ed03c56bd8e4a7b6e 100644
--- a/app/code/Magento/Sales/etc/fieldset.xml
+++ b/app/code/Magento/Sales/etc/fieldset.xml
@@ -499,9 +499,6 @@
             <field name="base_hidden_tax_amount">
                 <aspect name="to_order_item" />
             </field>
-            <field name="is_recurring">
-                <aspect name="to_order_item" />
-            </field>
             <field name="is_nominal">
                 <aspect name="to_order_item" />
             </field>
diff --git a/app/code/Magento/Sales/etc/frontend/page_types.xml b/app/code/Magento/Sales/etc/frontend/page_types.xml
index 6e67d62ebe6c74be7ff33823a38dc70e9bad8514..a67bb6fdeda7ac92812a191fbd6768a0c8d593be 100644
--- a/app/code/Magento/Sales/etc/frontend/page_types.xml
+++ b/app/code/Magento/Sales/etc/frontend/page_types.xml
@@ -24,8 +24,6 @@
  */
 -->
 <page_types>
-    <type id="sales_billing_agreement_index" label="Billing Agreement"/>
-    <type id="sales_billing_agreement_view" label="Billing Agreement View"/>
     <type id="sales_guest_creditmemo" label="Guest Order Creditmemo View"/>
     <type id="sales_guest_form" label="Returns"/>
     <type id="sales_guest_invoice" label="Guest Order Invoice View"/>
@@ -46,6 +44,6 @@
     <type id="sales_order_reorder" label="Sales Reorder"/>
     <type id="sales_order_shipment" label="Customer My Account Order Shipment View"/>
     <type id="sales_order_view" label="Customer My Account Order View"/>
-    <type id="sales_recurring_profile_index" label="Recurring Profile"/>
-    <type id="sales_recurring_profile_view" label="Recurring Profile View"/>
+    <type id="sales_recurringprofile_index" label="Recurring Profile"/>
+    <type id="sales_recurringprofile_view" label="Recurring Profile View"/>
 </page_types>
diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml
index 6f7a570a72044c662e9a2e6ec9b702529c192bb5..b1b4d2dfdc809889b1d789a772c53dad4d1bc638 100755
--- a/app/code/Magento/Sales/etc/module.xml
+++ b/app/code/Magento/Sales/etc/module.xml
@@ -51,6 +51,7 @@
             <module name="Magento_CatalogInventory"/>
             <module name="Magento_Wishlist"/>
             <module name="Magento_Email"/>
+            <module name="Magento_RecurringProfile"/>
         </depends>
     </module>
 </config>
diff --git a/app/code/Magento/Sales/i18n/de_DE.csv b/app/code/Magento/Sales/i18n/de_DE.csv
index f1aee67e8f71be3f35a2f5ae456270e86aa81557..aea52cff7a9603ea8d998bb667db06182f38a6bd 100644
--- a/app/code/Magento/Sales/i18n/de_DE.csv
+++ b/app/code/Magento/Sales/i18n/de_DE.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - Geben Sie benutzerdefinierten Preis ohne Steuer ein"
 "* - Enter custom price including tax","* - Geben Sie benutzerdefinierten Preis inklusive Steuer ein"
 "-- Please Select --","-- Bitte auswählen --"
-"-- Please Select Billing Agreement--","-- Bitte wählen Sie Rechnungsvereinbarung --"
 "About This Order:","Über diese Bestellung:"
 "About This Profile:","Über dieses Profil:"
 "About Your Invoice","Informationen zu Ihrer Rechnung"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","Bewilligte Summe von %s."
 "Authorizing amount of %s is pending approval on gateway.","Bewilligungssumme von %s wartet auf Zustimmung am Gateway."
 "Back","Zurück"
-"Back to Billing Agreements","Zurück zu Rechnungsvereinbarungen"
 "Back to My Orders","Zurück zu Meine Bestellungen"
 "Back to Recurring Profiles","Zurück zu Wiederkehrende Profile"
 "Backordered","Rückständig"
@@ -88,11 +86,6 @@
 "Bill-to Name","Rechnung auf Namen"
 "Billing","Abrechnung"
 "Billing Address","Rechnungsadresse"
-"Billing Agreement","Rechnungsvereinbarung"
-"Billing Agreement # %s","Rechnungsvereinbarung # %s"
-"Billing Agreement #%s","Rechnungsvereinbarung #%s"
-"Billing Agreement View","Rechnungsvereinbarung Ansicht"
-"Billing Agreements","Rechnungsvereinbarungen"
 "Billing Last Name","Nachname in der Rechnung"
 "Billing ZIP Code","PLZ in der Rechnung"
 "Buy %s for price %s","Kaufen Sie %s zum Preis von %s"
@@ -164,7 +157,6 @@
 "Create new shipment for order","Neue Lieferung für Bestellung fertig machen"
 "Create...","...erstellen"
 "Created","Erstellte At"
-"Created billing agreement #%s.","Rechnungsvereinbahrung #%s erstellt."
 "Created:","Erstellt:"
 "Credit Memo","Gutschrift"
 "Credit Memo #","Gutschrift #"
@@ -186,19 +178,15 @@
 "Custom Value","Kundenmehrwert"
 "Customer","Kunde"
 "Customer Can Define Start Date","Kunden können den Starttermin bestimmen"
-"Email","Kunden Email"
 "Customer Group","Kundengruppe"
-"Last Name","Nachname des Kunden"
 "Customer My Account Order Creditmemo View","Kundenbestellung My Account Ansicht der Gutschrift"
 "Customer My Account Order History","Kundenbestellung My Account Historie"
 "Customer My Account Order Invoice View","Kundenbestellung My Account Ansicht der Rechnung"
 "Customer My Account Order Shipment View","Kundenbestellung My Account Ansicht der Lieferung"
 "Customer My Account Order View","Kundenbestellung My Account Ansicht"
-"First Name","Kundenname"
 "Customer\'s Current Activities","Aktuelle Aktionen des Kunden"
 "Customs Value","Zollwert"
 "Date","Datum"
-"Ship Date","Versanddatum"
 "Default Status","Standardstatus"
 "Default Template","Standardvorlage"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png)","Vorgegebenes Logo, wird in PDF- und HTML-Dokumenten verwendet.<br />(jpeg, tiff, png)"
@@ -215,7 +203,7 @@
 "Edit Order #%s","Bestellung #%s bearbeiten"
 "Edit Order %s %s Address","Bestelladresse %s %s bearbeiten"
 "Edit Order Status","Auftragsstatus bearbeiten"
-"Email","E-Mail"
+"Email","Kunden Email"
 "Email Address","E-Mail-Adresse"
 "Email Copy of Credit Memo","E-Mail-Kopie der Gutschrift"
 "Email Copy of Invoice","Rechnungskopie per E-Mail senden"
@@ -230,23 +218,17 @@
 "Excl. Tax","ohne Steuern"
 "Expired","Abgelaufen"
 "Explanation","Erklärung"
-"Failed to cancel the billing agreement.","Aufhebung von Billing Agreement fehlgeschlagen."
-"Failed to create billing agreement for this order.","Erstellen von Billing Agreement für diese Bestellung fehlgeschlagen."
-"Failed to finish billing agreement wizard.","Abschließen von Billing Agreement Assistent fehlgeschlagen."
 "Failed to send the order email.","Senden der Auftrags-E-Mail fehlgeschlagen."
-"Failed to start billing agreement wizard.","Start von Billing Agreement Assistent fehlgeschlagen."
 "Failed to update the payment.","Aktualisieren der Bezahlung fehlgeschlagen."
 "Failed to update the profile.","Aktualisierung des Profils fehlgeschlagen."
 "Failed to void the payment.","Aufheben der Bezahlung fehlgeschlagen."
 "Fetch","Holen"
 "File extension not known or unsupported type in the following shipment: %s","Dateierweiterung ist unbekannt oder wird nicht unterstützt bei der folgenden Lieferung: %s"
 "Find Order By:","Bestellungen finden durch:"
-"First Name","Vorname"
+"First Name","Kundenname"
 "From","Von"
 "From Name","Von Name"
 "From:","Von:"
-"Grand Total (Base)","G.B. (Basis)"
-"Grand Total (Purchased)","G.T. (gekauft)"
 "General","Allgemein"
 "General Information","Allgemeine Informationen"
 "Get Payment Update","Zahlungsaktualisierung abrufen"
@@ -260,6 +242,8 @@
 "Gift Wrapping for the Entire Order","Geschenkverpackung für gesamte Bestellung"
 "Girth","Umfang"
 "Grand Total","Gesamtbetrag"
+"Grand Total (Base)","G.B. (Basis)"
+"Grand Total (Purchased)","G.T. (gekauft)"
 "Grand Total to be Charged","Gesamtsumme die belastet werden soll"
 "Guest","Gast"
 "Height","Höhe"
@@ -267,8 +251,8 @@
 "Hold","Warten"
 "Hold action is not available.","Zurückstellen nicht verfügbar."
 "Hold order","Bestellung zurückstellen"
-"ID","ID"
 "ID","ID Nr."
+"ID","ID"
 "IPN ""Refunded"". Refund issued by merchant. Registered notification about refunded amount of %s. Transaction ID: ""%s""","IPN ""Zurückerstattet"". Rückerstattung durch Händler erfolgt. Erhaltene Benachrichtigung über zurückerstatteten Betrag von %s. Transaktionsidentifikation: ""%s"""
 "If empty, the default description above will be used.","Wenn leer wird die Standardbeschreibung oben verwendet."
 "If empty, the default error above will be used.","Wenn leer, wird der obenstehende Standardfehler benutzt."
@@ -314,7 +298,6 @@
 "Invoice will be created without communication with payment gateway.","Rechnung wird ohne Verbindung zur Zahlungsschnittstelle erstellt."
 "Invoiced","In Rechnung gestellt."
 "Invoices","Rechnungen"
-"Closed","Geschlossen"
 "Item","Objekt"
 "Item Status","Artikelstatus"
 "Item object is not specified.","Objekt des Artikels nicht näher beschrieben."
@@ -332,7 +315,7 @@
 "Items to Refund","Artikel zur Rückvergütung"
 "Items to Ship","Zu versendende Artikel"
 "Key","Schlüssel"
-"Last Name","Letzter Name"
+"Last Name","Nachname des Kunden"
 "Last Ordered Items","Zuletzte bestellte Artikel"
 "Last status can\'t be unassigned from state.","Letzter Status kann vom Zustand nicht entfernt werden."
 "Length","Länge"
@@ -361,7 +344,6 @@
 "N/A","Nicht verfügbar"
 "Name","Name"
 "New","Neu"
-"New Billing Agreement","Neue Abrechnungsvereinbarung"
 "New Credit Memo","Neue Gutschrift"
 "New Credit Memo for Guest","Neue Gutschrift für Gast"
 "New Credit Memo for Invoice #%s","Neue Gutschrift für Rechnung #%s"
@@ -413,8 +395,8 @@
 "Order","Bestellung"
 "Order","Bestell-Nr."
 "Order %s","Bestellung # %s"
-"Order %s %s | %s","Bestellung # %s %s | %s"
 "Order %s","Bestellung #%s"
+"Order %s %s | %s","Bestellung # %s %s | %s"
 "Order %s - %s","Bestellung #%s - %s"
 "Order API","Auftrags-API"
 "Order Address Information","Lieferadressen-Information"
@@ -495,7 +477,6 @@
 "Pending","Ausstehend"
 "Pending Payment","Ausstehende Bezahlung"
 "Period","Zeitraum"
-"Place Order Using Billing Agreements","Auftrag mithilfe von Rechnungsvereinbahrungen erteilen"
 "Placed from IP","Bestellt von IP Nummer"
 "Please Select Products to Add","Bitte wählen Sie hinzuzufügende Produkte"
 "Please Select a Customer","Bitte wählen sie einen Kunden"
@@ -537,10 +518,10 @@
 "Promotion Coupons Usage Report","Bericht über die Verwendung von Werbungsgutscheinen"
 "Proper payment object must be set.","Es muss ein geeignetes Bezahlungsobjekt eingestellt werden."
 "Purchase Order Number:","Bestellungsnummer:"
-"Purchased From","Gekauft von"
 "Purchase Point","Erworben von (Geschäft)"
-"Purchased Item","Erworbener Artikel"
 "Purchased Date","Gekauft am"
+"Purchased From","Gekauft von"
+"Purchased Item","Erworbener Artikel"
 "Qty","Anzahl"
 "Qty Invoiced","In Rechnung gestellte Menge"
 "Qty Ordered","Bestellte Menge"
@@ -656,10 +637,11 @@
 "Send Tracking Information","Rückverfolgungsinformation schicken"
 "Set order for existing transactions not allowed","Die Reihenfolge für existierende Transaktionen festzulegen ist nicht gestattet"
 "Ship","Versenden"
+"Ship Date","Versanddatum"
 "Ship To","Lieferung an"
 "Ship-to Name","Lieferung auf Namen"
-"Shipment","Lieferung"
 "Shipment","Lieferung #"
+"Shipment","Lieferung"
 "Shipment %1$s | %3$s (%2$s)","Lieferung #%1$s | %3$s (%2$s)"
 "Shipment %s","Lieferung #%s"
 "Shipment Comment Email Sender","Lieferungskommentaremail-Absender"
@@ -724,8 +706,6 @@
 "Telephone","Telefon"
 "The Order State ""%s"" must not be set manually.","Der Auftragsstatus ""%s"" darf nicht manuell festgelegt werden."
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","Das adresse total model sollte von \Magento\Sales\Model\Quote\Address\Total\AbstractTotal erweitert werden."
-"The billing agreement ""%s"" has been canceled.","Die Rechnungsvereinbarung ""%s"" wurde annuliert."
-"The billing agreement ""%s"" has been created.","Die Rechnungsvereinbarung ""%s"" wurde erstellt."
 "The coupon code has been accepted.","Der Gutscheincode ist akzeptiert worden."
 "The message has been sent.","Die Nachricht ist gesendet."
 "The message was sent.","Die Nachricht ist gesendet worden."
@@ -755,7 +735,6 @@
 "The transaction ""%s"" (%s) is already closed.","Die Transaktion ""%s"" (%s) ist bereits abgeschlossen."
 "The transaction ""%s"" cannot be captured yet.","Die Transaktion ""%s"" kann noch nicht erfasst werden."
 "The value that you entered is not valid.","Der von Ihnen eingegebene Wert ist ungültig."
-"There are no billing agreements yet.","Es gibt noch keine Rechnungsvereinbahrungen."
 "There are no printable documents related to selected orders.","Es gibt keine ausdruckbaren Dokumente verbunden mit den gewählten Bestellungen."
 "There are no shipping labels related to selected %s.","Keine Versandetiketten beziehen sich auf das ausgewählte %s ."
 "There is no need to approve this payment.","Diese Zahlung muss nicht bestätigt werden."
@@ -844,7 +823,6 @@
 "Whether buyer can define the date when billing for the profile begins.","Ob Käufer das Datum festlegen kann, wann Abrechnung des Profils beginnt."
 "Width","Breite"
 "Wishlist","Wunschzettel"
-"Wrong billing agreement ID specified.","Falsche Zahlungsvereinbarungs-ID angegeben."
 "Wrong quote item id to update configuration.","Falsche Angebotskennnummer zur Aktualisierung der Konfiguration."
 "Wrong state: ""%s"".","Falscher Zustand: ""%s""."
 "Yes","Ja"
diff --git a/app/code/Magento/Sales/i18n/en_US.csv b/app/code/Magento/Sales/i18n/en_US.csv
index 23c0dbb6acd708471f27427724a130ee60c3d665..8a2e9ffcc2eca739e28220f307486f9765b810f2 100644
--- a/app/code/Magento/Sales/i18n/en_US.csv
+++ b/app/code/Magento/Sales/i18n/en_US.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - Enter custom price excluding tax"
 "* - Enter custom price including tax","* - Enter custom price including tax"
 "-- Please Select --","-- Please Select --"
-"-- Please Select Billing Agreement--","-- Please Select Billing Agreement--"
 "About This Order:","About This Order:"
 "About This Profile:","About This Profile:"
 "About Your Invoice","About Your Invoice"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","Authorized amount of %s."
 "Authorizing amount of %s is pending approval on gateway.","Authorizing amount of %s is pending approval on gateway."
 "Back","Back"
-"Back to Billing Agreements","Back to Billing Agreements"
 "Back to My Orders","Back to My Orders"
 "Back to Recurring Profiles","Back to Recurring Profiles"
 "Backordered","Backordered"
@@ -88,11 +86,6 @@
 "Bill-to Name","Bill-to Name"
 "Billing","Billing"
 "Billing Address","Billing Address"
-"Billing Agreement","Billing Agreement"
-"Billing Agreement # %s","Billing Agreement # %s"
-"Billing Agreement #%s","Billing Agreement #%s"
-"Billing Agreement View","Billing Agreement View"
-"Billing Agreements","Billing Agreements"
 "Billing Last Name","Billing Last Name"
 "Billing ZIP Code","Billing ZIP Code"
 "Buy %s for price %s","Buy %s for price %s"
@@ -164,7 +157,6 @@
 "Create new shipment for order","Create new shipment for order"
 "Create...","Create..."
 "Created","Created"
-"Created billing agreement #%s.","Created billing agreement #%s."
 "Created:","Created:"
 "Credit Memo","Credit Memo"
 "Credit Memo #","Credit Memo #"
@@ -187,19 +179,15 @@
 "Custom Value","Custom Value"
 "Customer","Customer"
 "Customer Can Define Start Date","Customer Can Define Start Date"
-"Email","Email"
 "Customer Group","Customer Group"
-"Last Name","Last Name"
 "Customer My Account Order Creditmemo View","Customer My Account Order Creditmemo View"
 "Customer My Account Order History","Customer My Account Order History"
 "Customer My Account Order Invoice View","Customer My Account Order Invoice View"
 "Customer My Account Order Shipment View","Customer My Account Order Shipment View"
 "Customer My Account Order View","Customer My Account Order View"
-"First Name","First Name"
 "Customer\'s Current Activities","Customer\'s Current Activities"
 "Customs Value","Customs Value"
 "Date","Date"
-"Ship Date","Ship Date"
 "Default Status","Default Status"
 "Default Template","Default Template"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png) If you see image distortion in PDF, try to use larger image","Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png) If you see image distortion in PDF, try to use larger image"
@@ -231,11 +219,7 @@
 "Excl. Tax","Excl. Tax"
 "Expired","Expired"
 "Explanation","Explanation"
-"Failed to cancel the billing agreement.","Failed to cancel the billing agreement."
-"Failed to create billing agreement for this order.","Failed to create billing agreement for this order."
-"Failed to finish billing agreement wizard.","Failed to finish billing agreement wizard."
 "Failed to send the order email.","Failed to send the order email."
-"Failed to start billing agreement wizard.","Failed to start billing agreement wizard."
 "Failed to update the payment.","Failed to update the payment."
 "Failed to update the profile.","Failed to update the profile."
 "Failed to void the payment.","Failed to void the payment."
@@ -246,8 +230,6 @@
 "From","From"
 "From Name","From Name"
 "From:","From:"
-"Grand Total (Base)","Grand Total (Base)"
-"Grand Total (Purchased)","Grand Total (Purchased)"
 "General","General"
 "General Information","General Information"
 "Get Payment Update","Get Payment Update"
@@ -261,6 +243,8 @@
 "Gift Wrapping for the Entire Order","Gift Wrapping for the Entire Order"
 "Girth","Girth"
 "Grand Total","Grand Total"
+"Grand Total (Base)","Grand Total (Base)"
+"Grand Total (Purchased)","Grand Total (Purchased)"
 "Grand Total to be Charged","Grand Total to be Charged"
 "Guest","Guest"
 "Height","Height"
@@ -316,7 +300,6 @@
 "Invoice will be created without communication with payment gateway.","Invoice will be created without communication with payment gateway."
 "Invoiced","Invoiced"
 "Invoices","Invoices"
-"Closed","Closed"
 "Item","Item"
 "Item Status","Item Status"
 "Item object is not specified.","Item object is not specified."
@@ -363,7 +346,6 @@
 "N/A","N/A"
 "Name","Name"
 "New","New"
-"New Billing Agreement","New Billing Agreement"
 "New Credit Memo","New Credit Memo"
 "New Credit Memo for Guest","New Credit Memo for Guest"
 "New Credit Memo for Invoice #%s","New Credit Memo for Invoice #%s"
@@ -416,8 +398,8 @@
 "Order","Order"
 "Order ","Order "
 "Order %s","Order %s"
-"Order %s %s | %s","Order %s %s | %s"
 "Order %s","Order %s"
+"Order %s %s | %s","Order %s %s | %s"
 "Order %s - %s","Order %s - %s"
 "Order API","Order API"
 "Order Address Information","Order Address Information"
@@ -498,7 +480,6 @@
 "Pending","Pending"
 "Pending Payment","Pending Payment"
 "Period","Period"
-"Place Order Using Billing Agreements","Place Order Using Billing Agreements"
 "Placed from IP","Placed from IP"
 "Please Select Products to Add","Please Select Products to Add"
 "Please Select a Customer","Please Select a Customer"
@@ -540,10 +521,10 @@
 "Promotion Coupons Usage Report","Promotion Coupons Usage Report"
 "Proper payment object must be set.","Proper payment object must be set."
 "Purchase Order Number:","Purchase Order Number:"
-"Purchased From","Purchased From"
 "Purchase Point","Purchase Point"
-"Purchased Item","Purchased Item"
 "Purchased Date","Purchased Date"
+"Purchased From","Purchased From"
+"Purchased Item","Purchased Item"
 "Qty","Qty"
 "Qty Invoiced","Qty Invoiced"
 "Qty Ordered","Qty Ordered"
@@ -657,13 +638,12 @@
 "Send Tracking Information","Send Tracking Information"
 "Set order for existing transactions not allowed","Set order for existing transactions not allowed"
 "Ship","Ship"
+"Ship Date","Ship Date"
 "Ship To","Ship To"
-"Ship-to Name","Ship-to Name"
 "Ship to:","Ship to:"
+"Ship-to Name","Ship-to Name"
 "Shipment","Shipment"
 "Shipment","Shipment"
-"Shipment%1$s | %3$s (%2$s)","Shipment%1$s | %3$s (%2$s)"
-"Shipment%s","Shipment%s"
 "Shipment Comment Email Sender","Shipment Comment Email Sender"
 "Shipment Comment Email Template","Shipment Comment Email Template"
 "Shipment Comment Email Template for Guest","Shipment Comment Email Template for Guest"
@@ -673,6 +653,8 @@
 "Shipment Email Template for Guest","Shipment Email Template for Guest"
 "Shipment Update","Shipment Update"
 "Shipment Update for Guest","Shipment Update for Guest"
+"Shipment%1$s | %3$s (%2$s)","Shipment%1$s | %3$s (%2$s)"
+"Shipment%s","Shipment%s"
 "Shipments","Shipments"
 "Shipped","Shipped"
 "Shipped By","Shipped By"
@@ -727,8 +709,6 @@
 "Telephone","Telephone"
 "The Order State ""%s"" must not be set manually.","The Order State ""%s"" must not be set manually."
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal."
-"The billing agreement ""%s"" has been canceled.","The billing agreement ""%s"" has been canceled."
-"The billing agreement ""%s"" has been created.","The billing agreement ""%s"" has been created."
 "The coupon code has been accepted.","The coupon code has been accepted."
 "The message has been sent.","The message has been sent."
 "The message was sent.","The message was sent."
@@ -758,7 +738,6 @@
 "The transaction ""%s"" (%s) is already closed.","The transaction ""%s"" (%s) is already closed."
 "The transaction ""%s"" cannot be captured yet.","The transaction ""%s"" cannot be captured yet."
 "The value that you entered is not valid.","The value that you entered is not valid."
-"There are no billing agreements yet.","There are no billing agreements yet."
 "There are no printable documents related to selected orders.","There are no printable documents related to selected orders."
 "There are no shipping labels related to selected %s.","There are no shipping labels related to selected %s."
 "There is no need to approve this payment.","There is no need to approve this payment."
@@ -847,7 +826,6 @@
 "Whether buyer can define the date when billing for the profile begins.","Whether buyer can define the date when billing for the profile begins."
 "Width","Width"
 "Wishlist","Wishlist"
-"Wrong billing agreement ID specified.","Wrong billing agreement ID specified."
 "Wrong quote item id to update configuration.","Wrong quote item id to update configuration."
 "Wrong state: ""%s"".","Wrong state: ""%s""."
 "Yes","Yes"
diff --git a/app/code/Magento/Sales/i18n/es_ES.csv b/app/code/Magento/Sales/i18n/es_ES.csv
index 56c9423f592c43e368bd544e4e42f9757894ed30..03b03053b27fb15f33153240a2ca4c37954790ee 100644
--- a/app/code/Magento/Sales/i18n/es_ES.csv
+++ b/app/code/Magento/Sales/i18n/es_ES.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - Introduzca el precio a medida sin impuestos"
 "* - Enter custom price including tax","* - Introduzca el precio a medida con impuestos"
 "-- Please Select --","-- Seleccionar, por favor --"
-"-- Please Select Billing Agreement--","-- Por favor, Seleccione el Acuerdo de Facturación--"
 "About This Order:","En Relación con Este Pedido:"
 "About This Profile:","En Relación con Este Perfil:"
 "About Your Invoice","Acerca de su factura"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","Cantidad autorizada  de %s."
 "Authorizing amount of %s is pending approval on gateway.","Cantidad autorizada de %s en espera de aprobación de la interfaz"
 "Back","Volver"
-"Back to Billing Agreements","Volver a los contratos de facturación"
 "Back to My Orders","Volver a mis pedidos"
 "Back to Recurring Profiles","Volver a los perfiles de suscripción"
 "Backordered","Pendientes de entrega"
@@ -88,11 +86,6 @@
 "Bill-to Name","Nombre de la factura"
 "Billing","Facturación"
 "Billing Address","Dirección de facturación"
-"Billing Agreement","Acuerdo de facturación"
-"Billing Agreement # %s","Contrato de facturación # %s"
-"Billing Agreement #%s","Contrato de facturación # %s"
-"Billing Agreement View","Ver contrato de facturación"
-"Billing Agreements","Contratos de facturación"
 "Billing Last Name","Apellido para Facturación"
 "Billing ZIP Code","Código Postal para Facturación"
 "Buy %s for price %s","Comprar %s por precio %s"
@@ -130,7 +123,7 @@
 "Clear Shopping Cart","Vaciar carro de la compra"
 "Click to change shipping method","Haz click aquí para cambiar el método de envío"
 "Close","Cerrar"
-"Closed","Cerrado"
+"Closed","Está cerrado"
 "Comma-separated.","Separados por comas."
 "Comment","Comentario"
 "Comment Text","Comentar el texto"
@@ -164,7 +157,6 @@
 "Create new shipment for order","Crear nuevo envío para el pedido"
 "Create...","Crear..."
 "Created","Creado en"
-"Created billing agreement #%s.","Crear contrato de facturación #%s."
 "Created:","Creado:"
 "Credit Memo","Factura rectificativa"
 "Credit Memo #","Nota de Crédito #"
@@ -186,19 +178,15 @@
 "Custom Value","Valor personalizado"
 "Customer","Cliente"
 "Customer Can Define Start Date","El cliente puede fijar la fecha de inicio"
-"Email","Dirección de correo electrónico del cliente"
 "Customer Group","Grupo de Clientes"
-"Last Name","Apellido del cliente"
 "Customer My Account Order Creditmemo View","Vista de la factura rectificativa del pedido de «mi cuenta» del cliente"
 "Customer My Account Order History","Historial de pedidos de «mi cuenta» del cliente"
 "Customer My Account Order Invoice View","Vista de la factura del pedido de «mi cuenta» del cliente"
 "Customer My Account Order Shipment View","Vista del envío del pedido de «mi cuenta» del cliente"
 "Customer My Account Order View","Vista del pedido de «mi cuenta» del cliente"
-"First Name","Nombre del Cliente"
 "Customer\'s Current Activities","Actividades actuales del cliente"
 "Customs Value","Valor en Aduana"
 "Date","Fecha"
-"Ship Date","Fecha de Envío"
 "Default Status","Estado por defecto"
 "Default Template","Plantilla predeterminada"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png)","Logotipo por omisión. Se usará en documentos PDF y HTML.<br />(jpeg, tiff, png)"
@@ -215,7 +203,7 @@
 "Edit Order #%s","Modificar el pedido nº %s"
 "Edit Order %s %s Address","Editar la dirección del pedido %s %s"
 "Edit Order Status","Editar estado de pedido"
-"Email","Correo electrónico"
+"Email","Dirección de correo electrónico del cliente"
 "Email Address","Dirección de correo electrónico"
 "Email Copy of Credit Memo","Enviar una copia de la factura rectificativa por correo electrónico"
 "Email Copy of Invoice","Enviar por Email Copia de Factura"
@@ -230,23 +218,17 @@
 "Excl. Tax","Sin impuestos"
 "Expired","Caducado"
 "Explanation","Explicación"
-"Failed to cancel the billing agreement.","No se ha podido cancelar el acuerdo de facturación"
-"Failed to create billing agreement for this order.","No se ha podido crear un acuerdo de facturación para este pedido."
-"Failed to finish billing agreement wizard.","El asistente de acuerdos de facturación no ha podido finalizar."
 "Failed to send the order email.","No se pudo enviar el email del pedido."
-"Failed to start billing agreement wizard.","El asistente de acuerdos de facturación no ha podido iniciarse."
 "Failed to update the payment.","No se pudo actualizar el pago."
 "Failed to update the profile.","No se ha podido actualizar el perfil."
 "Failed to void the payment.","No se pudo anular el pago."
 "Fetch","Capturar"
 "File extension not known or unsupported type in the following shipment: %s","Extensión de archivo desconocida o no se admite el tipo en el siguiente envío:% s"
 "Find Order By:","Buscar Pedido Por:"
-"First Name","Nombre"
+"First Name","Nombre del Cliente"
 "From","Desde"
 "From Name","Por nombre"
 "From:","De:"
-"Grand Total (Base)","Grand Total (Base)"
-"Grand Total (Purchased)","Grand Total (Comprado)"
 "General","General"
 "General Information","Información General"
 "Get Payment Update","Recibir la actualización de pago"
@@ -260,6 +242,8 @@
 "Gift Wrapping for the Entire Order","Papel para regalo para el Pedido completo"
 "Girth","Circunferencia"
 "Grand Total","Suma total"
+"Grand Total (Base)","Grand Total (Base)"
+"Grand Total (Purchased)","Grand Total (Comprado)"
 "Grand Total to be Charged","Importe total a cobrar"
 "Guest","Invitado"
 "Height","Altura"
@@ -314,7 +298,6 @@
 "Invoice will be created without communication with payment gateway.","Se creará la factura sin comunicación con la pasarela de pago."
 "Invoiced","Facturado"
 "Invoices","Facturas"
-"Closed","Está cerrado"
 "Item","Artículo"
 "Item Status","Estado del artículo"
 "Item object is not specified.","Objeto del artículo no especificado."
@@ -332,7 +315,7 @@
 "Items to Refund","Artículos para devolver"
 "Items to Ship","Artículos a Enviar"
 "Key","Clave"
-"Last Name","Apellido"
+"Last Name","Apellido del cliente"
 "Last Ordered Items","Últimos Artículos Pedidos"
 "Last status can\'t be unassigned from state.","El último estado no puede estar sin asignar desde estado."
 "Length","Longitud"
@@ -361,7 +344,6 @@
 "N/A","N/A"
 "Name","Nombre"
 "New","Nuevo"
-"New Billing Agreement","Nuevo Acuerdo de Facturación"
 "New Credit Memo","Nueva Factura de Abono"
 "New Credit Memo for Guest","Nueva Nota de Crédito para Huésped"
 "New Credit Memo for Invoice #%s","Nueva Nota de Crédito para Factura #%s"
@@ -386,6 +368,7 @@
 "No Items To Refund","Sin Artículos que Reembolsar"
 "No Payment Methods","Sin Formas de Pago"
 "No detail for number ""%s""","Sin detalles del número ""%s"""
+No hay etiquetas de envío para las %s seleccionadas. [[[if %s is feminine]]]"
 "No information available.","No hay información disponible."
 "No items","No hay artículos"
 "No order(s) were put on hold.","Ningún pedido fue puesto en suspenso."
@@ -413,8 +396,8 @@
 "Order","Pedido"
 "Order ","Pedido #"
 "Order %s","Pedido # %s"
-"Order %s %s | %s","Pedido # %s %s | %s"
 "Order %s","Pedido #%s"
+"Order %s %s | %s","Pedido # %s %s | %s"
 "Order %s - %s","Pedido #%s - %s"
 "Order API","API de Pedido"
 "Order Address Information","Información de la Dirección del Pedido"
@@ -484,8 +467,8 @@
 "Partial","Parcial"
 "Payment Failed","Pago Fallido"
 "Payment Information","Información de pago"
-"Payment Method","Método de pago"
 "Payment Method","Nombre del Método de Pago"
+"Payment Method","Método de pago"
 "Payment Method:","Método de pago:"
 "Payment Review","Revisión del Pago"
 "Payment disallow storing objects.","El pago no permite almacenar objetos."
@@ -495,7 +478,6 @@
 "Pending","Pendiente"
 "Pending Payment","Pago Pendiente"
 "Period","Período"
-"Place Order Using Billing Agreements","Hacer el Pedido Utilizando los Acuerdos de Facturación"
 "Placed from IP","Realizado desde IP"
 "Please Select Products to Add","Por favor, Selecciona Productos a Añadir"
 "Please Select a Customer","Seleccione un Cliente"
@@ -537,10 +519,10 @@
 "Promotion Coupons Usage Report","Informe de Utilización de Cupones de Promoción"
 "Proper payment object must be set.","Debe establecerse el apropiado objeto de pago."
 "Purchase Order Number:","Número de pedido de compra:"
-"Purchased From","Comprado de"
 "Purchase Point","Comprado En (Tienda)"
-"Purchased Item","Artículo Comprado"
 "Purchased Date","Comprado en"
+"Purchased From","Comprado de"
+"Purchased Item","Artículo Comprado"
 "Qty","Cantidad"
 "Qty Invoiced","Cantidad Facturada"
 "Qty Ordered","Cantidad Pedida"
@@ -656,6 +638,7 @@
 "Send Tracking Information","Enviar información de rastreo"
 "Set order for existing transactions not allowed","Establecer orden para las transacciones existentes no permitido"
 "Ship","Enviar"
+"Ship Date","Fecha de Envío"
 "Ship To","Enviar a"
 "Ship-to Name","Enviar a nombre de"
 "Shipment","Envío"
@@ -724,8 +707,6 @@
 "Telephone","Teléfono"
 "The Order State ""%s"" must not be set manually.","El estado del pedido ""%s"" no se debe establecer manualmente."
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","El modelo de dirección total debería extenderse desde \Magento\Sales\Model\Quote\Address\Total\AbstractTotal."
-"The billing agreement ""%s"" has been canceled.","El acuerdo de facturación ""%s"" se ha cancelado."
-"The billing agreement ""%s"" has been created.","El acuerdo de facturación ""%s"" se ha creado."
 "The coupon code has been accepted.","El código del cupón se ha aceptado"
 "The message has been sent.","El mensaje ha sido enviado."
 "The message was sent.","El mensaje se envió."
@@ -755,10 +736,8 @@
 "The transaction ""%s"" (%s) is already closed.","La transacción ""%s"" (%s) ya está cerrada."
 "The transaction ""%s"" cannot be captured yet.","La transacción ""%s"" no puede ser capturada todavía."
 "The value that you entered is not valid.","El valor que ha introducido no es válido."
-"There are no billing agreements yet.","No hay acuerdos de facturación todavía."
 "There are no printable documents related to selected orders.","No hay documentos para imprimir relacionados con los pedidos seleccionados."
 "There are no shipping labels related to selected %s.","No hay etiquetas de envío para los %s seleccionados. [[[if %s is masculine]]]
-No hay etiquetas de envío para las %s seleccionadas. [[[if %s is feminine]]]"
 "There is no need to approve this payment.","No hay necesidad de aprobar este pago."
 "There is no need to deny this payment.","No hay necesidad de negar este pago."
 "There is no update for the payment.","No hay actualizaciones para este pago."
@@ -845,7 +824,6 @@ No hay etiquetas de envío para las %s seleccionadas. [[[if %s is feminine]]]"
 "Whether buyer can define the date when billing for the profile begins.","Si el comprador puede definir la fecha en que la facturación comienza para el perfil."
 "Width","Ancho"
 "Wishlist","Lista de deseos"
-"Wrong billing agreement ID specified.","La identificación del contrato de facturación es incorrecta."
 "Wrong quote item id to update configuration.","Número identificativo del artículo incorrecto para actualizar la configuración."
 "Wrong state: ""%s"".","Estado incorrecto: ""%s""."
 "Yes","Sí"
diff --git a/app/code/Magento/Sales/i18n/fr_FR.csv b/app/code/Magento/Sales/i18n/fr_FR.csv
index cf1992a6da10451f84f40012c0f8321d45c5c0ea..49ac8d5789db877eb3a32fc747003ffa788579db 100644
--- a/app/code/Magento/Sales/i18n/fr_FR.csv
+++ b/app/code/Magento/Sales/i18n/fr_FR.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - Entrez le prix personnalisé sans les taxes"
 "* - Enter custom price including tax","* - Entrez le prix personnalisé avec les taxes"
 "-- Please Select --","-- Veuillez sélectionner --"
-"-- Please Select Billing Agreement--","-- Veuillez sélectionner un accord de facturation--"
 "About This Order:","A propos de cette commande :"
 "About This Profile:","A propos de ce profil :"
 "About Your Invoice","Au sujet de votre facture"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","Montant de %s autorisé."
 "Authorizing amount of %s is pending approval on gateway.","L'autorisation du paiement de %s est attente d'accord de la passerelle."
 "Back","Retour"
-"Back to Billing Agreements","Retour aux accords de facturation"
 "Back to My Orders","Retour à Mes commandes"
 "Back to Recurring Profiles","Retour aux profils récurrents"
 "Backordered","Rupture de stock"
@@ -88,11 +86,6 @@
 "Bill-to Name","Facture au nom"
 "Billing","Facturation"
 "Billing Address","Adresse de facturation"
-"Billing Agreement","Accord de facturation"
-"Billing Agreement # %s","Accord de facturation # %s"
-"Billing Agreement #%s","Accord de facturation #%s"
-"Billing Agreement View","Voir l'accord de facturation"
-"Billing Agreements","Accords de facturation"
 "Billing Last Name","Nom facturation"
 "Billing ZIP Code","Code postal facturation"
 "Buy %s for price %s","Acheter %s pour le prix de %s"
@@ -130,7 +123,7 @@
 "Clear Shopping Cart","Vider le panier"
 "Click to change shipping method","Cliquez pour changer la méthode d'envoi"
 "Close","Fermer"
-"Closed","Clos"
+"Closed","Est fermé"
 "Comma-separated.","Séparé(es) par des virgules."
 "Comment","Commenter"
 "Comment Text","Commenter texte"
@@ -164,7 +157,6 @@
 "Create new shipment for order","Créer une nouvelle livraison pour la commande"
 "Create...","Créer..."
 "Created","Créé à"
-"Created billing agreement #%s.","Créer un accord de paiement #%s"
 "Created:","Créé:"
 "Credit Memo","Avoir"
 "Credit Memo #","N° de note de crédit"
@@ -186,19 +178,15 @@
 "Custom Value","Personnaliser la valeur"
 "Customer","Client"
 "Customer Can Define Start Date","Le client peut définir la date de début"
-"Email","Email du client"
 "Customer Group","Groupe du client"
-"Last Name","Nom du client"
 "Customer My Account Order Creditmemo View","Client Mon Compte Commande Avoir Affichage"
 "Customer My Account Order History","Client Mon Compte Commande Historique"
 "Customer My Account Order Invoice View","Client Mon Compte Commande Facture Affichage"
 "Customer My Account Order Shipment View","Client Mon Compte Commande Livraison Affichage"
 "Customer My Account Order View","Client Mon Compte Commande Affichage"
-"First Name","Nom du client"
 "Customer\'s Current Activities","Activités en cours du client"
 "Customs Value","Valeurs personnalisées"
 "Date","Date"
-"Ship Date","Date d'envoi"
 "Default Status","État pas défaut"
 "Default Template","Modèle par défaut"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png)","Logo par défaut, sera utilisé dans les documents PDF et HTML.<br />(jpeg, tiff, png)"
@@ -215,7 +203,7 @@
 "Edit Order #%s","Modifier la commande #%s"
 "Edit Order %s %s Address","Éditer l'adresse de la commande"
 "Edit Order Status","Éditer l'état de la commande"
-"Email","Email"
+"Email","Email du client"
 "Email Address","Adresse email"
 "Email Copy of Credit Memo","Copie de l'e-mail de la note de crédit"
 "Email Copy of Invoice","Copie email de la facture"
@@ -230,11 +218,7 @@
 "Excl. Tax","H.T."
 "Expired","Expiré"
 "Explanation","Explication"
-"Failed to cancel the billing agreement.","Échec lors de l'annulation de l'accord de facturation."
-"Failed to create billing agreement for this order.","Échec de la création de l'accord de facturation pour cette commande."
-"Failed to finish billing agreement wizard.","Impossible de terminer l'assistant d'accord de facturation."
 "Failed to send the order email.","A échoué d'envoyer la demande d'email"
-"Failed to start billing agreement wizard.","Impossible de démarrer l'assistant d'accord de facturation"
 "Failed to update the payment.","Échec de la mise à jour du paiement."
 "Failed to update the profile.","Échec de la mise à jour du profil."
 "Failed to void the payment.","Impossible d'annuler le paiement."
@@ -245,8 +229,6 @@
 "From","De"
 "From Name","De Nom"
 "From:","De:"
-"Grand Total (Base)","G. T. (Base)"
-"Grand Total (Purchased)","Total général (acheté)"
 "General","Général"
 "General Information","Informations générales."
 "Get Payment Update","Obtenir la mise à jour du paiement"
@@ -260,6 +242,8 @@
 "Gift Wrapping for the Entire Order","Emballage cadeau pour l'ensemble de la commande"
 "Girth","circonférence"
 "Grand Total","Total final"
+"Grand Total (Base)","G. T. (Base)"
+"Grand Total (Purchased)","Total général (acheté)"
 "Grand Total to be Charged","Grand total à payer"
 "Guest","Invité"
 "Height","Hauteur"
@@ -267,8 +251,8 @@
 "Hold","Mise en attente"
 "Hold action is not available.","Le blocage n'est pas disponible."
 "Hold order","Bloquer commande."
-"ID","ID"
 "ID","Identifiant #"
+"ID","ID"
 "IPN ""Refunded"". Refund issued by merchant. Registered notification about refunded amount of %s. Transaction ID: ""%s""","IPN ""Remboursé"". Remboursement effectué par le vendeur. Notification enregistrée pour le montant remboursé de %s. ID de la transaction : ""%s"""
 "If empty, the default description above will be used.","Si laissé vide, la description par défaut ci-dessus sera utilisée."
 "If empty, the default error above will be used.","Si vide, l'erreur par défaut ci-dessus sera affichée."
@@ -314,7 +298,6 @@
 "Invoice will be created without communication with payment gateway.","La facture va être créée sans communication avec une passerelle de payement"
 "Invoiced","Facturé"
 "Invoices","Factures"
-"Closed","Est fermé"
 "Item","Article"
 "Item Status","Statut article"
 "Item object is not specified.","L'objet de l'article n'est pas spécifié."
@@ -332,7 +315,7 @@
 "Items to Refund","Articles à rembourser"
 "Items to Ship","Articles à expédier"
 "Key","Clé"
-"Last Name","Nom de famille"
+"Last Name","Nom du client"
 "Last Ordered Items","Derniers articles commandés"
 "Last status can\'t be unassigned from state.","Le dernier statut ne peut pas être retiré de l'État."
 "Length","Longueur"
@@ -361,7 +344,6 @@
 "N/A","N/A"
 "Name","Nom"
 "New","Nouveau"
-"New Billing Agreement","Nouvel Accord de Facturation"
 "New Credit Memo","Nouvel Avoir"
 "New Credit Memo for Guest","Nouvelle note de crédit pour le client"
 "New Credit Memo for Invoice #%s","Nouveau Credit Memo pour la facture #%s"
@@ -413,8 +395,8 @@
 "Order","Commande"
 "Order ","Commande #"
 "Order %s","Commande #%s"
-"Order %s %s | %s","Commande nËš %s %s | %s"
 "Order %s","Commande #%s"
+"Order %s %s | %s","Commande nËš %s %s | %s"
 "Order %s - %s","Commande #%s - %s"
 "Order API","Commander API"
 "Order Address Information","Informations sur l'adresse de la commande"
@@ -495,7 +477,6 @@
 "Pending","En cours"
 "Pending Payment","Paiement en attente"
 "Period","Période"
-"Place Order Using Billing Agreements","Passer une commande en recourant aux accords de facturation"
 "Placed from IP","Placé depuis l'IP"
 "Please Select Products to Add","Sélectionner les produits à acheter"
 "Please Select a Customer","Veuillez sélectionner un client"
@@ -537,10 +518,10 @@
 "Promotion Coupons Usage Report","Rapport sur l'Utilisation des Coupons de Promotions"
 "Proper payment object must be set.","Un objet de paiement approprié doit être défini."
 "Purchase Order Number:","Numéro de commande :"
-"Purchased From","Acheté à"
 "Purchase Point","Acheté chez (Boutique)"
-"Purchased Item","Article acheté"
 "Purchased Date","Acheté sur"
+"Purchased From","Acheté à"
+"Purchased Item","Article acheté"
 "Qty","Qté"
 "Qty Invoiced","Qté facturée"
 "Qty Ordered","Quantité commandée"
@@ -656,10 +637,11 @@
 "Send Tracking Information","Envoyer une information de suivi"
 "Set order for existing transactions not allowed","Le passage de commande pour des transactions existantes n'est pas autorisé"
 "Ship","Expédier"
+"Ship Date","Date d'envoi"
 "Ship To","Expédier à"
 "Ship-to Name","Expédier à Nom"
-"Shipment","Expédition"
 "Shipment","N° d'envoi"
+"Shipment","Expédition"
 "Shipment %1$s | %3$s (%2$s)","Expédition #%1$s | %3$s (%2$s)"
 "Shipment %s","Expédition n˚%s"
 "Shipment Comment Email Sender","Livraison Expéditeur du Commentaire"
@@ -724,8 +706,6 @@
 "Telephone","Téléphone"
 "The Order State ""%s"" must not be set manually.","L’État de la commande ""%s"" ne doit pas être défini manuellement."
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","Le modèle total de l'adresse devrait être étendu à partir de \Magento\Sales\Model\Quote\Address\Total\AbstractTotal."
-"The billing agreement ""%s"" has been canceled.","L'accord de facturation ""%s"" a été annulé."
-"The billing agreement ""%s"" has been created.","L'accord de facturation ""%s"" a été créé."
 "The coupon code has been accepted.","Le code de coupon a été accepté"
 "The message has been sent.","Le message a été envoyé."
 "The message was sent.","Le message a été envoyé"
@@ -755,7 +735,6 @@
 "The transaction ""%s"" (%s) is already closed.","La transaction ""%s"" (%s) est déjà clôturée."
 "The transaction ""%s"" cannot be captured yet.","La transaction ""%s"" ne peut pas encore être saisie."
 "The value that you entered is not valid.","La valeur que vous avez saisie n'est pas valide."
-"There are no billing agreements yet.","Il n'y a pas encore d'accord de facturation"
 "There are no printable documents related to selected orders.","Il n'exsite pas de documents imprimables concernant ces commandes."
 "There are no shipping labels related to selected %s.","Il n'y a pas de labels d'expédition liés à  %s."
 "There is no need to approve this payment.","Ce paiement ne requiert pas d'accord."
@@ -844,7 +823,6 @@
 "Whether buyer can define the date when billing for the profile begins.","Si l'acheteur peut définir la date de début de facturation"
 "Width","Largeur"
 "Wishlist","Souhaits"
-"Wrong billing agreement ID specified.","Mauvais identifiant des accords de facturation spécifié."
 "Wrong quote item id to update configuration.","L'identification du produit sélectionné est incorrecte et la configuration ne peut pas être mise à jour."
 "Wrong state: ""%s"".","État incorrect : ""%s""."
 "Yes","oui"
diff --git a/app/code/Magento/Sales/i18n/nl_NL.csv b/app/code/Magento/Sales/i18n/nl_NL.csv
index 80d2178c64749fb3404262886a30b1060b1fd2b7..1c4961b60378bec8d44505f42027865c720ec234 100644
--- a/app/code/Magento/Sales/i18n/nl_NL.csv
+++ b/app/code/Magento/Sales/i18n/nl_NL.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - Voer aangepaste prijs exclusief belasting in"
 "* - Enter custom price including tax","* - Voer aangepaste prijs inclusief belasting in"
 "-- Please Select --","-- Selecteer Alstublieft --"
-"-- Please Select Billing Agreement--","-- Selecteer a.u.b. rekeningovereenkomst --"
 "About This Order:","Over deze bestelling:"
 "About This Profile:","Over dit profiel:"
 "About Your Invoice","Over Uw Factuur"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","Geautoriseerd bedrag van %s."
 "Authorizing amount of %s is pending approval on gateway.","Te autoriseren bedrag van %s wacht op goedkeuring op toegangspoort."
 "Back","Terug"
-"Back to Billing Agreements","Terug naar Factureringsovereenkomsten"
 "Back to My Orders","Terug naar Mijn Bestellingen"
 "Back to Recurring Profiles","Terug naar Terugkomende Profielen"
 "Backordered","Nabesteld"
@@ -88,11 +86,6 @@
 "Bill-to Name","Rekening op naam"
 "Billing","Facturatie"
 "Billing Address","Factuuradres"
-"Billing Agreement","Factuurovereenkomst"
-"Billing Agreement # %s","Factureringsovereenkomst # %s"
-"Billing Agreement #%s","Factureringsovereenkomst #%s"
-"Billing Agreement View","Factureringsovereenkomst Beeld"
-"Billing Agreements","Facturering Overeenkomsten"
 "Billing Last Name","Rekening Achternaam"
 "Billing ZIP Code","Postcode betaling"
 "Buy %s for price %s","Koop %s voor een prijs van %s"
@@ -164,7 +157,6 @@
 "Create new shipment for order","Maak nieuwe verzending aan voor bestelling"
 "Create...","Creëer..."
 "Created","Gemaakt op"
-"Created billing agreement #%s.","Factuurovereenkomst #%s aangemaakt."
 "Created:","Gemaakt:"
 "Credit Memo","Credietmemo"
 "Credit Memo #","Kredietnota #"
@@ -186,19 +178,15 @@
 "Custom Value","Aangepaste waarde"
 "Customer","Klant"
 "Customer Can Define Start Date","Klant kan begindatum definieren"
-"Email","Klant e-mail"
 "Customer Group","Klantgroep"
-"Last Name","Klant Achternaam"
 "Customer My Account Order Creditmemo View","Klant mijn rekening bestelling credietmemo weergave"
 "Customer My Account Order History","Klant mijn rekening betellingsgeschiedenis"
 "Customer My Account Order Invoice View","Klant mijn rekening bestelling factuur weergave"
 "Customer My Account Order Shipment View","Klant mijn rekening bestelling verzending weergave"
 "Customer My Account Order View","Klant mijn rekening bestelling weergave"
-"First Name","Klant Naam"
 "Customer\'s Current Activities","Recente bezigheden van de klant"
 "Customs Value","Douanewaarde"
 "Date","Datum"
-"Ship Date","Datum waarop Verstuurd"
 "Default Status","Standaard Status"
 "Default Template","Vaststaand Sjabloon"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png)","Standaard logo, zal in PDF en HTML documenten worden gebruikt. <br />(jpeg, tiff, png)"
@@ -215,7 +203,7 @@
 "Edit Order #%s","Bewerk bestelling #%s"
 "Edit Order %s %s Address","Verander Order %s %s Adres"
 "Edit Order Status","Verander Orderstatus"
-"Email","E-mail"
+"Email","Klant e-mail"
 "Email Address","e-mailadres"
 "Email Copy of Credit Memo","E-mail een kopie van de credietmemo"
 "Email Copy of Invoice","Kopie van factuur emailen"
@@ -230,23 +218,17 @@
 "Excl. Tax","Excl. BTW"
 "Expired","Verlopen"
 "Explanation","Verklaring"
-"Failed to cancel the billing agreement.","Is er niet in geslaagd de facturering overeenkomst te ontbinden."
-"Failed to create billing agreement for this order.","Niet in staat om een factuurovereenkomst voor deze bestelling te maken."
-"Failed to finish billing agreement wizard.","Niet in staat om de factuur-wizard overeenkomst af te maken"
 "Failed to send the order email.","Kon de bestellings-e-mail niet versturen."
-"Failed to start billing agreement wizard.","Niet in staat om de factuur-wizard overeenkomst te starten"
 "Failed to update the payment.","Kon de betaling niet updaten."
 "Failed to update the profile.","Is er niet in geslaagd het profiel te updaten."
 "Failed to void the payment.","Was niet in staat de betaling te vernietigen."
 "Fetch","Halen"
 "File extension not known or unsupported type in the following shipment: %s","Bestandsextensie niet bekend of niet ondersteund in de volgende bestelling: %s"
 "Find Order By:","Vind een bestelling door:"
-"First Name","Voornaam"
+"First Name","Klant Naam"
 "From","Van"
 "From Name","Vanaf naam"
 "From:","Van:"
-"Grand Total (Base)","G.T. (basis)"
-"Grand Total (Purchased)","Bruto totaal (gekocht)"
 "General","Algemeen"
 "General Information","Algemene informatie"
 "Get Payment Update","Verkrijg betalings-update"
@@ -260,6 +242,8 @@
 "Gift Wrapping for the Entire Order","Cadeauverpakking voor gehele bestelling"
 "Girth","Omtrek"
 "Grand Total","Groot Totaal"
+"Grand Total (Base)","G.T. (basis)"
+"Grand Total (Purchased)","Bruto totaal (gekocht)"
 "Grand Total to be Charged","Totaalbedrag dat zal worden gefactureerd"
 "Guest","Gast"
 "Height","Hoogte"
@@ -267,8 +251,8 @@
 "Hold","In de wacht"
 "Hold action is not available.","Vasthoud-actie is niet beschikbaar"
 "Hold order","Houd bestelling vast"
-"ID","identiteit"
 "ID","ID"
+"ID","identiteit"
 "IPN ""Refunded"". Refund issued by merchant. Registered notification about refunded amount of %s. Transaction ID: ""%s""","IPN ""Terugbetaald"". Terugbetaling door verkoper. Geregistreerde melding over terugbetaald bedrag van %s. Transactie ID: ""%s"""
 "If empty, the default description above will be used.","Indien leeg, zal de bovenstaande standaard omschrijving worden gebruikt."
 "If empty, the default error above will be used.","Als het leeg is zal de standaard fout hierboven gebruikt worden."
@@ -314,7 +298,6 @@
 "Invoice will be created without communication with payment gateway.","Facturatie zal worden aangemaakt zonder communicatie met de betalingspoort."
 "Invoiced","Gefactureerd."
 "Invoices","Facturen"
-"Closed","Is afgesloten"
 "Item","item"
 "Item Status","Artikel Status"
 "Item object is not specified.","item object is niet gespecificeerd"
@@ -332,7 +315,7 @@
 "Items to Refund","items om te retourneren"
 "Items to Ship","Items te Verzenden"
 "Key","sleutel"
-"Last Name","Achternaam"
+"Last Name","Klant Achternaam"
 "Last Ordered Items","laatst bestelde items"
 "Last status can\'t be unassigned from state.","Laatste status kan niet vanuit staat herbenoemd worden."
 "Length","Lengte"
@@ -361,7 +344,6 @@
 "N/A","n.v.t."
 "Name","Naam"
 "New","Nieuw"
-"New Billing Agreement","Nieuwe factuurovereenkomst"
 "New Credit Memo","Nieuwe credietmemo"
 "New Credit Memo for Guest","Nieuwe creditnota voor Gast"
 "New Credit Memo for Invoice #%s","Nieuwe Credit Memo voor Factuur #%s"
@@ -413,8 +395,8 @@
 "Order","Bestelling"
 "Order ","Bestelling #"
 "Order %s","Bestelling # %s"
-"Order %s %s | %s","Bestelling # %s %s | %s"
 "Order %s","Bestelling #%s"
+"Order %s %s | %s","Bestelling # %s %s | %s"
 "Order %s - %s","Bestelling #%s - %s"
 "Order API","Bestel API"
 "Order Address Information","Bestelling Adres Informatie"
@@ -495,7 +477,6 @@
 "Pending","In behandeling"
 "Pending Payment","In afwachting van betaling"
 "Period","Periode"
-"Place Order Using Billing Agreements","Plaats uw bestelling met behulp van Facturering overeenkomsten"
 "Placed from IP","Geplaatst van IP"
 "Please Select Products to Add","Selecteer producten om toe te voegen alstublieft"
 "Please Select a Customer","Selecteer een klant"
@@ -537,10 +518,10 @@
 "Promotion Coupons Usage Report","Promotie Coupons Gebruiksrapport"
 "Proper payment object must be set.","Correct betalingsobject moet worden ingesteld."
 "Purchase Order Number:","Aankoop Bestellingsnummer:"
-"Purchased From","Gekocht Van"
 "Purchase Point","Gekocht van (winkel)"
-"Purchased Item","Gekocht artikel"
 "Purchased Date","Gekocht Op"
+"Purchased From","Gekocht Van"
+"Purchased Item","Gekocht artikel"
 "Qty","hoeveelheid"
 "Qty Invoiced","Aantal Gefactureerd"
 "Qty Ordered","Aantal Besteld"
@@ -656,10 +637,11 @@
 "Send Tracking Information","Stuur Volginformatie"
 "Set order for existing transactions not allowed","Volgorde voor bestaande transactie niet toegestaan"
 "Ship","Verstuur"
+"Ship Date","Datum waarop Verstuurd"
 "Ship To","Verzenden naar"
 "Ship-to Name","Verzenden naar Naam"
-"Shipment","Verzending"
 "Shipment","Zending #"
+"Shipment","Verzending"
 "Shipment %1$s | %3$s (%2$s)","Zending #%1$s | %3$s (%2$s)"
 "Shipment %s","Zending #%s"
 "Shipment Comment Email Sender","Zending Opmerking E-mail Verzender"
@@ -724,8 +706,6 @@
 "Telephone","telefoon"
 "The Order State ""%s"" must not be set manually.","De bestellingsstaat ""%s"" moet niet handmatig ingesteld worden."
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","Het totale adresmodel moet uitgebreid worden van \Magento\Sales\Model\Quote\Address\Total\AbstractTotal."
-"The billing agreement ""%s"" has been canceled.","De afrekeningsovereenkomst ""%s"" is geannuleerd."
-"The billing agreement ""%s"" has been created.","De afrekeningsovereenkomst ""%s"" is aangemaakt."
 "The coupon code has been accepted.","De kortingsboncode is geaccepteerd."
 "The message has been sent.","Het bericht is verzonden"
 "The message was sent.","Het bericht is verzonden."
@@ -755,7 +735,6 @@
 "The transaction ""%s"" (%s) is already closed.","De transactie ""%s"" (%s) is al gesloten."
 "The transaction ""%s"" cannot be captured yet.","De transactie ""%s"" kan nog niet opgenomen worden."
 "The value that you entered is not valid.","De door u ingevoerde waarde is niet juist."
-"There are no billing agreements yet.","Er zijn nog geen facturatieovereenkomsten."
 "There are no printable documents related to selected orders.","Er zijn geen printbare documenten gerelateerd aan de geselecteerde bestellingen."
 "There are no shipping labels related to selected %s.","Er zijn geen verschepingslabels gerelateerd aan de geselecteerde %s."
 "There is no need to approve this payment.","Er is geen nood om deze betaling te accepteren."
@@ -844,7 +823,6 @@
 "Whether buyer can define the date when billing for the profile begins.","Of koper kan de datum kan bepalen wanneer de facturering voor het profiel begint."
 "Width","Breedte"
 "Wishlist","Verlanglijst"
-"Wrong billing agreement ID specified.","Verkeerde factuur overeenkomst ID opgegeven."
 "Wrong quote item id to update configuration.","Verkeerde quote artikel id voor update configuratie."
 "Wrong state: ""%s"".","Verkeerde status: ""%s""."
 "Yes","Ja"
diff --git a/app/code/Magento/Sales/i18n/pt_BR.csv b/app/code/Magento/Sales/i18n/pt_BR.csv
index 69e72e45321898dec45fc50d97885d610f4c8dbf..1db1b6174aa40d98a20543bb6a9c4954720f1ee6 100644
--- a/app/code/Magento/Sales/i18n/pt_BR.csv
+++ b/app/code/Magento/Sales/i18n/pt_BR.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - Insira preço personalizado sem imposto"
 "* - Enter custom price including tax","* - Insira preço personalizado com imposto"
 "-- Please Select --","- Por Favor Selecione -"
-"-- Please Select Billing Agreement--","-- Por Favor, Escolha o Acordo de Cobrança--"
 "About This Order:","Sobre Este Pedido:"
 "About This Profile:","Sobre Este Perfil:"
 "About Your Invoice","Sobre Sua Fatura"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","Valor autorizado de %s."
 "Authorizing amount of %s is pending approval on gateway.","Autorização de valor %s está pendente de aprovação no portal."
 "Back","Voltar"
-"Back to Billing Agreements","Voltar para Contratos de Faturamento"
 "Back to My Orders","Voltar para Minhas Compras"
 "Back to Recurring Profiles","Voltar para Perfis Recorrentes"
 "Backordered","Pendente"
@@ -88,11 +86,6 @@
 "Bill-to Name","Faturar para Nome"
 "Billing","Faturamento"
 "Billing Address","Endereço de faturamento"
-"Billing Agreement","Contrato de faturamento"
-"Billing Agreement # %s","Contrato de Faturamento # %s"
-"Billing Agreement #%s","Contrato de Faturamento # %s"
-"Billing Agreement View","Visualização de Contrato de Faturamento"
-"Billing Agreements","Contratos de faturamento"
 "Billing Last Name","Último Nome do Faturamento"
 "Billing ZIP Code","Código Postal do Faturamento"
 "Buy %s for price %s","Comprar %s pelo preço %s"
@@ -130,7 +123,7 @@
 "Clear Shopping Cart","Limpar Carrinho de Compras"
 "Click to change shipping method","Clique para alterar método de remessa"
 "Close","Fechar"
-"Closed","Fechar"
+"Closed","Está Fechado"
 "Comma-separated.","Separados por vírgula."
 "Comment","Comentário"
 "Comment Text","Texto do comentário"
@@ -164,7 +157,6 @@
 "Create new shipment for order","Criar novo frete para pedido"
 "Create...","Criar..."
 "Created","Criada Em"
-"Created billing agreement #%s.","Criado o contrato de faturamento nº %s."
 "Created:","Criada:"
 "Credit Memo","Criar Memorando"
 "Credit Memo #","Memorando de Crédito Nº"
@@ -186,19 +178,15 @@
 "Custom Value","Valor Aduaneiro"
 "Customer","Cliente"
 "Customer Can Define Start Date","O cliente pode definir a data de início"
-"Email","E-mail do Cliente"
 "Customer Group","Grupo de Clientes"
-"Last Name","Último Nome do Cliente"
 "Customer My Account Order Creditmemo View","Ver Pedido Creditmemo da Minha Conta do Cliente"
 "Customer My Account Order History","Histórico de Pedido do Cliente"
 "Customer My Account Order Invoice View","Ver Faturamento do Pedido do Cliente"
 "Customer My Account Order Shipment View","Ver Pedidos Pagos do Cliente"
 "Customer My Account Order View","Ver Pedido do Cliente"
-"First Name","Nome do Cliente"
 "Customer\'s Current Activities","Atividades Atuais do Cliente"
 "Customs Value","Valores Aduaneiros"
 "Date","Data"
-"Ship Date","Enviado dia"
 "Default Status","Status Padrão"
 "Default Template","Modelo padrão"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png)","Logotipo padrão, será usado em documentos PDF e HTML. <br />(jpeg, tiff, png)"
@@ -215,7 +203,7 @@
 "Edit Order #%s","Editar Ordem (Pedido) #%s"
 "Edit Order %s %s Address","Editar Endereço da Ordem (Pedido) %s  %s"
 "Edit Order Status","Editar Status da Ordem (Pedido)"
-"Email","E-mail"
+"Email","E-mail do Cliente"
 "Email Address","Endereço de e-mail"
 "Email Copy of Credit Memo","Enviar Email Cópia da Nota de Crédito"
 "Email Copy of Invoice","Enviar Email Cópia da Fatura"
@@ -230,23 +218,17 @@
 "Excl. Tax","Excluir taxas"
 "Expired","Expirado"
 "Explanation","Explicação"
-"Failed to cancel the billing agreement.","Falha ao cancelar o contrato de faturamento."
-"Failed to create billing agreement for this order.","Falha ao criar contrato de faturamento para este pedido."
-"Failed to finish billing agreement wizard.","Falha ao concluir wizard do contrato de faturamento."
 "Failed to send the order email.","Falha ao enviar e-mail do pedido."
-"Failed to start billing agreement wizard.","Falha ao iniciar wizard do contrato de faturamento."
 "Failed to update the payment.","Falha ao atualizar o pagamento."
 "Failed to update the profile.","Falha ao atualizar o perfil."
 "Failed to void the payment.","Falha ao anular o pagamento."
 "Fetch","Buscar"
 "File extension not known or unsupported type in the following shipment: %s","Extensão de arquivo desconhecida ou tipo incompatível no seguinte frete: %s"
 "Find Order By:","Encontrar Pedido Por:"
-"First Name","Primeiro nome"
+"First Name","Nome do Cliente"
 "From","De"
 "From Name","Nome do Remetente"
 "From:","De:"
-"Grand Total (Base)","Total Geral (Moeda-Base)"
-"Grand Total (Purchased)","Total Geral (Moeda da Compra)"
 "General","Geral"
 "General Information","Informações gerais"
 "Get Payment Update","Obter Atualização de Pagamento"
@@ -260,6 +242,8 @@
 "Gift Wrapping for the Entire Order","Embrulho para o Pedido Total"
 "Girth","Circunferência"
 "Grand Total","Total geral"
+"Grand Total (Base)","Total Geral (Moeda-Base)"
+"Grand Total (Purchased)","Total Geral (Moeda da Compra)"
 "Grand Total to be Charged","Total a ser Cobrado"
 "Guest","Convidado"
 "Height","Altura"
@@ -267,8 +251,8 @@
 "Hold","Suspender"
 "Hold action is not available.","Ação de suspender não está disponível."
 "Hold order","Suspender compra"
-"ID","Identidade"
 "ID","Identificação #"
+"ID","Identidade"
 "IPN ""Refunded"". Refund issued by merchant. Registered notification about refunded amount of %s. Transaction ID: ""%s""","IPN de ""Restituído"". Restituição emitida por comerciante. Notificação registrada sobre a quantidade restituída de %s. Identificação da transação: ""%s"""
 "If empty, the default description above will be used.","Se estiver em branco, a descrição-padrão acima será usada."
 "If empty, the default error above will be used.","Se estiver em branco, o erro-padrão acima será usado."
@@ -314,7 +298,6 @@
 "Invoice will be created without communication with payment gateway.","A fatura será criada sem comunicação com o gateway de pagamentos"
 "Invoiced","Faturado"
 "Invoices","Faturas"
-"Closed","Está Fechado"
 "Item","Item"
 "Item Status","Status do item"
 "Item object is not specified.","Objeto do item não especificado."
@@ -332,7 +315,7 @@
 "Items to Refund","Itens para reembolso"
 "Items to Ship","Itens para remessa"
 "Key","Senha"
-"Last Name","Último nome"
+"Last Name","Último Nome do Cliente"
 "Last Ordered Items","Últimos itens pedidos"
 "Last status can\'t be unassigned from state.","O último estado não pode ser revertido."
 "Length","Comprimento"
@@ -361,7 +344,6 @@
 "N/A","Indisponível"
 "Name","Nome"
 "New","Novo"
-"New Billing Agreement","Novo Contrato de Faturamento"
 "New Credit Memo","Novo Memorando de Crédito"
 "New Credit Memo for Guest","Novo Memorando de Crédito para Convidado"
 "New Credit Memo for Invoice #%s","Novo Memorando de Crédito para Fatura #%s"
@@ -413,8 +395,8 @@
 "Order","Pedido"
 "Order ","Pedido nº"
 "Order %s","Pedido nº %s"
-"Order %s %s | %s","Order nº %s %s | %s"
 "Order %s","Pedido #%s"
+"Order %s %s | %s","Order nº %s %s | %s"
 "Order %s - %s","Pedido nº %s - %s"
 "Order API","API do pedido"
 "Order Address Information","Informação de endereço do pedido"
@@ -495,7 +477,6 @@
 "Pending","Pendente"
 "Pending Payment","Pagamento Pendente"
 "Period","Período"
-"Place Order Using Billing Agreements","Faça o Pedido Usando Acordos de Faturamento"
 "Placed from IP","Situado no IP"
 "Please Select Products to Add","Escolha os produtos a serem adicionados"
 "Please Select a Customer","Selecione um Cliente"
@@ -537,10 +518,10 @@
 "Promotion Coupons Usage Report","Relatório de uso dos cupons promocionais"
 "Proper payment object must be set.","O pagamento adequado deve ser definido"
 "Purchase Order Number:","Número de Ordem de Compra:"
-"Purchased From","Comprado de"
 "Purchase Point","Comprado de (Loja)"
-"Purchased Item","Item Comprado"
 "Purchased Date","Comprado Em"
+"Purchased From","Comprado de"
+"Purchased Item","Item Comprado"
 "Qty","Quant."
 "Qty Invoiced","Quant. faturada"
 "Qty Ordered","Qtde Pedida"
@@ -656,10 +637,11 @@
 "Send Tracking Information","Enviar informações para rastreamento"
 "Set order for existing transactions not allowed","Definir ordem de transações não permitidas existentes"
 "Ship","Envio"
+"Ship Date","Enviado dia"
 "Ship To","Enviar para"
 "Ship-to Name","Enviar em nome de"
-"Shipment","Remessa"
 "Shipment","Remessa #"
+"Shipment","Remessa"
 "Shipment %1$s | %3$s (%2$s)","Remessa #%1$s | %3$s (%2$s)"
 "Shipment %s","Remessa #%s"
 "Shipment Comment Email Sender","Remetente do E-mail de Comentários de Remessa"
@@ -724,8 +706,6 @@
 "Telephone","Telefone"
 "The Order State ""%s"" must not be set manually.","O Estado do Pedido ""%s"" não pode ser alterado manualmente"
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","O modelo de endereço total deve ser alargado de \Magento\Sales\Model\Quote\Address\Total\AbstractTotal."
-"The billing agreement ""%s"" has been canceled.","O contrato de faturamento ""%s"" foi cancelado."
-"The billing agreement ""%s"" has been created.","O contrato de faturamento ""%s"" foi criado."
 "The coupon code has been accepted.","O código do cupão foi aceite."
 "The message has been sent.","A mensagem foi enviada."
 "The message was sent.","A mensagem foi enviada."
@@ -755,7 +735,6 @@
 "The transaction ""%s"" (%s) is already closed.","A transação ""%s"" (%s) já está fechada."
 "The transaction ""%s"" cannot be captured yet.","A transação ""%s"" ainda não pode ser capturada."
 "The value that you entered is not valid.","O valor informado não é válido."
-"There are no billing agreements yet.","Ainda não existem acordos de faturamento."
 "There are no printable documents related to selected orders.","Não existem documentos imprimíveis relacionados com as ordens selecionadas."
 "There are no shipping labels related to selected %s.","Não há etiquetas de envio relacionadas com %s selecionados."
 "There is no need to approve this payment.","Não há necessidade de aprovar esse pagamento."
@@ -844,7 +823,6 @@
 "Whether buyer can define the date when billing for the profile begins.","Se o comprador pode definir a data para começar o faturamento do perfil."
 "Width","Largura"
 "Wishlist","Lista de presentes"
-"Wrong billing agreement ID specified.","ID de acordo de faturamento especificado errado."
 "Wrong quote item id to update configuration.","ID da cotação do item errada para atualizar configuração."
 "Wrong state: ""%s"".","Estado inadequado: ""%s""."
 "Yes","Sim"
diff --git a/app/code/Magento/Sales/i18n/zh_CN.csv b/app/code/Magento/Sales/i18n/zh_CN.csv
index e582a6d5df15b3e0233021e2986659a39604051a..535be8dcca5f8fc577f77bbb42540683eda57c9e 100644
--- a/app/code/Magento/Sales/i18n/zh_CN.csv
+++ b/app/code/Magento/Sales/i18n/zh_CN.csv
@@ -11,7 +11,6 @@
 "* - Enter custom price excluding tax","* - 输入不含税的自定义价格"
 "* - Enter custom price including tax","* - 输入含税的自定义价格"
 "-- Please Select --","-- 请选择 --"
-"-- Please Select Billing Agreement--","-- 请选择记账协议 --"
 "About This Order:","关于此订单:"
 "About This Profile:","关于此资料:"
 "About Your Invoice","关于您的发票"
@@ -80,7 +79,6 @@
 "Authorized amount of %s.","授权额度 %s"
 "Authorizing amount of %s is pending approval on gateway.","授权额度 %s 正等待网关的审批。"
 "Back","返回"
-"Back to Billing Agreements","返回记账协议"
 "Back to My Orders","返回我的订单"
 "Back to Recurring Profiles","返回循环配置文件"
 "Backordered","延期"
@@ -88,11 +86,6 @@
 "Bill-to Name","记账姓名"
 "Billing","账单"
 "Billing Address","账单地址"
-"Billing Agreement","记账协议"
-"Billing Agreement # %s","记账协议 # %s"
-"Billing Agreement #%s","记账协议#%s"
-"Billing Agreement View","记账协议视图"
-"Billing Agreements","记账协议"
 "Billing Last Name","按姓氏记账"
 "Billing ZIP Code","按邮编记账"
 "Buy %s for price %s","以 %s 价格购买 %s"
@@ -164,7 +157,6 @@
 "Create new shipment for order","为订单创建新运单"
 "Create...","创建..."
 "Created","创建于"
-"Created billing agreement #%s.","创建记账协议 #%s。"
 "Created:","创建:"
 "Credit Memo","信用记录"
 "Credit Memo #","信用记录 #"
@@ -186,19 +178,15 @@
 "Custom Value","自定义值"
 "Customer","客户"
 "Customer Can Define Start Date","客户可以定义开始日期"
-"Email","客户邮件"
 "Customer Group","客户组"
-"Last Name","客户姓氏"
 "Customer My Account Order Creditmemo View","客户我的帐户订单信用记录视图"
 "Customer My Account Order History","客户我的帐户订单历史"
 "Customer My Account Order Invoice View","客户我的帐户订单发票视图"
 "Customer My Account Order Shipment View","客户我的帐户订单发货视图"
 "Customer My Account Order View","客户我的帐户订单视图"
-"First Name","顾客姓名"
 "Customer\'s Current Activities","客户的当前活动"
 "Customs Value","自定义值"
 "Date","日期"
-"Ship Date","发货日期"
 "Default Status","默认状态"
 "Default Template","默认模板"
 "Default logo, will be used in PDF and HTML documents.<br />(jpeg, tiff, png)","默认徽标,将用在PDF与HTML文档中。<br />(jpeg, tiff, png)"
@@ -215,7 +203,7 @@
 "Edit Order #%s","编辑订单 #%s"
 "Edit Order %s %s Address","编辑订单 %s %s地址"
 "Edit Order Status","编辑订单状态"
-"Email","电子邮件"
+"Email","客户邮件"
 "Email Address","编辑电子邮件地址"
 "Email Copy of Credit Memo","信用记录副本用邮件发送"
 "Email Copy of Invoice","发票副本用邮件发送"
@@ -230,23 +218,17 @@
 "Excl. Tax","不含税"
 "Expired","已过期"
 "Explanation","解释"
-"Failed to cancel the billing agreement.","取消记账协议时出错。"
-"Failed to create billing agreement for this order.","为该订单创建记账协议时出错。"
-"Failed to finish billing agreement wizard.","完成地记账协议向导时出错。"
 "Failed to send the order email.","发送订单邮件出错。"
-"Failed to start billing agreement wizard.","开始记账协议向导时出错。"
 "Failed to update the payment.","更新支付时出错。"
 "Failed to update the profile.","更新配置文件时出错。"
 "Failed to void the payment.","取消支付时出错。"
 "Fetch","获取"
 "File extension not known or unsupported type in the following shipment: %s","下列订单 %s 中存在未知文件扩展,或不支持的类型"
 "Find Order By:","订单查找条件:"
-"First Name","名字"
+"First Name","顾客姓名"
 "From","来自"
 "From Name","通过名称"
 "From:","来自:"
-"Grand Total (Base)","G.T.(基本)"
-"Grand Total (Purchased)","G.T.(已购买)"
 "General","常规"
 "General Information","常规信息"
 "Get Payment Update","获得支付更新"
@@ -260,6 +242,8 @@
 "Gift Wrapping for the Entire Order","整个订单的礼品包装"
 "Girth","周长"
 "Grand Total","总计"
+"Grand Total (Base)","G.T.(基本)"
+"Grand Total (Purchased)","G.T.(已购买)"
 "Grand Total to be Charged","需要收取的总费用"
 "Guest","来宾"
 "Height","高度"
@@ -267,8 +251,8 @@
 "Hold","暂挂"
 "Hold action is not available.","暂挂操作不可用。"
 "Hold order","暂挂订单"
-"ID","ID"
 "ID","ID#"
+"ID","ID"
 "IPN ""Refunded"". Refund issued by merchant. Registered notification about refunded amount of %s. Transaction ID: ""%s""","IPN ""已退款""。 商家发起的退款。%s 退款数量已注册通知。交易ID: ""%s"""
 "If empty, the default description above will be used.","如果为空,将使用上述默认描述。"
 "If empty, the default error above will be used.","如果为空,将使用上述默认错误。"
@@ -314,7 +298,6 @@
 "Invoice will be created without communication with payment gateway.","发票会在不与支付网关沟通的情况下创建。"
 "Invoiced","已出发票"
 "Invoices","发票"
-"Closed","已关闭"
 "Item","商品"
 "Item Status","商品状态"
 "Item object is not specified.","商品对象未指定。"
@@ -332,7 +315,7 @@
 "Items to Refund","要退货的商品"
 "Items to Ship","要发货的商品"
 "Key","密钥"
-"Last Name","姓氏"
+"Last Name","客户姓氏"
 "Last Ordered Items","上次订购的商品"
 "Last status can\'t be unassigned from state.","上次状态无法被取消分配。"
 "Length","长度"
@@ -361,7 +344,6 @@
 "N/A","N/A"
 "Name","姓名"
 "New","新建"
-"New Billing Agreement","新建记账协议"
 "New Credit Memo","新建信用记录"
 "New Credit Memo for Guest","为来宾新建信用记录"
 "New Credit Memo for Invoice #%s","为收据 #%s 新建信用记录"
@@ -413,8 +395,8 @@
 "Order","订单"
 "Order ","订单 #"
 "Order %s","订单 #%s"
-"Order %s %s | %s","订单 # %s %s | %s"
 "Order %s","订单# %s"
+"Order %s %s | %s","订单 # %s %s | %s"
 "Order %s - %s","订单 #%s - %s"
 "Order API","订单API"
 "Order Address Information","订单地址信息"
@@ -495,7 +477,6 @@
 "Pending","挂起"
 "Pending Payment","挂起的支付"
 "Period","周期"
-"Place Order Using Billing Agreements","使用记账协议下单"
 "Placed from IP","下单用的IP"
 "Please Select Products to Add","请选择要添加的产品"
 "Please Select a Customer","请选择一个客户"
@@ -537,10 +518,10 @@
 "Promotion Coupons Usage Report","促销代金券使用情况报告"
 "Proper payment object must be set.","必须设置恰当的支付对象。"
 "Purchase Order Number:","采购订单号"
-"Purchased From","购买自"
 "Purchase Point","购买自(店铺)"
-"Purchased Item","已购买内容"
 "Purchased Date","购买于"
+"Purchased From","购买自"
+"Purchased Item","已购买内容"
 "Qty","数量"
 "Qty Invoiced","已开发票数量"
 "Qty Ordered","下单的数量"
@@ -656,10 +637,11 @@
 "Send Tracking Information","发送追踪信息"
 "Set order for existing transactions not allowed","不允许对已存在的交易设置订单"
 "Ship","送货"
+"Ship Date","发货日期"
 "Ship To","送货至"
 "Ship-to Name","收货人"
-"Shipment","发货"
 "Shipment","送货单号"
+"Shipment","发货"
 "Shipment %1$s | %3$s (%2$s)","送货单号#%1$s | %3$s (%2$s)"
 "Shipment %s","送货单号#%s"
 "Shipment Comment Email Sender","送货评价邮件发送者"
@@ -724,8 +706,6 @@
 "Telephone","电话"
 "The Order State ""%s"" must not be set manually.","订单状态 ""%s"" 必须手工设置。"
 "The address total model should be extended from \Magento\Sales\Model\Quote\Address\Total\AbstractTotal.","地址总模块应扩展自\Magento\Sales\Model\Quote\Address\Total\AbstractTotal。"
-"The billing agreement ""%s"" has been canceled.","该记账协议 ""%s"" 已被取消。"
-"The billing agreement ""%s"" has been created.","该记账协议 ""%s"" 已被创建。"
 "The coupon code has been accepted.","该代金券代码已被使用。"
 "The message has been sent.","该信息已发送。"
 "The message was sent.","消息已发送。"
@@ -755,7 +735,6 @@
 "The transaction ""%s"" (%s) is already closed.","交易 ""%s"" (%s) 已被关闭。"
 "The transaction ""%s"" cannot be captured yet.","交易 ""%s"" 尚无法获取。"
 "The value that you entered is not valid.","你输入的数值无效。"
-"There are no billing agreements yet.","尚无记账协议。"
 "There are no printable documents related to selected orders.","没有与所选订单有关的可打印文档。"
 "There are no shipping labels related to selected %s.","没有与所选 %s 有关的发货标签。"
 "There is no need to approve this payment.","无需审核该支付。"
@@ -844,7 +823,6 @@
 "Whether buyer can define the date when billing for the profile begins.","卖家是否可以在简介开始时定义日期。"
 "Width","宽"
 "Wishlist","愿望清单"
-"Wrong billing agreement ID specified.","指定的记账协议ID有误。"
 "Wrong quote item id to update configuration.","更新配置的报价项目ID错误。"
 "Wrong state: ""%s"".","州错误:""%s"""
 "Yes","是"
diff --git a/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php b/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php
index 88f7b56e8b6b4c02c8142cf0a89d54742b562aa2..6c6e88adb29852d2127678d07352cdaa8cd3b29d 100644
--- a/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php
+++ b/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php
@@ -3204,262 +3204,6 @@ $table = $installer->getConnection()
     ->setComment('Sales Bestsellers Aggregated Yearly');
 $installer->getConnection()->createTable($table);
 
-
-/**
- * Create table 'sales_billing_agreement'
- */
-$table = $installer->getConnection()
-    ->newTable($installer->getTable('sales_billing_agreement'))
-    ->addColumn('agreement_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'identity'  => true,
-        'unsigned'  => true,
-        'nullable'  => false,
-        'primary'   => true,
-        ), 'Agreement Id')
-    ->addColumn('customer_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        ), 'Customer Id')
-    ->addColumn('method_code', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
-        'nullable'  => false,
-        ), 'Method Code')
-    ->addColumn('reference_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
-        'nullable'  => false,
-        ), 'Reference Id')
-    ->addColumn('status', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
-        'nullable'  => false,
-        ), 'Status')
-    ->addColumn('created_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
-        'nullable'  => false,
-        ), 'Created At')
-    ->addColumn('updated_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
-        ), 'Updated At')
-    ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Store Id')
-    ->addColumn('agreement_label', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array(
-        ), 'Agreement Label')
-    ->addIndex($installer->getIdxName('sales_billing_agreement', array('customer_id')),
-        array('customer_id'))
-    ->addIndex($installer->getIdxName('sales_billing_agreement', array('store_id')),
-        array('store_id'))
-    ->addForeignKey($installer->getFkName('sales_billing_agreement', 'customer_id', 'customer_entity', 'entity_id'),
-        'customer_id', $installer->getTable('customer_entity'), 'entity_id',
-        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->addForeignKey($installer->getFkName('sales_billing_agreement', 'store_id', 'core_store', 'store_id'),
-        'store_id', $installer->getTable('core_store'), 'store_id',
-        \Magento\DB\Ddl\Table::ACTION_SET_NULL, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->setComment('Sales Billing Agreement');
-$installer->getConnection()->createTable($table);
-
-
-/**
- * Create table 'sales_billing_agreement_order'
- */
-$table = $installer->getConnection()
-    ->newTable($installer->getTable('sales_billing_agreement_order'))
-    ->addColumn('agreement_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        'primary'   => true,
-        ), 'Agreement Id')
-    ->addColumn('order_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        'primary'   => true,
-        ), 'Order Id')
-    ->addIndex($installer->getIdxName('sales_billing_agreement_order', array('order_id')),
-        array('order_id'))
-    ->addForeignKey(
-        $installer->getFkName(
-            'sales_billing_agreement_order',
-            'agreement_id',
-            'sales_billing_agreement',
-            'agreement_id'
-        ),
-        'agreement_id', $installer->getTable('sales_billing_agreement'), 'agreement_id',
-        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->addForeignKey($installer->getFkName('sales_billing_agreement_order', 'order_id', 'sales_flat_order', 'entity_id'),
-        'order_id', $installer->getTable('sales_flat_order'), 'entity_id',
-        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->setComment('Sales Billing Agreement Order');
-$installer->getConnection()->createTable($table);
-
-
-/**
- * Create table 'sales_recurring_profile'
- */
-$table = $installer->getConnection()
-    ->newTable($installer->getTable('sales_recurring_profile'))
-    ->addColumn('profile_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'identity'  => true,
-        'unsigned'  => true,
-        'nullable'  => false,
-        'primary'   => true,
-        ), 'Profile Id')
-    ->addColumn('state', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
-        'nullable'  => false,
-        ), 'State')
-    ->addColumn('customer_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'unsigned'  => true,
-        ), 'Customer Id')
-    ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Store Id')
-    ->addColumn('method_code', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
-        'nullable'  => false,
-        ), 'Method Code')
-    ->addColumn('created_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
-        'nullable'  => false,
-        ), 'Created At')
-    ->addColumn('updated_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
-        ), 'Updated At')
-    ->addColumn('reference_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 32, array(
-        ), 'Reference Id')
-    ->addColumn('subscriber_name', \Magento\DB\Ddl\Table::TYPE_TEXT, 150, array(
-        ), 'Subscriber Name')
-    ->addColumn('start_datetime', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array(
-        'nullable'  => false,
-        ), 'Start Datetime')
-    ->addColumn('internal_reference_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 42, array(
-        'nullable'  => false,
-        ), 'Internal Reference Id')
-    ->addColumn('schedule_description', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array(
-        'nullable'  => false,
-        ), 'Schedule Description')
-    ->addColumn('suspension_threshold', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Suspension Threshold')
-    ->addColumn('bill_failed_later', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        'default'   => '0',
-        ), 'Bill Failed Later')
-    ->addColumn('period_unit', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
-        'nullable'  => false,
-        ), 'Period Unit')
-    ->addColumn('period_frequency', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Period Frequency')
-    ->addColumn('period_max_cycles', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Period Max Cycles')
-    ->addColumn('billing_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
-        'nullable'  => false,
-        'default'   => '0.0000',
-        ), 'Billing Amount')
-    ->addColumn('trial_period_unit', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array(
-        ), 'Trial Period Unit')
-    ->addColumn('trial_period_frequency', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Trial Period Frequency')
-    ->addColumn('trial_period_max_cycles', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        ), 'Trial Period Max Cycles')
-    ->addColumn('trial_billing_amount', \Magento\DB\Ddl\Table::TYPE_TEXT, null, array(
-        ), 'Trial Billing Amount')
-    ->addColumn('currency_code', \Magento\DB\Ddl\Table::TYPE_TEXT, 3, array(
-        'nullable'  => false,
-        ), 'Currency Code')
-    ->addColumn('shipping_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
-        ), 'Shipping Amount')
-    ->addColumn('tax_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
-        ), 'Tax Amount')
-    ->addColumn('init_amount', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array(
-        ), 'Init Amount')
-    ->addColumn('init_may_fail', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        'default'   => '0',
-        ), 'Init May Fail')
-    ->addColumn('order_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
-        'nullable'  => false,
-        ), 'Order Info')
-    ->addColumn('order_item_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
-        'nullable'  => false,
-        ), 'Order Item Info')
-    ->addColumn('billing_address_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
-        'nullable'  => false,
-        ), 'Billing Address Info')
-    ->addColumn('shipping_address_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
-        ), 'Shipping Address Info')
-    ->addColumn('profile_vendor_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
-        ), 'Profile Vendor Info')
-    ->addColumn('additional_info', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array(
-        ), 'Additional Info')
-    ->addIndex(
-        $installer->getIdxName(
-            'sales_recurring_profile',
-            array('internal_reference_id'),
-            \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
-        ),
-        array('internal_reference_id'), array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE))
-    ->addIndex($installer->getIdxName('sales_recurring_profile', array('customer_id')),
-        array('customer_id'))
-    ->addIndex($installer->getIdxName('sales_recurring_profile', array('store_id')),
-        array('store_id'))
-    ->addForeignKey($installer->getFkName('sales_recurring_profile', 'customer_id', 'customer_entity', 'entity_id'),
-        'customer_id', $installer->getTable('customer_entity'), 'entity_id',
-        \Magento\DB\Ddl\Table::ACTION_SET_NULL, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->addForeignKey($installer->getFkName('sales_recurring_profile', 'store_id', 'core_store', 'store_id'),
-        'store_id', $installer->getTable('core_store'), 'store_id',
-        \Magento\DB\Ddl\Table::ACTION_SET_NULL, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->setComment('Sales Recurring Profile');
-$installer->getConnection()->createTable($table);
-
-
-/**
- * Create table 'sales_recurring_profile_order'
- */
-$table = $installer->getConnection()
-    ->newTable($installer->getTable('sales_recurring_profile_order'))
-    ->addColumn('link_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'identity'  => true,
-        'unsigned'  => true,
-        'nullable'  => false,
-        'primary'   => true,
-        ), 'Link Id')
-    ->addColumn('profile_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        'default'   => '0',
-        ), 'Profile Id')
-    ->addColumn('order_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array(
-        'unsigned'  => true,
-        'nullable'  => false,
-        'default'   => '0',
-        ), 'Order Id')
-    ->addIndex(
-        $installer->getIdxName(
-            'sales_recurring_profile_order',
-            array('profile_id', 'order_id'),
-            \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
-        ),
-        array('profile_id', 'order_id'), array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE))
-    ->addIndex($installer->getIdxName('sales_recurring_profile_order', array('order_id')),
-        array('order_id'))
-    ->addForeignKey(
-        $installer->getFkName(
-            'sales_recurring_profile_order',
-            'order_id',
-            'sales_flat_order',
-            'entity_id'
-        ),
-        'order_id', $installer->getTable('sales_flat_order'), 'entity_id',
-        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->addForeignKey(
-        $installer->getFkName(
-            'sales_recurring_profile_order',
-            'profile_id',
-            'sales_recurring_profile',
-            'profile_id'
-        ),
-        'profile_id', $installer->getTable('sales_recurring_profile'), 'profile_id',
-        \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE)
-    ->setComment('Sales Recurring Profile Order');
-$installer->getConnection()->createTable($table);
-
-
 /**
  * Create table 'sales_order_tax'
  */
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_grid.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_grid.xml
deleted file mode 100644
index 230f7e5b2a072a524000c904a7d3a00d7a1086de..0000000000000000000000000000000000000000
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_billing_agreement_grid.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <block class="Magento\Sales\Block\Adminhtml\Billing\Agreement\Grid" name="sales.billing.agreement.grid" output="1"/>
-</layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_customergrid.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_customergrid.xml
deleted file mode 100644
index 032d5c7ce9ef9c5ec96fdbaf2ae94f1ba01e05b7..0000000000000000000000000000000000000000
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_recurring_profile_customergrid.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Academic Free License (AFL 3.0)
- * that is bundled with this package in the file LICENSE_AFL.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/afl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
--->
-<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-    <block class="Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring\Profile" name="customer.recurring.profile.grid" output="1"/>
-</layout>
diff --git a/app/code/Magento/Sales/view/adminhtml/order/create/data.phtml b/app/code/Magento/Sales/view/adminhtml/order/create/data.phtml
index 1bf9054294a0e5758a4caa7e430c343818832f06..79f2e3f54d4400e63dd6cf751371924512469392 100644
--- a/app/code/Magento/Sales/view/adminhtml/order/create/data.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/order/create/data.phtml
@@ -46,7 +46,7 @@
         <div class="order-details-inner">
             <div id="order-additional_area" style="display:none" class="fieldset-wrapper order-additional-area"><?php echo $this->getChildHtml('additional_area') ?></div>
             <div id="order-search" style="display:none" class="fieldset-wrapper order-search-items"><?php echo $this->getChildHtml('search') ?></div>
-            <div id="order-items" class="order-items fieldset-wrapper" data-mage-init="{loader: {}}"><?php echo $this->getChildHtml('items') ?></div>
+            <div id="order-items" class="order-items fieldset-wrapper" data-mage-init='{"loader": {}}'><?php echo $this->getChildHtml('items') ?></div>
             <div id="order-errors" class="order-errors"><?php echo $this->getChildHtml('errors') ?></div>
             <div id="order-form_account" class="order-account-information fieldset-wrapper"><?php echo $this->getChildHtml('form_account') ?></div>
 
diff --git a/app/code/Magento/Sales/view/frontend/layout/customer_account.xml b/app/code/Magento/Sales/view/frontend/layout/customer_account.xml
index 3d13de8ffc0f58589a2bfc33a93837506ae2c81e..063f63e00c303eb93b015a970f5d62085007a6d6 100644
--- a/app/code/Magento/Sales/view/frontend/layout/customer_account.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/customer_account.xml
@@ -25,26 +25,12 @@
 -->
 <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <referenceBlock name="customer_account_navigation">
-        <block class="Magento\View\Element\Html\Link\Current" name="customer-account-navigation-billing-agreements-link">
-            <arguments>
-                <argument name="path" xsi:type="string">sales/billing_agreement</argument>
-                <argument name="label" xsi:type="string">Billing Agreements</argument>
-            </arguments>
-        </block>
         <block class="Magento\View\Element\Html\Link\Current" name="customer-account-navigation-orders-link">
             <arguments>
                 <argument name="path" xsi:type="string">sales/order/history</argument>
                 <argument name="label" xsi:type="string">My Orders</argument>
             </arguments>
         </block>
-        <block class="Magento\View\Element\Html\Link\Current" name="customer-account-navigation-recurring-profiles-link">
-            <arguments>
-                <argument name="path" xsi:type="string">sales/recurring_profile</argument>
-                <argument name="label" xsi:type="string">Recurring Profiles</argument>
-            </arguments>
-        </block>
     </referenceBlock>
-    <referenceContainer name="left">
-        <block class="Magento\Sales\Block\Reorder\Sidebar" name="sale.reorder.sidebar" as="reorder" template="reorder/sidebar.phtml" cacheable="false"/>
-    </referenceContainer>
+    <move element="sale.reorder.sidebar" destination="left"/>
 </layout>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_guest_info_links.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_guest_info_links.xml
index a9dd0a2ab7ce1a2379fb49c09adec985b131b314..6dee5a25ec2ffd504a247e6e06fe28a966999773 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_guest_info_links.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_guest_info_links.xml
@@ -29,7 +29,7 @@
             <arguments>
                 <argument name="css_class" xsi:type="string">items</argument>
             </arguments>
-            <block class="Magento\Sales\Block\Order\Link" name="sales.order.info.links.billing-agreements">
+            <block class="Magento\Sales\Block\Order\Link" name="sales.order.info.links.information">
                 <arguments>
                     <argument name="path" xsi:type="string">sales/guest/view</argument>
                     <argument name="label" xsi:type="string">Order Information</argument>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_info_links.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_info_links.xml
index c19370f9acf36fa1a2b3f6ff7179a6d0dd261b30..3c24bd12b5d8b18825ace4a44c042a76a9e49650 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_info_links.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_info_links.xml
@@ -29,7 +29,7 @@
             <arguments>
                 <argument name="css_class" xsi:type="string">items</argument>
             </arguments>
-            <block class="Magento\Sales\Block\Order\Link" name="sales.order.info.links.billing-agreements">
+            <block class="Magento\Sales\Block\Order\Link" name="sales.order.info.links.information">
                 <arguments>
                     <argument name="path" xsi:type="string">sales/order/view</argument>
                     <argument name="label" xsi:type="string">Order Information</argument>
diff --git a/app/code/Magento/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml
index 41d9c246a8df8d87b092e7bd5953197817862746..c4b56ef046d173b1cc6d2597988b7027c2e2359f 100644
--- a/app/code/Magento/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/order/creditmemo/items/renderer/default.phtml
@@ -35,7 +35,7 @@
             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
             <?php if (!$this->getPrintStatus()): ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                     <div class="truncated_full_value">
                         <dl class="item options">
diff --git a/app/code/Magento/Sales/view/frontend/order/invoice/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/order/invoice/items/renderer/default.phtml
index 60d37bd8a5f4b64ab1055ddcdf8048de2e7ea669..2191919489ed9b2cf4437ba1d8839d625c3aa7ad 100644
--- a/app/code/Magento/Sales/view/frontend/order/invoice/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/order/invoice/items/renderer/default.phtml
@@ -34,7 +34,7 @@
             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
             <?php if (!$this->getPrintStatus()): ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                     <?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                     <div class="truncated_full_value">
diff --git a/app/code/Magento/Sales/view/frontend/order/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/order/items/renderer/default.phtml
index e722805b2bc0ee9b05afc0ae57e9374138453fdc..0fa187bece7056cb55d957d9b680f67f260ac19e 100644
--- a/app/code/Magento/Sales/view/frontend/order/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/order/items/renderer/default.phtml
@@ -33,7 +33,7 @@
             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
             <?php if (!$this->getPrintStatus()): ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                     <?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                     <div class="truncated_full_value">
diff --git a/app/code/Magento/Sales/view/frontend/order/shipment/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/order/shipment/items/renderer/default.phtml
index c0f445281b97f630834a27df98b502773b581390..50275ae3c816f109f8a75466679fe18c42acf7ca 100644
--- a/app/code/Magento/Sales/view/frontend/order/shipment/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/order/shipment/items/renderer/default.phtml
@@ -34,7 +34,7 @@
             <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
             <?php if (!$this->getPrintStatus()): ?>
                 <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
-                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>>
+                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init='{"truncateOptions":[]}'<?php endif; ?>>
                     <?php echo $_formatedOptionValue['value'] ?>
                     <?php if (isset($_formatedOptionValue['full_view'])): ?>
                     <div class="truncated_full_value">
diff --git a/app/code/Magento/SalesRule/etc/crontab.xml b/app/code/Magento/SalesRule/etc/crontab.xml
index 6b33cf907f028cf51d8692f8730aefdce4d1dca6..2d6e4dfc2c28a4e45b44ecd811e0d34e771b9fec 100644
--- a/app/code/Magento/SalesRule/etc/crontab.xml
+++ b/app/code/Magento/SalesRule/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="aggregate_sales_report_coupons_data" instance="Magento\SalesRule\Model\Observer" method="aggregateSalesReportCouponsData">
-        <schedule>0 0 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="aggregate_sales_report_coupons_data" instance="Magento\SalesRule\Model\Observer" method="aggregateSalesReportCouponsData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Sendfriend/Model/Observer.php b/app/code/Magento/Sendfriend/Model/Observer.php
index d7caa7c49d70d83cecdac9977b6adb0f51406f13..d3d7ba42a0c7eb6177d687164e9f8732aee847ff 100644
--- a/app/code/Magento/Sendfriend/Model/Observer.php
+++ b/app/code/Magento/Sendfriend/Model/Observer.php
@@ -54,7 +54,7 @@ class Observer
      * Register Sendfriend Model in global registry
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Sendfriend\Model\Observer
+     * @return $this
      */
     public function register(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php
index 027ea8624284e7fdc538a6c012b240cf0f2f9ef8..c648ce192688d1defb54ea6f746fa34d82b69651 100644
--- a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php
+++ b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Sendfriend\Model\Resource;
 
 /**
  * SendFriend Log Resource Model
@@ -32,13 +32,12 @@
  * @package     Magento_Sendfriend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sendfriend\Model\Resource;
-
 class Sendfriend extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Initialize connection and table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -78,7 +77,7 @@ class Sendfriend extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int $ip
      * @param int $startTime
      * @param int $websiteId
-     * @return \Magento\Sendfriend\Model\Resource\Sendfriend
+     * @return $this
      */
     public function addSendItem($ip, $startTime, $websiteId)
     {
@@ -97,7 +96,7 @@ class Sendfriend extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete Old logs
      *
      * @param int $time
-     * @return \Magento\Sendfriend\Model\Resource\Sendfriend
+     * @return $this
      */
     public function deleteLogsBefore($time)
     {
diff --git a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php
index 4f2ffe26aab37b70631910eb3ff5425e28070934..23b1bae0a5ee331d862201bf987ac3f5f8da95b4 100644
--- a/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php
+++ b/app/code/Magento/Sendfriend/Model/Resource/Sendfriend/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\Sendfriend\Model\Resource\Sendfriend;
 
 /**
  * Sendfriend log resource collection
@@ -32,13 +32,12 @@
  * @package     Magento_Sendfriend
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Sendfriend\Model\Resource\Sendfriend;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Init resource collection
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Sendfriend/Model/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Sendfriend.php
index 7d650e67f9c81c53b6761afc2ccfddb077265435..0050b74b0aa04635306f1ba5ea4ed7f28c778495 100644
--- a/app/code/Magento/Sendfriend/Model/Sendfriend.php
+++ b/app/code/Magento/Sendfriend/Model/Sendfriend.php
@@ -152,6 +152,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Shipping/etc/crontab.xml b/app/code/Magento/Shipping/etc/crontab.xml
index 4bd12111cd07b80b9aa4f59cf2a298b7d6aee4d3..c5241e512a08af4b01841c968a4801a903a5045e 100644
--- a/app/code/Magento/Shipping/etc/crontab.xml
+++ b/app/code/Magento/Shipping/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="aggregate_sales_report_shipment_data" instance="Magento\Shipping\Model\Observer" method="aggregateSalesReportShipmentData">
-        <schedule>0 0 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="aggregate_sales_report_shipment_data" instance="Magento\Shipping\Model\Observer" method="aggregateSalesReportShipmentData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Shipping/view/frontend/items.phtml b/app/code/Magento/Shipping/view/frontend/items.phtml
index 5ae077024d8a08bfa85f4fd2729bfac280af02c7..f0714b3eeb21caa016ea59b844837139e7a26644 100644
--- a/app/code/Magento/Shipping/view/frontend/items.phtml
+++ b/app/code/Magento/Shipping/view/frontend/items.phtml
@@ -46,7 +46,7 @@
         <span><?php echo __('Print Shipment') ?></span
     </a>
     <a href="#"
-       data-mage-init="{popupWindow: {windowURL:'<?php echo $this->helper('Magento\Shipping\Helper\Data')->getTrackingPopupUrlBySalesModel($_shipment) ?>',windowName:'trackshipment',width:800,height:600,top:0,left:0,resizable:1,scrollbars:1}}"
+       data-mage-init='{"popupWindow": {"windowURL":"<?php echo $this->helper('Magento\Shipping\Helper\Data')->getTrackingPopupUrlBySalesModel($_shipment) ?>","windowName":"trackshipment","width":800,"height":600,"top":0,"left":0,"resizable":1,"scrollbars":1}}'
        title="<?php echo __('Track this shipment') ?>"
        class="action track">
         <span><?php echo __('Track this shipment') ?></span>
@@ -67,7 +67,7 @@
                     <?php echo $this->escapeHtml($track->getNumber()) ?>
                 <?php else: ?>
                     <a href="#"
-                       data-mage-init="{popupWindow: {windowURL:'<?php echo $this->helper('Magento\Shipping\Helper\Data')->getTrackingPopupUrlBySalesModel($track) ?>',windowName:'trackorder',width:800,height:600,left:0,top:0,resizable:1,scrollbars:1}}"
+                       data-mage-init='{"popupWindow": {"windowURL":"<?php echo $this->helper('Magento\Shipping\Helper\Data')->getTrackingPopupUrlBySalesModel($track) ?>","windowName":"trackorder","width":800,"height":600,"left":0,"top":0,"resizable":1,"scrollbars":1}}'
                        class="action track">
                         <span><?php echo $this->escapeHtml($track->getNumber()) ?></span>
                     </a>
diff --git a/app/code/Magento/Shipping/view/frontend/tracking/link.phtml b/app/code/Magento/Shipping/view/frontend/tracking/link.phtml
index 2eb73dab6b67388dc6b5a1a85bd43d3fd0084085..cd4ab6e3535bca8ac6e4449d04a047f6d90a3678 100644
--- a/app/code/Magento/Shipping/view/frontend/tracking/link.phtml
+++ b/app/code/Magento/Shipping/view/frontend/tracking/link.phtml
@@ -25,6 +25,6 @@
 <?php /** @var $this \Magento\Shipping\Block\Tracking\Link */ ?>
 <?php $order = $this->getOrder() ?>
 <a href="#" class="action track" title="<?php echo $this->getLabel() ?>"
-   data-mage-init="{popupWindow: {windowURL:'<?php echo $this->getWindowUrl($order) ?>',windowName:'trackorder',width:800,height:600,left:0,top:0,resizable:1,scrollbars:1}}">
+   data-mage-init='{"popupWindow": {"windowURL":"<?php echo $this->getWindowUrl($order) ?>","windowName":"trackorder","width":800,"height":600,"left":0,"top":0,"resizable":1,"scrollbars":1}}'>
     <span><?php echo $this->getLabel()?></span>
-</a>
\ No newline at end of file
+</a>
diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php
index 8d1fd206151b5caf5364bda01acb46e49dd85509..0a8d644e19601320c163d1523234415d7dbaa8c7 100644
--- a/app/code/Magento/Sitemap/Model/Observer.php
+++ b/app/code/Magento/Sitemap/Model/Observer.php
@@ -45,7 +45,7 @@ class Observer
     /**
      * Cronjob expression configuration
      */
-    const XML_PATH_CRON_EXPR = 'crontab/jobs/generate_sitemaps/schedule/cron_expr';
+    const XML_PATH_CRON_EXPR = 'crontab/default/jobs/generate_sitemaps/schedule/cron_expr';
 
     /**
      * Error email template configuration
diff --git a/app/code/Magento/Sitemap/etc/crontab.xml b/app/code/Magento/Sitemap/etc/crontab.xml
index e8dbb3cd0aeccd011d8b372bd93047a1efc898ac..d8a8e351247d973e8f63d3d6713ef1bb571c1138 100644
--- a/app/code/Magento/Sitemap/etc/crontab.xml
+++ b/app/code/Magento/Sitemap/etc/crontab.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="sitemap_generate" instance="Magento\Sitemap\Model\Observer" method="scheduledGenerateSitemaps" />
+    <group id="default">
+        <job name="sitemap_generate" instance="Magento\Sitemap\Model\Observer" method="scheduledGenerateSitemaps" />
+    </group>
 </config>
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php
index e3072c0d99365fa296b59c3317229d5f26d93179..b55f7a496c0990c5ab314bcb1ea8aeaa42e700f7 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Tax\Block\Adminhtml\Frontend\Region;
 
+use Magento\Data\Form\Element\AbstractElement;
+
 class Updater
     extends \Magento\Backend\Block\System\Config\Form\Field
 {
@@ -48,7 +50,11 @@ class Updater
         parent::__construct($context, $data);
     }
 
-    protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element)
+    /**
+     * @param AbstractElement $element
+     * @return string
+     */
+    protected function _getElementHtml(AbstractElement $element)
     {
         $html = parent::_getElementHtml($element);
 
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php
index 992cb80a90329fd01652fb37e1c173fa9fe9f373..f849a18be72c7509ac57ecbe01257c7a14a2d201 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php
@@ -38,21 +38,27 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
     const FORM_ELEMENT_ID = 'rate-form';
 
+    /**
+     * @var null
+     */
     protected $_titles = null;
 
+    /**
+     * @var string
+     */
     protected $_template = 'rate/form.phtml';
 
     /**
      * Tax data
      *
-     * @var \Magento\Tax\Helper\Data
+     * @var \Magento\Tax\Helper\Data|null
      */
     protected $_taxData = null;
 
     /**
-     * @var \Magento\Tax\Block\Adminhtml\Rate\Title\Fieldset
+     * @var \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory
      */
-    protected $_fieldset;
+    protected $_fieldsetFactory;
 
     /**
      * @var \Magento\Tax\Model\Calculation\RateFactory
@@ -80,7 +86,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
      * @param \Magento\Data\FormFactory $formFactory
      * @param \Magento\Directory\Model\RegionFactory $regionFactory
      * @param \Magento\Directory\Model\Config\Source\Country $country
-     * @param \Magento\Tax\Block\Adminhtml\Rate\Title\Fieldset $fieldset
+     * @param \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory $fieldsetFactory
      * @param \Magento\Tax\Model\Calculation\RateFactory $rateFactory
      * @param \Magento\Tax\Model\Calculation\Rate $rate
      * @param \Magento\Tax\Helper\Data $taxData
@@ -92,7 +98,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
         \Magento\Data\FormFactory $formFactory,
         \Magento\Directory\Model\RegionFactory $regionFactory,
         \Magento\Directory\Model\Config\Source\Country $country,
-        \Magento\Tax\Block\Adminhtml\Rate\Title\Fieldset $fieldset,
+        \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory $fieldsetFactory,
         \Magento\Tax\Model\Calculation\RateFactory $rateFactory,
         \Magento\Tax\Model\Calculation\Rate $rate,
         \Magento\Tax\Helper\Data $taxData,
@@ -100,13 +106,16 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     ) {
         $this->_regionFactory = $regionFactory;
         $this->_country = $country;
-        $this->_fieldset = $fieldset;
+        $this->_fieldsetFactory = $fieldsetFactory;
         $this->_rateFactory = $rateFactory;
         $this->_rate = $rate;
         $this->_taxData = $taxData;
         parent::__construct($context, $registry, $formFactory, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -114,6 +123,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
 
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareForm()
     {
         $rateObject = new \Magento\Object($this->_rate->getData());
@@ -228,7 +240,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
 
         if (!$this->_storeManager->hasSingleStore()) {
             $form->addElement(
-                $this->_fieldset->setLegend(__('Tax Titles'))
+                $this->_fieldsetFactory->create()->setLegend(__('Tax Titles'))
             );
         }
 
@@ -251,7 +263,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Get Tax Rates Collection
      *
-     * @return array
+     * @return mixed
      */
     public function getRateCollection()
     {
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php
index 05656925f3d1ec89c1a9e20477afff511cd36f6b..7951e800bffa8a757f640faaaadd9a5417b6aa77 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php
@@ -36,6 +36,10 @@ namespace Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer;
 
 class Data extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
 {
+    /**
+     * @param \Magento\Object $row
+     * @return int|string
+     */
     protected function _getValue (\Magento\Object $row)
     {
         $data = parent::_getValue($row);
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php
index 700a98169c6d972bb39db02ca0da471140a5b861..3ad0a75dd504435412509f210277216c5b2b38c6 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/ImportExport.php
@@ -29,6 +29,9 @@ namespace Magento\Tax\Block\Adminhtml\Rate;
 
 class ImportExport extends \Magento\Backend\Block\Widget
 {
+    /**
+     * @var string
+     */
     protected $_template = 'importExport.phtml';
 
     /**
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php
index 28db98d5f9143cb6d48c92c8f9fc437adee0d358..7a3c4232cf7b7046c2a8fb4d22e8c6029a36d7a5 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php
@@ -34,8 +34,14 @@ namespace Magento\Tax\Block\Adminhtml\Rate;
 
 class Title extends \Magento\View\Element\Template
 {
+    /**
+     * @var array
+     */
     protected $_titles;
 
+    /**
+     * @var string
+     */
     protected $_template = 'rate/title.phtml';
 
     /**
@@ -65,6 +71,9 @@ class Title extends \Magento\View\Element\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return array
+     */
     public function getTitles()
     {
         if (is_null($this->_titles)) {
@@ -82,6 +91,9 @@ class Title extends \Magento\View\Element\Template
         return $this->_titles;
     }
 
+    /**
+     * @return mixed
+     */
     public function getStores()
     {
         $stores = $this->getData('stores');
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php
index 13741eb10fddad1c54f367ec2bf737714373afe0..8538d46ae742b5cfc4f2ace68425861260a419e5 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php
@@ -57,6 +57,9 @@ class Fieldset extends \Magento\Data\Form\Element\Fieldset
         parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
     }
 
+    /**
+     * @return string
+     */
     public function getBasicChildrenHtml()
     {
         return $this->_title->toHtml();
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php
index 65cdf0ba52e72b2253ab631adae9ea0152c160f1..d100569c02b921d0c3ecc7b451c14cd966a82b20 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php
@@ -37,8 +37,14 @@ namespace Magento\Tax\Block\Adminhtml\Rate\Toolbar;
 class Add extends \Magento\Backend\Block\Template
 {
 
+    /**
+     * @var string
+     */
     protected $_template = 'toolbar/rate/add.phtml';
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->addChild('addButton', 'Magento\Backend\Block\Widget\Button', array(
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php
index 26f5b174e4a28ecc17b8e776caceb07646cda315..44bd92a67076d7e539130157301cf2764bd12ab4 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php
@@ -37,8 +37,14 @@ namespace Magento\Tax\Block\Adminhtml\Rate\Toolbar;
 class Save extends \Magento\Backend\Block\Template
 {
 
+    /**
+     * @var string
+     */
     protected $_template = 'toolbar/rate/save.phtml';
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -46,6 +52,9 @@ class Save extends \Magento\Backend\Block\Template
 
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->addChild('backButton', 'Magento\Backend\Block\Widget\Button', array(
@@ -72,16 +81,25 @@ class Save extends \Magento\Backend\Block\Template
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getBackButtonHtml()
     {
         return $this->getChildHtml('backButton');
     }
 
+    /**
+     * @return string
+     */
     public function getResetButtonHtml()
     {
         return $this->getChildHtml('resetButton');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveButtonHtml()
     {
         $formId = $this->getLayout()->getBlock('tax_rate_form')->getDestElementId();
@@ -94,6 +112,9 @@ class Save extends \Magento\Backend\Block\Template
         return $this->getChildHtml('saveButton');
     }
 
+    /**
+     * @return string|void
+     */
     public function getDeleteButtonHtml()
     {
         if( intval($this->getRequest()->getParam('rate')) == 0 ) {
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php
index 2954e84730097d9e6f464244cb5afb2ccebe0ac4..383d32d0b461e09fca2347556fc590cc53f0b7b0 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php
@@ -56,6 +56,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
     /**
      * Init class
      *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php
index ee8127f1168284fe27389a840932ebd2825f6c54..0da1fc646b0b6a0500e3771344c8ddf2efe2c0b7 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php
@@ -62,6 +62,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
 
     /**
      * Init class
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -73,7 +75,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     * return \Magento\Backend\Block\Widget\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
diff --git a/app/code/Magento/Tax/Block/Checkout/Tax.php b/app/code/Magento/Tax/Block/Checkout/Tax.php
index 723b47493dd0cda66d5d8f152d99e01b9e0450d7..6c3eceb0dc15883d59e596567e7addc9038efdc2 100644
--- a/app/code/Magento/Tax/Block/Checkout/Tax.php
+++ b/app/code/Magento/Tax/Block/Checkout/Tax.php
@@ -31,5 +31,8 @@ namespace Magento\Tax\Block\Checkout;
 
 class Tax extends \Magento\Checkout\Block\Total\DefaultTotal
 {
+    /**
+     * @var string
+     */
     protected $_template = 'checkout/tax.phtml';
 }
diff --git a/app/code/Magento/Tax/Block/Sales/Order/Tax.php b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
index 54bfa0cf8eef0e7129653998c52281a1569de4dc..58bfc0f128004d9c6217d2fd43f431e46296c982 100644
--- a/app/code/Magento/Tax/Block/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
@@ -29,6 +29,8 @@
  */
 namespace Magento\Tax\Block\Sales\Order;
 
+use Magento\Sales\Model\Order;
+
 class Tax extends \Magento\View\Element\Template
 {
     /**
@@ -37,7 +39,15 @@ class Tax extends \Magento\View\Element\Template
      * @var \Magento\Tax\Model\Config
      */
     protected $_config;
+
+    /**
+     * @var Order
+     */
     protected $_order;
+
+    /**
+     * @var \Magento\Object
+     */
     protected $_source;
 
     /**
@@ -126,6 +136,9 @@ class Tax extends \Magento\View\Element\Template
         return $this->_order->getStore();
     }
 
+    /**
+     * @return $this
+     */
     protected function _initSubtotal()
     {
         $store  = $this->getStore();
@@ -189,6 +202,9 @@ class Tax extends \Magento\View\Element\Template
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     protected function _initShipping()
     {
         $store  = $this->getStore();
@@ -244,6 +260,9 @@ class Tax extends \Magento\View\Element\Template
         return $this;
     }
 
+    /**
+     * @return void
+     */
     protected function _initDiscount()
     {
 //        $store  = $this->getStore();
@@ -255,6 +274,9 @@ class Tax extends \Magento\View\Element\Template
 //        }
     }
 
+    /**
+     * @return $this
+     */
     protected function _initGrandTotal()
     {
         $store  = $this->getStore();
@@ -292,16 +314,25 @@ class Tax extends \Magento\View\Element\Template
         return $this;
     }
 
+    /**
+     * @return Order
+     */
     public function getOrder()
     {
         return $this->_order;
     }
 
+    /**
+     * @return array
+     */
     public function getLabelProperties()
     {
         return $this->getParentBlock()->getLabelProperties();
     }
 
+    /**
+     * @return array
+     */
     public function getValueProperties()
     {
         return $this->getParentBlock()->getValueProperties();
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php
index 923c7ab15d36edf4d47af2da8e07a98d7c21fe62..7ff9d4d3149641c0b6b4fe37b5905dafb93ac3a9 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php
@@ -34,6 +34,8 @@
 
 namespace Magento\Tax\Controller\Adminhtml;
 
+use Magento\App\ResponseInterface;
+
 class Rate extends \Magento\Backend\App\Action
 {
     /**
@@ -56,6 +58,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * Show Main Grid
      *
+     * @return void
      */
     public function indexAction()
     {
@@ -69,6 +72,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * Show Add Form
      *
+     * @return void
      */
     public function addAction()
     {
@@ -138,6 +142,8 @@ class Rate extends \Magento\Backend\App\Action
 
     /**
      * Save Tax Rate via AJAX
+     *
+     * @return void
      */
     public function ajaxSaveAction()
     {
@@ -193,6 +199,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * Show Edit Form
      *
+     * @return void
      */
     public function editAction()
     {
@@ -265,6 +272,8 @@ class Rate extends \Magento\Backend\App\Action
 
     /**
      * Delete Tax Rate via AJAX
+     *
+     * @return void
      */
     public function ajaxDeleteAction()
     {
@@ -295,6 +304,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * Export rates grid to CSV format
      *
+     * @return ResponseInterface
      */
     public function exportCsvAction()
     {
@@ -305,6 +315,8 @@ class Rate extends \Magento\Backend\App\Action
 
     /**
      * Export rates grid to XML format
+     *
+     * @return ResponseInterface
      */
     public function exportXmlAction()
     {
@@ -330,6 +342,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * Import and export Page
      *
+     * @return void
      */
     public function importExportAction()
     {
@@ -347,6 +360,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * import action from import/export tax
      *
+     * @return void
      */
     public function importPostAction()
     {
@@ -371,6 +385,7 @@ class Rate extends \Magento\Backend\App\Action
     /**
      * export action from import/export tax
      *
+     * @return ResponseInterface
      */
     public function exportPostAction()
     {
@@ -434,6 +449,9 @@ class Rate extends \Magento\Backend\App\Action
         return $this->_fileFactory->create('tax_rates.csv', $content, \Magento\App\Filesystem::VAR_DIR);
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         switch ($this->getRequest()->getActionName()) {
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule.php
index 790f5afc09e1b716093fac47ae5213a202d618f5..81e01cbd325515b9695681b2a4e0d9135bfe6844 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule.php
@@ -56,6 +56,9 @@ class Rule extends \Magento\Backend\App\Action
         parent::__construct($context);
     }
 
+    /**
+     * @return $this
+     */
     public function indexAction()
     {
         $this->_title->add(__('Tax Rules'));
@@ -65,11 +68,17 @@ class Rule extends \Magento\Backend\App\Action
         return $this;
     }
 
+    /**
+     * @return void
+     */
     public function newAction()
     {
         $this->_forward('edit');
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $this->_title->add(__('Tax Rules'));
@@ -100,6 +109,9 @@ class Rule extends \Magento\Backend\App\Action
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function saveAction()
     {
         $postData = $this->getRequest()->getPost();
@@ -133,6 +145,9 @@ class Rule extends \Magento\Backend\App\Action
         $this->getResponse()->setRedirect($this->getUrl('tax/rule'));
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $ruleId = (int)$this->getRequest()->getParam('rule');
@@ -163,7 +178,7 @@ class Rule extends \Magento\Backend\App\Action
     /**
      * Initialize action
      *
-     * @return \Magento\Backend\App\Action
+     * @return $this
      */
     protected function _initAction()
     {
@@ -174,6 +189,9 @@ class Rule extends \Magento\Backend\App\Action
         return $this;
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_Tax::manage_tax');
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
index 3177479852a87153f5bc2c68eabc92e131d08fa1..aabc12309581d259704f0102db1121ea8102e525 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
@@ -37,6 +37,8 @@ class Tax extends \Magento\Backend\App\Action
 {
     /**
      * Save Tax Class via AJAX
+     *
+     * @return void
      */
     public function ajaxSaveAction()
     {
@@ -76,6 +78,8 @@ class Tax extends \Magento\Backend\App\Action
 
     /**
      * Delete Tax Class via AJAX
+     *
+     * @return void
      */
     public function ajaxDeleteAction()
     {
diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php
index ae668bd5b4a271f83e41929094e3b35eaf6e66d3..14cca5d72ce5f34d3a4ecfecca1b1591affe73a2 100644
--- a/app/code/Magento/Tax/Helper/Data.php
+++ b/app/code/Magento/Tax/Helper/Data.php
@@ -23,12 +23,14 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Tax\Helper;
+
+use Magento\Core\Model\Store;
+use Magento\Customer\Model\Address;
 
 /**
  * Catalog data helper
  */
-namespace Magento\Tax\Helper;
-
 class Data extends \Magento\App\Helper\AbstractHelper
 {
     const PRICE_CONVERSION_PLUS = 1;
@@ -42,19 +44,46 @@ class Data extends \Magento\App\Helper\AbstractHelper
      *
      * @var \Magento\Tax\Model\Config
      */
-    protected $_config      = null;
+    protected $_config = null;
 
     /**
      * @var \Magento\Tax\Model\Calculation
      */
     protected $_calculation;
 
+    /**
+     * @var mixed
+     */
     protected $_displayTaxColumn;
+
+    /**
+     * @var mixed
+     */
     protected $_taxData;
+
+    /**
+     * @var mixed
+     */
     protected $_priceIncludesTax;
+
+    /**
+     * @var mixed
+     */
     protected $_shippingPriceIncludesTax;
+
+    /**
+     * @var mixed
+     */
     protected $_applyTaxAfterDiscount;
+
+    /**
+     * @var mixed
+     */
     protected $_priceDisplayType;
+
+    /**
+     * @var mixed
+     */
     protected $_shippingPriceDisplayType;
 
     /**
@@ -72,7 +101,6 @@ class Data extends \Magento\App\Helper\AbstractHelper
     protected $_coreData = null;
 
     /**
-     * @param \Magento\Core\Helper\Data $coreData
      * Core registry
      *
      * @var \Magento\Core\Model\Registry
@@ -145,7 +173,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Return max postcode length to create search templates
      *
-     * @return integer  $len
+     * @return int $len
      */
     public function getPostCodeSubStringLength()
     {
@@ -169,7 +197,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get tax calculation object
      *
-     * @return  \Magento\Tax\Model\Calculation
+     * @return \Magento\Tax\Model\Calculation
      */
     public function getCalculator()
     {
@@ -179,9 +207,9 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get product price including store convertion rate
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @param   null|string $format
-     * @return  float|string
+     * @param \Magento\Catalog\Model\Product $product
+     * @param null|string $format
+     * @return float|string
      */
     public function getProductPrice($product, $format = null)
     {
@@ -197,7 +225,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if product prices inputed include tax
      *
-     * @param   mix $store
+     * @param   null|int|string|Store $store
      * @return  bool
      */
     public function priceIncludesTax($store = null)
@@ -208,7 +236,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check what taxes should be applied after discount
      *
-     * @param   mixed $store
+     * @param   null|int|string|Store $store
      * @return  bool
      */
     public function applyTaxAfterDiscount($store=null)
@@ -219,7 +247,9 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Output
      *
-     * @param boolean $includes
+     * @param bool $flag
+     * @param null|int|string|Store $store
+     * @return string
      */
     public function getIncExcText($flag, $store=null)
     {
@@ -237,8 +267,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
      *  2 - Including tax
      *  3 - Both
      *
-     * @param   mixed $store
-     * @return  int
+     * @param null|int|string|Store $store
+     * @return int
      */
     public function getPriceDisplayType($store = null)
     {
@@ -249,8 +279,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * Check if necessary do product price conversion
      * If it necessary will be returned conversion type (minus or plus)
      *
-     * @param   mixed $store
-     * @return  false | int
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function needPriceConversion($store = null)
     {
@@ -282,8 +312,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display full tax summary information in totals block
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displayFullSummary($store = null)
     {
@@ -293,8 +323,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display zero tax in subtotal
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displayZeroTax($store = null)
     {
@@ -304,8 +334,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display cart prices included tax
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displayCartPriceInclTax($store = null)
     {
@@ -315,8 +345,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display cart prices excluding price
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displayCartPriceExclTax($store = null)
     {
@@ -326,8 +356,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display cart prices excluding and including tax
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displayCartBothPrices($store = null)
     {
@@ -337,8 +367,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display order prices included tax
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displaySalesPriceInclTax($store = null)
     {
@@ -348,8 +378,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display order prices excluding price
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displaySalesPriceExclTax($store = null)
     {
@@ -359,8 +389,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display order prices excluding and including tax
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|int|string|Store $store
+     * @return bool
      */
     public function displaySalesBothPrices($store = null)
     {
@@ -371,7 +401,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if we need display price include and exclude tax for order/invoice subtotal
      *
-     * @param mixed $store
+     * @param null|int|string|Store $store
      * @return bool
      */
     public function displaySalesSubtotalBoth($store = null)
@@ -382,7 +412,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if we need display price include tax for order/invoice subtotal
      *
-     * @param mixed $store
+     * @param null|int|string|Store $store
      * @return bool
      */
     public function displaySalesSubtotalInclTax($store = null)
@@ -393,7 +423,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if we need display price exclude tax for order/invoice subtotal
      *
-     * @param mixed $store
+     * @param null|int|string|Store $store
      * @return bool
      */
     public function displaySalesSubtotalExclTax($store = null)
@@ -404,8 +434,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if need display tax column in for shopping cart/order items
      *
-     * @param   mixed $store
-     * @return  bool
+     * @param null|string|bool|int|Store $store
+     * @return bool
      */
     public function displayTaxColumn($store = null)
     {
@@ -415,8 +445,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get prices javascript format json
      *
-     * @param   mixed $store
-     * @return  string
+     * @param null|int|string|Store $store
+     * @return string
      */
     public function getPriceFormat($store = null)
     {
@@ -432,11 +462,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get all tax rates JSON for all product tax classes of specific store
      *
-     * array(
-     *      value_{$productTaxVlassId} => $rate
-     * )
-     *
-     * @param null string|$store
+     * @param null|string|bool|int|Store $store
      * @return string
      */
     public function getAllRatesByProductClass($store = null)
@@ -448,11 +474,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get all tax rates JSON for all product tax classes of specific store
      *
-     * array(
-     *      value_{$productTaxVlassId} => $rate
-     * )
-     *
-     * @param string|null $store
+     * @param null|string|bool|int|Store $store
      * @return string
      */
     protected function _getAllRatesByProductClass($store = null)
@@ -472,10 +494,10 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @param   \Magento\Catalog\Model\Product $product
      * @param   float $price inputed product price
      * @param   bool $includingTax return price include tax flag
-     * @param   null|\Magento\Customer\Model\Address $shippingAddress
-     * @param   null|\Magento\Customer\Model\Address $billingAddress
+     * @param   null|Address $shippingAddress
+     * @param   null|Address $billingAddress
      * @param   null|int $ctc customer tax class
-     * @param   mixed $store
+     * @param   null|string|bool|int|Store $store
      * @param   bool $priceIncludesTax flag what price parameter contain tax
      * @return  float
      */
@@ -627,37 +649,62 @@ class Data extends \Magento\App\Helper\AbstractHelper
         }
     }
 
+    /**
+     * @param bool $flag
+     * @return string
+     */
     public function getIncExcTaxLabel($flag)
     {
         $text = $this->getIncExcText($flag);
         return $text ? ' <span class="tax-flag">('.$text.')</span>' : '';
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function shippingPriceIncludesTax($store = null)
     {
         return $this->_config->shippingPriceIncludesTax($store);
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return int
+     */
     public function getShippingPriceDisplayType($store = null)
     {
         return $this->_config->getShippingPriceDisplayType($store);
     }
 
+    /**
+     * @return bool
+     */
     public function displayShippingPriceIncludingTax()
     {
         return $this->getShippingPriceDisplayType() == \Magento\Tax\Model\Config::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @return bool
+     */
     public function displayShippingPriceExcludingTax()
     {
         return $this->getShippingPriceDisplayType() == \Magento\Tax\Model\Config::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @return bool
+     */
     public function displayShippingBothPrices()
     {
         return $this->getShippingPriceDisplayType() == \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return int
+     */
     public function getShippingTaxClass($store)
     {
         return $this->_config->getShippingTaxClass($store);
@@ -666,6 +713,11 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get shipping price
      *
+     * @param float $price
+     * @param bool|null $includingTax
+     * @param Address|null $shippingAddress
+     * @param int|null $ctc
+     * @param null|string|bool|int|Store $store
      * @return float
      */
     public function getShippingPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null)
@@ -691,6 +743,11 @@ class Data extends \Magento\App\Helper\AbstractHelper
         return $price;
     }
 
+    /**
+     * @param string $priceField
+     * @param string $taxClassField
+     * @return string
+     */
     public function getPriceTaxSql($priceField, $taxClassField)
     {
         if (!$this->priceIncludesTax() && $this->displayPriceExcludingTax()) {
@@ -747,7 +804,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * @param \Magento\DB\Select $select
      * @param int $storeId
      * @param string $priceTable
-     * @return \Magento\Tax\Helper\Data
+     * @return $this
      */
     public function joinTaxClass($select, $storeId, $priceTable = 'main_table')
     {
@@ -780,8 +837,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get configuration setting "Apply Discount On Prices Including Tax" value
      *
-     * @param   null|int $store
-     * @return  0|1
+     * @param null|string|bool|int|Store $store
+     * @return bool
      */
     public function discountTax($store=null)
     {
@@ -791,8 +848,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Get value of "Apply Tax On" custom/original price configuration settings
      *
-     * @param $store
-     * @return 0|1
+     * @param null|string|bool|int|Store $store
+     * @return string|null
      */
     public function getTaxBasedOn($store = null)
     {
@@ -802,7 +859,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if tax can be applied to custom price
      *
-     * @param $store
+     * @param null|string|bool|int|Store $store
      * @return bool
      */
     public function applyTaxOnCustomPrice($store = null)
@@ -813,7 +870,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Check if tax should be applied just to original price
      *
-     * @param $store
+     * @param null|string|bool|int|Store $store
      * @return bool
      */
     public function applyTaxOnOriginalPrice($store = null)
@@ -826,8 +883,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * This sequence depends on "Catalog price include tax", "Apply Tax After Discount"
      * and "Apply Discount On Prices Including Tax" configuration options.
      *
-     * @param   null|int|string|\Magento\Core\Model\Store $store
-     * @return  string
+     * @param null|int|string|Store $store
+     * @return string
      */
     public function getCalculationSequence($store = null)
     {
@@ -835,10 +892,10 @@ class Data extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
-     * Get tax caclulation algorithm code
+     * Get tax calculation algorithm code
      *
-     * @param   null|int $store
-     * @return  string
+     * @param null|string|bool|int|Store $store
+     * @return string
      */
     public function getCalculationAgorithm($store = null)
     {
@@ -961,6 +1018,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
 
     /**
      * Retrieve default customer tax class from config
+     *
+     * @return string|null
      */
     public function getDefaultCustomerTaxClass()
     {
@@ -969,6 +1028,8 @@ class Data extends \Magento\App\Helper\AbstractHelper
 
     /**
      * Retrieve default product tax class from config
+     *
+     * @return string|null
      */
     public function getDefaultProductTaxClass()
     {
diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php
index 22c8f01eb31dc246d5bc2a64387f11c9539f7a5e..b0501aaeb42fc9fd729f95d6076c4fc68019d38f 100644
--- a/app/code/Magento/Tax/Model/Calculation.php
+++ b/app/code/Magento/Tax/Model/Calculation.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Tax\Model;
 
+use Magento\Core\Model\Store;
+
 /**
  * Tax Calculation Model
  */
@@ -40,18 +42,39 @@ class Calculation extends \Magento\Core\Model\AbstractModel
     const CALC_ROW_BASE                         = 'ROW_BASE_CALCULATION';
     const CALC_TOTAL_BASE                       = 'TOTAL_BASE_CALCULATION';
 
-    protected $_rates                           = array();
-    protected $_ctc                             = array();
-    protected $_ptc                             = array();
+    /**
+     * @var array
+     */
+    protected $_rates = array();
+
+    /**
+     * @var array
+     */
+    protected $_ctc = array();
 
-    protected $_rateCache                       = array();
-    protected $_rateCalculationProcess          = array();
+    /**
+     * @var array
+     */
+    protected $_ptc = array();
+
+    /**
+     * @var array
+     */
+    protected $_rateCache = array();
+
+    /**
+     * @var array
+     */
+    protected $_rateCalculationProcess = array();
 
     /**
      * @var \Magento\Customer\Model\Customer|bool
      */
     protected $_customer;
 
+    /**
+     * @var mixed
+     */
     protected $_defaultCustomerTaxClass;
 
     /**
@@ -131,6 +154,9 @@ class Calculation extends \Magento\Core\Model\AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Tax\Model\Resource\Calculation');
@@ -140,7 +166,7 @@ class Calculation extends \Magento\Core\Model\AbstractModel
      * Specify customer object which can be used for rate calculation
      *
      * @param   \Magento\Customer\Model\Customer $customer
-     * @return  \Magento\Tax\Model\Calculation
+     * @return  $this
      */
     public function setCustomer(\Magento\Customer\Model\Customer $customer)
     {
@@ -148,6 +174,10 @@ class Calculation extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param null|Store|string|int $store
+     * @return mixed
+     */
     public function getDefaultCustomerTaxClass($store = null)
     {
         if ($this->_defaultCustomerTaxClass === null) {
@@ -184,7 +214,7 @@ class Calculation extends \Magento\Core\Model\AbstractModel
      * Delete calculation settings by rule id
      *
      * @param   int $ruleId
-     * @return  \Magento\Tax\Model\Calculation
+     * @return  $this
      */
     public function deleteByRuleId($ruleId)
     {
@@ -289,7 +319,7 @@ class Calculation extends \Magento\Core\Model\AbstractModel
     /**
      * Get cache key value for specific tax rate request
      *
-     * @param   $request
+     * @param   \Magento\Object $request
      * @return  string
      */
     protected function _getRequestCacheKey($request)
@@ -306,7 +336,7 @@ class Calculation extends \Magento\Core\Model\AbstractModel
      * store price excluding tax
      *
      * @param \Magento\Object $request
-     * @param null|string|bool|int|\Magento\Core\Model\Store $store
+     * @param null|string|bool|int|Store $store
      * @return float
      */
     public function getStoreRate($request, $store = null)
@@ -319,7 +349,7 @@ class Calculation extends \Magento\Core\Model\AbstractModel
     /**
      * Get request object for getting tax rate based on store shipping original address
      *
-     * @param   null|string|bool|int|\Magento\Core\Model\Store $store
+     * @param   null|string|bool|int|Store $store
      * @return  \Magento\Object
      */
     public function getRateOriginRequest($store = null)
@@ -500,6 +530,12 @@ class Calculation extends \Magento\Core\Model\AbstractModel
         return $identical;
     }
 
+    /**
+     * @param \Magento\Object $request
+     * @param string|array $fieldName
+     * @param string|array $type
+     * @return array
+     */
     protected function _getRates($request, $fieldName, $type)
     {
         $result = array();
@@ -513,11 +549,19 @@ class Calculation extends \Magento\Core\Model\AbstractModel
         return $result;
     }
 
+    /**
+     * @param \Magento\Object $request
+     * @return array
+     */
     public function getRatesForAllProductTaxClasses($request)
     {
         return $this->_getRates($request, 'product_class_id', \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT);
     }
 
+    /**
+     * @param \Magento\Object $request
+     * @return array
+     */
     public function getRatesForAllCustomerTaxClasses($request)
     {
         return $this->_getRates($request, 'customer_class_id', \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER);
@@ -538,16 +582,29 @@ class Calculation extends \Magento\Core\Model\AbstractModel
         return $this->_rateCalculationProcess[$cacheKey];
     }
 
+    /**
+     * @param array $rates
+     * @return array
+     */
     public function reproduceProcess($rates)
     {
         return $this->getResource()->getCalculationProcess(null, $rates);
     }
 
+    /**
+     * @param int $customerTaxClass
+     * @return array
+     */
     public function getRatesByCustomerTaxClass($customerTaxClass)
     {
         return $this->getResource()->getRatesByCustomerTaxClass($customerTaxClass);
     }
 
+    /**
+     * @param int $customerTaxClass
+     * @param int $productTaxClass
+     * @return array
+     */
     public function getRatesByCustomerAndProductTaxClasses($customerTaxClass, $productTaxClass)
     {
         return $this->getResource()->getRatesByCustomerTaxClass($customerTaxClass, $productTaxClass);
diff --git a/app/code/Magento/Tax/Model/Calculation/Rate.php b/app/code/Magento/Tax/Model/Calculation/Rate.php
index 74850fa1da4815cf8c54298e93cf69693b86de80..adc8620fc8a5e6ce5dff7c115fd6b91758246430 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rate.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rate.php
@@ -50,7 +50,14 @@ namespace Magento\Tax\Model\Calculation;
 
 class Rate extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * @var mixed
+     */
     protected $_titles = null;
+
+    /**
+     * @var mixed
+     */
     protected $_titleModel = null;
 
     /**
@@ -88,6 +95,8 @@ class Rate extends \Magento\Core\Model\AbstractModel
 
     /**
      * Magento model constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -97,7 +106,7 @@ class Rate extends \Magento\Core\Model\AbstractModel
     /**
      * Prepare location settings and tax postcode before save rate
      *
-     * @return \Magento\Tax\Model\Calculation\Rate
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeSave()
@@ -160,7 +169,7 @@ class Rate extends \Magento\Core\Model\AbstractModel
     /**
      * Save rate titles
      *
-     * @return \Magento\Tax\Model\Calculation\Rate
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -172,7 +181,7 @@ class Rate extends \Magento\Core\Model\AbstractModel
     /**
      * Processing object before delete data
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     protected function _beforeDelete()
@@ -187,7 +196,7 @@ class Rate extends \Magento\Core\Model\AbstractModel
      * After rate delete
      * redeclared for dispatch tax_settings_change_after event
      *
-     * @return \Magento\Tax\Model\Calculation\Rate
+     * @return $this
      */
     protected function _afterDelete()
     {
@@ -195,6 +204,10 @@ class Rate extends \Magento\Core\Model\AbstractModel
         return parent::_afterDelete();
     }
 
+    /**
+     * @param array|null $titles
+     * @return void
+     */
     public function saveTitles($titles = null)
     {
         if (is_null($titles)) {
@@ -216,6 +229,9 @@ class Rate extends \Magento\Core\Model\AbstractModel
         }
     }
 
+    /**
+     * @return mixed
+     */
     public function getTitleModel()
     {
         if (is_null($this->_titleModel)) {
@@ -224,6 +240,9 @@ class Rate extends \Magento\Core\Model\AbstractModel
         return $this->_titleModel;
     }
 
+    /**
+     * @return mixed
+     */
     public function getTitles()
     {
         if (is_null($this->_titles)) {
@@ -232,6 +251,9 @@ class Rate extends \Magento\Core\Model\AbstractModel
         return $this->_titles;
     }
 
+    /**
+     * @return $this
+     */
     public function deleteAllRates()
     {
         $this->_getResource()->deleteAllRates();
@@ -243,7 +265,7 @@ class Rate extends \Magento\Core\Model\AbstractModel
      * Load rate model by code
      *
      * @param  string $code
-     * @return \Magento\Tax\Model\Calculation\Rate
+     * @return $this
      */
     public function loadByCode($code)
     {
diff --git a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php
index c65c495d110aacb3279373b061ece8d440bbe63f..92e3274cd4ba6bd6393ccac5a65c7a3dbaa8b7ee 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php
@@ -45,11 +45,18 @@ namespace Magento\Tax\Model\Calculation\Rate;
 
 class Title extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\Tax\Model\Resource\Calculation\Rate\Title');
     }
 
+    /**
+     * @param int $rateId
+     * @return $this
+     */
     public function deleteByRateId($rateId)
     {
         $this->getResource()->deleteByRateId($rateId);
diff --git a/app/code/Magento/Tax/Model/Calculation/Rule.php b/app/code/Magento/Tax/Model/Calculation/Rule.php
index cb101276db1fcef7c9a9cbdee008c89d2a9b95e1..5e8df8790b6a2661e5f759746eac69a2f758b05a 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rule.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rule.php
@@ -40,13 +40,35 @@ namespace Magento\Tax\Model\Calculation;
 
 class Rule extends \Magento\Core\Model\AbstractModel
 {
-    protected $_ctcs                = null;
-    protected $_ptcs                = null;
-    protected $_rates               = null;
+    /**
+     * @var mixed
+     */
+    protected $_ctcs = null;
+
+    /**
+     * @var mixed
+     */
+    protected $_ptcs = null;
+
+    /**
+     * @var mixed
+     */
+    protected $_rates = null;
 
-    protected $_ctcModel            = null;
-    protected $_ptcModel            = null;
-    protected $_rateModel           = null;
+    /**
+     * @var mixed
+     */
+    protected $_ctcModel = null;
+
+    /**
+     * @var mixed
+     */
+    protected $_ptcModel = null;
+
+    /**
+     * @var mixed
+     */
+    protected $_rateModel = null;
 
     /**
      * Prefix of model events names
@@ -107,7 +129,7 @@ class Rule extends \Magento\Core\Model\AbstractModel
      * After save rule
      * Redeclared for populate rate calculations
      *
-     * @return \Magento\Tax\Model\Calculation\Rule
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -119,9 +141,9 @@ class Rule extends \Magento\Core\Model\AbstractModel
 
     /**
      * After rule delete
-     * redeclared for dispatch tax_settings_change_after event
+     * re-declared for dispatch tax_settings_change_after event
      *
-     * @return \Magento\Tax\Model\Calculation\Rule
+     * @return $this
      */
     protected function _afterDelete()
     {
@@ -129,6 +151,9 @@ class Rule extends \Magento\Core\Model\AbstractModel
         return parent::_afterDelete();
     }
 
+    /**
+     * @return void
+     */
     public function saveCalculationData()
     {
         $ctc = $this->getData('tax_customer_class');
@@ -159,16 +184,25 @@ class Rule extends \Magento\Core\Model\AbstractModel
         return $this->_calculation;
     }
 
+    /**
+     * @return array
+     */
     public function getRates()
     {
         return $this->getCalculationModel()->getRates($this->getId());
     }
 
+    /**
+     * @return array
+     */
     public function getCustomerTaxClasses()
     {
         return $this->getCalculationModel()->getCustomerTaxClasses($this->getId());
     }
 
+    /**
+     * @return array
+     */
     public function getProductTaxClasses()
     {
         return $this->getCalculationModel()->getProductTaxClasses($this->getId());
diff --git a/app/code/Magento/Tax/Model/ClassModel.php b/app/code/Magento/Tax/Model/ClassModel.php
index 0cbba530449a478fb016804c7d8e2a9f485c9b1b..12eb37553d6949b4ca3d2d67f8ddf47dc8094772 100644
--- a/app/code/Magento/Tax/Model/ClassModel.php
+++ b/app/code/Magento/Tax/Model/ClassModel.php
@@ -78,6 +78,9 @@ class ClassModel extends \Magento\Core\Model\AbstractModel
         $this->_classFactory = $classFactory;
     }
 
+    /**
+     * @return void
+     */
     public function _construct()
     {
         $this->_init('Magento\Tax\Model\Resource\TaxClass');
diff --git a/app/code/Magento/Tax/Model/Config.php b/app/code/Magento/Tax/Model/Config.php
index 460cc1bc9645e1acf2e789b68970ccca9095cf45..3cec0d4dfc00907cee8f609115549e78e93ec055 100644
--- a/app/code/Magento/Tax/Model/Config.php
+++ b/app/code/Magento/Tax/Model/Config.php
@@ -33,6 +33,8 @@
  */
 namespace Magento\Tax\Model;
 
+use Magento\Core\Model\Store;
+
 class Config
 {
     // tax classes
@@ -55,30 +57,30 @@ class Config
     /**
      * Prices display settings
      */
-    const CONFIG_XML_PATH_PRICE_DISPLAY_TYPE    = 'tax/display/type';
-    const CONFIG_XML_PATH_DISPLAY_SHIPPING      = 'tax/display/shipping';
+    const CONFIG_XML_PATH_PRICE_DISPLAY_TYPE = 'tax/display/type';
+    const CONFIG_XML_PATH_DISPLAY_SHIPPING = 'tax/display/shipping';
 
     /**
      * Shopping cart display settings
      */
-    const XML_PATH_DISPLAY_CART_PRICE       = 'tax/cart_display/price';
-    const XML_PATH_DISPLAY_CART_SUBTOTAL    = 'tax/cart_display/subtotal';
-    const XML_PATH_DISPLAY_CART_SHIPPING    = 'tax/cart_display/shipping';
-    const XML_PATH_DISPLAY_CART_DISCOUNT    = 'tax/cart_display/discount';
-    const XML_PATH_DISPLAY_CART_GRANDTOTAL  = 'tax/cart_display/grandtotal';
-    const XML_PATH_DISPLAY_CART_FULL_SUMMARY= 'tax/cart_display/full_summary';
-    const XML_PATH_DISPLAY_CART_ZERO_TAX    = 'tax/cart_display/zero_tax';
+    const XML_PATH_DISPLAY_CART_PRICE = 'tax/cart_display/price';
+    const XML_PATH_DISPLAY_CART_SUBTOTAL = 'tax/cart_display/subtotal';
+    const XML_PATH_DISPLAY_CART_SHIPPING = 'tax/cart_display/shipping';
+    const XML_PATH_DISPLAY_CART_DISCOUNT = 'tax/cart_display/discount';
+    const XML_PATH_DISPLAY_CART_GRANDTOTAL = 'tax/cart_display/grandtotal';
+    const XML_PATH_DISPLAY_CART_FULL_SUMMARY = 'tax/cart_display/full_summary';
+    const XML_PATH_DISPLAY_CART_ZERO_TAX = 'tax/cart_display/zero_tax';
 
     /**
      * Shopping cart display settings
      */
-    const XML_PATH_DISPLAY_SALES_PRICE       = 'tax/sales_display/price';
-    const XML_PATH_DISPLAY_SALES_SUBTOTAL    = 'tax/sales_display/subtotal';
-    const XML_PATH_DISPLAY_SALES_SHIPPING    = 'tax/sales_display/shipping';
-    const XML_PATH_DISPLAY_SALES_DISCOUNT    = 'tax/sales_display/discount';
-    const XML_PATH_DISPLAY_SALES_GRANDTOTAL  = 'tax/sales_display/grandtotal';
-    const XML_PATH_DISPLAY_SALES_FULL_SUMMARY= 'tax/sales_display/full_summary';
-    const XML_PATH_DISPLAY_SALES_ZERO_TAX    = 'tax/sales_display/zero_tax';
+    const XML_PATH_DISPLAY_SALES_PRICE = 'tax/sales_display/price';
+    const XML_PATH_DISPLAY_SALES_SUBTOTAL = 'tax/sales_display/subtotal';
+    const XML_PATH_DISPLAY_SALES_SHIPPING = 'tax/sales_display/shipping';
+    const XML_PATH_DISPLAY_SALES_DISCOUNT = 'tax/sales_display/discount';
+    const XML_PATH_DISPLAY_SALES_GRANDTOTAL = 'tax/sales_display/grandtotal';
+    const XML_PATH_DISPLAY_SALES_FULL_SUMMARY = 'tax/sales_display/full_summary';
+    const XML_PATH_DISPLAY_SALES_ZERO_TAX = 'tax/sales_display/zero_tax';
 
     const CALCULATION_STRING_SEPARATOR = '|';
 
@@ -122,7 +124,7 @@ class Config
     /**
      * Check if prices of product in catalog include tax
      *
-     * @param   mixed $store
+     * @param   null|string|bool|int|Store $store
      * @return  bool
      */
     public function priceIncludesTax($store = null)
@@ -137,7 +139,7 @@ class Config
      * Override "price includes tax" variable regardless of system configuration of any store
      *
      * @param bool|null $value
-     * @return \Magento\Tax\Model\Config
+     * @return $this
      */
     public function setPriceIncludesTax($value)
     {
@@ -152,7 +154,7 @@ class Config
     /**
      * Check what taxes should be applied after discount
      *
-     * @param   mixed $store
+     * @param   null|string|bool|int|Store $store
      * @return  bool
      */
     public function applyTaxAfterDiscount($store=null)
@@ -166,7 +168,7 @@ class Config
      *  2 - Including tax
      *  3 - Both
      *
-     * @param   mixed $store
+     * @param   null|string|bool|int|Store $store
      * @return  int
      */
     public function getPriceDisplayType($store = null)
@@ -177,8 +179,8 @@ class Config
     /**
      * Get configuration setting "Apply Discount On Prices Including Tax" value
      *
-     * @param   null|int $store
-     * @return  0|1
+     * @param   null|string|bool|int|Store $store
+     * @return  bool
      */
     public function discountTax($store=null)
     {
@@ -189,7 +191,7 @@ class Config
      * Get taxes/discounts calculation sequence.
      * This sequence depends on "Apply Customer Tax" and "Apply Discount On Prices" configuration options.
      *
-     * @param   null|int|string|\Magento\Core\Model\Store $store
+     * @param   null|int|string|Store $store
      * @return  string
      */
     public function getCalculationSequence($store=null)
@@ -236,7 +238,7 @@ class Config
     /**
      * Get defined tax calculation agorithm
      *
-     * @param   store $store
+     * @param   null|string|bool|int|Store $store
      * @return  string
      */
     public function getAlgorithm($store=null)
@@ -247,7 +249,7 @@ class Config
     /**
      * Get tax class id specified for shipping tax estimation
      *
-     * @param   store $store
+     * @param   null|string|bool|int|Store $store
      * @return  int
      */
     public function getShippingTaxClass($store=null)
@@ -258,7 +260,7 @@ class Config
     /**
      * Get shipping methods prices display type
      *
-     * @param   store $store
+     * @param   null|string|bool|int|Store $store
      * @return  int
      */
     public function getShippingPriceDisplayType($store = null)
@@ -269,7 +271,7 @@ class Config
     /**
      * Check if shipping prices include tax
      *
-     * @param   store $store
+     * @param   null|string|bool|int|Store $store
      * @return  bool
      */
     public function shippingPriceIncludesTax($store = null)
@@ -285,7 +287,9 @@ class Config
 
     /**
      * Declare shipping prices type
+     *
      * @param bool $flag
+     * @return $this
      */
     public function setShippingPriceIncludeTax($flag)
     {
@@ -293,155 +297,273 @@ class Config
         return $this;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartPricesInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_PRICE, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartPricesExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_PRICE, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartPricesBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_PRICE, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartSubtotalInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_SUBTOTAL, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartSubtotalExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_SUBTOTAL, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartSubtotalBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_SUBTOTAL, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartShippingInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_SHIPPING, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartShippingExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_SHIPPING, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartShippingBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_SHIPPING, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartDiscountInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_DISCOUNT, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartDiscountExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_DISCOUNT, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartDiscountBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_DISCOUNT, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartTaxWithGrandTotal($store = null)
     {
         return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_GRANDTOTAL, $store);
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartFullSummary($store = null)
     {
         return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_FULL_SUMMARY, $store);
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displayCartZeroTax($store = null)
     {
         return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_CART_ZERO_TAX, $store);
     }
 
-
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesPricesInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_PRICE, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesPricesExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_PRICE, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesPricesBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_PRICE, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesSubtotalInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_SUBTOTAL, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesSubtotalExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_SUBTOTAL, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesSubtotalBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_SUBTOTAL, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesShippingInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_SHIPPING, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesShippingExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_SHIPPING, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesShippingBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_SHIPPING, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesDiscountInclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_DISCOUNT, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalestDiscountExclTax($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_DISCOUNT, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesDiscountBoth($store = null)
     {
         return $this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_DISCOUNT, $store) == self::DISPLAY_TYPE_BOTH;
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesTaxWithGrandTotal($store = null)
     {
         return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_GRANDTOTAL, $store);
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesFullSummary($store = null)
     {
         return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_FULL_SUMMARY, $store);
     }
 
+    /**
+     * @param null|string|bool|int|Store $store
+     * @return bool
+     */
     public function displaySalesZeroTax($store = null)
     {
         return (bool)$this->_coreStoreConfig->getConfig(self::XML_PATH_DISPLAY_SALES_ZERO_TAX, $store);
     }
 }
-
diff --git a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
index 41ce467fa9ae69778ce29fce5b67c50fe60b71eb..83dde3145b76f59858dfdb4ea3e1749aad02f581 100644
--- a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
+++ b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
@@ -57,6 +57,9 @@ class IncludePrice extends \Magento\Core\Model\Config\Value
         parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * @return void
+     */
     public function _afterSave()
     {
         parent::_afterSave();
diff --git a/app/code/Magento/Tax/Model/Config/Source/Apply/On.php b/app/code/Magento/Tax/Model/Config/Source/Apply/On.php
index 497a9c0583056a1f232542fe3b8dfa4757075588..3ad73a8062ebbaac6dba798930a23c195c0868c4 100644
--- a/app/code/Magento/Tax/Model/Config/Source/Apply/On.php
+++ b/app/code/Magento/Tax/Model/Config/Source/Apply/On.php
@@ -27,6 +27,9 @@ namespace Magento\Tax\Model\Config\Source\Apply;
 
 class On implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Tax/Model/Config/Source/Basedon.php b/app/code/Magento/Tax/Model/Config/Source/Basedon.php
index 199dbb66a6858ce52dd5823ac5dae43df7e31b85..f03a55ee5eed1fda59a375192308215b5bf67a18 100644
--- a/app/code/Magento/Tax/Model/Config/Source/Basedon.php
+++ b/app/code/Magento/Tax/Model/Config/Source/Basedon.php
@@ -27,6 +27,9 @@ namespace Magento\Tax\Model\Config\Source;
 
 class Basedon implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Tax/Model/Config/Source/Catalog.php b/app/code/Magento/Tax/Model/Config/Source/Catalog.php
index 68514c853c0c5483cbb597bae5247cfb4a4e063c..070e8aaa1404891ae0f4f15220ed6b435b1e558f 100644
--- a/app/code/Magento/Tax/Model/Config/Source/Catalog.php
+++ b/app/code/Magento/Tax/Model/Config/Source/Catalog.php
@@ -27,6 +27,9 @@ namespace Magento\Tax\Model\Config\Source;
 
 class Catalog implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Tax/Model/Observer.php b/app/code/Magento/Tax/Model/Observer.php
index 799848f669e493d1ff8db3aab321a4155a29a8d0..8fc0474e9a3c334b0b0c3505e57834e5399309db 100644
--- a/app/code/Magento/Tax/Model/Observer.php
+++ b/app/code/Magento/Tax/Model/Observer.php
@@ -91,6 +91,7 @@ class Observer
      * Put quote address tax information into order
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function salesEventConvertQuoteAddressToOrder(\Magento\Event\Observer $observer)
     {
@@ -111,6 +112,7 @@ class Observer
      * Save order tax information
      *
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function salesEventOrderAfterSave(\Magento\Event\Observer $observer)
     {
@@ -216,7 +218,7 @@ class Observer
      * Add tax percent values to product collection items
      *
      * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Tax\Model\Observer
+     * @return  $this
      */
     public function addTaxPercentToProductCollection($observer)
     {
@@ -248,7 +250,7 @@ class Observer
      * Refresh sales tax report statistics for last day
      *
      * @param \Magento\Cron\Model\Schedule $schedule
-     * @return \Magento\Tax\Model\Observer
+     * @return $this
      */
     public function aggregateSalesReportTaxData($schedule)
     {
@@ -266,7 +268,7 @@ class Observer
      * Reset extra tax amounts on quote addresses before recollecting totals
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Tax\Model\Observer
+     * @return $this
      */
     public function quoteCollectTotalsBefore(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php b/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php
index f857b8694d5c7f6728ec2d0a293b89ea04469566..9708be6b39795971f2feb0a17b50733d0463ff10 100644
--- a/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php
+++ b/app/code/Magento/Tax/Model/Rate/CsvImportHandler.php
@@ -105,6 +105,7 @@ class CsvImportHandler
      * Import Tax Rates from CSV file
      *
      * @param array $file file info retrieved from $_FILES array
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function importFromCsvFile($file)
@@ -135,7 +136,7 @@ class CsvImportHandler
      * Filter file fields (i.e. unset invalid fields)
      *
      * @param array $fileFields
-     * @return array filtered fields
+     * @return string[] filtered fields
      */
     protected function _filterFileFields(array $fileFields)
     {
@@ -192,7 +193,7 @@ class CsvImportHandler
      *
      * This cache is used to quickly retrieve store ID when handling locale-specific tax rate titles
      *
-     * @param $validFields list of valid CSV file fields
+     * @param string[] $validFields list of valid CSV file fields
      * @return array
      */
     protected function _composeStoreCache($validFields)
diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php
index 3c16f4992d3ad1177241ee24615302fed5671b99..00964354d9ed9c22e64bef724c6bfc68bccacc60 100644
--- a/app/code/Magento/Tax/Model/Resource/Calculation.php
+++ b/app/code/Magento/Tax/Model/Resource/Calculation.php
@@ -37,14 +37,14 @@ class Calculation extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @var array
      */
-    protected $_ratesCache              = array();
+    protected $_ratesCache = array();
 
     /**
      * Primary key auto increment flag
      *
      * @var bool
      */
-    protected $_isPkAutoIncrement    = false;
+    protected $_isPkAutoIncrement = false;
 
     /**
      * Tax data
@@ -76,6 +76,7 @@ class Calculation extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Resource initialization
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -86,7 +87,7 @@ class Calculation extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete calculation settings by rule id
      *
      * @param int $ruleId
-     * @return \Magento\Tax\Model\Resource\Calculation
+     * @return $this
      */
     public function deleteByRuleId($ruleId)
     {
@@ -143,7 +144,7 @@ class Calculation extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Retrieve Calculation Process
      *
      * @param \Magento\Object $request
-     * @param array $rates
+     * @param array|null $rates
      * @return array
      */
     public function getCalculationProcess($request, $rates = null)
@@ -224,7 +225,7 @@ class Calculation extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Create search templates for postcode
      *
      * @param string $postcode
-     * @return array  $strArr
+     * @return string[]
      */
     protected function _createSearchPostCodeTemplates($postcode)
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php
index 7dc3727cef6589c4795fde9257d9962d42f79b76..1c0261bd0ff3fa0c33e61dfeacdabe244102bba7 100644
--- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php
+++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate.php
@@ -38,6 +38,8 @@ class Rate extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -47,7 +49,7 @@ class Rate extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize unique fields
      *
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate
+     * @return $this
      */
     protected function _initUniqueFields()
     {
@@ -61,7 +63,7 @@ class Rate extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Delete all rates
      *
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate
+     * @return $this
      */
     public function deleteAllRates()
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php
index 5f845f4a6d3c30000d9b12e7c306a503eb0ef509..0e73fae819d4a69310e9659df399343622cb1a7a 100644
--- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php
+++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Collection.php
@@ -61,6 +61,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -70,7 +72,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Join country table to result
      *
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate\Collection
+     * @return $this
      */
     public function joinCountryTable()
     {
@@ -86,7 +88,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Join Region Table
      *
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate\Collection
+     * @return $this
      */
     public function joinRegionTable()
     {
@@ -102,7 +104,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Join rate title for specified store
      *
      * @param \Magento\Core\Model\Store|string|int $store
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate\Collection
+     * @return $this
      */
     public function joinTitle($store = null)
     {
@@ -119,7 +121,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Joins store titles for rates
      *
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate\Collection
+     * @return $this
      */
     public function joinStoreTitles()
     {
@@ -143,7 +145,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add rate filter
      *
      * @param int $rateId
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate\Collection
+     * @return $this
      */
     public function addRateFilter($rateId)
     {
@@ -176,11 +178,11 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 
     /**
      * Convert items array to hash for select options
-     * unsing fetchItem method
+     * using fetchItem method
      *
-     * @see     _toOptionHashOptimized()
+     * @see _toOptionHashOptimized()
      *
-     * @return  array
+     * @return array
      */
     public function toOptionHashOptimized()
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php
index e8988bcdf9bc59af1b5d7a8f48b16a309994da2f..dd30f06e2841af7cb6ce067e8828819bdadd9c03 100644
--- a/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php
+++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rate/Title.php
@@ -48,7 +48,7 @@ class Title extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete title by rate identifier
      *
      * @param int $rateId
-     * @return \Magento\Tax\Model\Resource\Calculation\Rate\Title
+     * @return $this
      */
     public function deleteByRateId($rateId)
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Report/Collection.php b/app/code/Magento/Tax/Model/Resource/Report/Collection.php
index 314160760449b3fd17f02a852b5f38fb0f98fc0b..ab7e81a5137e095516202b77d21ba0b68eb7ccfd 100644
--- a/app/code/Magento/Tax/Model/Resource/Report/Collection.php
+++ b/app/code/Magento/Tax/Model/Resource/Report/Collection.php
@@ -51,7 +51,7 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac
     /**
      * @var array
      */
-    protected $_selectedColumns    = array();
+    protected $_selectedColumns = array();
 
     /**
      * @param \Magento\Core\Model\EntityFactory $entityFactory
@@ -110,7 +110,7 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac
     /**
      * Add selected data
      *
-     * @return \Magento\Tax\Model\Resource\Report\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax.php b/app/code/Magento/Tax/Model/Resource/Report/Tax.php
index 333123db9c3e0297105873957e0ec307fcb2936c..6212d3b6674a4256809c0092e20f3d439a3b9330 100644
--- a/app/code/Magento/Tax/Model/Resource/Report/Tax.php
+++ b/app/code/Magento/Tax/Model/Resource/Report/Tax.php
@@ -68,6 +68,8 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport
 
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -79,7 +81,7 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport
      *
      * @param mixed $from
      * @param mixed $to
-     * @return \Magento\Tax\Model\Resource\Report\Tax
+     * @return $this
      */
     public function aggregate($from = null, $to = null)
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php b/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php
index b6f354757d8cf1727f405f8f720e04879501b8e8..972a20a751e68d2c624a1fad3bdf91b04be494de 100644
--- a/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php
+++ b/app/code/Magento/Tax/Model/Resource/Report/Tax/Createdat.php
@@ -38,6 +38,8 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport
 {
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -49,7 +51,7 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport
      *
      * @param mixed $from
      * @param mixed $to
-     * @return \Magento\Tax\Model\Resource\Report\Tax\Createdat
+     * @return $this
      */
     public function aggregate($from = null, $to = null)
     {
@@ -59,11 +61,11 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport
     /**
      * Aggregate Tax data by orders
      *
-     * @throws \Exception
      * @param string $aggregationField
      * @param mixed $from
      * @param mixed $to
-     * @return \Magento\Tax\Model\Resource\Report\Tax\Createdat
+     * @return $this
+     * @throws \Exception
      */
     protected function _aggregateByOrder($aggregationField, $from, $to)
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax/Updatedat.php b/app/code/Magento/Tax/Model/Resource/Report/Tax/Updatedat.php
index 2c175e1040803bec2b5119dbbbaaebd628d76a50..649daa15d950c995679a90823e713e3169ab691e 100644
--- a/app/code/Magento/Tax/Model/Resource/Report/Tax/Updatedat.php
+++ b/app/code/Magento/Tax/Model/Resource/Report/Tax/Updatedat.php
@@ -38,6 +38,8 @@ class Updatedat extends \Magento\Tax\Model\Resource\Report\Tax\Createdat
 {
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -49,7 +51,7 @@ class Updatedat extends \Magento\Tax\Model\Resource\Report\Tax\Createdat
      *
      * @param mixed $from
      * @param mixed $to
-     * @return \Magento\Tax\Model\Resource\Report\Tax\Updatedat
+     * @return $this
      */
     public function aggregate($from = null, $to = null)
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Rule/Grid/Collection.php b/app/code/Magento/Tax/Model/Resource/Rule/Grid/Collection.php
index d78419c209377b83417e905be6a7f8b0d5ef52e0..ecf0c2ddb5bfb3176f3935f5a9c232aeed528562 100644
--- a/app/code/Magento/Tax/Model/Resource/Rule/Grid/Collection.php
+++ b/app/code/Magento/Tax/Model/Resource/Rule/Grid/Collection.php
@@ -30,7 +30,7 @@ class Collection extends \Magento\Tax\Model\Resource\Calculation\Rule\Collection
     /**
      * Process loaded collection data
      *
-     * @return \Magento\Tax\Model\Resource\Rule\Grid\Collection
+     * @return $this
      */
     protected function _afterLoadData()
     {
@@ -43,9 +43,9 @@ class Collection extends \Magento\Tax\Model\Resource\Calculation\Rule\Collection
     }
 
     /**
-     * @param array|string $field
-     * @param null $condition
-     * @return \Magento\Tax\Model\Resource\Rule\Grid\Collection
+     * @param string|array $field
+     * @param null|string|array $condition
+     * @return $this
      */
     public function addFieldToFilter($field, $condition = null)
     {
diff --git a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php
index 1c2e289bb062b3e1cdd57d5b2de91b1d6b2cb514..59fa27d1d20e700bb7ed845b6939bdade7eb55f1 100644
--- a/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php
+++ b/app/code/Magento/Tax/Model/Resource/Sales/Order/Tax/Item.php
@@ -38,6 +38,8 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
     /**
      * Resource initialization
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php b/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php
index b63615a80bcf386320f3de1b3fe657272b34dd45..314a31eb65853ccc5bbd9df3e84806de16815393 100644
--- a/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php
+++ b/app/code/Magento/Tax/Model/Resource/TaxClass/Collection.php
@@ -38,6 +38,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
 {
     /**
      * Resource initialization
+     *
+     * @return void
      */
     public function _construct()
     {
@@ -48,7 +50,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add class type filter to result
      *
      * @param int $classTypeId
-     * @return \Magento\Tax\Model\Resource\TaxClass\Collection
+     * @return $this
      */
     public function setClassTypeFilter($classTypeId)
     {
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php
index 4636dddc10738169ed55c38744f4e14cc72c4e4a..5d8fbebd1102e784f48f53d8efed9f4156df7065 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php
@@ -26,6 +26,8 @@
 
 namespace Magento\Tax\Model\Sales\Total\Quote;
 
+use Magento\Sales\Model\Quote\Address;
+
 class Shipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
 {
     /**
@@ -59,6 +61,9 @@ class Shipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
 
     /**
      * Class constructor
+     *
+     * @param \Magento\Tax\Model\Calculation $calculation
+     * @param \Magento\Tax\Model\Config $taxConfig
      */
     public function __construct(\Magento\Tax\Model\Calculation $calculation, \Magento\Tax\Model\Config $taxConfig)
     {
@@ -70,10 +75,10 @@ class Shipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Collect totals information about shipping
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @return  \Magento\Sales\Model\Quote\Address\Total\Shipping
+     * @param   Address $address
+     * @return  $this
      */
-    public function collect(\Magento\Sales\Model\Quote\Address $address)
+    public function collect(Address $address)
     {
         parent::collect($address);
         $calc               = $this->_calculator;
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php
index 420e7cf12bbdf52fa5af4ba3ad9c4734c07dcc6b..c72f2031d9f8d0efe7b277968ab51a0dfb2ef105 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php
@@ -29,6 +29,9 @@
  */
 namespace Magento\Tax\Model\Sales\Total\Quote;
 
+use Magento\Sales\Model\Quote\Address;
+use Magento\Sales\Model\Quote\Item\AbstractItem;
+
 class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
 {
     /**
@@ -44,12 +47,31 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
      * @var \Magento\Tax\Model\Config
      */
     protected $_config = null;
+
+    /**
+     * @var \Magento\Tax\Helper\Data|null
+     */
     protected $_helper = null;
 
-    protected $_subtotalInclTax     = 0;
+    /**
+     * @var int
+     */
+    protected $_subtotalInclTax = 0;
+
+    /**
+     * @var int
+     */
     protected $_baseSubtotalInclTax = 0;
-    protected $_subtotal            = 0;
-    protected $_baseSubtotal        = 0;
+
+    /**
+     * @var int
+     */
+    protected $_subtotal = 0;
+
+    /**
+     * @var int
+     */
+    protected $_baseSubtotal = 0;
 
     /**
      * Flag which is initialized when collect method is started and catalog prices include tax.
@@ -111,10 +133,10 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
      * and subtotal including/excluding tax.
      * Determine discount price if needed
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @param   Address $address
+     * @return  $this
      */
-    public function collect(\Magento\Sales\Model\Quote\Address $address)
+    public function collect(Address $address)
     {
         $this->_store   = $address->getQuote()->getStore();
         $this->_address = $address;
@@ -173,11 +195,11 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     }
 
     /**
-     * Caclulate item price and row total with configured rounding level
+     * Calculate item price and row total with configured rounding level
      *
-     * @param \Magento\Sales\Model\Quote\Address $address
-     * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item
-     * @return \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @param AbstractItem $item
+     * @param \Magento\Object $taxRequest
+     * @return $this
      */
     protected function _processItem($item, $taxRequest)
     {
@@ -200,9 +222,9 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate item price and row total including/excluding tax based on unit price rounding level
      *
-     * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item
+     * @param AbstractItem $item
      * @param \Magento\Object $request
-     * @return \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @return $this
      */
     protected function _unitBaseCalculation($item, $request)
     {
@@ -312,9 +334,9 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate item price and row total including/excluding tax based on row total price rounding level
      *
-     * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item
+     * @param AbstractItem $item
      * @param \Magento\Object $request
-     * @return \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @return $this
      */
     protected function _rowBaseCalculation($item, $request)
     {
@@ -427,9 +449,9 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate item price and row total including/excluding tax based on total price rounding level
      *
-     * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item
+     * @param AbstractItem $item
      * @param \Magento\Object $request
-     * @return \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @return $this
      */
     protected function _totalBaseCalculation($item, $request)
     {
@@ -624,10 +646,10 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Recalculate row information for item based on children calculation
      *
-     * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @param   AbstractItem $item
+     * @return  $this
      */
-    protected function _recalculateParent(\Magento\Sales\Model\Quote\Item\AbstractItem $item)
+    protected function _recalculateParent(AbstractItem $item)
     {
         $price       = 0;
         $basePrice   = 0;
@@ -661,7 +683,7 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Get request for fetching store tax rate
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
+     * @param   Address $address
      * @return  \Magento\Object
      */
     protected function _getStoreTaxRequest($address)
@@ -675,7 +697,7 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Get request for fetching address tax rate
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
+     * @param   Address $address
      * @return  \Magento\Object
      */
     protected function _getAddressTaxRequest($address)
@@ -692,11 +714,11 @@ class Subtotal extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Add row total item amount to subtotal
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Subtotal
+     * @param   Address $address
+     * @param   AbstractItem $item
+     * @return  $this
      */
-    protected function _addSubtotalAmount(\Magento\Sales\Model\Quote\Address $address, $item)
+    protected function _addSubtotalAmount(Address $address, $item)
     {
         $address->setTotalAmount('subtotal', $address->getTotalAmount('subtotal')+$item->getRowTotal());
         $address->setBaseTotalAmount('subtotal', $address->getBaseTotalAmount('subtotal')+$item->getBaseRowTotal());
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php
index af1e81ab8a411149c7a12a44cbde4d697261ea78..070e3baf7bb2dfe017e43923be0042bed6cec0f1 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php
@@ -23,13 +23,17 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Tax\Model\Sales\Total\Quote;
+
+use Magento\Core\Model\Store;
+use Magento\Sales\Model\Quote\Address;
+use Magento\Sales\Model\Quote\Address\Total\AbstractTotal;
+use Magento\Sales\Model\Quote\Item\AbstractItem;
 
 /**
  * Tax totals calculation model
  */
-namespace Magento\Tax\Model\Sales\Total\Quote;
-
-class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
+class Tax extends AbstractTotal
 {
     /**
      * Tax module helper
@@ -60,10 +64,19 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
      */
     protected $_areTaxRequestsSimilar = false;
 
-
+    /**
+     * @var array
+     */
     protected $_roundingDeltas = array();
+
+    /**
+     * @var array
+     */
     protected $_baseRoundingDeltas = array();
 
+    /**
+     * @var Store
+     */
     protected $_store;
 
     /**
@@ -75,6 +88,10 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
 
     /**
      * Class constructor
+     *
+     * @param \Magento\Tax\Helper\Data $taxData
+     * @param \Magento\Tax\Model\Calculation $calculation
+     * @param \Magento\Tax\Model\Config $taxConfig
      */
     public function __construct(
         \Magento\Tax\Helper\Data $taxData,
@@ -90,10 +107,10 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Collect tax totals for quote address
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @param   Address $address
+     * @return  $this
      */
-    public function collect(\Magento\Sales\Model\Quote\Address $address)
+    public function collect(Address $address)
     {
         parent::collect($address);
         $this->_roundingDeltas      = array();
@@ -207,11 +224,11 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Tax caclulation for shipping price
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
+     * @param   Address $address
      * @param   \Magento\Object $taxRateRequest
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @return  $this
      */
-    protected function _calculateShippingTax(\Magento\Sales\Model\Quote\Address $address, $taxRateRequest)
+    protected function _calculateShippingTax(Address $address, $taxRateRequest)
     {
         $taxRateRequest->setProductClassId($this->_config->getShippingTaxClass($this->_store));
         $rate           = $this->_calculator->getRate($taxRateRequest);
@@ -279,10 +296,11 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate address tax amount based on one unit price and tax amount
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @param Address $address
+     * @param \Magento\Object $taxRateRequest
+     * @return $this
      */
-    protected function _unitBaseCalculation(\Magento\Sales\Model\Quote\Address $address, $taxRateRequest)
+    protected function _unitBaseCalculation(Address $address, $taxRateRequest)
     {
         $items = $this->_getAddressItems($address);
         $itemTaxGroups  = array();
@@ -343,11 +361,11 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate unit tax anount based on unit price
      *
-     * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
+     * @param   AbstractItem $item
      * @param   float $rate
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @return  $this
      */
-    protected function _calcUnitTaxAmount(\Magento\Sales\Model\Quote\Item\AbstractItem $item, $rate)
+    protected function _calcUnitTaxAmount(AbstractItem $item, $rate)
     {
         $qty        = $item->getTotalQty();
         $inclTax    = $item->getIsPriceInclTax();
@@ -413,11 +431,11 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate address total tax based on row total
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
+     * @param   Address $address
      * @param   \Magento\Object $taxRateRequest
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @return  $this
      */
-    protected function _rowBaseCalculation(\Magento\Sales\Model\Quote\Address $address, $taxRateRequest)
+    protected function _rowBaseCalculation(Address $address, $taxRateRequest)
     {
         $items = $this->_getAddressItems($address);
         $itemTaxGroups  = array();
@@ -478,9 +496,9 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate item tax amount based on row total
      *
-     * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
+     * @param   AbstractItem $item
      * @param   float $rate
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @return  $this
      */
     protected function _calcRowTaxAmount($item, $rate)
     {
@@ -545,11 +563,11 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Calculate address total tax based on address subtotal
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
+     * @param   Address $address
      * @param   \Magento\Object $taxRateRequest
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @return  $this
      */
-    protected function _totalBaseCalculation(\Magento\Sales\Model\Quote\Address $address, $taxRateRequest)
+    protected function _totalBaseCalculation(Address $address, $taxRateRequest)
     {
         $items          = $this->_getAddressItems($address);
         $store          = $address->getQuote()->getStore();
@@ -607,10 +625,10 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Aggregate row totals per tax rate in array
      *
-     * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
+     * @param   AbstractItem $item
      * @param   float $rate
-     * @param   array $taxGroups
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @param   array &$taxGroups
+     * @return  $this
      */
     protected function _aggregateTaxPerRate($item, $rate, &$taxGroups)
     {
@@ -726,10 +744,10 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Recalculate parent item amounts base on children data
      *
-     * @param   \Magento\Sales\Model\Quote\Item\AbstractItem $item
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @param   AbstractItem $item
+     * @return  $this
      */
-    protected function _recalculateParent(\Magento\Sales\Model\Quote\Item\AbstractItem $item)
+    protected function _recalculateParent(AbstractItem $item)
     {
         $rowTaxAmount       = 0;
         $baseRowTaxAmount   = 0;
@@ -745,13 +763,14 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Collect applied tax rates information on address level
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @param   array $applied
-     * @param   float $amount
-     * @param   float $baseAmount
-     * @param   float $rate
+     * @param Address $address
+     * @param array $applied
+     * @param float $amount
+     * @param float $baseAmount
+     * @param float $rate
+     * @return void
      */
-    protected function _saveAppliedTaxes(\Magento\Sales\Model\Quote\Address $address, $applied, $amount, $baseAmount, $rate)
+    protected function _saveAppliedTaxes(Address $address, $applied, $amount, $baseAmount, $rate)
     {
         $previouslyAppliedTaxes = $address->getAppliedTaxes();
         $process = count($previouslyAppliedTaxes);
@@ -796,10 +815,10 @@ class Tax extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal
     /**
      * Add tax totals information to address object
      *
-     * @param   \Magento\Sales\Model\Quote\Address $address
-     * @return  \Magento\Tax\Model\Sales\Total\Quote\Tax
+     * @param   Address $address
+     * @return  $this
      */
-    public function fetch(\Magento\Sales\Model\Quote\Address $address)
+    public function fetch(Address $address)
     {
         $applied    = $address->getAppliedTaxes();
         $store      = $address->getQuote()->getStore();
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php b/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php
index 010de42d5d6f54564f693af5d3c5a4e02a28596b..5261d5887c83f9b52230ab53380b8afd3dd907ac 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php
@@ -28,8 +28,14 @@ namespace Magento\Tax\Model\System\Config\Source;
 
 class Algorithm implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @var array
+     */
     protected $_options;
 
+    /**
+     * Initialize the options array
+     */
     public function __construct()
     {
         $this->_options = array(
@@ -48,6 +54,9 @@ class Algorithm implements \Magento\Core\Model\Option\ArrayInterface
         );
     }
 
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return $this->_options;
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Apply.php b/app/code/Magento/Tax/Model/System/Config/Source/Apply.php
index 0615434f137f23f3b6c400acffdff780c2e3991e..a44c086d70b67ba404a5430d6dba870808b651d6 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Apply.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Apply.php
@@ -28,8 +28,14 @@ namespace Magento\Tax\Model\System\Config\Source;
 
 class Apply implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @var array
+     */
     protected $_options;
 
+    /**
+     * Initialize the options array
+     */
     public function __construct()
     {
         $this->_options = array(
@@ -44,6 +50,9 @@ class Apply implements \Magento\Core\Model\Option\ArrayInterface
         );
     }
 
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return $this->_options;
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php b/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php
index 0b2404e124d4b16f7ecfd199c3ff8404e43f6580..87df0a045556057971680a6b8f70009fe3885ec9 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php
@@ -28,6 +28,9 @@ namespace Magento\Tax\Model\System\Config\Source;
 
 class PriceType implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @var array
+     */
     protected $_options;
 
     public function __construct()
@@ -44,6 +47,9 @@ class PriceType implements \Magento\Core\Model\Option\ArrayInterface
         );
     }
 
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return $this->_options;
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
index a420ed7bc0af5fc94de0fed4fc0640d2082fa18e..0a31c055afad089514165f3e2a856a297ec18526 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
@@ -29,8 +29,15 @@ namespace Magento\Tax\Model\System\Config\Source\Tax;
 
 class Country extends \Magento\Directory\Model\Config\Source\Country
 {
+    /**
+     * @var array
+     */
     protected $_options;
 
+    /**
+     * @param bool $noEmpty
+     * @return array
+     */
     public function toOptionArray($noEmpty=false)
     {
         $options = parent::toOptionArray($noEmpty);
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php
index 69962273206415010c57cc917376fe258f49d329..d848ab6a940e5c73128456a4f7dafb3b76b9cd9d 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php
@@ -33,8 +33,14 @@ namespace Magento\Tax\Model\System\Config\Source\Tax\Display;
 
 class Type implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @var array
+     */
     protected $_options;
 
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         if (!$this->_options) {
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php
index 7a8b78be9e1034d658d1d07368b96c022e3a7e9d..13db8946479b1cce9eb8a9ff403bcc31be3a2bf3 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php
@@ -28,6 +28,9 @@ namespace Magento\Tax\Model\System\Config\Source\Tax;
 
 class Region implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @var array
+     */
     protected $_options;
 
     /**
@@ -43,6 +46,11 @@ class Region implements \Magento\Core\Model\Option\ArrayInterface
         $this->_regionsFactory = $regionsFactory;
     }
 
+    /**
+     * @param bool $noEmpty
+     * @param string|array|null $country
+     * @return array
+     */
     public function toOptionArray($noEmpty = false, $country = null)
     {
         /** @var $region \Magento\Directory\Model\Resource\Region\Collection */
diff --git a/app/code/Magento/Tax/etc/crontab.xml b/app/code/Magento/Tax/etc/crontab.xml
index 46c7ed8e9bfaa1aaec5832c352ca7f94ff56a90b..2c1b048cb91576da7d91f2e629b35a878299e692 100644
--- a/app/code/Magento/Tax/etc/crontab.xml
+++ b/app/code/Magento/Tax/etc/crontab.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="aggregate_sales_report_tax_data" instance="Magento\Tax\Model\Observer" method="aggregateSalesReportTaxData">
-        <schedule>0 0 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="aggregate_sales_report_tax_data" instance="Magento\Tax\Model\Observer" method="aggregateSalesReportTaxData">
+            <schedule>0 0 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/app/code/Magento/Tax/view/frontend/checkout/tax.phtml b/app/code/Magento/Tax/view/frontend/checkout/tax.phtml
index ea44d6a5265d5c4509bcdce182d5e162a71db09d..84368cfa6a4162dc4d300a65b59bd6f2a3e1d58f 100644
--- a/app/code/Magento/Tax/view/frontend/checkout/tax.phtml
+++ b/app/code/Magento/Tax/view/frontend/checkout/tax.phtml
@@ -64,7 +64,7 @@
 <?php
     $attributes = 'class="totals tax"';
     if ($this->helper('Magento\Tax\Helper\Data')->displayFullSummary() && $_value!=0) {
-        $attributes = 'class="totals tax summary" data-mage-init=\'{toggleAdvanced: {selectorsToggleClass: "shown", baseToggleClass: "expanded", toggleContainers: ".totals.tax.details"}}\'';
+        $attributes = 'class="totals tax summary" data-mage-init=\'{"toggleAdvanced": {"selectorsToggleClass": "shown", "baseToggleClass": "expanded", "toggleContainers": ".totals.tax.details"}}\'';
     }
 ?>
 
diff --git a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php
index 21539d381901978c60d89c0a907e9bc8c7ec0cb8..8eb6de1099d09f466971d59690267d84093cc8a1 100644
--- a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php
+++ b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/File.php
@@ -34,14 +34,14 @@ class File extends \Magento\Data\Form\Element\File
     /**
      * Additional html attributes
      *
-     * @var array
+     * @var string[]
      */
     protected $_htmlAttributes = array('accept', 'multiple');
 
     /**
      * Html attributes
      *
-     * @return array
+     * @return string[]
      */
     public function getHtmlAttributes()
     {
diff --git a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php
index 0016826a0a96a912758e9fc2fcf97ab64f55a84a..2a5379c87113c39bdfbd045b64186e57d103ae25 100644
--- a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php
+++ b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Form/Element/Links.php
@@ -105,7 +105,7 @@ class Links
     /**
      * Prepare array of anchor attributes
      *
-     * @return array
+     * @return string[]
      */
     public function getHtmlAttributes()
     {
diff --git a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php
index 3e25716156469ba9f88b75125f786ffaae540739..7598a532f479cb4ce60ddede53cedded8bd9f5b8 100644
--- a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php
+++ b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Css.php
@@ -83,7 +83,7 @@ class Css
     /**
      * Create a form element with necessary controls
      *
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -115,7 +115,7 @@ class Css
     /**
      * Set theme css fieldset
      *
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css
+     * @return $this
      */
     protected function _addThemeCssFieldset()
     {
@@ -159,7 +159,7 @@ class Css
     /**
      * Set custom css fieldset
      *
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css
+     * @return $this
      */
     protected function _addCustomCssFieldset()
     {
diff --git a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php
index ac7007e2a0451fdfe5f25bc1deaa5f7acee9f537..1ac6786447ae16af210fd7a38ae161b285a5328f 100644
--- a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php
+++ b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/General.php
@@ -77,7 +77,7 @@ class General
     /**
      * Create a form element with necessary controls
      *
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\General|\Magento\Backend\Block\Widget\Form
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -113,7 +113,7 @@ class General
      *
      * @param \Magento\Data\Form $form
      * @param array $formData
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\General
+     * @return $this
      */
     protected function _addThemeFieldset($form, $formData)
     {
@@ -210,7 +210,7 @@ class General
     /**
      * No field notes if theme is not editable
      *
-     * @param $text
+     * @param string $text
      * @return string
      */
     protected function _filterFieldNote($text)
@@ -287,7 +287,7 @@ class General
     /**
      * Get theme default values while inheriting other theme
      *
-     * @param $themesCollections
+     * @param array $themesCollections
      * @return array
      */
     protected function _getDefaultsInherited($themesCollections)
diff --git a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php
index 40f967ce6e3a776caf1b7ecc254953622f205522..12f8c7cb85e18dad788675ea0689256197c13436 100644
--- a/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php
+++ b/app/code/Magento/Theme/Block/Adminhtml/System/Design/Theme/Edit/Tab/Js.php
@@ -37,7 +37,7 @@ class Js
     /**
      * Create a form element with necessary controls
      *
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Js
+     * @return $this
      */
     protected function _prepareForm()
     {
@@ -52,7 +52,7 @@ class Js
     /**
      * Set theme js fieldset
      *
-     * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Js
+     * @return $this
      */
     protected function _addThemeJsFieldset()
     {
diff --git a/app/code/Magento/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php b/app/code/Magento/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php
index baaa7d3e8a885856605bcc8b2b312a8486e915e8..13635cb26060d6a8613ccf6cd552328c39c46acc 100644
--- a/app/code/Magento/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php
+++ b/app/code/Magento/Theme/Block/Adminhtml/Wysiwyg/Files/Content.php
@@ -62,6 +62,8 @@ class Content extends \Magento\Backend\Block\Widget\Container
 
     /**
      * Block construction
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Theme/Block/Html.php b/app/code/Magento/Theme/Block/Html.php
index 7c2ebee96a9ac1629aa5b184f05e04de9d37a690..982b8c95f1fa2145af5f57c3bbe366c14571f237 100644
--- a/app/code/Magento/Theme/Block/Html.php
+++ b/app/code/Magento/Theme/Block/Html.php
@@ -43,6 +43,7 @@ class Html extends \Magento\View\Element\Template
 
     /**
      * Add block data
+     * @return void
      */
     protected function _construct()
     {
@@ -141,7 +142,7 @@ class Html extends \Magento\View\Element\Template
      * Set header title
      *
      * @param string $title
-     * @return \Magento\Theme\Block\Html
+     * @return $this
      */
     public function setHeaderTitle($title)
     {
@@ -163,7 +164,7 @@ class Html extends \Magento\View\Element\Template
      * Add CSS class to page body tag
      *
      * @param string $className
-     * @return \Magento\Theme\Block\Html
+     * @return $this
      */
     public function addBodyClass($className)
     {
diff --git a/app/code/Magento/Theme/Block/Html/Breadcrumbs.php b/app/code/Magento/Theme/Block/Html/Breadcrumbs.php
index eca1c6aef36c9f3578b2d7a7b66d75e9d91da012..f1120dce74a2a0c367aeed9c85a108ef966ad240 100644
--- a/app/code/Magento/Theme/Block/Html/Breadcrumbs.php
+++ b/app/code/Magento/Theme/Block/Html/Breadcrumbs.php
@@ -39,7 +39,7 @@ class Breadcrumbs extends \Magento\View\Element\Template
     /**
      * List of available breadcrumb properties
      *
-     * @var array
+     * @var string[]
      */
     protected $_properties = array(
         'label',
@@ -69,7 +69,7 @@ class Breadcrumbs extends \Magento\View\Element\Template
      *
      * @param string $crumbName
      * @param array $crumbInfo
-     * @return \Magento\Theme\Block\Html\Breadcrumbs
+     * @return $this
      */
     public function addCrumb($crumbName, $crumbInfo)
     {
diff --git a/app/code/Magento/Theme/Block/Html/Footer.php b/app/code/Magento/Theme/Block/Html/Footer.php
index ee61c96227446673cb7d01c1e845e197d69688dd..bb7ecad4ba685c0b28c127c645616d117fa69310 100644
--- a/app/code/Magento/Theme/Block/Html/Footer.php
+++ b/app/code/Magento/Theme/Block/Html/Footer.php
@@ -57,6 +57,8 @@ class Footer extends \Magento\View\Element\Template
 
     /**
      * Set footer data
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Theme/Block/Html/Head.php b/app/code/Magento/Theme/Block/Html/Head.php
index 4902352edb13bf83e08af1786d1b11e6b03462a3..802b18ca4f7cd9bfded689d00f299630344ca7f2 100644
--- a/app/code/Magento/Theme/Block/Html/Head.php
+++ b/app/code/Magento/Theme/Block/Html/Head.php
@@ -107,7 +107,7 @@ class Head extends \Magento\View\Element\Template
      *
      * @param string $title
      * @param string $href
-     * @return \Magento\Theme\Block\Html\Head
+     * @return $this
      */
     public function addRss($title, $href)
     {
@@ -123,11 +123,11 @@ class Head extends \Magento\View\Element\Template
     }
 
     /**
+     * Render HTML for the added head items
+     *
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
      *
-     * Render HTML for the added head items
-     *
      * @return string
      */
     public function getCssJsHtml()
@@ -208,6 +208,7 @@ class Head extends \Magento\View\Element\Template
                 $result .= sprintf($template, $asset->getUrl());
             }
         } catch (\Magento\Exception $e) {
+            $this->_logger->logException($e);
             $result .= sprintf($template, $this->_getNotFoundUrl());
         }
         return $result;
@@ -290,7 +291,7 @@ class Head extends \Magento\View\Element\Template
     /**
      * Same as getTitle(), but return only first item from chunk for backend pages
      *
-     * @return mixed|string
+     * @return mixed
      */
     public function getShortTitle()
     {
diff --git a/app/code/Magento/Theme/Block/Html/Pager.php b/app/code/Magento/Theme/Block/Html/Pager.php
index ca0123e8357af0056eb010eeb9cb7b8b39023687..2284f5b07a873339ce42e928e8c3f9b4988bc049 100644
--- a/app/code/Magento/Theme/Block/Html/Pager.php
+++ b/app/code/Magento/Theme/Block/Html/Pager.php
@@ -74,7 +74,7 @@ class Pager extends \Magento\View\Element\Template
     protected $_showPerPage = true;
 
     /**
-     * @var null
+     * @var int
      */
     protected $_limit;
 
@@ -120,6 +120,8 @@ class Pager extends \Magento\View\Element\Template
 
     /**
      * Set pager data
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -167,7 +169,7 @@ class Pager extends \Magento\View\Element\Template
      * Setter for limit items per page
      *
      * @param int $limit
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setLimit($limit)
     {
@@ -179,7 +181,7 @@ class Pager extends \Magento\View\Element\Template
      * Set collection for pagination
      *
      * @param  \Magento\Data\Collection $collection
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setCollection($collection)
     {
@@ -204,7 +206,7 @@ class Pager extends \Magento\View\Element\Template
 
     /**
      * @param string $varName
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setPageVarName($varName)
     {
@@ -222,7 +224,7 @@ class Pager extends \Magento\View\Element\Template
 
     /**
      * @param bool $varName
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setShowPerPage($varName)
     {
@@ -245,7 +247,7 @@ class Pager extends \Magento\View\Element\Template
      * Set the name for pager limit data
      *
      * @param string $varName
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setLimitVarName($varName)
     {
@@ -267,6 +269,7 @@ class Pager extends \Magento\View\Element\Template
      * Set pager limit
      *
      * @param array $limits
+     * @return void
      */
     public function setAvailableLimit(array $limits)
     {
@@ -497,7 +500,7 @@ class Pager extends \Magento\View\Element\Template
     /**
      * Return page number of Previous jump
      *
-     * @return int
+     * @return int|null
      */
     public function getPreviousJumpPage()
     {
@@ -526,7 +529,7 @@ class Pager extends \Magento\View\Element\Template
     /**
      * Return page number of Next jump
      *
-     * @return int
+     * @return int|null
      */
     public function getNextJumpPage()
     {
@@ -576,7 +579,7 @@ class Pager extends \Magento\View\Element\Template
      * Setter for $_frameLength
      *
      * @param int $frame
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setFrameLength($frame)
     {
@@ -596,7 +599,7 @@ class Pager extends \Magento\View\Element\Template
      * Setter for $_jump
      *
      * @param int $jump
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setJump($jump)
     {
@@ -652,7 +655,7 @@ class Pager extends \Magento\View\Element\Template
     /**
      * Initialize frame data, such as frame start, frame start etc.
      *
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     protected function _initFrame()
     {
@@ -692,7 +695,7 @@ class Pager extends \Magento\View\Element\Template
      * Setter for flag _frameInitialized
      *
      * @param bool $flag
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     protected function _setFrameInitialized($flag)
     {
@@ -703,7 +706,7 @@ class Pager extends \Magento\View\Element\Template
     /**
      * Check if frame data was initialized
      *
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return bool
      */
     public function isFrameInitialized()
     {
@@ -734,7 +737,7 @@ class Pager extends \Magento\View\Element\Template
      * Set whether output of the pager is mandatory
      *
      * @param bool $isRequired
-     * @return \Magento\Theme\Block\Html\Pager
+     * @return $this
      */
     public function setIsOutputRequired($isRequired)
     {
diff --git a/app/code/Magento/Theme/Block/Html/Title.php b/app/code/Magento/Theme/Block/Html/Title.php
index 17f19124f2d550fc0ab682c38085775cc5c0512c..62b02a16c80c5d46f73b615319809f7c3fed1f93 100644
--- a/app/code/Magento/Theme/Block/Html/Title.php
+++ b/app/code/Magento/Theme/Block/Html/Title.php
@@ -53,6 +53,7 @@ class Title extends \Magento\View\Element\Template
      * Set own page title
      *
      * @param string $pageTitle
+     * @return void
      */
     public function setPageTitle($pageTitle)
     {
diff --git a/app/code/Magento/Theme/Block/Html/Topmenu.php b/app/code/Magento/Theme/Block/Html/Topmenu.php
index 3e286a298b0239601517cca57f4b7129b4fce84c..fde794411bcc31fd8d9ad952191ea2822bc39446 100644
--- a/app/code/Magento/Theme/Block/Html/Topmenu.php
+++ b/app/code/Magento/Theme/Block/Html/Topmenu.php
@@ -38,6 +38,8 @@ class Topmenu extends \Magento\View\Element\Template
 
     /**
      * Init top menu tree structure
+     *
+     * @return void
      */
     public function _construct()
     {
@@ -95,7 +97,7 @@ class Topmenu extends \Magento\View\Element\Template
      *
      * @param \Magento\Backend\Model\Menu $items
      * @param int $limit
-     * @return array
+     * @return array|void
      *
      * @todo: Add Depth Level limit, and better logic for columns
      */
diff --git a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php
index 7dde52893f805a74e8830eebe7cc8af64ffc8613..4246d132f68a0b9b26362bcdbfc598e5f9b0941d 100644
--- a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php
+++ b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme.php
@@ -29,6 +29,8 @@
  */
 namespace Magento\Theme\Controller\Adminhtml\System\Design;
 
+use Magento\App\ResponseInterface;
+
 class Theme extends \Magento\Backend\App\Action
 {
     /**
@@ -60,6 +62,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Index action
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -70,6 +74,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Grid ajax action
+     *
+     * @return void
      */
     public function gridAction()
     {
@@ -79,6 +85,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Create new theme
+     *
+     * @return void
      */
     public function newAction()
     {
@@ -87,6 +95,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Edit theme
+     *
+     * @return void
      */
     public function editAction()
     {
@@ -123,6 +133,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Save action
+     *
+     * @return void
      */
     public function saveAction()
     {
@@ -180,6 +192,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Delete action
+     *
+     * @return void
      */
     public function deleteAction()
     {
@@ -214,6 +228,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Upload css file
+     *
+     * @return void
      */
     public function uploadCssAction()
     {
@@ -234,6 +250,7 @@ class Theme extends \Magento\Backend\App\Action
     /**
      * Upload js file
      *
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function uploadJsAction()
@@ -273,6 +290,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Download custom css file
+     *
+     * @return ResponseInterface|void
      */
     public function downloadCustomCssAction()
     {
@@ -309,6 +328,8 @@ class Theme extends \Magento\Backend\App\Action
 
     /**
      * Download css file
+     *
+     * @return ResponseInterface|void
      */
     public function downloadCssAction()
     {
diff --git a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php
index a2dfef884c6da39a3de50bff7e0507c5302f3780..82dbf18888bc1d3af6e6e83f11126c2f74ae298f 100644
--- a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php
+++ b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Wysiwyg/Files.php
@@ -29,6 +29,8 @@
  */
 namespace Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg;
 
+use Magento\App\ResponseInterface;
+
 class Files extends \Magento\Backend\App\Action
 {
     /**
@@ -50,6 +52,8 @@ class Files extends \Magento\Backend\App\Action
     
     /**
      * Index action
+     *
+     * @return void
      */
     public function indexAction()
     {
@@ -59,6 +63,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Tree json action
+     *
+     * @return void
      */
     public function treeJsonAction()
     {
@@ -75,6 +81,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * New folder action
+     *
+     * @return void
      */
     public function newFolderAction()
     {
@@ -93,6 +101,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Delete folder action
+     *
+     * @return void
      */
     public function deleteFolderAction()
     {
@@ -107,6 +117,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Contents action
+     *
+     * @return void
      */
     public function contentsAction()
     {
@@ -126,6 +138,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Files upload action
+     *
+     * @return void
      */
     public function uploadAction()
     {
@@ -140,6 +154,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Preview image action
+     *
+     * @return ResponseInterface|void
      */
     public function previewImageAction()
     {
@@ -163,6 +179,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Delete file from media storage
+     *
+     * @return void
      * @throws \Exception
      */
     public function deleteFilesAction()
@@ -185,6 +203,8 @@ class Files extends \Magento\Backend\App\Action
 
     /**
      * Fire when select image
+     *
+     * @return void
      */
     public function onInsertAction()
     {
diff --git a/app/code/Magento/Theme/Helper/Storage.php b/app/code/Magento/Theme/Helper/Storage.php
index bdfed246db64026c9f77d125b62bc3095c519729..e30a33e6688df56ca9d34231c8362a17935e6a8c 100644
--- a/app/code/Magento/Theme/Helper/Storage.php
+++ b/app/code/Magento/Theme/Helper/Storage.php
@@ -269,7 +269,7 @@ class Storage extends \Magento\App\Helper\AbstractHelper
     /**
      * Get thumbnail path in current directory by image name
      *
-     * @param $imageName
+     * @param string $imageName
      * @return string
      * @throws \InvalidArgumentException
      */
@@ -305,7 +305,7 @@ class Storage extends \Magento\App\Helper\AbstractHelper
     /**
      * Get allowed extensions by type
      *
-     * @return array
+     * @return string[]
      * @throws \Magento\Exception
      */
     public function getAllowedExtensionsByType()
diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php
index 1aa12001593d3830fde554b6b33f15e34aa382ea..f81769f8f250d2ac1811ef3ba880870f3d4801fc 100644
--- a/app/code/Magento/Theme/Model/Config.php
+++ b/app/code/Magento/Theme/Model/Config.php
@@ -148,8 +148,8 @@ class Config
      * @param string $themeId
      * @param array $stores
      * @param string $scope
-     * @param bool $isReassigned
-     * @return Config
+     * @param bool &$isReassigned
+     * @return $this
      */
     protected function _unassignThemeFromStores($themeId, $stores, $scope, &$isReassigned)
     {
@@ -169,8 +169,8 @@ class Config
      * @param string $themeId
      * @param array $stores
      * @param string $scope
-     * @param bool $isReassigned
-     * @return Config
+     * @param bool &$isReassigned
+     * @return $this
      */
     protected function _assignThemeToStores($themeId, $stores, $scope, &$isReassigned)
     {
@@ -188,8 +188,8 @@ class Config
      * Assign theme to default scope
      *
      * @param string $themeId
-     * @param bool $isReassigned
-     * @return Config
+     * @param bool &$isReassigned
+     * @return $this
      */
     protected function _assignThemeToDefaultScope($themeId, &$isReassigned)
     {
diff --git a/app/code/Magento/Theme/Model/Config/Customization.php b/app/code/Magento/Theme/Model/Config/Customization.php
index a083e4375e59a79135468c6ac2d6ed6e74940cbc..5f3b32f0fbc593112fa385f8280a292122cfabdd 100644
--- a/app/code/Magento/Theme/Model/Config/Customization.php
+++ b/app/code/Magento/Theme/Model/Config/Customization.php
@@ -184,7 +184,7 @@ class Customization
      * NOTE: To get into "assigned" list theme customization not necessary should be assigned to store-view directly.
      * It can be set to website or as default theme and be used by store-view via config fallback mechanism.
      *
-     * @return Customization
+     * @return $this
      */
     protected function _prepareThemeCustomizations()
     {
diff --git a/app/code/Magento/Theme/Model/CopyService.php b/app/code/Magento/Theme/Model/CopyService.php
index be261bfb0adc55000d90122a4320fd5f2ee3779f..902d3a04f09ed8de7f45a99fe3ed58a77abfd8c0 100644
--- a/app/code/Magento/Theme/Model/CopyService.php
+++ b/app/code/Magento/Theme/Model/CopyService.php
@@ -29,6 +29,8 @@
  */
 namespace Magento\Theme\Model;
 
+use Magento\View\Design\ThemeInterface;
+
 class CopyService
 {
     /**
@@ -88,10 +90,11 @@ class CopyService
     /**
      * Copy customizations from one theme to another
      *
-     * @param \Magento\View\Design\ThemeInterface $source
-     * @param \Magento\View\Design\ThemeInterface $target
+     * @param ThemeInterface $source
+     * @param ThemeInterface $target
+     * @return void
      */
-    public function copy(\Magento\View\Design\ThemeInterface $source, \Magento\View\Design\ThemeInterface $target)
+    public function copy(ThemeInterface $source, ThemeInterface $target)
     {
         $this->_copyDatabaseCustomization($source, $target);
         $this->_copyLayoutCustomization($source, $target);
@@ -101,12 +104,13 @@ class CopyService
     /**
      * Copy customizations stored in a database from one theme to another, overriding existing data
      *
-     * @param \Magento\View\Design\ThemeInterface $source
-     * @param \Magento\View\Design\ThemeInterface $target
+     * @param ThemeInterface $source
+     * @param ThemeInterface $target
+     * @return void
      */
     protected function _copyDatabaseCustomization(
-        \Magento\View\Design\ThemeInterface $source,
-        \Magento\View\Design\ThemeInterface $target
+        ThemeInterface $source,
+        ThemeInterface $target
     ) {
         /** @var $themeFile \Magento\Core\Model\Theme\File */
         foreach ($target->getCustomization()->getFiles() as $themeFile) {
@@ -132,12 +136,13 @@ class CopyService
     /**
      * Add layout links to general layout updates for themes
      *
-     * @param \Magento\View\Design\ThemeInterface $source
-     * @param \Magento\View\Design\ThemeInterface $target
+     * @param ThemeInterface $source
+     * @param ThemeInterface $target
+     * @return void
      */
     protected function _copyLayoutCustomization(
-        \Magento\View\Design\ThemeInterface $source,
-        \Magento\View\Design\ThemeInterface $target
+        ThemeInterface $source,
+        ThemeInterface $target
     ) {
         $update = $this->_updateFactory->create();
         /** @var $targetUpdates \Magento\Core\Model\Resource\Layout\Update\Collection */
@@ -167,12 +172,13 @@ class CopyService
     /**
      * Copy customizations stored in a file system from one theme to another, overriding existing data
      *
-     * @param \Magento\View\Design\ThemeInterface $source
-     * @param \Magento\View\Design\ThemeInterface $target
+     * @param ThemeInterface $source
+     * @param ThemeInterface $target
+     * @return void
      */
     protected function _copyFilesystemCustomization(
-        \Magento\View\Design\ThemeInterface $source,
-        \Magento\View\Design\ThemeInterface $target
+        ThemeInterface $source,
+        ThemeInterface $target
     ) {
         $sourcePath = $this->_customizationPath->getCustomizationPath($source);
         $targetPath = $this->_customizationPath->getCustomizationPath($target);
@@ -194,6 +200,7 @@ class CopyService
      * @param string $baseDir
      * @param string $sourceDir
      * @param string $targetDir
+     * @return void
      */
     protected function _copyFilesRecursively($baseDir, $sourceDir, $targetDir)
     {
@@ -211,6 +218,7 @@ class CopyService
      * Delete all files in a directory recursively
      *
      * @param string $targetDir
+     * @return void
      */
     protected function _deleteFilesRecursively($targetDir)
     {
diff --git a/app/code/Magento/Theme/view/frontend/1column.phtml b/app/code/Magento/Theme/view/frontend/1column.phtml
index b51f3fcc95a948bf1f584f71446b51d93e86d89b..d2b241dae5144072bb65d277b60f765bcaba2317 100644
--- a/app/code/Magento/Theme/view/frontend/1column.phtml
+++ b/app/code/Magento/Theme/view/frontend/1column.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="col1-layout<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('global_notices') ?>
diff --git a/app/code/Magento/Theme/view/frontend/2columns-left.phtml b/app/code/Magento/Theme/view/frontend/2columns-left.phtml
index 5644f07412ff536d3e7de344756cb79ef4c1d869..9b9bb1b6c266baa55278f751613566c38757b31c 100644
--- a/app/code/Magento/Theme/view/frontend/2columns-left.phtml
+++ b/app/code/Magento/Theme/view/frontend/2columns-left.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="col2-left-layout<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute(); ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('global_notices') ?>
diff --git a/app/code/Magento/Theme/view/frontend/2columns-right.phtml b/app/code/Magento/Theme/view/frontend/2columns-right.phtml
index e4e2780ca30e85e96ec84ef6b5f05e6c7f74459b..6321f9c82618f9ca667c0c86ba2a34fcd9fbd2e3 100644
--- a/app/code/Magento/Theme/view/frontend/2columns-right.phtml
+++ b/app/code/Magento/Theme/view/frontend/2columns-right.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="col2-right-layout<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('global_notices') ?>
diff --git a/app/code/Magento/Theme/view/frontend/3columns.phtml b/app/code/Magento/Theme/view/frontend/3columns.phtml
index 71cfc30f06420f484729ec32ec311e24547c21d7..39ae662089f8cad5948aa93672543261d813c611 100644
--- a/app/code/Magento/Theme/view/frontend/3columns.phtml
+++ b/app/code/Magento/Theme/view/frontend/3columns.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="col3-layout<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('global_notices') ?>
diff --git a/app/code/Magento/Theme/view/frontend/empty.phtml b/app/code/Magento/Theme/view/frontend/empty.phtml
index c1888695102141d0365008019ab2792620535eba..32d6376fd1189dcb488e9499c53dc0ce338ddbef 100644
--- a/app/code/Magento/Theme/view/frontend/empty.phtml
+++ b/app/code/Magento/Theme/view/frontend/empty.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="page-empty<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('global_notices') ?>
@@ -55,4 +55,4 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
     </div>
     <?php echo $this->getAbsoluteFooter() ?>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/app/code/Magento/Theme/view/frontend/page.phtml b/app/code/Magento/Theme/view/frontend/page.phtml
index 6cacc7b9319c89806e777e4b758a1d292be30d06..c2612d79fe8581a93187cfc958ab66f5c3179a05 100644
--- a/app/code/Magento/Theme/view/frontend/page.phtml
+++ b/app/code/Magento/Theme/view/frontend/page.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('global_notices') ?>
diff --git a/app/code/Magento/Theme/view/frontend/popup.phtml b/app/code/Magento/Theme/view/frontend/popup.phtml
index e1683f0f8f9b0ea581583fa7267cadd6a5e80fdc..1f38bf6d80326f6f6bf32dd5088c12c3e8fd8809 100644
--- a/app/code/Magento/Theme/view/frontend/popup.phtml
+++ b/app/code/Magento/Theme/view/frontend/popup.phtml
@@ -40,7 +40,7 @@ $bodyCss = $this->getBodyClass() ? $this->getBodyClass() : '';
 <body class="page popup<?php echo $bodyCss ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
     <?php echo $this->getChildHtml('after_body_start') ?>
     <div class="page wrapper">
         <?php echo $this->getChildHtml('main') ?>
diff --git a/app/code/Magento/Theme/view/frontend/print.phtml b/app/code/Magento/Theme/view/frontend/print.phtml
index a6c7760b3f43bb77804369815c9ddca237867b91..e92054e34152bffd32592451dce99505215cf87a 100644
--- a/app/code/Magento/Theme/view/frontend/print.phtml
+++ b/app/code/Magento/Theme/view/frontend/print.phtml
@@ -37,7 +37,7 @@
 <body class="page print<?php echo $this->getBodyClass()?$this->getBodyClass():'' ?>"
       data-container="body"
       <?php echo $this->getAddAttribute() ?>
-      data-mage-init="{loaderAjax: {}, loader: {}}">
+      data-mage-init='{"loaderAjax": {}, "loader": {}}'>
 <?php echo $this->getChildHtml('after_body_start') ?>
 <div class="page print wrapper">
     <header class="header print">
diff --git a/app/code/Magento/User/Block/Buttons.php b/app/code/Magento/User/Block/Buttons.php
index 6c1dbdc0ec4fdfc009d1911f1f8fd36d3568bef3..486c9947b3be88bf0ad363f1dc13d4278fb1ff1b 100644
--- a/app/code/Magento/User/Block/Buttons.php
+++ b/app/code/Magento/User/Block/Buttons.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Block;
 
 class Buttons extends \Magento\Backend\Block\Template
@@ -50,6 +49,9 @@ class Buttons extends \Magento\Backend\Block\Template
         parent::__construct($context, $data);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->addChild('backButton', 'Magento\Backend\Block\Widget\Button', array(
@@ -85,21 +87,33 @@ class Buttons extends \Magento\Backend\Block\Template
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getBackButtonHtml()
     {
         return $this->getChildHtml('backButton');
     }
 
+    /**
+     * @return string
+     */
     public function getResetButtonHtml()
     {
         return $this->getChildHtml('resetButton');
     }
 
+    /**
+     * @return string
+     */
     public function getSaveButtonHtml()
     {
         return $this->getChildHtml('saveButton');
     }
 
+    /**
+     * @return string|void
+     */
     public function getDeleteButtonHtml()
     {
         if (intval($this->getRequest()->getParam('rid')) == 0 ) {
@@ -108,6 +122,9 @@ class Buttons extends \Magento\Backend\Block\Template
         return $this->getChildHtml('deleteButton');
     }
 
+    /**
+     * @return mixed
+     */
     public function getUser()
     {
         return $this->_coreRegistry->registry('user_data');
diff --git a/app/code/Magento/User/Block/Role.php b/app/code/Magento/User/Block/Role.php
index a87d58ed668cfbce74491d5c7b030fb122d6e445..9873bcc5319a5cecff1750877f6f145ac562a494 100644
--- a/app/code/Magento/User/Block/Role.php
+++ b/app/code/Magento/User/Block/Role.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Block;
 
 /**
  * Magento_User role block
@@ -31,9 +32,6 @@
  * @package    Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\User\Block;
-
 class Role extends \Magento\Backend\Block\Widget\Grid\Container
 {
     /**
@@ -46,6 +44,11 @@ class Role extends \Magento\Backend\Block\Widget\Grid\Container
      */
     protected $_blockGroup = 'Magento_User';
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->_headerText = __('Roles');
@@ -53,11 +56,17 @@ class Role extends \Magento\Backend\Block\Widget\Grid\Container
         parent::_construct();
     }
 
+    /**
+     * @return string
+     */
     public function getCreateUrl()
     {
         return $this->getUrl('*/*/editrole');
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         if (!$this->getLayout()->getChildName($this->getNameInLayout(), 'grid')) {
diff --git a/app/code/Magento/User/Block/Role/Edit.php b/app/code/Magento/User/Block/Role/Edit.php
index 0d0f26671137d15256acf40564ffac5e742970d1..72cebbd477b11c0ba0fcc85395c386bb91f62a58 100644
--- a/app/code/Magento/User/Block/Role/Edit.php
+++ b/app/code/Magento/User/Block/Role/Edit.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Block\Role;
 
 class Edit extends \Magento\Backend\Block\Widget\Tabs
@@ -53,6 +52,11 @@ class Edit extends \Magento\Backend\Block\Widget\Tabs
         parent::__construct($context, $jsonEncoder, $authSession, $data);
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -61,6 +65,9 @@ class Edit extends \Magento\Backend\Block\Widget\Tabs
         $this->setTitle(__('Role Information'));
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $role = $this->_coreRegistry->registry('current_role');
diff --git a/app/code/Magento/User/Block/Role/Grid/User.php b/app/code/Magento/User/Block/Role/Grid/User.php
index da95b46590381d6a5f3f52d5587575fdb38e667b..89269e758ac08a0fd4fcfd1b4d1687738da20f78 100644
--- a/app/code/Magento/User/Block/Role/Grid/User.php
+++ b/app/code/Magento/User/Block/Role/Grid/User.php
@@ -21,12 +21,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Block\Role\Grid;
+
+use Magento\Backend\Block\Widget\Grid\Column;
 
 /**
  * Acl role user grid.
  */
-namespace Magento\User\Block\Role\Grid;
-
 class User extends \Magento\Backend\Block\Widget\Grid\Extended
 {
     /**
@@ -70,6 +71,11 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
         $this->_roleFactory = $roleFactory;
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -80,6 +86,10 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
         $this->setUseAjax(true);
     }
 
+    /**
+     * @param Column $column
+     * @return $this
+     */
     protected function _addColumnFilterToCollection($column)
     {
         if ($column->getId() == 'in_role_users') {
@@ -100,6 +110,9 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareCollection()
     {
         $roleId = $this->getRequest()->getParam('rid');
@@ -109,6 +122,9 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareCollection();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
         $this->addColumn('in_role_users', array(
@@ -185,12 +201,19 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareColumns();
     }
 
+    /**
+     * @return string
+     */
     public function getGridUrl()
     {
         $roleId = $this->getRequest()->getParam('rid');
         return $this->getUrl('*/*/editrolegrid', array('rid' => $roleId));
     }
 
+    /**
+     * @param bool $json
+     * @return string|array
+     */
     public function getUsers($json=false)
     {
         if ( $this->getRequest()->getParam('in_role_user') != "" ) {
diff --git a/app/code/Magento/User/Block/Role/Tab/Edit.php b/app/code/Magento/User/Block/Role/Tab/Edit.php
index 15ee02cd15455f72f245dc13be43c3fc2c934081..542d262bebe9e379e69ce53453db39b765a936f7 100644
--- a/app/code/Magento/User/Block/Role/Tab/Edit.php
+++ b/app/code/Magento/User/Block/Role/Tab/Edit.php
@@ -32,7 +32,9 @@ namespace Magento\User\Block\Role\Tab;
 class Edit extends \Magento\Backend\Block\Widget\Form
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'role/edit.phtml';
 
     /**
@@ -159,7 +161,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form
     /**
      * Check if everything is allowed
      *
-     * @return boolean
+     * @return bool
      */
     public function isEverythingAllowed()
     {
diff --git a/app/code/Magento/User/Block/Role/Tab/Info.php b/app/code/Magento/User/Block/Role/Tab/Info.php
index b866794be59c1c122c4e68dc6a8cb9492929b570..c15ca151780a57fd223d24c4efe12d7d5abfcf3e 100644
--- a/app/code/Magento/User/Block/Role/Tab/Info.php
+++ b/app/code/Magento/User/Block/Role/Tab/Info.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Block\Role\Tab;
 
 /**
@@ -35,26 +34,41 @@ class Info
     extends \Magento\Backend\Block\Widget\Form\Generic
     implements \Magento\Backend\Block\Widget\Tab\TabInterface
 {
+    /**
+     * @return string
+     */
     public function getTabLabel()
     {
         return __('Role Info');
     }
 
+    /**
+     * @return string
+     */
     public function getTabTitle()
     {
         return $this->getTabLabel();
     }
 
+    /**
+     * @return bool
+     */
     public function canShowTab()
     {
         return true;
     }
 
+    /**
+     * @return bool
+     */
     public function isHidden()
     {
         return false;
     }
 
+    /**
+     * @return $this
+     */
     public function _beforeToHtml()
     {
         $this->_initForm();
@@ -62,6 +76,9 @@ class Info
         return parent::_beforeToHtml();
     }
 
+    /**
+     * @return void
+     */
     protected function _initForm()
     {
         /** @var \Magento\Data\Form $form */
diff --git a/app/code/Magento/User/Block/Role/Tab/Users.php b/app/code/Magento/User/Block/Role/Tab/Users.php
index 3093e2e20fbc53145c7e3da28db20ce9d4175af8..375248735b3c92bc668ca38774657b13f2f30681 100644
--- a/app/code/Magento/User/Block/Role/Tab/Users.php
+++ b/app/code/Magento/User/Block/Role/Tab/Users.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Block\Role\Tab;
 
 /**
@@ -57,6 +56,11 @@ class Users extends \Magento\Backend\Block\Widget\Tabs
         parent::__construct($context, $jsonEncoder, $authSession, $data);
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -69,6 +73,9 @@ class Users extends \Magento\Backend\Block\Widget\Tabs
             ->assign('roleId', $roleId);
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareLayout()
     {
         $this->setChild(
@@ -78,6 +85,9 @@ class Users extends \Magento\Backend\Block\Widget\Tabs
         return parent::_prepareLayout();
     }
 
+    /**
+     * @return string
+     */
     public function getGridHtml()
     {
         return $this->getChildHtml('userGrid');
diff --git a/app/code/Magento/User/Block/User.php b/app/code/Magento/User/Block/User.php
index 8fb638c30109e275917a3c2e4cf2b2614358dd82..391f89ba6cdb3976517ce4c90839c9bd4f317fef 100644
--- a/app/code/Magento/User/Block/User.php
+++ b/app/code/Magento/User/Block/User.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Block;
 
 /**
  * User block
@@ -31,8 +32,6 @@
  * @package    Magento_User
  * @author     Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Block;
-
 class User extends \Magento\Backend\Block\Widget\Grid\Container
 {
     /**
@@ -54,6 +53,11 @@ class User extends \Magento\Backend\Block\Widget\Grid\Container
         $this->_resourceModel = $resourceModel;
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->addData(array(
diff --git a/app/code/Magento/User/Block/User/Edit.php b/app/code/Magento/User/Block/User/Edit.php
index e9ab7b6108f7b8699651b8f9f5c395dbd3bb586b..5930e8c24080bc2ff8fa20c04efc9fd200c0ea01 100644
--- a/app/code/Magento/User/Block/User/Edit.php
+++ b/app/code/Magento/User/Block/User/Edit.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Block\User;
 
 /**
  * User edit page
@@ -31,8 +32,6 @@
  * @package    Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Block\User;
-
 class Edit extends \Magento\Backend\Block\Widget\Form\Container
 {
     /**
@@ -56,6 +55,11 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         parent::__construct($context, $data);
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->_objectId = 'user_id';
@@ -68,6 +72,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
         $this->_updateButton('delete', 'label', __('Delete User'));
     }
 
+    /**
+     * @return string
+     */
     public function getHeaderText()
     {
         if ($this->_coreRegistry->registry('permissions_user')->getId()) {
diff --git a/app/code/Magento/User/Block/User/Edit/Form.php b/app/code/Magento/User/Block/User/Edit/Form.php
index 37d3766b8da0df8771e3b9f514308950813e5584..968ba802b55f4ac256d3276d7da844088d8c7068 100644
--- a/app/code/Magento/User/Block/User/Edit/Form.php
+++ b/app/code/Magento/User/Block/User/Edit/Form.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Block\User\Edit;
 
 /**
  * Adminhtml permissions user edit form
@@ -32,13 +33,14 @@
  * @author     Magento Core Team <core@magentocommerce.com>
  *
  */
-namespace Magento\User\Block\User\Edit;
-
 /**
  * @SuppressWarnings(PHPMD.DepthOfInheritance)
  */
 class Form extends \Magento\Backend\Block\Widget\Form\Generic
 {
+    /**
+     * @return $this
+     */
     protected function _prepareForm()
     {
         /** @var \Magento\Data\Form $form */
diff --git a/app/code/Magento/User/Block/User/Edit/Tab/Main.php b/app/code/Magento/User/Block/User/Edit/Tab/Main.php
index 2fcd28a3665e299d444287fb05743698a371dfaa..bb3c0e89a04f57089fa75fd419a5533af7d4521f 100644
--- a/app/code/Magento/User/Block/User/Edit/Tab/Main.php
+++ b/app/code/Magento/User/Block/User/Edit/Tab/Main.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Block\User\Edit\Tab;
 
 /**
@@ -172,6 +171,7 @@ class Main extends \Magento\Backend\Block\Widget\Form\Generic
      * @param string $passwordLabel
      * @param string $confirmationLabel
      * @param bool $isRequired
+     * @return void
      */
     protected function _addPasswordFields(
         \Magento\Data\Form\Element\Fieldset $fieldset, $passwordLabel, $confirmationLabel, $isRequired = false
diff --git a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php
index cc496d68128ecdc3aceea2c60620f765b246459f..8e208b73beec9f14ecccbcb8b0112fa28c249fd3 100644
--- a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php
+++ b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php
@@ -23,9 +23,10 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Block\User\Edit\Tab;
 
+use Magento\Backend\Block\Widget\Grid\Column;
+
 class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
 {
     /**
@@ -35,7 +36,6 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
      */
     protected $_coreRegistry = null;
 
-
     /**
      * @var \Magento\User\Model\Resource\Role\CollectionFactory
      */
@@ -68,6 +68,11 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
         parent::__construct($context, $backendHelper, $data);
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -78,6 +83,10 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
         $this->setUseAjax(true);
     }
 
+    /**
+     * @param Column $column
+     * @return $this
+     */
     protected function _addColumnFilterToCollection($column)
     {
         if ($column->getId() == 'assigned_user_role') {
@@ -98,6 +107,9 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareCollection()
     {
         $collection = $this->_userRolesFactory->create();
@@ -106,6 +118,9 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareCollection();
     }
 
+    /**
+     * @return $this
+     */
     protected function _prepareColumns()
     {
 
@@ -127,12 +142,19 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
         return parent::_prepareColumns();
     }
 
+    /**
+     * @return string
+     */
     public function getGridUrl()
     {
         $userPermissions = $this->_coreRegistry->registry('permissions_user');
         return $this->getUrl('*/*/rolesGrid', array('user_id' => $userPermissions->getUserId()));
     }
 
+    /**
+     * @param bool $json
+     * @return array|string
+     */
     public function getSelectedRoles($json=false)
     {
         if ( $this->getRequest()->getParam('user_roles') != "" ) {
diff --git a/app/code/Magento/User/Block/User/Edit/Tabs.php b/app/code/Magento/User/Block/User/Edit/Tabs.php
index 9cc60894494ff08f2fb1ebab63ae921d6583f376..19ff62809e8654eb21d6e2de43636d30745fc4f0 100644
--- a/app/code/Magento/User/Block/User/Edit/Tabs.php
+++ b/app/code/Magento/User/Block/User/Edit/Tabs.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Block\User\Edit;
 
 /**
  * User page left menu
@@ -31,11 +32,14 @@
  * @package    Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Block\User\Edit;
-
 class Tabs extends \Magento\Backend\Block\Widget\Tabs
 {
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         parent::_construct();
@@ -44,6 +48,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs
         $this->setTitle(__('User Information'));
     }
 
+    /**
+     * @return $this
+     */
     protected function _beforeToHtml()
     {
         $this->addTab('main_section', array(
diff --git a/app/code/Magento/User/Controller/Adminhtml/Auth.php b/app/code/Magento/User/Controller/Adminhtml/Auth.php
index e91709f514ffefbb2449ebc91aa1f84bd6cc7691..ff4132180647341bf9490dde1bce26f6c1daa731 100644
--- a/app/code/Magento/User/Controller/Adminhtml/Auth.php
+++ b/app/code/Magento/User/Controller/Adminhtml/Auth.php
@@ -21,12 +21,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Controller\Adminhtml;
 
 /**
  * \Magento\User Auth controller
  */
-namespace Magento\User\Controller\Adminhtml;
-
 class Auth extends \Magento\Backend\App\AbstractAction
 {
     /**
@@ -52,6 +51,8 @@ class Auth extends \Magento\Backend\App\AbstractAction
 
     /**
      * Forgot administrator password action
+     *
+     * @return void
      */
     public function forgotpasswordAction()
     {
@@ -102,6 +103,8 @@ class Auth extends \Magento\Backend\App\AbstractAction
      * Display reset forgotten password form
      *
      * User is redirected on this action when he clicks on the corresponding link in password reset confirmation email
+     *
+     * @return void
      */
     public function resetPasswordAction()
     {
@@ -132,6 +135,8 @@ class Auth extends \Magento\Backend\App\AbstractAction
      * Reset forgotten password
      *
      * Used to handle data received from reset forgotten password form
+     *
+     * @return void
      */
     public function resetPasswordPostAction()
     {
@@ -188,6 +193,7 @@ class Auth extends \Magento\Backend\App\AbstractAction
      *
      * @param int $userId
      * @param string $resetPasswordToken
+     * @return void
      * @throws \Magento\Core\Exception
      */
     protected function _validateResetPasswordLinkToken($userId, $resetPasswordToken)
@@ -216,7 +222,7 @@ class Auth extends \Magento\Backend\App\AbstractAction
     /**
      * Check if user has permissions to access this controller
      *
-     * @return boolean
+     * @return bool
      */
     protected function _isAllowed()
     {
diff --git a/app/code/Magento/User/Controller/Adminhtml/User.php b/app/code/Magento/User/Controller/Adminhtml/User.php
index 12d09b31cf75812c19313dc3e8b51bcbcb28a015..5511c532ad411ae90cd7cb7ece2098509c554764 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User.php
@@ -54,6 +54,9 @@ class User extends \Magento\Backend\App\AbstractAction
         $this->_userFactory = $userFactory;
     }
 
+    /**
+     * @return $this
+     */
     protected function _initAction()
     {
         $this->_view->loadLayout();
@@ -65,6 +68,9 @@ class User extends \Magento\Backend\App\AbstractAction
         return $this;
     }
 
+    /**
+     * @return void
+     */
     public function indexAction()
     {
         $this->_title->add(__('Users'));
@@ -72,11 +78,17 @@ class User extends \Magento\Backend\App\AbstractAction
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function newAction()
     {
         $this->_forward('edit');
     }
 
+    /**
+     * @return void
+     */
     public function editAction()
     {
         $this->_title->add(__('Users'));
@@ -115,6 +127,9 @@ class User extends \Magento\Backend\App\AbstractAction
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function saveAction()
     {
         $userId = (int)$this->getRequest()->getParam('user_id');
@@ -173,6 +188,9 @@ class User extends \Magento\Backend\App\AbstractAction
         return $data;
     }
 
+    /**
+     * @return void
+     */
     public function deleteAction()
     {
         $currentUser = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser();
@@ -202,6 +220,9 @@ class User extends \Magento\Backend\App\AbstractAction
         $this->_redirect('adminhtml/*/');
     }
 
+    /**
+     * @return void
+     */
     public function rolesGridAction()
     {
         $userId = $this->getRequest()->getParam('user_id');
@@ -216,12 +237,18 @@ class User extends \Magento\Backend\App\AbstractAction
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return void
+     */
     public function roleGridAction()
     {
         $this->_view->loadLayout(false);
         $this->_view->renderLayout();
     }
 
+    /**
+     * @return bool
+     */
     protected function _isAllowed()
     {
         return $this->_authorization->isAllowed('Magento_User::acl_users');
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role.php b/app/code/Magento/User/Controller/Adminhtml/User/Role.php
index 04a7f9209dfb7c08cac40dced858f0f507d45d61..bc0397b95e36119f996832e070843e5bd6e4c660 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Role.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Role.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Controller\Adminhtml\User;
 
 use Magento\User\Model\Acl\Role\Group as RoleGroup;
@@ -125,6 +124,7 @@ class Role extends \Magento\Backend\App\AbstractAction
     /**
      * Show grid with roles existing in systems
      *
+     * @return void
      */
     public function indexAction()
     {
@@ -138,6 +138,7 @@ class Role extends \Magento\Backend\App\AbstractAction
     /**
      * Action for ajax request from grid
      *
+     * @return void
      */
     public function roleGridAction()
     {
@@ -148,6 +149,7 @@ class Role extends \Magento\Backend\App\AbstractAction
     /**
      * Edit role action
      *
+     * @return void
      */
     public function editRoleAction()
     {
@@ -177,6 +179,7 @@ class Role extends \Magento\Backend\App\AbstractAction
     /**
      * Remove role action
      *
+     * @return void
      */
     public function deleteAction()
     {
@@ -203,6 +206,7 @@ class Role extends \Magento\Backend\App\AbstractAction
     /**
      * Role form submit action to save or create new role
      *
+     * @return void
      */
     public function saveRoleAction()
     {
@@ -264,6 +268,8 @@ class Role extends \Magento\Backend\App\AbstractAction
 
     /**
      * Action for ajax request from assigned users grid
+     *
+     * @return void
      */
     public function editrolegridAction()
     {
diff --git a/app/code/Magento/User/Helper/Data.php b/app/code/Magento/User/Helper/Data.php
index 555ce0b3ff8ebd4d008d5043da991d1f047092d6..44d1c3906097dc9e096274453cce6937d5cdc42c 100644
--- a/app/code/Magento/User/Helper/Data.php
+++ b/app/code/Magento/User/Helper/Data.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\User\Helper;
 
 /**
  * User data helper
@@ -31,8 +32,6 @@
  * @package  Magento_User
  * @author   Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Helper;
-
 class Data extends \Magento\App\Helper\AbstractHelper
 {
     /**
diff --git a/app/code/Magento/User/Model/Acl/Loader/Role.php b/app/code/Magento/User/Model/Acl/Loader/Role.php
index 1015c443f0611f2fd89fb84b47ef5856142d3c78..1c4fc334158a42927576c414509c446eef02ce24 100644
--- a/app/code/Magento/User/Model/Acl/Loader/Role.php
+++ b/app/code/Magento/User/Model/Acl/Loader/Role.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Acl\Loader;
 
 use Magento\User\Model\Acl\Role\Group as RoleGroup;
@@ -63,6 +62,7 @@ class Role implements \Magento\Acl\LoaderInterface
      * Populate ACL with roles from external storage
      *
      * @param \Magento\Acl $acl
+     * @return void
      */
     public function populateAcl(\Magento\Acl $acl)
     {
diff --git a/app/code/Magento/User/Model/Acl/Loader/Rule.php b/app/code/Magento/User/Model/Acl/Loader/Rule.php
index 58aad5494535bf9d1f481f5b7ce8b64e98349181..d292b2c33be33272f339f2072d50ce51ab27a120 100644
--- a/app/code/Magento/User/Model/Acl/Loader/Rule.php
+++ b/app/code/Magento/User/Model/Acl/Loader/Rule.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Acl\Loader;
 
 class Rule implements \Magento\Acl\LoaderInterface
@@ -50,6 +49,7 @@ class Rule implements \Magento\Acl\LoaderInterface
      * Populate ACL with rules from external storage
      *
      * @param \Magento\Acl $acl
+     * @return void
      */
     public function populateAcl(\Magento\Acl $acl)
     {
diff --git a/app/code/Magento/User/Model/Acl/Role/Generic.php b/app/code/Magento/User/Model/Acl/Role/Generic.php
index 2b8e9cd260c22feb324000627e03bfd006a05e60..7442d6ba080dc3950407e0302d86ea03455bc2ed 100644
--- a/app/code/Magento/User/Model/Acl/Role/Generic.php
+++ b/app/code/Magento/User/Model/Acl/Role/Generic.php
@@ -23,13 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Acl\Role;
 
 /**
  * User acl role
  */
-namespace Magento\User\Model\Acl\Role;
-
 class Generic extends \Zend_Acl_Role
 {
 
diff --git a/app/code/Magento/User/Model/Acl/Role/Group.php b/app/code/Magento/User/Model/Acl/Role/Group.php
index 842413cc4a3b789e0dc81eadd804432ec7fc4295..10e589aa1843ee2265908bc19fba77557979988f 100644
--- a/app/code/Magento/User/Model/Acl/Role/Group.php
+++ b/app/code/Magento/User/Model/Acl/Role/Group.php
@@ -23,13 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Acl\Role;
 
 /**
  * Acl Group model
  */
-namespace Magento\User\Model\Acl\Role;
-
 class Group extends \Magento\User\Model\Acl\Role\Generic
 {
     /**
diff --git a/app/code/Magento/User/Model/Acl/Role/User.php b/app/code/Magento/User/Model/Acl/Role/User.php
index 755b22bdcfc1fd26f8c79a15480140769c44dc97..b3bb0a7c751b4d11cf6f64529b26b19fed0dde85 100644
--- a/app/code/Magento/User/Model/Acl/Role/User.php
+++ b/app/code/Magento/User/Model/Acl/Role/User.php
@@ -23,13 +23,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Acl\Role;
 
 /**
  * User acl role
  */
-namespace Magento\User\Model\Acl\Role;
-
 class User extends \Magento\User\Model\Acl\Role\Generic
 {
     /**
diff --git a/app/code/Magento/User/Model/Resource/Permissions/Collection.php b/app/code/Magento/User/Model/Resource/Permissions/Collection.php
index e2c910100874f8fa18325180dc6c140d6142adf6..57b453267c91b8757bc37ef521dcbe3285567b95 100644
--- a/app/code/Magento/User/Model/Resource/Permissions/Collection.php
+++ b/app/code/Magento/User/Model/Resource/Permissions/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Resource\Permissions;
 
 /**
  * Admin permissions collection
@@ -32,8 +32,6 @@
  * @package     Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Model\Resource\Permissions;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
diff --git a/app/code/Magento/User/Model/Resource/Role.php b/app/code/Magento/User/Model/Resource/Role.php
index bde0da7369f025f17ddedd2acf5929032bfe3fb7..deaa576caee990a4e989f82483a076df20e38425 100644
--- a/app/code/Magento/User/Model/Resource/Role.php
+++ b/app/code/Magento/User/Model/Resource/Role.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Resource;
 
 use Magento\User\Model\Acl\Role\User as RoleUser;
@@ -61,6 +60,7 @@ class Role extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param \Magento\App\Resource $resource
      * @param \Magento\App\CacheInterface $cache
      * @param \Magento\Stdlib\DateTime $dateTime
+     * @return void
      */
     public function __construct(
         \Magento\App\Resource $resource,
@@ -74,7 +74,6 @@ class Role extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Define main table
-     *
      */
     protected function _construct()
     {
@@ -88,7 +87,7 @@ class Role extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Process role before saving
      *
      * @param \Magento\Core\Model\AbstractModel $role
-     * @return \Magento\User\Model\Resource\Role
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $role)
     {
@@ -134,7 +133,7 @@ class Role extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Process role after saving
      *
      * @param \Magento\Core\Model\AbstractModel $role
-     * @return \Magento\User\Model\Resource\Role
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $role)
     {
@@ -148,7 +147,7 @@ class Role extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Process role after deleting
      *
      * @param \Magento\Core\Model\AbstractModel $role
-     * @return \Magento\User\Model\Resource\Role
+     * @return $this
      */
     protected function _afterDelete(\Magento\Core\Model\AbstractModel $role)
     {
diff --git a/app/code/Magento/User/Model/Resource/Role/Collection.php b/app/code/Magento/User/Model/Resource/Role/Collection.php
index da0349154f2a54e80d87a8bac2711d3a1cc07859..2b0240dad099451c2000dce3b17383c5bf1b1135 100644
--- a/app/code/Magento/User/Model/Resource/Role/Collection.php
+++ b/app/code/Magento/User/Model/Resource/Role/Collection.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Resource\Role;
 
 use Magento\User\Model\Acl\Role\Group as RoleGroup;
@@ -34,6 +33,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -45,7 +45,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      *
      * @param int $userId
      * @param string $userType
-     * @return \Magento\User\Model\Resource\Role\Collection
+     * @return $this
      */
     public function setUserFilter($userId, $userType)
     {
@@ -57,7 +57,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Set roles filter
      *
-     * @return \Magento\User\Model\Resource\Role\Collection
+     * @return $this
      */
     public function setRolesFilter()
     {
diff --git a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php b/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php
index d62f682cf98a35eb1a4e0d8c8b61e84d8de714d5..a111d9b1d60a9b38506d436e7daa775f9ba21332 100644
--- a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php
+++ b/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Resource\Role\Grid;
 
 use Magento\User\Model\Acl\Role\Group as RoleGroup;
@@ -33,6 +32,8 @@ class Collection extends \Magento\User\Model\Resource\Role\Collection
 {
     /**
      * Prepare select for load
+     *
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/User/Model/Resource/Role/User/Collection.php b/app/code/Magento/User/Model/Resource/Role/User/Collection.php
index e91b92f7e93fb588d1624b105fb918b00445261d..c14ba5cbfe4607ca0706547ec3aea37e1c253cc8 100644
--- a/app/code/Magento/User/Model/Resource/Role/User/Collection.php
+++ b/app/code/Magento/User/Model/Resource/Role/User/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Resource\Role\User;
 
 /**
  * Admin role users collection
@@ -32,13 +32,12 @@
  * @package     Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Model\Resource\Role\User;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -48,7 +47,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Initialize select
      *
-     * @return \Magento\User\Model\Resource\Role\User\Collection
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/User/Model/Resource/Rules.php b/app/code/Magento/User/Model/Resource/Rules.php
index 9216986be3fb711fbda8283bf43fd0205f8cd33f..2d087f334a2d9f1d07df2d56f32a6980eef0bbd7 100644
--- a/app/code/Magento/User/Model/Resource/Rules.php
+++ b/app/code/Magento/User/Model/Resource/Rules.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Resource;
 
 /**
@@ -77,6 +76,7 @@ class Rules extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -87,6 +87,7 @@ class Rules extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Save ACL resources
      *
      * @param \Magento\User\Model\Rules $rule
+     * @return void
      * @throws \Magento\Core\Exception
      */
     public function saveRel(\Magento\User\Model\Rules $rule)
diff --git a/app/code/Magento/User/Model/Resource/Rules/Collection.php b/app/code/Magento/User/Model/Resource/Rules/Collection.php
index 7be6f19b14fa40eaab11aec194531135fc79fba3..76f59717ce9049622993e63061c8ba0fc0dddd3d 100644
--- a/app/code/Magento/User/Model/Resource/Rules/Collection.php
+++ b/app/code/Magento/User/Model/Resource/Rules/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Resource\Rules;
 
 /**
  * Rules collection
@@ -32,13 +32,12 @@
  * @package     Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Model\Resource\Rules;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -49,7 +48,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Get rules by role id
      *
      * @param int $roleId
-     * @return \Magento\User\Model\Resource\Rules\Collection
+     * @return $this
      */
     public function getByRoles($roleId)
     {
@@ -60,7 +59,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Sort by length
      *
-     * @return \Magento\User\Model\Resource\Rules\Collection
+     * @return $this
      */
     public function addSortByLength()
     {
diff --git a/app/code/Magento/User/Model/Resource/Setup.php b/app/code/Magento/User/Model/Resource/Setup.php
index f287e54b2009f20323d2bb7e51abeafae8fb5c4d..7da2f039bcdf242966a12cd456fd6d87e17e9136 100644
--- a/app/code/Magento/User/Model/Resource/Setup.php
+++ b/app/code/Magento/User/Model/Resource/Setup.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Resource;
 
 /**
diff --git a/app/code/Magento/User/Model/Resource/User.php b/app/code/Magento/User/Model/Resource/User.php
index e43bcb45412a4fabd3f899b2f6de2573d83877e3..8bf9311fc48335583451337669f9f708e5a2d29b 100644
--- a/app/code/Magento/User/Model/Resource/User.php
+++ b/app/code/Magento/User/Model/Resource/User.php
@@ -21,11 +21,11 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model\Resource;
 
 use \Magento\User\Model\Acl\Role\Group as RoleGroup;
 use \Magento\User\Model\Acl\Role\User as RoleUser;
+use Magento\User\Model\User as ModelUser;
 
 /**
  * ACL user resource
@@ -72,6 +72,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Define main table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -81,7 +82,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize unique fields
      *
-     * @return \Magento\User\Model\Resource\User
+     * @return $this
      */
     protected function _initUniqueFields()
     {
@@ -101,10 +102,10 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Authenticate user by $username and $password
      *
-     * @param \Magento\User\Model\User $user
-     * @return \Magento\User\Model\Resource\User
+     * @param ModelUser $user
+     * @return $this
      */
-    public function recordLogin(\Magento\User\Model\User $user)
+    public function recordLogin(ModelUser $user)
     {
         $adapter = $this->_getWriteAdapter();
 
@@ -126,7 +127,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Load data by specified username
      *
      * @param string $username
-     * @return false|array
+     * @return array
      */
     public function loadByUsername($username)
     {
@@ -146,8 +147,8 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Check if user is assigned to any role
      *
-     * @param int|\Magento\Core\Admin\Model\User $user
-     * @return null|false|array
+     * @param int|ModelUser $user
+     * @return null|array
      */
     public function hasAssigned2Role($user)
     {
@@ -182,7 +183,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Set created/modified values before user save
      *
      * @param \Magento\Core\Model\AbstractModel $user
-     * @return \Magento\User\Model\Resource\User
+     * @return $this
      */
     protected function _beforeSave(\Magento\Core\Model\AbstractModel $user)
     {
@@ -198,7 +199,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Unserialize user extra data after user save
      *
      * @param \Magento\Core\Model\AbstractModel $user
-     * @return \Magento\User\Model\Resource\User
+     * @return $this
      */
     protected function _afterSave(\Magento\Core\Model\AbstractModel $user)
     {
@@ -213,9 +214,10 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Clear all user-specific roles of provided user
      *
-     * @param \Magento\User\Model\User $user
+     * @param ModelUser $user
+     * @return void
      */
-    public function _clearUserRoles(\Magento\User\Model\User $user)
+    public function _clearUserRoles(ModelUser $user)
     {
         $conditions = array(
             'user_id = ?' => (int) $user->getId(),
@@ -227,9 +229,10 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Create role for provided user of provided type
      *
      * @param $parentId
-     * @param \Magento\User\Model\User $user
+     * @param ModelUser $user
+     * @return void
      */
-    protected function _createUserRole($parentId, \Magento\User\Model\User $user)
+    protected function _createUserRole($parentId, ModelUser $user)
     {
         if ($parentId > 0) {
             /** @var \Magento\User\Model\Role $parentRole */
@@ -259,7 +262,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Unserialize user extra data after user load
      *
      * @param \Magento\Core\Model\AbstractModel $user
-     * @return \Magento\User\Model\Resource\User
+     * @return $this
      */
     protected function _afterLoad(\Magento\Core\Model\AbstractModel $user)
     {
@@ -343,7 +346,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Delete user role
      *
      * @param \Magento\Core\Model\AbstractModel $user
-     * @return \Magento\User\Model\Resource\User
+     * @return $this
      */
     public function deleteFromRole(\Magento\Core\Model\AbstractModel $user)
     {
@@ -369,7 +372,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Check if role user exists
      *
      * @param \Magento\Core\Model\AbstractModel $user
-     * @return array|false
+     * @return array
      */
     public function roleUserExists(\Magento\Core\Model\AbstractModel $user)
     {
@@ -397,7 +400,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      * Check if user exists
      *
      * @param \Magento\Core\Model\AbstractModel $user
-     * @return array|false
+     * @return array
      */
     public function userExists(\Magento\Core\Model\AbstractModel $user)
     {
@@ -433,7 +436,7 @@ class User extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param \Magento\Core\Model\AbstractModel $object
      * @param string $data
-     * @return \Magento\User\Model\Resource\User
+     * @return $this
      */
     public function saveExtra($object, $data)
     {
diff --git a/app/code/Magento/User/Model/Resource/User/Collection.php b/app/code/Magento/User/Model/Resource/User/Collection.php
index c89fa2e0f0d741111f79dc9caa7d19e67475f1b8..194b78e327407811e4daddc6909844ed66057312 100644
--- a/app/code/Magento/User/Model/Resource/User/Collection.php
+++ b/app/code/Magento/User/Model/Resource/User/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Resource\User;
 
 /**
  * Admin user collection
@@ -32,8 +32,6 @@
  * @package     Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Model\Resource\User;
-
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
diff --git a/app/code/Magento/User/Model/Resource/User/Locked/Collection.php b/app/code/Magento/User/Model/Resource/User/Locked/Collection.php
index 26d4ec457f83c2a09dca9e6fff64b3b719943278..84273a9111ae2786aaf311d43dfb14ce43e267fa 100644
--- a/app/code/Magento/User/Model/Resource/User/Locked/Collection.php
+++ b/app/code/Magento/User/Model/Resource/User/Locked/Collection.php
@@ -23,7 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento\User\Model\Resource\User\Locked;
 
 /**
  * Admin user collection
@@ -32,14 +32,13 @@
  * @package     Magento_User
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\User\Model\Resource\User\Locked;
-
 class Collection extends \Magento\User\Model\Resource\User\Collection
 {
     /**
      * Collection Init Select
      *
      * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource
+     * @return $this
      */
     protected function _initSelect()
     {
diff --git a/app/code/Magento/User/Model/Role.php b/app/code/Magento/User/Model/Role.php
index a75e335ee38133d60ff71deeb95ca00a1a4a8a40..243ce22b64f35dd153f9f0ce5cf803f0b90194c2 100644
--- a/app/code/Magento/User/Model/Role.php
+++ b/app/code/Magento/User/Model/Role.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model;
 
 /**
@@ -72,7 +71,7 @@ class Role extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function __sleep()
     {
@@ -81,7 +80,7 @@ class Role extends \Magento\Core\Model\AbstractModel
     }
 
     /**
-     * @inheritdoc
+     * {@inheritdoc}
      */
     public function __wakeup()
     {
@@ -97,6 +96,11 @@ class Role extends \Magento\Core\Model\AbstractModel
      */
     protected $_eventPrefix = 'admin_roles';
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\User\Model\Resource\Role');
@@ -105,7 +109,7 @@ class Role extends \Magento\Core\Model\AbstractModel
     /**
      * Update object into database
      *
-     * @return \Magento\User\Model\Role
+     * @return $this
      */
     public function update()
     {
diff --git a/app/code/Magento/User/Model/Rules.php b/app/code/Magento/User/Model/Rules.php
index 3d9cec340ec237fcecb13b87443d1c32795334dc..0d0e494b26d79ae839b8180429494beae78e3174 100644
--- a/app/code/Magento/User/Model/Rules.php
+++ b/app/code/Magento/User/Model/Rules.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model;
 
 /**
@@ -42,6 +41,15 @@ namespace Magento\User\Model;
  */
 class Rules extends \Magento\Core\Model\AbstractModel
 {
+    /**
+     * Class constructor
+     *
+     * @param \Magento\Core\Model\Context $context
+     * @param \Magento\Core\Model\Registry $registry
+     * @param Resource\Rules $resource
+     * @param Resource\Permissions\Collection $resourceCollection
+     * @param array $data
+     */
     public function __construct(
         \Magento\Core\Model\Context $context,
         \Magento\Core\Model\Registry $registry,
@@ -52,17 +60,28 @@ class Rules extends \Magento\Core\Model\AbstractModel
         parent::__construct($context, $registry, $resource, $resourceCollection, $data);
     }
 
+    /**
+     * Class constructor
+     *
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('Magento\User\Model\Resource\Rules');
     }
 
+    /**
+     * @return $this
+     */
     public function update()
     {
         $this->getResource()->update($this);
         return $this;
     }
 
+    /**
+     * @return $this
+     */
     public function saveRel()
     {
         $this->getResource()->saveRel($this);
diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php
index 4cd95ead3db1e4df3fa7dbc9135f7460c1665a9b..e30b438faeaff79524071f485746e835536bb8ab 100644
--- a/app/code/Magento/User/Model/User.php
+++ b/app/code/Magento/User/Model/User.php
@@ -21,7 +21,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\User\Model;
 
 /**
@@ -90,7 +89,7 @@ class User
     /**
      * Available resources flag
      *
-     * @var boolean
+     * @var bool
      */
     protected $_hasResources = true;
 
@@ -121,9 +120,9 @@ class User
     /**
      * Factory for validator composite object
      *
-     * @var \Magento\Validator\Composite\VarienObjectFactory
+     * @var \Magento\Validator\ObjectFactory
      */
-    protected $_validatorComposite;
+    protected $_validatorObject;
 
     /**
      * Role model factory
@@ -155,7 +154,7 @@ class User
      * @param \Magento\User\Helper\Data $userData
      * @param \Magento\Email\Model\Sender $sender
      * @param \Magento\Backend\App\ConfigInterface $config
-     * @param \Magento\Validator\Composite\VarienObjectFactory $validatorCompositeFactory
+     * @param \Magento\Validator\ObjectFactory $validatorObjectFactory
      * @param \Magento\User\Model\RoleFactory $roleFactory
      * @param \Magento\Email\Model\InfoFactory $emailInfoFactory
      * @param \Magento\Email\Model\Template\MailerFactory $mailerFactory
@@ -173,7 +172,7 @@ class User
         \Magento\User\Helper\Data $userData,
         \Magento\Email\Model\Sender $sender,
         \Magento\Backend\App\ConfigInterface $config,
-        \Magento\Validator\Composite\VarienObjectFactory $validatorCompositeFactory,
+        \Magento\Validator\ObjectFactory $validatorObjectFactory,
         \Magento\User\Model\RoleFactory $roleFactory,
         \Magento\Email\Model\InfoFactory $emailInfoFactory,
         \Magento\Email\Model\Template\MailerFactory $mailerFactory,
@@ -189,7 +188,7 @@ class User
         $this->_userData = $userData;
         $this->_sender = $sender;
         $this->_config = $config;
-        $this->_validatorComposite = $validatorCompositeFactory;
+        $this->_validatorObject = $validatorObjectFactory;
         $this->_roleFactory = $roleFactory;
         $this->_emailInfoFactory = $emailInfoFactory;
         $this->_mailer = $mailerFactory->create();
@@ -197,12 +196,17 @@ class User
 
     /**
      * Initialize user model
+     *
+     * @return void
      */
     protected function _construct()
     {
         $this->_init('Magento\User\Model\Resource\User');
     }
 
+    /**
+     * @return string[]
+     */
     public function __sleep()
     {
         $properties = parent::__sleep();
@@ -211,7 +215,7 @@ class User
             '_sender',
             '_userData',
             '_config',
-            '_validatorComposite',
+            '_validatorObject',
             '_roleFactory',
             '_emailInfoFactory',
             '_mailer',
@@ -219,6 +223,9 @@ class User
         ));
     }
 
+    /**
+     * @return void
+     */
     public function __wakeup()
     {
         parent::__wakeup();
@@ -228,7 +235,7 @@ class User
         $this->_userData        = $objectManager->get('Magento\User\Helper\Data');
         $this->_config = $objectManager->get('Magento\Backend\App\ConfigInterface');
         $this->_coreRegistry    = $objectManager->get('Magento\Core\Model\Registry');
-        $this->_validatorComposite = $objectManager->get('Magento\Validator\Composite\VarienObjectFactory');
+        $this->_validatorObject = $objectManager->get('Magento\Validator\ObjectFactory');
         $this->_roleFactory = $objectManager->get('Magento\User\Model\RoleFactory');
         $this->_emailInfoFactory = $objectManager->get('Magento\Email\Model\InfoFactory');
         $this->_mailer = $objectManager->get('Magento\Email\Model\Template\MailerFactory');
@@ -238,7 +245,7 @@ class User
     /**
      * Processing data before model save
      *
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -309,8 +316,8 @@ class User
             \Zend_Validate_EmailAddress::INVALID
         );
 
-        /** @var $validator \Magento\Validator\Composite\VarienObject */
-        $validator = $this->_validatorComposite->create();
+        /** @var $validator \Magento\Validator\Object */
+        $validator = $this->_validatorObject->create();
         $validator->addRule($userNameNotEmpty, 'username')
             ->addRule($firstNameNotEmpty, 'firstname')
             ->addRule($lastNameNotEmpty, 'lastname')
@@ -325,9 +332,10 @@ class User
     /**
      * Add validation rules for the password management fields
      *
-     * @param \Magento\Validator\Composite\VarienObject $validator
+     * @param \Magento\Validator\Object $validator
+     * @return void
      */
-    protected function _addPasswordValidation(\Magento\Validator\Composite\VarienObject $validator)
+    protected function _addPasswordValidation(\Magento\Validator\Object $validator)
     {
         $passwordNotEmpty = new \Zend_Validate_NotEmpty();
         $passwordNotEmpty->setMessage(
@@ -363,7 +371,7 @@ class User
     /**
      * Process data after model is saved
      *
-     * @return \Magento\Core\Model\AbstractModel
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -375,7 +383,7 @@ class User
      * Save admin user extra data (like configuration sections state)
      *
      * @param   array $data
-     * @return  \Magento\User\Model\User
+     * @return  $this
      */
     public function saveExtra($data)
     {
@@ -416,7 +424,7 @@ class User
     /**
      * Unassign user from his current role
      *
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function deleteFromRole()
     {
@@ -427,7 +435,7 @@ class User
     /**
      * Check if such combination role/user exists
      *
-     * @return boolean
+     * @return bool
      */
     public function roleUserExists()
     {
@@ -439,7 +447,7 @@ class User
      * Set custom mail handler
      *
      * @param \Magento\Email\Model\Template\Mailer $mailer
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function setMailer(\Magento\Email\Model\Template\Mailer $mailer)
     {
@@ -450,7 +458,7 @@ class User
     /**
      * Send email with reset password confirmation link
      *
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function sendPasswordResetConfirmationEmail()
     {
@@ -474,7 +482,7 @@ class User
     /**
      * Send email to when password is resetting
      *
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function sendPasswordResetNotificationEmail()
     {
@@ -525,7 +533,7 @@ class User
      *
      * @param string $username
      * @param string $password
-     * @return boolean
+     * @return bool
      * @throws \Magento\Core\Exception
      * @throws \Magento\Backend\Model\Auth\Exception
      * @throws \Magento\Backend\Model\Auth\Plugin\Exception
@@ -582,7 +590,7 @@ class User
      *
      * @param   string $username
      * @param   string $password
-     * @return  \Magento\User\Model\User
+     * @return  $this
      */
     public function login($username, $password)
     {
@@ -595,7 +603,7 @@ class User
     /**
      * Reload current user
      *
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function reload()
     {
@@ -609,7 +617,7 @@ class User
      * Load user by its username
      *
      * @param string $username
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function loadByUsername($username)
     {
@@ -624,7 +632,7 @@ class User
      * Check if user is assigned to any role
      *
      * @param int|\Magento\User\Model\User $user
-     * @return null|boolean|array
+     * @return null|array
      */
     public function hasAssigned2Role($user)
     {
@@ -648,7 +656,7 @@ class User
      * Stores new reset password link token and its creation time
      *
      * @param string $newToken
-     * @return \Magento\User\Model\User
+     * @return $this
      * @throws \Magento\Core\Exception
      */
     public function changeResetPasswordLinkToken($newToken)
@@ -665,7 +673,7 @@ class User
     /**
      * Check if current reset password link token is expired
      *
-     * @return boolean
+     * @return bool
      */
     public function isResetPasswordLinkTokenExpired()
     {
@@ -706,7 +714,7 @@ class User
      * Set user has available resources
      *
      * @param bool $hasResources
-     * @return \Magento\User\Model\User
+     * @return $this
      */
     public function setHasAvailableResources($hasResources)
     {
diff --git a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php b/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php
index 8f506ed93b2a740ef398332a02eabd8c57d8f6fc..09c248a6dbba01c919f9fd6d42443ce74d9d89d2 100644
--- a/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php
+++ b/app/code/Magento/User/data/user_setup/data-upgrade-1.6.1.1-1.6.1.2.php
@@ -164,11 +164,11 @@ $map = array(
     'admin/system/config/rss' => 'Magento_Rss::rss',
     'admin/sales/order/actions' => 'Magento_Sales::actions',
     'admin/sales/order/actions/edit' => 'Magento_Sales::actions_edit',
-    'admin/sales/billing_agreement/actions/manage' => 'Magento_Sales::actions_manage',
+    'admin/paypal/billing_agreement/actions/manage' => 'Magento_Paypal::actions_manage',
     'admin/sales/order/actions/view' => 'Magento_Sales::actions_view',
-    'admin/sales/billing_agreement' => 'Magento_Sales::billing_agreement',
-    'admin/sales/billing_agreement/actions' => 'Magento_Sales::billing_agreement_actions',
-    'admin/sales/billing_agreement/actions/view' => 'Magento_Sales::billing_agreement_actions_view',
+    'admin/paypal/billing_agreement' => 'Magento_Paypal::billing_agreement',
+    'admin/paypal/billing_agreement/actions' => 'Magento_Paypal::billing_agreement_actions',
+    'admin/paypal/billing_agreement/actions/view' => 'Magento_Paypal::billing_agreement_actions_view',
     'admin/sales/order/actions/cancel' => 'Magento_Sales::cancel',
     'admin/sales/order/actions/capture' => 'Magento_Sales::capture',
     'admin/sales/order/actions/comment' => 'Magento_Sales::comment',
@@ -180,7 +180,7 @@ $map = array(
     'admin/sales/order/actions/hold' => 'Magento_Sales::hold',
     'admin/sales/order/actions/invoice' => 'Magento_Sales::invoice',
     'admin/system/order_statuses' => 'Magento_Sales::order_statuses',
-    'admin/sales/recurring_profile' => 'Magento_Sales::recurring_profile',
+    'admin/sales/recurringProfile' => 'Magento_Sales::recurring_profile',
     'admin/sales/order/actions/reorder' => 'Magento_Sales::reorder',
     'admin/sales/order/actions/review_payment' => 'Magento_Sales::review_payment',
     'admin/sales' => 'Magento_Sales::sales',
@@ -194,7 +194,7 @@ $map = array(
     'admin/sales/transactions' => 'Magento_Sales::transactions',
     'admin/sales/transactions/fetch' => 'Magento_Sales::transactions_fetch',
     'admin/sales/order/actions/unhold' => 'Magento_Sales::unhold',
-    'admin/sales/billing_agreement/actions/use' => 'Magento_Sales::use',
+    'admin/sales/billing_agreement/actions/use' => 'Magento_Paypal::use',
     'admin/system/config/promo' => 'Magento_SalesRule::config_promo',
     'admin/promo/quote' => 'Magento_SalesRule::quote',
     'admin/system/config/carriers' => 'Magento_Shipping::carriers',
diff --git a/app/code/Magento/User/view/adminhtml/role/edit.phtml b/app/code/Magento/User/view/adminhtml/role/edit.phtml
index 7738878171978c3b6301bd3cc91c3f0d8895f214..a1fd96f42b076c718c38615d1d14d8c7c8c319aa 100644
--- a/app/code/Magento/User/view/adminhtml/role/edit.phtml
+++ b/app/code/Magento/User/view/adminhtml/role/edit.phtml
@@ -51,14 +51,14 @@
         <label class="label"><span><?php echo __('Resources') ?></span></label>
 
         <div class="control">
-            <div class="tree x-tree" data-role="resource-tree" data-mage-init="<?php
+            <div class="tree x-tree" data-role="resource-tree" data-mage-init='<?php
             echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode(array(
-                "rolesTree" => array(
+                'rolesTree' => array(
                     "treeInitData" => $this->getTree(),
                     "treeInitSelectedData" => $this->getSelectedResources(),
                 )
             )));
-            ?>"></div>
+            ?>'></div>
         </div>
     </div>
 </fieldset>
diff --git a/app/code/Magento/Webapi/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php b/app/code/Magento/Webapi/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php
index 4c60d6ed3f8245d21f2e4585f0d331d193d24f8f..dd6fbcbf8ed6a743cd795cb7ad2e7e622f12edcb 100644
--- a/app/code/Magento/Webapi/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php
+++ b/app/code/Magento/Webapi/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php
@@ -91,6 +91,8 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Set the selected resources, which is an array of resource ids. If everything is allowed, the
      * array will contain just the root resource id, which is "Magento_Adminhtml::all".
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -99,7 +101,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     * {@inheritDoc}
+     * {@inheritdoc}
      */
     public function canShowTab()
     {
@@ -109,7 +111,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     * {@inheritDoc}
+     * {@inheritdoc}
      */
     public function getTabLabel()
     {
@@ -117,7 +119,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     * {@inheritDoc}
+     * {@inheritdoc}
      */
     public function getTabTitle()
     {
@@ -125,7 +127,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
     }
 
     /**
-     * {@inheritDoc}
+     * {@inheritdoc}
      */
     public function isHidden()
     {
diff --git a/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php b/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php
index a750b81667f56c19c1ee2a0ac893e71c61843522..63e13de83b00918b517484724998179d8a8652de 100644
--- a/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php
+++ b/app/code/Magento/Webapi/Block/Adminhtml/Integration/Edit/Tab/Webapi.php
@@ -64,9 +64,6 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
     /**
      * Initialize dependencies.
      *
-     * TODO: Fix excessive number of arguments
-     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
-     *
      * @param \Magento\Backend\Block\Template\Context $context
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Data\FormFactory $formFactory
@@ -76,6 +73,9 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
      * @param \Magento\Webapi\Helper\Data $webapiData
      * @param \Magento\Integration\Helper\Data $integrationData
      * @param array $data
+     *
+     * @todo Fix excessive number of arguments
+     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
         \Magento\Backend\Block\Template\Context $context,
@@ -140,6 +140,8 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic
 
     /**
      * Class constructor
+     *
+     * @return void
      */
     protected function _construct()
     {
diff --git a/app/code/Magento/Webapi/Controller/ErrorProcessor.php b/app/code/Magento/Webapi/Controller/ErrorProcessor.php
index 352221dec660f09f12feb5579526b9ebda40ff87..169ca8aafe009b8563cadea194ec291e5e69454f 100644
--- a/app/code/Magento/Webapi/Controller/ErrorProcessor.php
+++ b/app/code/Magento/Webapi/Controller/ErrorProcessor.php
@@ -137,6 +137,7 @@ class ErrorProcessor
      *
      * @param \Exception $exception
      * @param int $httpCode
+     * @return void
      * @SuppressWarnings(PHPMD.ExitExpression)
      */
     public function renderException(\Exception $exception, $httpCode = self::DEFAULT_ERROR_HTTP_CODE)
@@ -179,6 +180,7 @@ class ErrorProcessor
      * @param string $errorMessage
      * @param string $trace
      * @param int $httpCode
+     * @return void
      */
     public function render(
         $errorMessage,
@@ -205,9 +207,9 @@ class ErrorProcessor
      *
      * @param string $errorMessage
      * @param string $trace
-     * @param string $format
      * @param int $httpCode
-     * @return array
+     * @param string $format
+     * @return array|string
      */
     protected function _formatError($errorMessage, $trace, $httpCode, $format)
     {
@@ -242,7 +244,7 @@ class ErrorProcessor
     /**
      * Declare web API-specific shutdown function.
      *
-     * @return \Magento\Webapi\Controller\ErrorProcessor
+     * @return $this
      */
     public function registerShutdownFunction()
     {
@@ -252,6 +254,8 @@ class ErrorProcessor
 
     /**
      * Function to catch errors, that has not been caught by the user error dispatcher function.
+     *
+     * @return void
      */
     public function apiShutdownFunction()
     {
diff --git a/app/code/Magento/Webapi/Controller/Request.php b/app/code/Magento/Webapi/Controller/Request.php
index 620f9b41b3aefe6148bd919297438f6d71bdc289..442980e4f72ab0eec805097199e13785ef61da8c 100644
--- a/app/code/Magento/Webapi/Controller/Request.php
+++ b/app/code/Magento/Webapi/Controller/Request.php
@@ -55,6 +55,7 @@ class Request extends \Zend_Controller_Request_Http implements \Magento\App\Requ
      * Set consumer ID.
      *
      * @param int $consumerId
+     * @return void
      */
     public function setConsumerId($consumerId)
     {
diff --git a/app/code/Magento/Webapi/Controller/Response.php b/app/code/Magento/Webapi/Controller/Response.php
index 26ba47cd5bb1ef0b640c8a8864f03fa9a782b1bd..66e4af726d5de20f7fd26d7e14ee54de8c867ff2 100644
--- a/app/code/Magento/Webapi/Controller/Response.php
+++ b/app/code/Magento/Webapi/Controller/Response.php
@@ -57,7 +57,7 @@ class Response extends \Zend_Controller_Response_Http implements \Magento\App\Re
      * Set header appropriate to specified MIME type.
      *
      * @param string $mimeType MIME type
-     * @return \Magento\Webapi\Controller\Response
+     * @return $this
      */
     public function setMimeType($mimeType)
     {
@@ -71,7 +71,7 @@ class Response extends \Zend_Controller_Response_Http implements \Magento\App\Re
      * @param string $code
      * @param array $params
      * @param string $type
-     * @return \Magento\Webapi\Controller\Response
+     * @return $this
      */
     public function addMessage($message, $code, $params = array(), $type = self::MESSAGE_TYPE_ERROR)
     {
@@ -104,7 +104,7 @@ class Response extends \Zend_Controller_Response_Http implements \Magento\App\Re
     /**
      * Clear messages.
      *
-     * @return \Magento\Webapi\Controller\Response
+     * @return $this
      */
     public function clearMessages()
     {
diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php
index 98b2a14b2ae82933c0ff392e4b13d1a2784fa695..778948d28a65473ab6eb799dd721be8c36a3c9b9 100644
--- a/app/code/Magento/Webapi/Controller/Rest.php
+++ b/app/code/Magento/Webapi/Controller/Rest.php
@@ -25,8 +25,9 @@
 namespace Magento\Webapi\Controller;
 
 use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService;
-use Magento\Webapi\Controller\Rest\Router\Route;
-use Magento\Service\Entity\MagentoDtoInterface;
+use Magento\Webapi\Controller\Rest\Request as RestRequest;
+use Magento\Webapi\Controller\Rest\Response as RestResponse;
+use Magento\Webapi\Controller\Rest\Router;
 
 /**
  * Front controller for WebAPI REST area.
@@ -37,13 +38,13 @@ use Magento\Service\Entity\MagentoDtoInterface;
  */
 class Rest implements \Magento\App\FrontControllerInterface
 {
-    /** @var \Magento\Webapi\Controller\Rest\Router */
+    /** @var Router */
     protected $_router;
 
-    /** @var \Magento\Webapi\Controller\Rest\Request */
+    /** @var RestRequest */
     protected $_request;
 
-    /** @var \Magento\Webapi\Controller\Rest\Response */
+    /** @var RestResponse */
     protected $_response;
 
     /** @var \Magento\ObjectManager */
@@ -64,37 +65,37 @@ class Rest implements \Magento\App\FrontControllerInterface
     /** @var ServiceArgsSerializer */
     protected $_serializer;
 
-    /** @var \Magento\Webapi\Controller\ErrorProcessor */
+    /** @var ErrorProcessor */
     protected $_errorProcessor;
 
     /**
      * Initialize dependencies.
      *
-     * TODO: Consider removal of warning suppression
-     *
-     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
-     * @param Rest\Request $request
-     * @param Rest\Response $response
-     * @param Rest\Router $router
+     * @param RestRequest $request
+     * @param RestResponse $response
+     * @param Router $router
      * @param \Magento\ObjectManager $objectManager
      * @param \Magento\App\State $appState
      * @param \Magento\Oauth\OauthInterface $oauthService
      * @param \Magento\Oauth\Helper\Request $oauthHelper
      * @param AuthorizationService $authorizationService
      * @param ServiceArgsSerializer $serializer
-     * @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor
+     * @param ErrorProcessor $errorProcessor
+     *
+     * TODO: Consider removal of warning suppression
+     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
-        \Magento\Webapi\Controller\Rest\Request $request,
-        \Magento\Webapi\Controller\Rest\Response $response,
-        \Magento\Webapi\Controller\Rest\Router $router,
+        RestRequest $request,
+        RestResponse $response,
+        Router $router,
         \Magento\ObjectManager $objectManager,
         \Magento\App\State $appState,
         \Magento\Oauth\OauthInterface $oauthService,
         \Magento\Oauth\Helper\Request $oauthHelper,
         AuthorizationService $authorizationService,
         ServiceArgsSerializer $serializer,
-        \Magento\Webapi\Controller\ErrorProcessor $errorProcessor
+        ErrorProcessor $errorProcessor
     ) {
         $this->_router = $router;
         $this->_request = $request;
diff --git a/app/code/Magento/Webapi/Controller/Rest/Request.php b/app/code/Magento/Webapi/Controller/Rest/Request.php
index a175a6fbfcc9600aa4547bece90a0f13d3bec58a..73261b21b90cf310a2dc2d3c51fa51ed701b8f09 100644
--- a/app/code/Magento/Webapi/Controller/Rest/Request.php
+++ b/app/code/Magento/Webapi/Controller/Rest/Request.php
@@ -81,7 +81,7 @@ class Request extends \Magento\Webapi\Controller\Request
     /**
      * Retrieve accept types understandable by requester in a form of array sorted by quality in descending order.
      *
-     * @return array
+     * @return string[]
      */
     public function getAcceptTypes()
     {
diff --git a/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php b/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php
index 753cddb824e680fa65a4ec6780dbd9fe91a71b23..7c6c0e19d566e8a7199047d10bd1a520d41838de 100644
--- a/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php
+++ b/app/code/Magento/Webapi/Controller/Rest/Request/Deserializer/Xml.php
@@ -102,6 +102,7 @@ class Xml implements
      * @param string $errorMessage
      * @param string $errorFile
      * @param integer $errorLine
+     * @return void
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
     public function handleErrors($errorNumber, $errorMessage, $errorFile, $errorLine)
diff --git a/app/code/Magento/Webapi/Controller/Rest/Response.php b/app/code/Magento/Webapi/Controller/Rest/Response.php
index 5337a40efc0a24206dba54b6fb30d0c8ee9b18fc..408cc12081c480e2bf4da1274d305b4c186a8e0f 100644
--- a/app/code/Magento/Webapi/Controller/Rest/Response.php
+++ b/app/code/Magento/Webapi/Controller/Rest/Response.php
@@ -55,6 +55,8 @@ class Response extends \Magento\Webapi\Controller\Response
 
     /**
      * Send response to the client, render exceptions if they are present.
+     *
+     * @return void
      */
     public function sendResponse()
     {
@@ -80,12 +82,14 @@ class Response extends \Magento\Webapi\Controller\Response
 
     /**
      * Generate and set HTTP response code, error messages to Response object.
+     *
+     * @return $this
      */
     protected function _renderMessages()
     {
         $formattedMessages = $this->getMessages();
         $responseHttpCode = null;
-        /** @var Exception $exception */
+        /** @var \Exception $exception */
         foreach ($this->getException() as $exception) {
             $maskedException = $this->_errorProcessor->maskException($exception);
             $messageData = array(
@@ -115,7 +119,7 @@ class Response extends \Magento\Webapi\Controller\Response
      * Perform rendering of response data.
      *
      * @param array|null $outputData
-     * @return \Magento\Webapi\Controller\Rest\Response
+     * @return $this
      */
     public function prepareResponse($outputData = null)
     {
@@ -129,7 +133,8 @@ class Response extends \Magento\Webapi\Controller\Response
     /**
      * Render data using registered Renderer.
      *
-     * @param mixed $data
+     * @param array|object $data
+     * @return void
      */
     protected function _render($data)
     {
diff --git a/app/code/Magento/Webapi/Controller/Rest/Router.php b/app/code/Magento/Webapi/Controller/Rest/Router.php
index 7a656634688ee8906cd63eb5a39b3e354d8b3b04..a4e95d2c0a6aaa8440c46d3b3375b0546b40b018 100644
--- a/app/code/Magento/Webapi/Controller/Rest/Router.php
+++ b/app/code/Magento/Webapi/Controller/Rest/Router.php
@@ -47,11 +47,11 @@ class Router
      * Route the Request, the only responsibility of the class.
      * Find route that matches current URL, set parameters of the route to Request object.
      *
-     * @param \Magento\Webapi\Controller\Rest\Request $request
+     * @param Request $request
      * @return \Magento\Webapi\Controller\Rest\Router\Route
      * @throws \Magento\Webapi\Exception
      */
-    public function match(\Magento\Webapi\Controller\Rest\Request $request)
+    public function match(Request $request)
     {
         /** @var \Magento\Webapi\Controller\Rest\Router\Route[] $routes */
         $routes = $this->_apiConfig->getRestRoutes($request);
diff --git a/app/code/Magento/Webapi/Controller/Rest/Router/Route.php b/app/code/Magento/Webapi/Controller/Rest/Router/Route.php
index 2e3a403c4b6523a401fcdcfbfc691ed23e5c72dd..2c85514c4819a44cb8d6d6cdaba50e1b7ae0d2ab 100644
--- a/app/code/Magento/Webapi/Controller/Rest/Router/Route.php
+++ b/app/code/Magento/Webapi/Controller/Rest/Router/Route.php
@@ -43,7 +43,7 @@ class Route extends \Zend_Controller_Router_Route
      * Set service class.
      *
      * @param string $serviceClass
-     * @return \Magento\Webapi\Controller\Rest\Router\Route
+     * @return $this
      */
     public function setServiceClass($serviceClass)
     {
@@ -65,7 +65,7 @@ class Route extends \Zend_Controller_Router_Route
      * Set service method name.
      *
      * @param string $serviceMethod
-     * @return \Magento\Webapi\Controller\Rest\Router\Route
+     * @return $this
      */
     public function setServiceMethod($serviceMethod)
     {
@@ -87,7 +87,7 @@ class Route extends \Zend_Controller_Router_Route
      * Set if the route is secure
      *
      * @param boolean $secure
-     * @return \Magento\Webapi\Controller\Rest\Router\Route
+     * @return $this
      */
     public function setSecure($secure)
     {
@@ -109,6 +109,7 @@ class Route extends \Zend_Controller_Router_Route
      * Set ACL resources list.
      *
      * @param array $aclResources
+     * @return void
      */
     public function setAclResources($aclResources)
     {
diff --git a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php
index 4a8ce5ea919ddf62aaf723506a1bbbac51b8b80f..2c0ac5c4f8273532e74181013c73398f3d30b0c3 100644
--- a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php
+++ b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php
@@ -60,7 +60,6 @@ class ServiceArgsSerializer
      * @param string $serviceClassName name of the service class that we are trying to call
      * @param string $serviceMethodName name of the method that we are trying to call
      * @param array $inputArray data to send to method in key-value format
-     *
      * @return array list of parameters that can be used to call the service method
      */
     public function getInputData($serviceClassName, $serviceMethodName, array $inputArray)
diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php
index b617a0324a3cc3588e34442b466aecd96521cbc9..a4702dceed463e1d8f4186a25a5335284e111710 100644
--- a/app/code/Magento/Webapi/Controller/Soap.php
+++ b/app/code/Magento/Webapi/Controller/Soap.php
@@ -51,10 +51,10 @@ class Soap implements \Magento\App\FrontControllerInterface
     /** @var \Magento\Webapi\Controller\Soap\Request */
     protected $_request;
 
-    /** @var \Magento\Webapi\Controller\Response */
+    /** @var Response */
     protected $_response;
 
-    /** @var \Magento\Webapi\Controller\ErrorProcessor */
+    /** @var ErrorProcessor */
     protected $_errorProcessor;
 
     /** @var \Magento\App\State */
@@ -70,20 +70,20 @@ class Soap implements \Magento\App\FrontControllerInterface
      * Initialize dependencies.
      *
      * @param \Magento\Webapi\Controller\Soap\Request $request
-     * @param \Magento\Webapi\Controller\Response $response
+     * @param Response $response
      * @param \Magento\Webapi\Model\Soap\Wsdl\Generator $wsdlGenerator
      * @param \Magento\Webapi\Model\Soap\Server $soapServer
-     * @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor
+     * @param ErrorProcessor $errorProcessor
      * @param \Magento\App\State $appState
      * @param \Magento\AppInterface $application
      * @param \Magento\Oauth\OauthInterface $oauthService
      */
     public function __construct(
         \Magento\Webapi\Controller\Soap\Request $request,
-        \Magento\Webapi\Controller\Response $response,
+        Response $response,
         \Magento\Webapi\Model\Soap\Wsdl\Generator $wsdlGenerator,
         \Magento\Webapi\Model\Soap\Server $soapServer,
-        \Magento\Webapi\Controller\ErrorProcessor $errorProcessor,
+        ErrorProcessor $errorProcessor,
         \Magento\App\State $appState,
         \Magento\AppInterface $application,
         \Magento\Oauth\OauthInterface $oauthService
@@ -161,6 +161,7 @@ class Soap implements \Magento\App\FrontControllerInterface
      * Set body and status code to response using information extracted from provided exception.
      *
      * @param \Exception $exception
+     * @return void
      */
     protected function _prepareErrorResponse($exception)
     {
@@ -169,7 +170,7 @@ class Soap implements \Magento\App\FrontControllerInterface
             $httpCode = $maskedException->getHttpCode();
             $contentType = self::CONTENT_TYPE_WSDL_REQUEST;
         } else {
-            $httpCode = \Magento\Webapi\Controller\Response::HTTP_OK;
+            $httpCode = Response::HTTP_OK;
             $contentType = self::CONTENT_TYPE_SOAP_CALL;
         }
         $this->_setResponseContentType($contentType);
@@ -183,7 +184,7 @@ class Soap implements \Magento\App\FrontControllerInterface
      * Set content type to response object.
      *
      * @param string $contentType
-     * @return \Magento\Webapi\Controller\Soap
+     * @return $this
      */
     protected function _setResponseContentType($contentType = 'text/xml')
     {
@@ -196,7 +197,7 @@ class Soap implements \Magento\App\FrontControllerInterface
      * Replace WSDL xml encoding from config, if present, else default to UTF-8 and set it to the response object.
      *
      * @param string $responseBody
-     * @return \Magento\Webapi\Controller\Soap
+     * @return $this
      */
     protected function _setResponseBody($responseBody)
     {
diff --git a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
index 383428ad47b62fe13d3bbc406f5e696eab5d7293..cef4b66f2277ba376f23677084b327b5e322b275 100644
--- a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
+++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
@@ -145,7 +145,7 @@ class Handler
     /**
      * Convert service response into format acceptable by SoapServer.
      *
-     * @param object|array|string|int|double|null $data
+     * @param object|array|string|int|float|null $data
      * @return array
      * @throws \InvalidArgumentException
      */
diff --git a/app/code/Magento/Webapi/Exception.php b/app/code/Magento/Webapi/Exception.php
index 1c1362d8f0eac6682bb4288e45175cf08e895105..55de4cad66868d280e423c3f8e3594497d17b40e 100644
--- a/app/code/Magento/Webapi/Exception.php
+++ b/app/code/Magento/Webapi/Exception.php
@@ -64,8 +64,8 @@ class Exception extends \RuntimeException
      * Initialize exception with HTTP code.
      *
      * @param string $message
-     * @param int $httpCode
      * @param int $code Error code
+     * @param int $httpCode
      * @param array $details Additional exception details
      * @param string $name Exception name
      * @throws \InvalidArgumentException
diff --git a/app/code/Magento/Webapi/Helper/Data.php b/app/code/Magento/Webapi/Helper/Data.php
index aa996df32aa3c255f0cf40f496cfe5884e7e924e..472e5fd4a20c9cdac1e290a48783b47e313d1db2 100644
--- a/app/code/Magento/Webapi/Helper/Data.php
+++ b/app/code/Magento/Webapi/Helper/Data.php
@@ -24,21 +24,30 @@
 
 namespace Magento\Webapi\Helper;
 
+use Magento\App\Helper\Context;
+use Magento\Core\Model\Registry;
 use Magento\Integration\Controller\Adminhtml\Integration as IntegrationController;
 
 class Data extends \Magento\App\Helper\AbstractHelper
 {
-    /** @var \Magento\Core\Model\Registry */
+    /** @var Registry */
     protected $_registry;
 
+    /**
+     * @param Context $context
+     * @param Registry $registry
+     */
     public function __construct(
-        \Magento\App\Helper\Context $context,
-        \Magento\Core\Model\Registry $registry
+        Context $context,
+        Registry $registry
     ) {
         $this->_registry = $registry;
         parent::__construct($context);
     }
 
+    /**
+     * @return array
+     */
     public function getSelectedResources()
     {
         $selectedResourceIds = array();
@@ -81,7 +90,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      *
      * @param string $className
      * @param bool $preserveVersion Should version be preserved during class name conversion into service name
-     * @return array
+     * @return string[]
      * @throws \InvalidArgumentException When class is not valid API service.
      */
     public function getServiceNameParts($className, $preserveVersion = false)
diff --git a/app/code/Magento/Webapi/Model/Config.php b/app/code/Magento/Webapi/Model/Config.php
index 404132d2eb2b561e318d61ecf9ee5756c8750420..d670f05d5157ec8da729a82c5bda8156c4ebfc64 100644
--- a/app/code/Magento/Webapi/Model/Config.php
+++ b/app/code/Magento/Webapi/Model/Config.php
@@ -24,6 +24,9 @@
  */
 namespace Magento\Webapi\Model;
 
+use Magento\Webapi\Model\Cache\Type;
+use Magento\Webapi\Model\Config\Reader;
+
 /**
  * Web API Config Model.
  *
@@ -44,7 +47,7 @@ class Config
     protected $_configCacheType;
 
     /**
-     * @var \Magento\Webapi\Model\Config\Reader
+     * @var Reader
      */
     protected $_configReader;
 
@@ -61,12 +64,12 @@ class Config
     protected $_services;
 
     /**
-     * @param Cache\Type $configCacheType
-     * @param Config\Reader $configReader
+     * @param Type $configCacheType
+     * @param Reader $configReader
      */
     public function __construct(
-        \Magento\Webapi\Model\Cache\Type $configCacheType,
-        \Magento\Webapi\Model\Config\Reader $configReader
+        Type $configCacheType,
+        Reader $configReader
     ) {
         $this->_configCacheType = $configCacheType;
         $this->_configReader = $configReader;
@@ -93,6 +96,8 @@ class Config
 
     /**
      * Load services from cache
+     *
+     * @return string|bool
      */
     protected function _loadFromCache()
     {
@@ -103,7 +108,7 @@ class Config
      * Save services into the cache
      *
      * @param string $data serialized version of the webapi registry
-     * @return \Magento\Webapi\Model\Config
+     * @return $this
      */
     protected function _saveToCache($data)
     {
diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector.php b/app/code/Magento/Webapi/Model/Config/ClassReflector.php
index 72cc4f855587013c2d169c4d5ca15d26487b6d21..81b67b4731286ea7e252539c311744ecf1eb3f42 100644
--- a/app/code/Magento/Webapi/Model/Config/ClassReflector.php
+++ b/app/code/Magento/Webapi/Model/Config/ClassReflector.php
@@ -48,8 +48,8 @@ class ClassReflector
     /**
      * Reflect methods in given class and set retrieved data into reader.
      *
-     * @param array $methods
      * @param string $className
+     * @param array $methods
      * @return array <pre>array(
      *     $firstMethod => array(
      *         'documentation' => $methodDocumentation,
diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php
index 72264cf7c75c80cd332c34107f0274f47cf9ed88..e4a9905737c62e9fe9aadd91f07f4751685f4473 100644
--- a/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php
+++ b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php
@@ -36,8 +36,7 @@ class TypeProcessor
 
     /**
      * Array of types data.
-     *
-     * @var array <pre>array(
+     * <pre>array(
      *     $complexTypeName => array(
      *         'documentation' => $typeDocumentation
      *         'parameters' => array(
@@ -52,16 +51,19 @@ class TypeProcessor
      *     ),
      *     ...
      * )</pre>
+     *
+     * @var array
      */
     protected $_types = array();
 
     /**
      * Types class map.
-     *
-     * @var array <pre>array(
+     * <pre>array(
      *     $complexTypeName => $interfaceName,
      *     ...
      * )</pre>
+     *
+     * @var array
      */
     protected $_typeToClassMap = array();
 
@@ -105,6 +107,7 @@ class TypeProcessor
      *
      * @param string $typeName
      * @param array $data
+     * @return void
      */
     public function setTypeData($typeName, $data)
     {
@@ -182,6 +185,7 @@ class TypeProcessor
      *
      * @param \Zend\Code\Reflection\MethodReflection $methodReflection
      * @param string $typeName
+     * @return void
      */
     protected function _processMethod(\Zend\Code\Reflection\MethodReflection $methodReflection, $typeName)
     {
diff --git a/app/code/Magento/Webapi/Model/Config/Integration/Reader.php b/app/code/Magento/Webapi/Model/Config/Integration/Reader.php
index 63afe34d121b0f1e60b0ae5b096db2100272caf8..a1139a0d283042ba0bf0f8d924a7de3fe76151d3 100644
--- a/app/code/Magento/Webapi/Model/Config/Integration/Reader.php
+++ b/app/code/Magento/Webapi/Model/Config/Integration/Reader.php
@@ -50,8 +50,8 @@ class Reader extends \Magento\Config\Reader\Filesystem
      */
     public function __construct(
         \Magento\Config\FileResolverInterface $fileResolver,
-        \Magento\Webapi\Model\Config\Integration\Converter $converter,
-        \Magento\Webapi\Model\Config\Integration\SchemaLocator $schemaLocator,
+        Converter $converter,
+        SchemaLocator $schemaLocator,
         \Magento\Config\ValidationStateInterface $validationState,
         $fileName = 'integration\api.xml',
         $idAttributes = array(),
diff --git a/app/code/Magento/Webapi/Model/Config/Reader.php b/app/code/Magento/Webapi/Model/Config/Reader.php
index c9756afbc4361116ba317fcbc0cd90a2bd4cf7a5..a1a50095209e4498aa61224d255e5898dc319866 100644
--- a/app/code/Magento/Webapi/Model/Config/Reader.php
+++ b/app/code/Magento/Webapi/Model/Config/Reader.php
@@ -50,8 +50,8 @@ class Reader extends \Magento\Config\Reader\Filesystem
      */
     public function __construct(
         \Magento\Config\FileResolverInterface $fileResolver,
-        \Magento\Webapi\Model\Config\Converter $converter,
-        \Magento\Webapi\Model\Config\SchemaLocator $schemaLocator,
+        Converter $converter,
+        SchemaLocator $schemaLocator,
         \Magento\Config\ValidationStateInterface $validationState,
         $fileName = 'webapi.xml',
         $idAttributes = array(),
diff --git a/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php b/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php
index 3d8cdaa46a0a0366934d042f19556bd62c66a5b4..0adb76dd9c45466f786c237e4adfe93e92095224 100644
--- a/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php
+++ b/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php
@@ -92,6 +92,7 @@ class IntegrationServiceV1
      * Add the list of allowed resources to the integration object data by 'resource' key.
      *
      * @param IntegrationModel $integration
+     * @return void
      */
     protected function _addAllowedResources(IntegrationModel $integration)
     {
@@ -108,6 +109,7 @@ class IntegrationServiceV1
      * If 'all_resources' is set and is evaluated to true, permissions to all resources will be granted.
      *
      * @param IntegrationModel $integration
+     * @return void
      */
     protected function _saveApiPermissions(IntegrationModel $integration)
     {
diff --git a/app/code/Magento/Webapi/Model/Plugin/Setup.php b/app/code/Magento/Webapi/Model/Plugin/Setup.php
index f0984acd46830468118277185651cdcc3fe28643..02a6b4eef123b41a86b145f7f38be01ed0ab3943 100644
--- a/app/code/Magento/Webapi/Model/Plugin/Setup.php
+++ b/app/code/Magento/Webapi/Model/Plugin/Setup.php
@@ -26,6 +26,7 @@ namespace Magento\Webapi\Model\Plugin;
 
 use Magento\Authz\Model\UserIdentifier;
 use Magento\Integration\Model\Integration;
+use Magento\Webapi\Model\IntegrationConfig;
 
 /**
  * Plugin for Magento\Core\Model\Resource\Setup model to manage resource permissions of
@@ -36,7 +37,7 @@ class Setup
     /**
      * API Integration config
      *
-     * @var Config
+     * @var IntegrationConfig
      */
     protected $_integrationConfig;
 
@@ -65,13 +66,13 @@ class Setup
     /**
      * Construct Setup plugin instance
      *
-     * @param \Magento\Webapi\Model\IntegrationConfig $integrationConfig
+     * @param IntegrationConfig $integrationConfig
      * @param \Magento\Authz\Service\AuthorizationV1 $authzService
      * @param \Magento\Integration\Service\IntegrationV1Interface $integrationService
      * @param \Magento\Authz\Model\UserIdentifier\Factory $userIdentifierFactory
      */
     public function __construct(
-        \Magento\Webapi\Model\IntegrationConfig $integrationConfig,
+        IntegrationConfig $integrationConfig,
         \Magento\Authz\Service\AuthorizationV1 $authzService,
         \Magento\Integration\Service\IntegrationV1Interface $integrationService,
         \Magento\Authz\Model\UserIdentifier\Factory $userIdentifierFactory
@@ -85,8 +86,8 @@ class Setup
     /**
      * Process integration resource permissions after the integration is created
      *
-     * @param array $integrationNames Name of integrations passed as array from the invocation chain
-     * @return array
+     * @param string[] $integrationNames Name of integrations passed as array from the invocation chain
+     * @return string[]
      */
     public function afterInitIntegrationProcessing($integrationNames)
     {
diff --git a/app/code/Magento/Webapi/Model/Rest/Config.php b/app/code/Magento/Webapi/Model/Rest/Config.php
index 7f75332c38e1687480f8fdcfddfffced37689e40..edb934460434baf16fca14c7b1e018bd6b90eaf2 100644
--- a/app/code/Magento/Webapi/Model/Rest/Config.php
+++ b/app/code/Magento/Webapi/Model/Rest/Config.php
@@ -23,7 +23,9 @@
  */
 namespace Magento\Webapi\Model\Rest;
 
+use Magento\Webapi\Controller\Rest\Router\Route;
 use \Magento\Webapi\Model\Config\Converter;
+use Magento\Webapi\Model\Config as ModelConfig;
 
 /**
  * Webapi Config Model for Rest.
@@ -49,18 +51,18 @@ class Config
     const KEY_ACL_RESOURCES = 'resources';
     /*#@-*/
 
-    /** @var \Magento\Webapi\Model\Config  */
+    /** @var ModelConfig */
     protected $_config;
 
     /** @var \Magento\Controller\Router\Route\Factory */
     protected $_routeFactory;
 
     /**
-     * @param \Magento\Webapi\Model\Config
+     * @param ModelConfig $config
      * @param \Magento\Controller\Router\Route\Factory $routeFactory
      */
     public function __construct(
-        \Magento\Webapi\Model\Config $config,
+        ModelConfig $config,
         \Magento\Controller\Router\Route\Factory $routeFactory
     ) {
         $this->_config = $config;
@@ -114,7 +116,7 @@ class Config
      * Generate the list of available REST routes. Current HTTP method is taken into account.
      *
      * @param \Magento\Webapi\Controller\Rest\Request $request
-     * @return array
+     * @return Route[]
      * @throws \Magento\Webapi\Exception
      */
     public function getRestRoutes(\Magento\Webapi\Controller\Rest\Request $request)
diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php
index b748e5bf2244974e5be9642386a4edddaef63f7a..0e295ca1f348c6f67de220333664aee6b5da3e2b 100644
--- a/app/code/Magento/Webapi/Model/Soap/Fault.php
+++ b/app/code/Magento/Webapi/Model/Soap/Fault.php
@@ -78,19 +78,19 @@ class Fault extends \RuntimeException
     /** @var \Magento\Core\Model\App */
     protected $_application;
 
-    /** @var \Magento\Webapi\Model\Soap\Server */
+    /** @var Server */
     protected $_soapServer;
 
     /**
      * Construct exception.
      *
      * @param \Magento\Core\Model\App $application
+     * @param Server $soapServer
      * @param \Magento\Webapi\Exception $previousException
-     * @param \Magento\Webapi\Model\Soap\Server $soapServer
      */
     public function __construct(
         \Magento\Core\Model\App $application,
-        \Magento\Webapi\Model\Soap\Server $soapServer,
+        Server $soapServer,
         \Magento\Webapi\Exception $previousException
     ) {
         parent::__construct($previousException->getMessage(), $previousException->getCode(), $previousException);
@@ -145,7 +145,8 @@ class Fault extends \RuntimeException
     /**
      * Define current SOAP fault name. It is used as a name of the wrapper node for SOAP fault details.
      *
-     * @param $exceptionName
+     * @param string $exceptionName
+     * @return void
      */
     protected function _setFaultName($exceptionName)
     {
@@ -173,7 +174,7 @@ class Fault extends \RuntimeException
      * Add details about current fault.
      *
      * @param array $details Associative array containing details about current fault
-     * @return \Magento\Webapi\Model\Soap\Fault
+     * @return $this
      */
     public function addDetails($details)
     {
diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php
index cf9e60c9ded323d0b24a29bdcd9b4ebae0d15667..dc9f366785ae8bb4431dba3a22300b60cc832c89 100644
--- a/app/code/Magento/Webapi/Model/Soap/Server.php
+++ b/app/code/Magento/Webapi/Model/Soap/Server.php
@@ -107,6 +107,8 @@ class Server
 
     /**
      * Handle SOAP request. Response is sent by SOAP server.
+     *
+     * @return void
      */
     public function handle()
     {
@@ -128,7 +130,7 @@ class Server
     public function getApiCharset()
     {
         $charset = $this->_storeManager->getStore()->getConfig(self::CONFIG_PATH_SOAP_CHARSET);
-        return $charset ? $charset : \Magento\Webapi\Model\Soap\Server::SOAP_DEFAULT_ENCODING;
+        return $charset ? $charset : self::SOAP_DEFAULT_ENCODING;
     }
 
     /**
@@ -141,7 +143,7 @@ class Server
     {
         $params = array(
             self::REQUEST_PARAM_SERVICES => $this->_request->getParam(
-                \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_SERVICES
+                self::REQUEST_PARAM_SERVICES
             )
         );
         if ($isWsdl) {
@@ -166,8 +168,8 @@ class Server
      * Generate exception if request is invalid.
      *
      * @param string $soapRequest
-     * @throws \Magento\Webapi\Exception with invalid SOAP extension
-     * @return \Magento\Webapi\Model\Soap\Server
+     * @throws \Magento\Webapi\Exception With invalid SOAP extension
+     * @return $this
      */
     protected function _checkRequest($soapRequest)
     {
diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php
index cc48f70fced4d87d2a85cb4a27a82cb68d17a9e1..88be0a701604ddf205cd69a4ec5e0a2efc404846 100644
--- a/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php
+++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php
@@ -148,6 +148,7 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * @param array $parameterData
      * @param string $parameterType
      * @param array $callInfo
+     * @return void
      */
     protected function _processParameter(\DOMElement $element, $isRequired, $parameterData, $parameterType, $callInfo)
     {
@@ -168,6 +169,7 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      *
      * @param string $type
      * @param array $callInfo
+     * @return void
      */
     protected function _processArrayParameter($type, $callInfo = array())
     {
@@ -195,8 +197,9 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
     /**
      * Revert required call info data if needed.
      *
-     * @param boolean $isRequired
-     * @param array $callInfo
+     * @param bool $isRequired
+     * @param array &$callInfo
+     * @return void
      */
     protected function _revertRequiredCallInfo($isRequired, &$callInfo)
     {
@@ -222,6 +225,7 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * @param string $documentation parameter documentation string
      * @param string|null $default
      * @param array $callInfo
+     * @return void
      */
     public function addAnnotation(\DOMElement $element, $documentation, $default = null, $callInfo = array())
     {
@@ -290,6 +294,7 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * @param string $elementType
      * @param string $documentation
      * @param \DOMElement $appInfoNode
+     * @return void
      */
     protected function _processElementType($elementType, $documentation, \DOMElement $appInfoNode)
     {
@@ -314,6 +319,7 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * @param string $elementType
      * @param string $default
      * @param \DOMElement $appInfoNode
+     * @return void
      */
     protected function _processDefaultValueAnnotation($elementType, $default, \DOMElement $appInfoNode)
     {
@@ -346,9 +352,10 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
     /**
      * Check if there is given annotation in documentation, and if not - create an empty one.
      *
-     * @param $annotation
-     * @param $documentation
+     * @param string $annotation
+     * @param string $documentation
      * @param \DOMElement $appInfoNode
+     * @return void
      */
     protected function _processRequiredAnnotation($annotation, $documentation, \DOMElement $appInfoNode)
     {
@@ -362,7 +369,8 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * Process 'callInfo' appinfo tag.
      *
      * @param \DOMElement $appInfoNode
-     * @param $callInfo
+     * @param array $callInfo
+     * @return void
      */
     protected function _processCallInfo(\DOMElement $appInfoNode, $callInfo)
     {
@@ -394,7 +402,8 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * Process 'docInstructions' appinfo tag.
      *
      * @param \DOMElement $appInfoNode
-     * @param $tagValue
+     * @param string $tagValue
+     * @return void
      */
     protected function _processDocInstructions(\DOMElement $appInfoNode, $tagValue)
     {
@@ -412,7 +421,8 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
      * Process 'seeLink' appinfo tag.
      *
      * @param \DOMElement $appInfoNode
-     * @param $tagValue
+     * @param string $tagValue
+     * @return void
      */
     protected function _processSeeLink(\DOMElement $appInfoNode, $tagValue)
     {
@@ -437,8 +447,9 @@ class ComplexTypeStrategy extends AbstractComplexTypeStrategy
     /**
      * Delete callName if it's already defined in some direction group.
      *
-     * @param $callInfo
-     * @param $callName
+     * @param array &$callInfo
+     * @param string $callName
+     * @return void
      */
     protected function _overrideCallInfoName(&$callInfo, $callName)
     {
diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php
index 018327b311e8143582d94dbb42b4edd9f9bf3b04..db17cef1f0f36add865888c286e0aee21d3f23fb 100644
--- a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php
+++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php
@@ -38,7 +38,7 @@ class Generator
     /**
      * WSDL factory instance.
      *
-     * @var \Magento\Webapi\Model\Soap\Wsdl\Factory
+     * @var Factory
      */
     protected $_wsdlFactory;
 
@@ -66,13 +66,13 @@ class Generator
      * Initialize dependencies.
      *
      * @param \Magento\Webapi\Model\Soap\Config $apiConfig
-     * @param \Magento\Webapi\Model\Soap\Wsdl\Factory $wsdlFactory
+     * @param Factory $wsdlFactory
      * @param \Magento\Webapi\Model\Cache\Type $cache
      * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor
      */
     public function __construct(
         \Magento\Webapi\Model\Soap\Config $apiConfig,
-        \Magento\Webapi\Model\Soap\Wsdl\Factory $wsdlFactory,
+        Factory $wsdlFactory,
         \Magento\Webapi\Model\Cache\Type $cache,
         \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor
     ) {
@@ -346,6 +346,7 @@ class Generator
      * Walks through all requested services and checks all methods 'in' and 'out' parameters.
      *
      * @param array $requestedServices
+     * @return void
      */
     protected function _collectCallInfo($requestedServices)
     {
@@ -362,6 +363,7 @@ class Generator
      * @param array $interface
      * @param string $serviceName
      * @param string $methodName
+     * @return void
      */
     protected function _processInterfaceCallInfo($interface, $serviceName, $methodName)
     {
diff --git a/app/code/Magento/Webapi/view/adminhtml/resourcetree.phtml b/app/code/Magento/Webapi/view/adminhtml/resourcetree.phtml
index 3e89c7bbea5683608d0c1d6453dbee3c10cb0fd4..e09e6a356aea309817793c0c52a52c97da6c347a 100644
--- a/app/code/Magento/Webapi/view/adminhtml/resourcetree.phtml
+++ b/app/code/Magento/Webapi/view/adminhtml/resourcetree.phtml
@@ -49,14 +49,14 @@
         <label class="label"><span><?php echo __('Resources') ?></span></label>
 
         <div class="control">
-            <div class="tree x-tree" data-role="resource-tree" data-mage-init="<?php
+            <div class="tree x-tree" data-role="resource-tree" data-mage-init='<?php
             echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode(array(
-                "rolesTree" => array(
+                'rolesTree' => array(
                     "treeInitData" => $this->getTree(),
                     "treeInitSelectedData" => $this->getSelectedResources(),
                 )
             )));
-            ?>"></div>
+            ?>'></div>
         </div>
     </div>
 </fieldset>
diff --git a/app/code/Magento/Weee/view/adminhtml/renderer/tax.phtml b/app/code/Magento/Weee/view/adminhtml/renderer/tax.phtml
index d2cb7bea295fb3a4ea70cd14bedb89ec6c284920..6e57cd6ebd9ee7cac46b9f6c1e7fd8ce471f801d 100644
--- a/app/code/Magento/Weee/view/adminhtml/renderer/tax.phtml
+++ b/app/code/Magento/Weee/view/adminhtml/renderer/tax.phtml
@@ -27,11 +27,11 @@
 <?php /** @var $this \Magento\Weee\Block\Renderer\Weee\Tax */?>
 <div id="attribute-<?php echo $this->getElement()->getHtmlId(); ?>-container" class="field"
      data-element-id="<?php echo $this->getElement()->getHtmlId(); ?>"
-     data-mage-init="{fptAttribute:{
-        region: <?php echo $this->escapeHtml($this->helper('Magento\Directory\Helper\Data')->getRegionJson()) ?>,
-        itemsData: <?php echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode($this->getValues())); ?>,
-        bundlePriceType: '#price_type'
-        }}">
+     data-mage-init='{"fptAttribute":{
+        "region": <?php echo $this->escapeHtml($this->helper('Magento\Directory\Helper\Data')->getRegionJson()) ?>,
+        "itemsData": <?php echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode($this->getValues())); ?>,
+        "bundlePriceType": "#price_type"
+     }}'>
     <label class="label"><span><?php echo $this->getElement()->getLabel() ?></span></label>
 
     <div class="control">
diff --git a/app/code/Magento/Wishlist/Block/Customer/Sharing.php b/app/code/Magento/Wishlist/Block/Customer/Sharing.php
index f7c6aa1ecc98c8c28da19642ba27a77841b07179..15957b0b53f2d5b9b557ebec516196c95ac7f925 100644
--- a/app/code/Magento/Wishlist/Block/Customer/Sharing.php
+++ b/app/code/Magento/Wishlist/Block/Customer/Sharing.php
@@ -39,7 +39,7 @@ class Sharing extends \Magento\View\Element\Template
     /**
      * Entered Data cache
      *
-     * @param array
+     * @var array|null
      */
     protected $_enteredData = null;
 
@@ -76,7 +76,7 @@ class Sharing extends \Magento\View\Element\Template
     /**
      * Prepare Global Layout
      *
-     * @return \Magento\Wishlist\Block\Customer\Sharing
+     * @return void
      */
     protected function _prepareLayout()
     {
@@ -100,7 +100,7 @@ class Sharing extends \Magento\View\Element\Template
      * Retrieve Entered Data by key
      *
      * @param string $key
-     * @return mixed
+     * @return string|null
      */
     public function getEnteredData($key)
     {
@@ -110,8 +110,7 @@ class Sharing extends \Magento\View\Element\Template
 
         if (!$this->_enteredData || !isset($this->_enteredData[$key])) {
             return null;
-        }
-        else {
+        } else {
             return $this->escapeHtml($this->_enteredData[$key]);
         }
     }
diff --git a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php
index e15667f172ab724bfa22d6fbcfaf0cc37830d7b8..a8928b407a443bedf3bd59a5ed0029f7c472f076 100644
--- a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php
+++ b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php
@@ -50,7 +50,7 @@ class Sidebar extends \Magento\Wishlist\Block\AbstractBlock
      * Add sidebar conditions to collection
      *
      * @param  \Magento\Wishlist\Model\Resource\Item\Collection $collection
-     * @return \Magento\Wishlist\Block\Customer\Wishlist
+     * @return $this
      */
     protected function _prepareCollection($collection)
     {
diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php
index 89a3ee50018e5d155496532a184714483275fce2..b0b9d97dfc10556989548f2f3a17079bba617564 100644
--- a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php
+++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php
@@ -36,8 +36,10 @@ namespace Magento\Wishlist\Block\Customer;
 
 class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
 {
-    /*
+    /**
      * List of product options rendering configurations by product type
+     *
+     * @var array
      */
     protected $_optionsCfg = array();
 
@@ -116,7 +118,7 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
      * Add wishlist conditions to collection
      *
      * @param  \Magento\Wishlist\Model\Resource\Item\Collection $collection
-     * @return \Magento\Wishlist\Block\Customer\Wishlist
+     * @return $this
      */
     protected function _prepareCollection($collection)
     {
@@ -127,7 +129,7 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
     /**
      * Preparing global layout
      *
-     * @return \Magento\Wishlist\Block\Customer\Wishlist
+     * @return void
      */
     protected function _prepareLayout()
     {
@@ -151,9 +153,10 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
     /**
      * Sets all options render configurations
      *
-     * @deprecated after 1.6.2.0
      * @param null|array $optionCfg
-     * @return \Magento\Wishlist\Block\Customer\Wishlist
+     * @return $this
+     *
+     * @deprecated after 1.6.2.0
      */
     public function setOptionsRenderCfgs($optionCfg)
     {
@@ -172,14 +175,15 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
         return $this->_optionsCfg;
     }
 
-    /*
+    /**
      * Adds config for rendering product type options
      *
-     * @deprecated after 1.6.2.0
      * @param string $productType
      * @param string $helperName
      * @param null|string $template
-     * @return \Magento\Wishlist\Block\Customer\Wishlist
+     * @return $this
+     *
+     * @deprecated after 1.6.2.0
      */
     public function addOptionsRenderCfg($productType, $helperName, $template = null)
     {
@@ -190,9 +194,10 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
     /**
      * Returns html for showing item options
      *
-     * @deprecated after 1.6.2.0
      * @param string $productType
      * @return array|null
+     *
+     * @deprecated after 1.6.2.0
      */
     public function getOptionsRenderCfg($productType)
     {
@@ -208,9 +213,10 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
     /**
      * Returns html for showing item options
      *
-     * @deprecated after 1.6.2.0
      * @param \Magento\Wishlist\Model\Item $item
      * @return string
+     *
+     * @deprecated after 1.6.2.0
      */
     public function getDetailsHtml(\Magento\Wishlist\Model\Item $item)
     {
@@ -242,9 +248,10 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
     /**
      * Returns qty to show visually to user
      *
-     * @deprecated after 1.6.2.0
      * @param \Magento\Wishlist\Model\Item $item
      * @return float
+     *
+     * @deprecated after 1.6.2.0
      */
     public function getAddToCartQty(\Magento\Wishlist\Model\Item $item)
     {
diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php
index 1e1b7998712ef2dcd33900948a561b7f8041424c..bbb943111969a3631888be2cbc4e303793bdbd55 100644
--- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php
+++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php
@@ -110,6 +110,8 @@ class Options extends \Magento\Wishlist\Block\AbstractBlock
 
     /**
      * Initialize block
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -117,13 +119,13 @@ class Options extends \Magento\Wishlist\Block\AbstractBlock
         $this->_eventManager->dispatch('product_option_renderer_init', array('block' => $this));
     }
 
-    /*
+    /**
      * Adds config for rendering product type options
      *
      * @param string $productType
      * @param string $helperName
      * @param null|string $template
-     * @return \Magento\Wishlist\Block\Customer\Wishlist\Item\Options
+     * @return $this
      */
     public function addOptionsRenderCfg($productType, $helperName, $template = null)
     {
diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php
index c8c09dc9f54eced27e9975e7b11f4a575a2654be..28f20def3bff4420b33aff7e3d331fd3cce47c3c 100644
--- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php
+++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Items.php
@@ -56,7 +56,7 @@ class Items extends \Magento\View\Element\Template
     {
         $columns = array();
         foreach ($this->getLayout()->getChildBlocks($this->getNameInLayout()) as $child) {
-            if ($child->isEnabled()){
+            if ($child->isEnabled()) {
                 $columns[] = $child;
             }
         }
diff --git a/app/code/Magento/Wishlist/Block/Item/Configure.php b/app/code/Magento/Wishlist/Block/Item/Configure.php
index 3caca11ad0d71df591abb8675d3ff0d8e7ca3ce8..273e28b21a9503c4788c69163dd785c74c477382 100644
--- a/app/code/Magento/Wishlist/Block/Item/Configure.php
+++ b/app/code/Magento/Wishlist/Block/Item/Configure.php
@@ -100,7 +100,7 @@ class Configure extends \Magento\View\Element\Template
     /**
      * Configure product view blocks
      *
-     * @return \Magento\Wishlist\Block\Item\Configure
+     * @return $this
      */
     protected function _prepareLayout()
     {
diff --git a/app/code/Magento/Wishlist/Block/Link.php b/app/code/Magento/Wishlist/Block/Link.php
index 2cba0c3d24b4d0d6369354a85988a2330a3f07db..b398b4ad3c9fd9be946b87c9316170bfad927df8 100644
--- a/app/code/Magento/Wishlist/Block/Link.php
+++ b/app/code/Magento/Wishlist/Block/Link.php
@@ -112,7 +112,7 @@ class Link extends \Magento\View\Element\Html\Link
      * Create button label based on wishlist item quantity
      *
      * @param int $count
-     * @return string
+     * @return string|void
      */
     protected function _createCounter($count)
     {
diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Items.php b/app/code/Magento/Wishlist/Block/Share/Email/Items.php
index 0d331f2d7908c84fe4854f63feda0049c7e67e29..8a24b86d65aa6a3330eb95297bc979b2defa79f4 100644
--- a/app/code/Magento/Wishlist/Block/Share/Email/Items.php
+++ b/app/code/Magento/Wishlist/Block/Share/Email/Items.php
@@ -36,6 +36,9 @@ namespace Magento\Wishlist\Block\Share\Email;
 
 class Items extends \Magento\Wishlist\Block\AbstractBlock
 {
+    /**
+     * @var string
+     */
     protected $_template = 'email/items.phtml';
 
     /**
@@ -66,7 +69,7 @@ class Items extends \Magento\Wishlist\Block\AbstractBlock
     }
 
     /**
-     * Check whether whishlist item has description
+     * Check whether wishlist item has description
      *
      * @param \Magento\Wishlist\Model\Item $item
      * @return bool
diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Rss.php b/app/code/Magento/Wishlist/Block/Share/Email/Rss.php
index a2c2fbc622e0c895c8fd56e2da2b3c661b1c4b5e..c651c1a4d103b61d3259523fd0bea1d7ab8ffe24 100644
--- a/app/code/Magento/Wishlist/Block/Share/Email/Rss.php
+++ b/app/code/Magento/Wishlist/Block/Share/Email/Rss.php
@@ -36,6 +36,8 @@ namespace Magento\Wishlist\Block\Share\Email;
 
 class Rss extends \Magento\View\Element\Template
 {
-
+    /**
+     * @var string
+     */
     protected $_template = 'email/rss.phtml';
 }
diff --git a/app/code/Magento/Wishlist/Block/Share/Wishlist.php b/app/code/Magento/Wishlist/Block/Share/Wishlist.php
index c8a56f5337bcc85e3124b0f828e7ce80a8172c90..209c46c497333b8193aab9c62c86b3cd2336c060 100644
--- a/app/code/Magento/Wishlist/Block/Share/Wishlist.php
+++ b/app/code/Magento/Wishlist/Block/Share/Wishlist.php
@@ -109,7 +109,7 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock
     /**
      * Prepare global layout
      *
-     * @return \Magento\Wishlist\Block\Share\Wishlist
+     * @return $this
      *
      */
     protected function _prepareLayout()
diff --git a/app/code/Magento/Wishlist/Controller/AbstractController.php b/app/code/Magento/Wishlist/Controller/AbstractController.php
index 85a1e808b0e86f90dfea2e1c0bad23f5aca3ddfd..dd1f61fd3d19a4392c7e73abc3bf137be9598793 100644
--- a/app/code/Magento/Wishlist/Controller/AbstractController.php
+++ b/app/code/Magento/Wishlist/Controller/AbstractController.php
@@ -35,6 +35,7 @@ abstract class AbstractController extends \Magento\App\Action\Action
 {
     /**
      * Filter to convert localized values to internal ones
+     *
      * @var \Zend_Filter_LocalizedToNormalized
      */
     protected $_localFilter = null;
@@ -49,7 +50,7 @@ abstract class AbstractController extends \Magento\App\Action\Action
      * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator
      */
     public function __construct(
-        \Magento\App\Action\Context $context,
+        Context $context,
         \Magento\Core\App\Action\FormKeyValidator $formKeyValidator
     ) {
         $this->_formKeyValidator = $formKeyValidator;
@@ -85,6 +86,8 @@ abstract class AbstractController extends \Magento\App\Action\Action
 
     /**
      * Add all items from wishlist to shopping cart
+     *
+     * @return void
      */
     public function allcartAction()
     {
diff --git a/app/code/Magento/Wishlist/Controller/Index.php b/app/code/Magento/Wishlist/Controller/Index.php
index ff93087979029f54bcfec4ac2481976ef7c521e2..e5af21c4aaeb2024553b4b39cae39ebb3535a3d7 100644
--- a/app/code/Magento/Wishlist/Controller/Index.php
+++ b/app/code/Magento/Wishlist/Controller/Index.php
@@ -36,6 +36,7 @@ namespace Magento\Wishlist\Controller;
 
 use Magento\App\Action\NotFoundException;
 use Magento\App\RequestInterface;
+use Magento\App\ResponseInterface;
 
 class Index
     extends \Magento\Wishlist\Controller\AbstractController
@@ -87,7 +88,7 @@ class Index
 
     /**
      * @param RequestInterface $request
-     * @return \Magento\App\ResponseInterface
+     * @return ResponseInterface
      * @throws \Magento\App\Action\NotFoundException
      */
     public function dispatch(RequestInterface $request)
@@ -111,7 +112,7 @@ class Index
     /**
      * Set skipping authentication in actions of this controller (wishlist)
      *
-     * @return \Magento\Wishlist\Controller\Index
+     * @return $this
      */
     public function skipAuthentication()
     {
@@ -121,8 +122,9 @@ class Index
 
     /**
      * Retrieve wishlist object
+     *
      * @param int $wishlistId
-     * @return \Magento\Wishlist\Model\Wishlist|bool
+     * @return \Magento\Wishlist\Model\Wishlist|false
      */
     protected function _getWishlist($wishlistId = null)
     {
@@ -166,6 +168,7 @@ class Index
     /**
      * Display customer wishlist
      *
+     * @return void
      * @throws NotFoundException
      */
     public function indexAction()
@@ -193,6 +196,7 @@ class Index
     /**
      * Adding new item
      *
+     * @return void
      * @throws NotFoundException
      */
     public function addAction()
@@ -275,6 +279,7 @@ class Index
     /**
      * Action to reconfigure wishlist item
      *
+     * @return void
      * @throws NotFoundException
      */
     public function configureAction()
@@ -322,6 +327,8 @@ class Index
 
     /**
      * Action to accept new configuration for a wishlist item
+     *
+     * @return void
      */
     public function updateItemOptionsAction()
     {
@@ -379,6 +386,7 @@ class Index
     /**
      * Update wishlist item comments
      *
+     * @return ResponseInterface|void
      * @throws NotFoundException
      */
     public function updateAction()
@@ -467,6 +475,7 @@ class Index
     /**
      * Remove item
      *
+     * @return void
      * @throws NotFoundException
      */
     public function removeAction()
@@ -504,6 +513,8 @@ class Index
      *
      * If Product has required options - item removed from wishlist and redirect
      * to product view page with message about needed defined required options
+     *
+     * @return ResponseInterface
      */
     public function cartAction()
     {
@@ -554,6 +565,14 @@ class Index
             $cart->save()->getQuote()->collectTotals();
             $wishlist->save();
 
+            if (!$cart->getQuote()->getHasError()) {
+                $message = __(
+                    'You added %1 to your shopping cart.',
+                    $this->_objectManager->get('Magento\Escaper')->escapeHtml($item->getProduct()->getName())
+                );
+                $this->messageManager->addSuccess($message);
+            }
+
             $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate();
 
             if ($this->_objectManager->get('Magento\Checkout\Helper\Cart')->getShouldRedirectToCart()) {
@@ -584,6 +603,7 @@ class Index
     /**
      * Add cart item to wishlist and remove from cart
      *
+     * @return \Zend_Controller_Response_Abstract
      * @throws NotFoundException
      */
     public function fromcartAction()
@@ -634,6 +654,8 @@ class Index
 
     /**
      * Prepare wishlist for share
+     *
+     * @return void
      */
     public function shareAction()
     {
@@ -646,7 +668,7 @@ class Index
     /**
      * Share wishlist
      *
-     * @return \Magento\App\Action\Action|void
+     * @return ResponseInterface|void
      * @throws NotFoundException
      */
     public function sendAction()
@@ -767,6 +789,7 @@ class Index
 
     /**
      * Custom options download action
+     *
      * @return void
      */
     public function downloadCustomOptionAction()
diff --git a/app/code/Magento/Wishlist/Controller/Shared.php b/app/code/Magento/Wishlist/Controller/Shared.php
index 21bc8520a235ffae9fc0af727857725ee97e7ac6..526d59f1cef61130aece079729e0bbd1bcb137aa 100644
--- a/app/code/Magento/Wishlist/Controller/Shared.php
+++ b/app/code/Magento/Wishlist/Controller/Shared.php
@@ -34,7 +34,7 @@
  */
 namespace Magento\Wishlist\Controller;
 
-class Shared extends \Magento\Wishlist\Controller\AbstractController
+class Shared extends AbstractController
 {
     /**
      * Core registry
@@ -82,6 +82,7 @@ class Shared extends \Magento\Wishlist\Controller\AbstractController
     /**
      * Shared wishlist view page
      *
+     * @return void
      */
     public function indexAction()
     {
@@ -108,6 +109,7 @@ class Shared extends \Magento\Wishlist\Controller\AbstractController
      * If Product has required options - redirect
      * to product view page with message about needed defined required options
      *
+     * @return \Zend_Controller_Response_Abstract
      */
     public function cartAction()
     {
diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php
index 1038fa3166746f9e0ddd6ee430cee21e661df7ea..7fefcdb24aab2e453b25916b7ef0cc8e1f0b38ec 100644
--- a/app/code/Magento/Wishlist/Helper/Data.php
+++ b/app/code/Magento/Wishlist/Helper/Data.php
@@ -169,6 +169,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * Set current customer
      *
      * @param \Magento\Customer\Model\Customer $customer
+     * @return void
      */
     public function setCustomer(\Magento\Customer\Model\Customer $customer)
     {
@@ -312,7 +313,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      *
      * @param \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
      * @param array $params
-     * @return array
+     * @return string
      */
     public function getAddParams($item, array $params = array())
     {
@@ -351,7 +352,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      *
      * @param \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
      *
-     * @return  string|bool
+     * @return  string|false
      */
     public function getUpdateParams($item)
     {
@@ -378,7 +379,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     }
 
     /**
-     * Retrieve URL for adding item to shoping cart
+     * Retrieve URL for adding item to shopping cart
      *
      * @param string|\Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
      * @return  string
@@ -464,7 +465,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Retrieve customer name
      *
-     * @return string|null
+     * @return string|void
      */
     public function getCustomerName()
     {
@@ -477,7 +478,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
     /**
      * Retrieve RSS URL
      *
-     * @param $wishlistId
+     * @param int|string|null $wishlistId
      * @return string
      */
     public function getRssUrl($wishlistId = null)
@@ -534,7 +535,7 @@ class Data extends \Magento\App\Helper\AbstractHelper
      * Method called after wishlist modifications and trigger 'wishlist_items_renewed' event.
      * Depends from configuration.
      *
-     * @return \Magento\Wishlist\Helper\Data
+     * @return $this
      */
     public function calculate()
     {
diff --git a/app/code/Magento/Wishlist/Model/Config/Source/Summary.php b/app/code/Magento/Wishlist/Model/Config/Source/Summary.php
index 175514b3a878a1b8f634e0c63dbcaff067867f89..fa16c6f720b4891926cc2f14324bfa0a5d10213e 100644
--- a/app/code/Magento/Wishlist/Model/Config/Source/Summary.php
+++ b/app/code/Magento/Wishlist/Model/Config/Source/Summary.php
@@ -27,6 +27,9 @@ namespace Magento\Wishlist\Model\Config\Source;
 
 class Summary implements \Magento\Core\Model\Option\ArrayInterface
 {
+    /**
+     * @return array
+     */
     public function toOptionArray()
     {
         return array(
diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php
index dd5e0bcb807c3d0b380ee523e2def232210ff5f0..647da8fda575425ea55c0e3f5efaa0dd9fb749ac 100644
--- a/app/code/Magento/Wishlist/Model/Item.php
+++ b/app/code/Magento/Wishlist/Model/Item.php
@@ -46,6 +46,10 @@
  */
 namespace Magento\Wishlist\Model;
 
+use Magento\Wishlist\Model\Item\Option;
+use Magento\Wishlist\Model\Item\OptionFactory;
+use Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory;
+
 class Item extends \Magento\Core\Model\AbstractModel
     implements \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
 {
@@ -77,7 +81,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Item options array
      *
-     * @var array
+     * @var Option[]
      */
     protected $_options             = array();
 
@@ -91,13 +95,14 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Not Represent options
      *
-     * @var array
+     * @var string[]
      */
     protected $_notRepresentOptions = array('info_buyRequest');
 
     /**
      * Flag stating that options were successfully saved
      *
+     * @var bool|null
      */
     protected $_flagOptionsSaved = null;
 
@@ -122,12 +127,12 @@ class Item extends \Magento\Core\Model\AbstractModel
     protected $_catalogUrl;
 
     /**
-     * @var \Magento\Wishlist\Model\Item\OptionFactory
+     * @var OptionFactory
      */
     protected $_wishlistOptFactory;
 
     /**
-     * @var \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory
+     * @var CollectionFactory
      */
     protected $_wishlOptionCollectionFactory;
 
@@ -143,8 +148,8 @@ class Item extends \Magento\Core\Model\AbstractModel
      * @param \Magento\Core\Model\Date $date
      * @param \Magento\Catalog\Model\ProductFactory $productFactory
      * @param \Magento\Catalog\Model\Resource\Url $catalogUrl
-     * @param Item\OptionFactory $wishlistOptFactory
-     * @param Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory
+     * @param OptionFactory $wishlistOptFactory
+     * @param CollectionFactory $wishlOptionCollectionFactory
      * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
@@ -157,8 +162,8 @@ class Item extends \Magento\Core\Model\AbstractModel
         \Magento\Core\Model\Date $date,
         \Magento\Catalog\Model\ProductFactory $productFactory,
         \Magento\Catalog\Model\Resource\Url $catalogUrl,
-        \Magento\Wishlist\Model\Item\OptionFactory $wishlistOptFactory,
-        \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory,
+        OptionFactory $wishlistOptFactory,
+        CollectionFactory $wishlOptionCollectionFactory,
         \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
@@ -177,6 +182,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize resource model
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -187,7 +193,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Set quantity. If quantity is less than 0 - set it to 1
      *
      * @param int $qty
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     public function setQty($qty)
     {
@@ -229,8 +235,8 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Register option code
      *
-     * @param   \Magento\Wishlist\Model\Item\Option $option
-     * @return  \Magento\Wishlist\Model\Item
+     * @param   Option $option
+     * @return  $this
      * @throws \Magento\Core\Exception
      */
     protected function _addOptionCode($option)
@@ -261,7 +267,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Save item options
      *
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     protected function _saveItemOptions()
     {
@@ -283,6 +289,8 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Save model plus its options
      * Ensures saving options in case when resource model was not changed
+     *
+     * @return void
      */
     public function save()
     {
@@ -299,7 +307,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Save item options after item saved
      *
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -328,7 +336,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Check required data
      *
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -357,7 +365,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * @param int $wishlistId
      * @param int $productId
      * @param array $sharedStores
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     public function loadByProductWishlist($wishlistId, $productId, $sharedStores)
     {
@@ -403,10 +411,10 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Return true if product was successful added or exception with code
      * Return false for disabled or unvisible products
      *
-     * @throws \Magento\Core\Exception
      * @param \Magento\Checkout\Model\Cart $cart
      * @param bool $delete  delete the item after successful add to cart
      * @return bool
+     * @throws \Magento\Core\Exception
      */
     public function addToCart(\Magento\Checkout\Model\Cart $cart, $delete = false)
     {
@@ -496,7 +504,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Merge data to item info_buyRequest option
      *
      * @param array|\Magento\Object $buyRequest
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     public function mergeBuyRequest($buyRequest)
     {
@@ -529,7 +537,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Set buy request - object, holding request received from
      * product view page with keys and options for configured product
      * @param \Magento\Object $buyRequest
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     public function setBuyRequest($buyRequest)
     {
@@ -593,10 +601,10 @@ class Item extends \Magento\Core\Model\AbstractModel
         $itemOptions    = $this->getOptionsByCode();
         $productOptions = $product->getCustomOptions();
 
-        if(!$this->compareOptions($itemOptions, $productOptions)){
+        if (!$this->compareOptions($itemOptions, $productOptions)) {
             return false;
         }
-        if(!$this->compareOptions($productOptions, $itemOptions)){
+        if (!$this->compareOptions($productOptions, $itemOptions)) {
             return false;
         }
         return true;
@@ -632,7 +640,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Initialize item options
      *
      * @param   array $options
-     * @return  \Magento\Wishlist\Model\Item
+     * @return  $this
      */
     public function setOptions($options)
     {
@@ -645,7 +653,7 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Get all item options
      *
-     * @return array
+     * @return Option[]
      */
     public function getOptions()
     {
@@ -665,8 +673,8 @@ class Item extends \Magento\Core\Model\AbstractModel
     /**
      * Add option to item
      *
-     * @param   \Magento\Wishlist\Model\Item\Option $option
-     * @return  \Magento\Wishlist\Model\Item
+     * @param   Option|\Magento\Object|array $option
+     * @return  $this
      * @throws \Magento\Core\Exception
      */
     public function addOption($option)
@@ -674,7 +682,7 @@ class Item extends \Magento\Core\Model\AbstractModel
         if (is_array($option)) {
             $option = $this->_wishlistOptFactory->create()->setData($option)
                 ->setItem($this);
-        } else if ($option instanceof \Magento\Wishlist\Model\Item\Option) {
+        } else if ($option instanceof Option) {
             $option->setItem($this);
         } else if ($option instanceof \Magento\Object) {
             $option = $this->_wishlistOptFactory->create()->setData($option->getData())
@@ -698,7 +706,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      *Remove option from item options
      *
      * @param string $code
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     public function removeOption($code)
     {
@@ -713,7 +721,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * Get item option by code
      *
      * @param   string $code
-     * @return  \Magento\Wishlist\Model\Item\Option || null
+     * @return  Option|null
      */
     public function getOptionByCode($code)
     {
@@ -736,6 +744,8 @@ class Item extends \Magento\Core\Model\AbstractModel
 
     /**
      * Get current custom option download url
+     *
+     * @return string
      */
     public function getCustomDownloadUrl()
     {
@@ -744,6 +754,9 @@ class Item extends \Magento\Core\Model\AbstractModel
 
     /**
      * Sets custom option download url
+     *
+     * @param string $url
+     * @return void
      */
     public function setCustomDownloadUrl($url)
     {
@@ -773,7 +786,7 @@ class Item extends \Magento\Core\Model\AbstractModel
      * @param int $id
      * @param null|string|array $optionsFilter
      *
-     * @return \Magento\Wishlist\Model\Item
+     * @return $this
      */
     public function loadWithOptions($id, $optionsFilter = null)
     {
diff --git a/app/code/Magento/Wishlist/Model/Item/Option.php b/app/code/Magento/Wishlist/Model/Item/Option.php
index 7f86ac25ce3a4ee7e00697680b3bb3ed7c47482b..8f9355c29683ba2235a4621ffe1241ec0c55fd54 100644
--- a/app/code/Magento/Wishlist/Model/Item/Option.php
+++ b/app/code/Magento/Wishlist/Model/Item/Option.php
@@ -33,14 +33,26 @@
  */
 namespace Magento\Wishlist\Model\Item;
 
+use Magento\Catalog\Model\Product;
+use Magento\Wishlist\Model\Item;
+
 class Option extends \Magento\Core\Model\AbstractModel
     implements \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface
 {
+    /**
+     * @var Item
+     */
     protected $_item;
+
+    /**
+     * @var Product
+     */
     protected $_product;
 
     /**
      * Initialize resource model
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -64,8 +76,8 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Set quote item
      *
-     * @param   \Magento\Wishlist\Model\Item $item
-     * @return  \Magento\Wishlist\Model\Item\Option
+     * @param   Item $item
+     * @return  $this
      */
     public function setItem($item)
     {
@@ -77,7 +89,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Get option item
      *
-     * @return \Magento\Wishlist\Model\Item
+     * @return Item
      */
     public function getItem()
     {
@@ -87,8 +99,8 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Set option product
      *
-     * @param   \Magento\Catalog\Model\Product $product
-     * @return  \Magento\Wishlist\Model\Item\Option
+     * @param   Product $product
+     * @return  $this
      */
     public function setProduct($product)
     {
@@ -100,7 +112,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Get option product
      *
-     * @return \Magento\Catalog\Model\Product
+     * @return Product
      */
     public function getProduct()
     {
@@ -120,7 +132,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Initialize item identifier before save data
      *
-     * @return \Magento\Wishlist\Model\Item\Option
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -133,7 +145,7 @@ class Option extends \Magento\Core\Model\AbstractModel
     /**
      * Clone option object
      *
-     * @return \Magento\Wishlist\Model\Item\Option
+     * @return $this
      */
     public function __clone()
     {
diff --git a/app/code/Magento/Wishlist/Model/Observer.php b/app/code/Magento/Wishlist/Model/Observer.php
index c28cd06cef29630320027a5ea4451448425bff32..8a7048eb1f74b6e654aa8a94530326dea86af29e 100644
--- a/app/code/Magento/Wishlist/Model/Observer.php
+++ b/app/code/Magento/Wishlist/Model/Observer.php
@@ -51,7 +51,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
     protected $_customerSession;
 
     /**
-     * @var \Magento\Wishlist\Model\WishlistFactory
+     * @var WishlistFactory
      */
     protected $_wishlistFactory;
 
@@ -66,7 +66,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
      * @param \Magento\Wishlist\Helper\Data $wishlistData
      * @param \Magento\Checkout\Model\Session $checkoutSession
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory
+     * @param WishlistFactory $wishlistFactory
      * @param \Magento\Message\ManagerInterface $messageManager
      * @param \Magento\Core\Model\Resource\AbstractResource $resource
      * @param \Magento\Data\Collection\Db $resourceCollection
@@ -78,7 +78,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
         \Magento\Wishlist\Helper\Data $wishlistData,
         \Magento\Checkout\Model\Session $checkoutSession,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Wishlist\Model\WishlistFactory $wishlistFactory,
+        WishlistFactory $wishlistFactory,
         \Magento\Message\ManagerInterface $messageManager,
         \Magento\Core\Model\Resource\AbstractResource $resource = null,
         \Magento\Data\Collection\Db $resourceCollection = null,
@@ -96,7 +96,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
      * Get customer wishlist model instance
      *
      * @param   int $customerId
-     * @return  \Magento\Wishlist\Model\Wishlist || false
+     * @return  Wishlist|false
      */
     protected function _getWishlist($customerId)
     {
@@ -110,7 +110,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
      * Check move quote item to wishlist request
      *
      * @param   \Magento\Event\Observer $observer
-     * @return  \Magento\Wishlist\Model\Observer
+     * @return  $this
      */
     public function processCartUpdateBefore($observer)
     {
@@ -150,6 +150,10 @@ class Observer extends \Magento\Core\Model\AbstractModel
         return $this;
     }
 
+    /**
+     * @param \Magento\Event\Observer $observer
+     * @return void
+     */
     public function processAddToCart($observer)
     {
         $request = $observer->getEvent()->getRequest();
@@ -204,7 +208,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
      * Customer login processing
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Wishlist\Model\Observer
+     * @return $this
      */
     public function customerLogin(\Magento\Event\Observer $observer)
     {
@@ -217,7 +221,7 @@ class Observer extends \Magento\Core\Model\AbstractModel
      * Customer logout processing
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Wishlist\Model\Observer
+     * @return $this
      */
     public function customerLogout(\Magento\Event\Observer $observer)
     {
diff --git a/app/code/Magento/Wishlist/Model/Resource/Item.php b/app/code/Magento/Wishlist/Model/Resource/Item.php
index 9d736e64c2b8a3de697a5a7d2a24036066c145f5..0ed61587bb73e0a69182979c3c3d1f5984068fcb 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Item.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Item.php
@@ -39,6 +39,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Initialize connection and define main table
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -52,7 +53,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb
      * @param int $wishlistId
      * @param int $productId
      * @param array $sharedStores
-     * @return \Magento\Wishlist\Model\Resource\Item
+     * @return $this
      */
     public function loadByProductWishlist($object, $wishlistId, $productId, $sharedStores)
     {
diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php
index 218f7d8f5161906019c3c11387d4d6eb21255ac4..3bbe9caac5dfb889e9dae0ddb5ac0647cddb01b3 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php
@@ -72,7 +72,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     protected $_storeIds = array();
 
     /**
-     * Add days in whishlist filter of product collection
+     * Add days in wishlist filter of product collection
      *
      * @var boolean
      */
@@ -174,7 +174,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * @param \Magento\Catalog\Model\Entity\AttributeFactory $catalogAttrFactory
      * @param \Magento\Wishlist\Model\Resource\Item $resource
      * @param \Magento\App\State $appState
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * 
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -227,7 +227,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * After load processing
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -248,7 +248,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add options to items
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     protected function _assignOptions()
     {
@@ -270,7 +270,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add products to items and item options
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     protected function _assignProducts()
     {
@@ -345,7 +345,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by wishlist object
      *
      * @param \Magento\Wishlist\Model\Wishlist $wishlist
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addWishlistFilter(\Magento\Wishlist\Model\Wishlist $wishlist)
     {
@@ -357,7 +357,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filtration by customer id
      *
      * @param int $customerId
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addCustomerIdFilter($customerId)
     {
@@ -375,8 +375,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Add filter by shared stores
      *
      * @param array $storeIds
-     *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addStoreFilter($storeIds = array())
     {
@@ -392,7 +391,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Add items store data to collection
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addStoreData()
     {
@@ -407,7 +406,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Reset sort order
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function resetSortOrder()
     {
@@ -419,7 +418,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Set product Visibility Filter to product collection flag
      *
      * @param bool $flag
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function setVisibilityFilter($flag = true)
     {
@@ -432,7 +431,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * This filter apply Salable Product Types Filter to product collection.
      *
      * @param bool $flag
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function setSalableFilter($flag = true)
     {
@@ -445,7 +444,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * This filter remove items with no salable product.
      *
      * @param bool $flag
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function setInStockFilter($flag = true)
     {
@@ -456,7 +455,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Set flag of adding days in wishlist
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addDaysInWishlist()
     {
@@ -467,10 +466,10 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Adds filter on days in wishlist
      *
-     * $constraints may contain 'from' and 'to' indexes with number of days to look for items
+     * The $constraints may contain 'from' and 'to' indexes with number of days to look for items
      *
      * @param array $constraints
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addDaysFilter($constraints)
     {
@@ -507,7 +506,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Joins product name attribute value to use it in WHERE and ORDER clauses
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     protected function _joinProductNameTable()
     {
@@ -538,7 +537,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Adds filter on product name
      *
      * @param string $productName
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function addProductNameFilter($productName)
     {
@@ -553,7 +552,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Sets ordering by product name
      *
      * @param string $dir
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection
+     * @return $this
      */
     public function setOrderByProductName($dir)
     {
@@ -581,7 +580,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     }
 
     /**
-     * @return \Magento\Wishlist\Model\Resource\Item\Collection|\Magento\Data\Collection\Db
+     * @return $this
      */
     protected function _afterLoadData()
     {
diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php
index 6452dba2f732042b050c9a65e9b3b7fae245f150..2b5aadc4cad635c89ef0d67cef43296369a88a7b 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php
@@ -55,7 +55,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection
      * @param \Magento\Wishlist\Model\Resource\Item $resource
      * @param \Magento\App\State $appState
      * @param \Magento\Core\Model\Registry $registry
-     * @param mixed $connection
+     * @param \Zend_Db_Adapter_Abstract $connection
      * 
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -106,7 +106,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection
     /**
      * Initialize db select
      *
-     * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
+     * @return $this
      */
     protected function _initSelect()
     {
@@ -141,10 +141,9 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection
     /**
      * Add field filter to collection
      *
-     * @see self::_getConditionSql for $condition
-     *
      * @param string|array $field
      * @param null|string|array $condition
+     * @see self::_getConditionSql for $condition
      * @return \Magento\Data\Collection\Db
      */
     public function addFieldToFilter($field, $condition = null)
diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Option.php b/app/code/Magento/Wishlist/Model/Resource/Item/Option.php
index e3db1e7f534abb3b62bf0bcdf883b1cc27c03b8f..84147c9728649e6fe64827ad5e17fbe4eb2e4444 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Item/Option.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Item/Option.php
@@ -35,6 +35,9 @@ namespace Magento\Wishlist\Model\Resource\Item;
 
 class Option extends \Magento\Core\Model\Resource\Db\AbstractDb
 {
+    /**
+     * @return void
+     */
     protected function _construct()
     {
         $this->_init('wishlist_item_option', 'option_id');
diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php
index 2f401f192545e52fdd0b67b6d59eecb605791ed0..74503ae1746e5dd6b62d0c355bdee762b6a3c5d2 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Item/Option/Collection.php
@@ -34,6 +34,9 @@
  */
 namespace Magento\Wishlist\Model\Resource\Item\Option;
 
+use Magento\Catalog\Model\Product;
+use Magento\Wishlist\Model\Item;
+
 class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection
 {
     /**
@@ -63,7 +66,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Fill array of options by item and product
      *
-     * @return \Magento\Wishlist\Model\Resource\Item\Option\Collection
+     * @return $this
      */
     protected function _afterLoad()
     {
@@ -91,8 +94,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Apply quote item(s) filter to collection
      *
-     * @param  int|array $item
-     * @return \Magento\Wishlist\Model\Resource\Item\Option\Collection
+     * @param  int|array|Item $item
+     * @return $this
      */
     public function addItemFilter($item)
     {
@@ -101,7 +104,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
             $this->_setIsLoaded(true);
         } else if (is_array($item)) {
             $this->addFieldToFilter('wishlist_item_id', array('in' => $item));
-        } else if ($item instanceof \Magento\Wishlist\Model\Item) {
+        } else if ($item instanceof Item) {
             $this->addFieldToFilter('wishlist_item_id', $item->getId());
         } else {
             $this->addFieldToFilter('wishlist_item_id', $item);
@@ -125,12 +128,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Get all option for item
      *
-     * @param  mixed $item
+     * @param Item|int|string $item
      * @return array
      */
     public function getOptionsByItem($item)
     {
-        if ($item instanceof \Magento\Wishlist\Model\Item) {
+        if ($item instanceof Item) {
             $itemId = $item->getId();
         } else {
             $itemId = $item;
@@ -151,12 +154,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Get all option for item
      *
-     * @param  mixed $item
+     * @param  Product|int|string $product
      * @return array
      */
     public function getOptionsByProduct($product)
     {
-        if ($product instanceof \Magento\Catalog\Model\Product) {
+        if ($product instanceof Product) {
             $productId = $product->getId();
         } else {
             $productId = $product;
diff --git a/app/code/Magento/Wishlist/Model/Resource/Wishlist.php b/app/code/Magento/Wishlist/Model/Resource/Wishlist.php
index cd9f937a03f6fa17cf482b0f468b2ff504823d1b..78c937e2032f81c1da6f6ad15aeb478b2d30a547 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Wishlist.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Wishlist.php
@@ -52,6 +52,8 @@ class Wishlist extends \Magento\Core\Model\Resource\Db\AbstractDb
 
     /**
      * Set main entity table name and primary key field name
+     *
+     * @return void
      */
     protected function _construct()
     {
@@ -63,7 +65,7 @@ class Wishlist extends \Magento\Core\Model\Resource\Db\AbstractDb
      *
      * @param string $field
      * @param mixed $value
-     * @param mixed $object
+     * @param \Magento\Core\Model\AbstractModel $object
      * @return \Zend_Db_Select
      */
     protected function _getLoadSelect($field, $value, $object)
@@ -89,9 +91,8 @@ class Wishlist extends \Magento\Core\Model\Resource\Db\AbstractDb
     /**
      * Setter for customer ID field name
      *
-     * @param $fieldName
-     *
-     * @return \Magento\Wishlist\Model\Resource\Wishlist
+     * @param string $fieldName
+     * @return $this
      */
     public function setCustomerIdFieldName($fieldName)
     {
diff --git a/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php
index 9d37907d5bc20fe606ee11fbaa4666db6127cc9e..f766a82d82735fe7422fa0c57e944bdd06f466a4 100644
--- a/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php
+++ b/app/code/Magento/Wishlist/Model/Resource/Wishlist/Collection.php
@@ -26,7 +26,7 @@
 
 
 /**
- * Wislist model collection
+ * Wishlist model collection
  *
  * @category    Magento
  * @package     Magento_Wishlist
@@ -39,6 +39,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
     /**
      * Initialize resource
      *
+     * @return void
      */
     protected function _construct()
     {
@@ -49,7 +50,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter collection by customer
      *
      * @param \Magento\Customer\Model\Customer $customer
-     * @return \Magento\Wishlist\Model\Resource\Wishlist\Collection
+     * @return $this
      */
     public function filterByCustomer(\Magento\Customer\Model\Customer $customer)
     {
@@ -60,7 +61,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter collection by customer id
      *
      * @param int $customerId
-     * @return \Magento\Wishlist\Model\Resource\Wishlist\Collection
+     * @return $this
      */
     public function filterByCustomerId($customerId)
     {
@@ -72,7 +73,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl
      * Filter collection by customer ids
      *
      * @param array $customerIds
-     * @return \Magento\Wishlist\Model\Resource\Wishlist\Collection
+     * @return $this
      */
     public function filterByCustomerIds(array $customerIds)
     {
diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php
index 56ae6b995f0699916a844e7a8dc4cb3fd3ec975f..d534ef50c5305a326c70f5fd463d1172fa17b86b 100644
--- a/app/code/Magento/Wishlist/Model/Wishlist.php
+++ b/app/code/Magento/Wishlist/Model/Wishlist.php
@@ -26,6 +26,12 @@
 
 namespace Magento\Wishlist\Model;
 
+use Magento\Core\Exception;
+use Magento\Customer\Model\Customer;
+use Magento\Wishlist\Model\Resource\Item\CollectionFactory;
+use Magento\Wishlist\Model\Resource\Wishlist as ResourceWishlist;
+use Magento\Wishlist\Model\Resource\Wishlist\Collection;
+
 /**
  * Wishlist model
  *
@@ -92,12 +98,12 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     protected $_date;
 
     /**
-     * @var \Magento\Wishlist\Model\ItemFactory
+     * @var ItemFactory
      */
     protected $_wishlistItemFactory;
 
     /**
-     * @var \Magento\Wishlist\Model\Resource\Item\CollectionFactory
+     * @var CollectionFactory
      */
     protected $_wishlistCollectionFactory;
 
@@ -126,12 +132,12 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * @param \Magento\Core\Model\Registry $registry
      * @param \Magento\Catalog\Helper\Product $catalogProduct
      * @param \Magento\Wishlist\Helper\Data $wishlistData
-     * @param Resource\Wishlist $resource
-     * @param Resource\Wishlist\Collection $resourceCollection
+     * @param ResourceWishlist $resource
+     * @param Collection $resourceCollection
      * @param \Magento\Core\Model\StoreManagerInterface $storeManager
      * @param \Magento\Core\Model\Date $date
      * @param ItemFactory $wishlistItemFactory
-     * @param Resource\Item\CollectionFactory $wishlistCollectionFactory
+     * @param CollectionFactory $wishlistCollectionFactory
      * @param \Magento\Catalog\Model\ProductFactory $productFactory
      * @param \Magento\Math\Random $mathRandom
      * @param \Magento\Stdlib\DateTime $dateTime
@@ -143,12 +149,12 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
         \Magento\Core\Model\Registry $registry,
         \Magento\Catalog\Helper\Product $catalogProduct,
         \Magento\Wishlist\Helper\Data $wishlistData,
-        \Magento\Wishlist\Model\Resource\Wishlist $resource,
-        \Magento\Wishlist\Model\Resource\Wishlist\Collection $resourceCollection,
+        ResourceWishlist $resource,
+        Collection $resourceCollection,
         \Magento\Core\Model\StoreManagerInterface $storeManager,
         \Magento\Core\Model\Date $date,
-        \Magento\Wishlist\Model\ItemFactory $wishlistItemFactory,
-        \Magento\Wishlist\Model\Resource\Item\CollectionFactory $wishlistCollectionFactory,
+        ItemFactory $wishlistItemFactory,
+        CollectionFactory $wishlistCollectionFactory,
         \Magento\Catalog\Model\ProductFactory $productFactory,
         \Magento\Math\Random $mathRandom,
         \Magento\Stdlib\DateTime $dateTime,
@@ -171,13 +177,13 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Load wishlist by customer
      *
-     * @param mixed $customer
+     * @param Customer|int $customer
      * @param bool $create Create wishlist if don't exists
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function loadByCustomer($customer, $create = false)
     {
-        if ($customer instanceof \Magento\Customer\Model\Customer) {
+        if ($customer instanceof Customer) {
             $customer = $customer->getId();
         }
 
@@ -210,7 +216,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Set random sharing code
      *
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function generateSharingCode()
     {
@@ -222,7 +228,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * Load by sharing code
      *
      * @param string $code
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function loadByCode($code)
     {
@@ -247,7 +253,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Set date of last update for wishlist
      *
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     protected function _beforeSave()
     {
@@ -259,7 +265,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Save related items
      *
-     * @return \Magento\Sales\Model\Quote
+     * @return $this
      */
     protected function _afterSave()
     {
@@ -278,7 +284,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * @param   int $qty
      * @param   bool $forciblySetQty
      *
-     * @return  \Magento\Wishlist\Model\Item
+     * @return  Item
      */
     protected function _addCatalogProduct(\Magento\Catalog\Model\Product $product, $qty = 1, $forciblySetQty = false)
     {
@@ -336,7 +342,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * Retrieve wishlist item collection
      *
      * @param int $itemId
-     * @return \Magento\Wishlist\Model\Item
+     * @return false|Item
      */
     public function getItem($itemId)
     {
@@ -349,10 +355,10 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Adding item to wishlist
      *
-     * @param   \Magento\Wishlist\Model\Item $item
-     * @return  \Magento\Wishlist\Model\Wishlist
+     * @param   Item $item
+     * @return  $this
      */
-    public function addItem(\Magento\Wishlist\Model\Item $item)
+    public function addItem(Item $item)
     {
         $item->setWishlist($this);
         if (!$item->getId()) {
@@ -367,9 +373,9 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * Returns new item or string on error.
      *
      * @param int|\Magento\Catalog\Model\Product $product
-     * @param mixed $buyRequest
+     * @param \Magento\Object|array|string|null $buyRequest
      * @param bool $forciblySetQty
-     * @return \Magento\Wishlist\Model\Item|string
+     * @return Item|string
      */
     public function addNewItem($product, $buyRequest = null, $forciblySetQty = false)
     {
@@ -451,7 +457,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * Set customer id
      *
      * @param int $customerId
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function setCustomerId($customerId)
     {
@@ -508,7 +514,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * Set shared store ids
      *
      * @param array $storeIds
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function setSharedStoreIds($storeIds)
     {
@@ -533,7 +539,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      * Set wishlist store
      *
      * @param \Magento\Core\Model\Store $store
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function setStore($store)
     {
@@ -581,7 +587,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Update wishlist Item and set data from request
      *
-     * $params sets how current item configuration must be taken into account and additional options.
+     * The $params sets how current item configuration must be taken into account and additional options.
      * It's passed to \Magento\Catalog\Helper\Product->addParamsToBuyRequest() to compose resulting buyRequest.
      *
      * Basically it can hold
@@ -592,23 +598,24 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
      *
      * For more options see \Magento\Catalog\Helper\Product->addParamsToBuyRequest()
      *
-     * @param int|\Magento\Wishlist\Model\Item $itemId
+     * @param int|Item $itemId
      * @param \Magento\Object $buyRequest
      * @param null|array|\Magento\Object $params
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
+     * @throws Exception
      *
      * @see \Magento\Catalog\Helper\Product::addParamsToBuyRequest()
      */
     public function updateItem($itemId, $buyRequest, $params = null)
     {
         $item = null;
-        if ($itemId instanceof \Magento\Wishlist\Model\Item) {
+        if ($itemId instanceof Item) {
             $item = $itemId;
         } else {
             $item = $this->getItem((int)$itemId);
         }
         if (!$item) {
-            throw new \Magento\Core\Exception(__('We can\'t specify a wish list item.'));
+            throw new Exception(__('We can\'t specify a wish list item.'));
         }
 
         $product = $item->getProduct();
@@ -626,7 +633,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
             $items = $this->getItemCollection();
             $isForceSetQuantity = true;
             foreach ($items as $_item) {
-                /* @var $_item \Magento\Wishlist\Model\Item */
+                /* @var $_item Item */
                 if ($_item->getProductId() == $product->getId()
                     && $_item->representProduct($product)
                     && $_item->getId() != $item->getId()) {
@@ -639,7 +646,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
              * Error message
              */
             if (is_string($resultItem)) {
-                throw new \Magento\Core\Exception(__($resultItem));
+                throw new Exception(__($resultItem));
             }
 
             if ($resultItem->getId() != $itemId) {
@@ -653,7 +660,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
                 $resultItem->setOrigData('qty', 0);
             }
         } else {
-            throw new \Magento\Core\Exception(__('The product does not exist.'));
+            throw new Exception(__('The product does not exist.'));
         }
         return $this;
     }
@@ -661,7 +668,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel
     /**
      * Save wishlist.
      *
-     * @return \Magento\Wishlist\Model\Wishlist
+     * @return $this
      */
     public function save()
     {
diff --git a/app/code/Magento/Wishlist/view/frontend/item/configure/addto.phtml b/app/code/Magento/Wishlist/view/frontend/item/configure/addto.phtml
index 7f0d79b0a735bd8b8c6227fe9f26e07011f84a81..df087aa314c4c0e3bbce04bfe6e472928010e203 100644
--- a/app/code/Magento/Wishlist/view/frontend/item/configure/addto.phtml
+++ b/app/code/Magento/Wishlist/view/frontend/item/configure/addto.phtml
@@ -40,7 +40,7 @@
 </div>
 <script type="text/javascript">
     head.js("<?php echo $this->getViewFileUrl('Magento_Wishlist::js/add-to-wishlist.js') ?>", function () {
-        jQuery('.product.info.main').addToWishlist(
+        jQuery('body').addToWishlist(
             <?php echo $this->helper('Magento\Core\Helper\Data')->jsonEncode(array('productType' => $_product->getTypeId()))?>
         );
     });
diff --git a/app/code/Magento/Wishlist/view/frontend/js/add-to-wishlist.js b/app/code/Magento/Wishlist/view/frontend/js/add-to-wishlist.js
index 17518edf38fe0b0ff862690e3a52d65998484d7d..8a8b20e7ee76c524d1878490e8181c7c94b8c575 100644
--- a/app/code/Magento/Wishlist/view/frontend/js/add-to-wishlist.js
+++ b/app/code/Magento/Wishlist/view/frontend/js/add-to-wishlist.js
@@ -27,7 +27,7 @@
             bundleInfo: '[id^=bundle-option-]',
             configurableInfo: '.super-attribute-select',
             groupedInfo: '#super-product-table input',
-            downloadableInfo: '.options-list input',
+            downloadableInfo: '#downloadable-links-list input',
             customOptionsInfo: '.product-custom-option'
         },
         _create: function () {
diff --git a/app/code/Magento/Wishlist/view/frontend/options_list.phtml b/app/code/Magento/Wishlist/view/frontend/options_list.phtml
index 655ec3729b91642b0d098dc4e64e6df0e7b18448..1818a1779f059188ecb4b0aa2b1422b4329e5d01 100644
--- a/app/code/Magento/Wishlist/view/frontend/options_list.phtml
+++ b/app/code/Magento/Wishlist/view/frontend/options_list.phtml
@@ -27,7 +27,7 @@
 
 <?php $options = $this->getOptionList(); ?>
 <?php if ($options): ?>
-<div class="truncated" data-mage-init="{truncateOptions:[]}">
+<div class="truncated" data-mage-init='{"truncateOptions":[]}'>
   <div class="truncated full value">
       <p><?php echo __('Options Details'); ?></p>
       <dl>
diff --git a/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml b/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml
index 0cd6a17a30de88f1a8574d036eaf708006fbcf86..1ea9a37f8d1ec36dfb8833e9ff4b1c1be927da5c 100644
--- a/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml
+++ b/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml
@@ -27,11 +27,6 @@
     <referenceBlock name="header.links">
         <block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-" cacheable="false"/>
         <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login" cacheable="false"/>
-        <block class="Magento\Customer\Block\Account\RegisterLink" after="authorization-link-login" name="register-link" cacheable="false">
-            <arguments>
-                <argument name="label" xsi:type="string">Register</argument>
-            </arguments>
-        </block>
     </referenceBlock>
     <move element="register-link" destination="header.links"/>
     <move element="top.links" destination="customer"/>
diff --git a/app/design/frontend/magento_plushe/less/lib/navigation.less b/app/design/frontend/magento_plushe/less/lib/navigation.less
index 986e821cf596ef949aa9cc128d67ae9d33e17dcd..a898840ecde10fbdb1abf6958bc0c73309d7538d 100644
--- a/app/design/frontend/magento_plushe/less/lib/navigation.less
+++ b/app/design/frontend/magento_plushe/less/lib/navigation.less
@@ -28,7 +28,7 @@
 //
 //  ```html
 //<div class="header"></div>
-//<nav class="navigation" data-role="navigation" data-mage-init="{ navigationMenu: { submenuContiniumEffect: false } }">
+//<nav class="navigation" data-role="navigation" data-mage-init='{ "navigationMenu": { "submenuContiniumEffect": false } }'>
 //    <ul>
 //        <li class="level0 nav-1 first level-top parent"><a href="http://m2.loc/index.php/ewr.html" class="level-top"><span> First level 1 </span></a>
 //            <div class="submenu">
@@ -814,4 +814,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 66111870dcb7a8ab3cc8cead550e298e7c256dfc..3aadf66b981fb0f33b6a891ed420b30a20db9880 100644
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -317,6 +317,12 @@
             </array>
         </param>
     </type>
+    <preference for="Magento\Mview\ConfigInterface" type="Magento\Mview\Config" />
+    <preference for="Magento\Mview\ViewInterface" type="Magento\Mview\View" />
+    <preference for="Magento\Mview\ProcessorInterface" type="Magento\Mview\Processor" />
+    <preference for="Magento\Mview\View\CollectionInterface" type="Magento\Mview\View\Collection" />
+    <preference for="Magento\Mview\View\SubscriptionInterface" type="Magento\Mview\View\Subscription" />
+    <preference for="Magento\Mview\View\ChangelogInterface" type="Magento\Mview\View\Changelog" />
     <type name="Magento\Mview\View">
         <param name="state">
             <instance type="Magento\Core\Model\Mview\View\State" shared="false"/>
@@ -325,4 +331,14 @@
             <instance type="Magento\Mview\View\Changelog" shared="false"/>
         </param>
     </type>
+    <type name="Magento\Mview\Config">
+        <param name="configData">
+            <instance type="Magento\Mview\Config\Data\Proxy"/>
+        </param>
+    </type>
+    <type name="Magento\Mview\Config\Data">
+        <param name="stateCollection">
+            <instance type="Magento\Mview\View\State\CollectionInterface" shared="false"/>
+        </param>
+    </type>
 </config>
diff --git a/dev/tests/integration/framework/bootstrap.php b/dev/tests/integration/framework/bootstrap.php
index 0663d27b189505dc8224c80d05e63d297938dd5d..f1143ee027a4a0f63c45049f30167ebc715f46f0 100644
--- a/dev/tests/integration/framework/bootstrap.php
+++ b/dev/tests/integration/framework/bootstrap.php
@@ -64,7 +64,7 @@ $bootstrap = new \Magento\TestFramework\Bootstrap(
     new \Magento\TestFramework\Bootstrap\Environment(),
     new \Magento\TestFramework\Bootstrap\DocBlock("$testsBaseDir/testsuite"),
     new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Profiler\Driver\Standard()),
-    new \Magento\Shell(),
+    new \Magento\Shell(new \Magento\OSInfo()),
     $testsTmpDir
 );
 $bootstrap->runBootstrap();
diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php
index 9390003424e6c9849fe560851b600998d6c9b257..92c2458327e20b839e417d8a057de17e8b6b07d9 100644
--- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php
+++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/BootstrapTest.php
@@ -102,7 +102,7 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase
             'Magento\TestFramework\Bootstrap\Memory', array('activateStatsDisplaying', 'activateLimitValidation'),
             array(), '', false
         );
-        $this->_shell = $this->getMock('Magento\Shell', array('execute'));
+        $this->_shell = $this->getMock('Magento\Shell', array('execute'), array(), '', false);
         $this->_object = new \Magento\TestFramework\Bootstrap(
             $this->_settings,
             $this->_envBootstrap,
diff --git a/dev/tests/integration/testsuite/Magento/App/FilesystemTest.php b/dev/tests/integration/testsuite/Magento/App/FilesystemTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..b5a3dc5ac97ed096bb33b565bf56602fda25a37b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/App/FilesystemTest.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Test for \Magento\App\Filesystem
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\App;
+
+use Magento\TestFramework\Helper\Bootstrap;
+
+/**
+ * Class FilesystemTest
+ * Test for Magento\App\Filesystem class
+ *
+ * @package Magento
+ */
+class FilesystemTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\App\Filesystem
+     */
+    protected $filesystem;
+
+    protected function setUp()
+    {
+        $this->filesystem = Bootstrap::getObjectManager()->create('Magento\App\Filesystem');
+    }
+
+    /**
+     * Test getPath returns right path
+     */
+    public function testGetPath()
+    {
+        $this->assertContains('design', $this->filesystem->getPath(\Magento\App\Filesystem::THEMES_DIR));
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Category/FlatTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Category/FlatTest.php
deleted file mode 100644
index cf7fe1b5c3cc2bb3c6aae0f7f7b536fda3b7a24d..0000000000000000000000000000000000000000
--- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Category/FlatTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Catalog
- * @subpackage  integration_tests
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-namespace Magento\Catalog\Helper\Category;
-
-class FlatTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Catalog\Helper\Category\Flat
-     */
-    protected $_helper;
-
-    protected function setUp()
-    {
-        $this->_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->get('Magento\Catalog\Helper\Category\Flat');
-    }
-
-    public function testIsEnabledDefault()
-    {
-        $this->assertFalse($this->_helper->isEnabled());
-        $this->assertFalse($this->_helper->isEnabled(true));
-    }
-
-    /**
-     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category 1
-     */
-    public function testIsEnabled()
-    {
-        $this->assertTrue($this->_helper->isEnabled());
-    }
-
-    public function testIsRebuilt()
-    {
-        $this->assertFalse($this->_helper->isRebuilt());
-    }
-
-    public function testIsBuilt()
-    {
-        $this->assertEquals($this->_helper->isBuilt(), $this->_helper->isEnabled(true));
-    }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php
index d1882e7714162b4ba4f04b90692be497b1c4262a..7eaa52cf4c098624b5d929833903c3888b0d4b9f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php
@@ -41,20 +41,6 @@ class CategoryTest extends \PHPUnit_Framework_TestCase
      */
     protected static $_objectManager;
 
-    /**
-     * Default flat category indexer mode
-     *
-     * @var string
-     */
-    protected static $_indexerMode;
-
-    /**
-     * List of index tables to create/delete
-     *
-     * @var array
-     */
-    protected static $_indexerTables = array();
-
     /**
      * @var \Magento\Core\Model\Store
      */
@@ -72,76 +58,11 @@ class CategoryTest extends \PHPUnit_Framework_TestCase
         if (\Magento\TestFramework\Helper\Bootstrap::getInstance()->getDbVendorName() != 'mysql') {
             self::markTestIncomplete('Bug MAGETWO-8513');
         }
-
-        // get list of not existing tables
-        /** @var $storeManager \Magento\Core\Model\StoreManagerInterface */
-        $storeManager  = self::$_objectManager->get('Magento\Core\Model\StoreManagerInterface');
-        /** @var $categoryResource \Magento\Catalog\Model\Resource\Category\Flat */
-        $categoryResource = self::$_objectManager->create('Magento\Catalog\Model\Resource\Category\Flat');
-        /** @var $setupModel \Magento\Core\Model\Resource\Setup */
-        $setupModel = self::$_objectManager->create('Magento\Core\Model\Resource\Setup',
-            array(
-                'resourceName' => \Magento\Core\Model\Resource\Setup::DEFAULT_SETUP_CONNECTION,
-                'moduleName' => 'Magento_Core',
-            )
-        );
-        $stores = $storeManager->getStores();
-        /** @var $store \Magento\Core\Model\Store */
-        foreach ($stores as $store) {
-            $tableName = $categoryResource->getMainStoreTable($store->getId());
-            if (!$setupModel->getConnection()->isTableExists($tableName)) {
-                self::$_indexerTables[] = $tableName;
-            }
-        }
-
-        // create flat tables
-        /** @var $indexer \Magento\Catalog\Model\Category\Indexer\Flat */
-        $indexer = self::$_objectManager->create('Magento\Catalog\Model\Category\Indexer\Flat');
-        $indexer->reindexAll();
-
-        // set real time indexer mode
-        $process = self::_getCategoryIndexerProcess();
-        self::$_indexerMode = $process->getMode();
-        $process->setMode(\Magento\Index\Model\Process::MODE_REAL_TIME);
-        $process->save();
     }
 
     public static function tearDownAfterClass()
     {
-        // revert default indexer mode
-        $process = self::_getCategoryIndexerProcess();
-        $process->setMode(self::$_indexerMode);
-        $process->save();
-
-        // remove flat tables
-        /** @var $setupModel \Magento\Core\Model\Resource\Setup */
-        $setupModel = self::$_objectManager->create('Magento\Core\Model\Resource\Setup',
-            array(
-                'resourceName' => \Magento\Core\Model\Resource\Setup::DEFAULT_SETUP_CONNECTION,
-                'moduleName' => 'Magento_Core',
-            )
-        );
-        foreach (self::$_indexerTables as $tableName) {
-            if ($setupModel->getConnection()->isTableExists($tableName)) {
-                $setupModel->getConnection()->dropTable($tableName);
-            }
-        }
-
         self::$_objectManager = null;
-        self::$_indexerMode   = null;
-        self::$_indexerTables = null;
-    }
-
-    /**
-     * @static
-     * @return \Magento\Index\Model\Process
-     */
-    protected static function _getCategoryIndexerProcess()
-    {
-        /** @var $process \Magento\Index\Model\Process */
-        $process = self::$_objectManager->create('Magento\Index\Model\Process');
-        $process->load(\Magento\Catalog\Helper\Category\Flat::CATALOG_CATEGORY_FLAT_PROCESS_CODE, 'indexer_code');
-        return $process;
     }
 
     protected function setUp()
@@ -375,38 +296,4 @@ class CategoryTest extends \PHPUnit_Framework_TestCase
     {
         $this->assertNotEmpty($this->_model->validate());
     }
-
-    /**
-     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category 1
-     * @magentoDbIsolation enabled
-     */
-    public function testSaveWithFlatIndexer()
-    {
-        $categoryName = 'Indexer Category Name ' . uniqid();
-
-        /** @var $parentCategory \Magento\Catalog\Model\Category */
-        $parentCategory = self::$_objectManager->create('Magento\Catalog\Model\Category');
-        $parentCategory->load($this->_store->getRootCategoryId());
-
-        // init category model with EAV entity resource model
-        $resourceModel = self::$_objectManager->create('Magento\Catalog\Model\Resource\Category');
-        $this->_model  = self::$_objectManager->create('Magento\Catalog\Model\Category',
-            array('resource' => $resourceModel)
-        );
-        $this->_model->setName($categoryName)
-            ->setParentId($parentCategory->getId())
-            ->setPath($parentCategory->getPath())
-            ->setLevel(2)
-            ->setPosition(1)
-            ->setAvailableSortBy('name')
-            ->setDefaultSortBy('name')
-            ->setIsActive(true)
-            ->save();
-
-        // check if category record exists in flat table
-        /** @var $collection \Magento\Catalog\Model\Resource\Category\Flat\Collection */
-        $collection = self::$_objectManager->create('Magento\Catalog\Model\Resource\Category\Flat\Collection');
-        $collection->addFieldToFilter('name', $categoryName);
-        $this->assertCount(1, $collection->getItems());
-    }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..b2d65b9bd0975d89bcdd17f1ba2c769bd81eca79
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/FlatTest.php
@@ -0,0 +1,383 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer;
+
+class FlatTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var int
+     */
+    protected static $categoryOne;
+
+    /**
+     * @var int
+     */
+    protected static $categoryTwo;
+
+    /**
+     * List of attribute codes
+     *
+     * @var string[]
+     */
+    protected static $attributeCodes = array();
+
+    /**
+     * List of attribute values
+     * Data loaded from EAV
+     *
+     * @var string[]
+     */
+    protected static $attributeValues = array();
+
+    /**
+     * List of attributes to exclude
+     *
+     * @var string[]
+     */
+    protected static $attributesToExclude = array('url_path', 'display_mode');
+
+    /**
+     * @var int
+     */
+    protected static $totalBefore = 0;
+
+    public static function setUpBeforeClass()
+    {
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+
+        self::loadAttributeCodes();
+        self::loadAttributeValues($category);
+    }
+
+    public function testEntityItemsBefore()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category');
+
+        $result = $category->getCollection()->getAllIds();
+        $this->assertNotEmpty($result);
+        $this->assertTrue(is_array($result));
+
+        self::$totalBefore = count($result);
+    }
+
+    /**
+     * Reindex All
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     * @magentoAppArea frontend
+     */
+    public function testReindexAll()
+    {
+        /** @var  $indexer \Magento\Indexer\Model\IndexerInterface */
+        $indexer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Indexer\Model\Indexer');
+        $indexer->load('catalog_category_flat');
+        $indexer->reindexAll();
+        $this->assertTrue($indexer->isValid());
+
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $category->getResource());
+        $this->checkCategoryData($category);
+    }
+
+    /**
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     * @magentoAppArea frontend
+     */
+    public function testFlatItemsBefore()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $category->getResource());
+
+        $result = $category->getAllChildren(true);
+        $this->assertNotEmpty($result);
+        $this->assertCount(1, $result);
+    }
+
+    /**
+     * Populate EAV category data
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     */
+    public function testCreateCategory()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category');
+        $category->load(2);
+
+        /** @var \Magento\Catalog\Model\Category $categoryOne */
+        $categoryOne = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category');
+        $categoryOne->setName('Category One')
+            ->setPath($category->getPath())
+            ->setIsActive(true)
+            ->save();
+        self::loadAttributeValues($categoryOne);
+
+        self::$categoryOne = $categoryOne->getId();
+
+        /** @var \Magento\Catalog\Model\Category $categoryTwo */
+        $categoryTwo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category');
+
+        $categoryTwo->setName('Category Two')
+            ->setPath($categoryOne->getPath())
+            ->setIsActive(true)
+            ->save();
+
+        self::loadAttributeValues($categoryTwo);
+
+        self::$categoryTwo = $categoryTwo->getId();
+
+        $result = $category->getCollection()->getItems();
+        $this->assertTrue(is_array($result));
+
+        $this->assertEquals($category->getId(), $result[self::$categoryOne]->getParentId());
+        $this->assertEquals(self::$categoryOne, $result[self::$categoryTwo]->getParentId());
+    }
+
+    /**
+     * Test for reindex row action
+     * Check that category data created at testCreateCategory() were syncing to flat structure
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     * @magentoAppArea frontend
+     *
+     * @depends testCreateCategory
+     */
+    public function testFlatAfterCreate()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $category->getResource());
+
+        $result = $category->getAllChildren(true);
+        $this->assertNotEmpty($result);
+        $this->assertCount(3, $result);
+        $this->assertContains(self::$categoryOne, $result);
+
+        /** @var \Magento\Catalog\Model\Category $categoryOne */
+        $categoryOne = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(self::$categoryOne);
+
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $categoryOne->getResource());
+
+        $result = $categoryOne->getAllChildren(true);
+        $this->assertNotEmpty($result);
+        $this->assertCount(2, $result);
+        $this->assertContains(self::$categoryTwo, $result);
+        $this->checkCategoryData($categoryOne);
+
+        /** @var \Magento\Catalog\Model\Category $categoryTwo */
+        $categoryTwo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(self::$categoryTwo);
+
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $categoryTwo->getResource());
+
+        $this->assertEquals(self::$categoryOne, $categoryTwo->getParentId());
+        $this->checkCategoryData($categoryTwo);
+    }
+
+    /**
+     * Move category and populate EAV category data
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     */
+    public function testMoveCategory()
+    {
+        /** @var \Magento\Catalog\Model\Category $categoryTwo */
+        $categoryTwo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(self::$categoryTwo);
+
+        $this->assertEquals($categoryTwo->getData('parent_id'), self::$categoryOne);
+
+        $categoryTwo->move(2, self::$categoryOne);
+        self::loadAttributeValues($categoryTwo);
+
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+
+        self::loadAttributeValues($category);
+
+        $categoryOne = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(self::$categoryOne);
+        self::loadAttributeValues($categoryOne);
+
+        $this->assertEquals($categoryTwo->getData('parent_id'), 2);
+    }
+
+    /**
+     * Test for reindex list action
+     * Check that category data created at testMoveCategory() were syncing to flat structure
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     * @magentoAppArea frontend
+     *
+     * @depends testMoveCategory
+     */
+    public function testFlatAfterMove()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $category->getResource());
+
+        $this->checkCategoryData($category);
+
+        $result = $category->getAllChildren(true);
+        $this->assertNotEmpty($result);
+        $this->assertCount(3, $result);
+
+        /** @var \Magento\Catalog\Model\Category $categoryTwo */
+        $categoryTwo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(self::$categoryTwo);
+        $this->checkCategoryData($categoryTwo);
+
+        /** @var \Magento\Catalog\Model\Category $categoryOne */
+        $categoryOne = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(self::$categoryOne);
+        $this->checkCategoryData($categoryOne);
+    }
+
+    /**
+     * Delete created categories at testCreateCategory()
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     * @magentoAppArea adminhtml
+     */
+    public function testDeleteCategory()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category');
+
+        $category->load(self::$categoryTwo);
+        $category->delete();
+
+        $category->load(self::$categoryOne);
+        $category->delete();
+
+        $result = $category->getCollection()->getAllIds();
+        $this->assertNotEmpty($result);
+        $this->assertTrue(is_array($result));
+        $this->assertCount(self::$totalBefore, $result);
+    }
+
+    /**
+     * Test for reindex row action
+     * Check that category data deleted at testDeleteCategory() were syncing to flat structure
+     *
+     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
+     * @magentoAppArea frontend
+     *
+     * @depends testDeleteCategory
+     */
+    public function testFlatAfterDeleted()
+    {
+        /** @var \Magento\Catalog\Model\Category $category */
+        $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Category')
+            ->load(2);
+
+        $this->assertInstanceOf('Magento\Catalog\Model\Resource\Category\Flat', $category->getResource());
+
+        $result = $category->getAllChildren(true);
+        $this->assertNotEmpty($result);
+        $this->assertCount(1, $result);
+    }
+
+    /**
+     * Populate attribute values from category
+     * Data loaded from EAV
+     *
+     * @param \Magento\Catalog\Model\Category $category
+     */
+    protected static function loadAttributeValues(\Magento\Catalog\Model\Category $category)
+    {
+        foreach (self::$attributeCodes as $attributeCode) {
+            self::$attributeValues[$category->getId()][$attributeCode] = $category->getData($attributeCode);
+        }
+    }
+
+    /**
+     * Populate attribute codes for category entity
+     * Data loaded from EAV
+     *
+     */
+    protected static function loadAttributeCodes()
+    {
+        /** @var \Magento\Catalog\Model\Config $catalogConfig */
+        $catalogConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Catalog\Model\Config');
+        $attributeCodes = $catalogConfig->getEntityAttributeCodes(\Magento\Catalog\Model\Category::ENTITY);
+
+        foreach ($attributeCodes as $attributeCode) {
+            if (in_array($attributeCode, self::$attributesToExclude)) {
+                continue;
+            }
+            self::$attributeCodes[]  = $attributeCode;
+        }
+    }
+
+    /**
+     * Check EAV and flat data
+     *
+     * @param \Magento\Catalog\Model\Category $category
+     */
+    protected function checkCategoryData(\Magento\Catalog\Model\Category $category)
+    {
+        foreach (self::$attributeCodes as $attributeCode) {
+            $this->assertEquals(
+                self::$attributeValues[$category->getId()][$attributeCode],
+                $category->getData($attributeCode),
+                "Data for {$category->getId()} attribute code [{$attributeCode}] is wrong"
+            );
+        }
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php
index 14f7cb622e8fe40025cc27149d4019454aef927b..580515e7f7531d35533b1f020a163bdd0d509526 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/AbstractTest.php
@@ -193,7 +193,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase
             ->create('Magento\Catalog\Model\Product');
         $product->load(1); // fixture
         $this->assertEquals(
-            'Please specify the product required option(s).',
+            'Please specify the product\'s required option(s).',
             $this->_model->prepareForCart(new \Magento\Object, $product)
         );
     }
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Category/FlatTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Category/FlatTest.php
deleted file mode 100644
index 0b97083aa9ebb47933dd82b38952f1449b96e159..0000000000000000000000000000000000000000
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Resource/Category/FlatTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-namespace Magento\Catalog\Model\Resource\Category;
-
-class FlatTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Catalog\Model\Resource\Category\Flat
-     */
-    protected $model;
-
-    /**
-     * @var \Magento\TestFramework\ObjectManager
-     */
-    protected $objectManager;
-
-    protected function setUp()
-    {
-        $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-        $this->model = $this->objectManager->create('Magento\Catalog\Model\Resource\Category\Flat');
-    }
-
-    /**
-     * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category 1
-     */
-    public function testGetParentDesignCategory()
-    {
-        $category = $this->objectManager->create('Magento\Catalog\Model\Category');
-        $category->setId(3)
-            ->setName('Category 1')
-            ->setParentId(2)
-            ->setPath('1/2/3')
-            ->setLevel(2)
-            ->setAvailableSortBy('name')
-            ->setDefaultSortBy('name')
-            ->setIsActive(true)
-            ->setPosition(1)
-            ->save();
-        $designCategory = $this->model->getParentDesignCategory($category);
-        $this->assertInstanceOf('\Magento\Catalog\Model\Category', $designCategory, 'Invalid type for category');
-        $this->assertContains($designCategory->getId(), array(1, 2, 3), 'Incorrect data for parent design category');
-    }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/test_default/result_source.css b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/test_default/result_source.css
new file mode 100644
index 0000000000000000000000000000000000000000..7a5591f60aa20e86c2acd0c09bdec3f5d031521d
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/test_default/result_source.css
@@ -0,0 +1,42 @@
+#header {
+  color: #4d926f;
+}
+h2 {
+  color: #4d926f;
+}
+#header {
+  -webkit-border-radius: 5px;
+  -moz-border-radius: 5px;
+  -ms-border-radius: 5px;
+  -o-border-radius: 5px;
+  border-radius: 5px;
+}
+#footer {
+  -webkit-border-radius: 10px;
+  -moz-border-radius: 10px;
+  -ms-border-radius: 10px;
+  -o-border-radius: 10px;
+  border-radius: 10px;
+}
+#header h1 {
+  font-size: 26px;
+  font-weight: bold;
+}
+#header p {
+  font-size: 12px;
+}
+#header p a {
+  text-decoration: none;
+}
+#header p a:hover {
+  border-width: 1px;
+}
+#header {
+  color: #333333;
+  border-left: 1px;
+  border-right: 2px;
+}
+#footer {
+  color: #114411;
+  border-color: #7d2717;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/test_default/source.less b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/test_default/source.less
new file mode 100644
index 0000000000000000000000000000000000000000..4bb52500ff1b1c153e3cd688ed9246c5f841e0eb
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/frontend/test_default/source.less
@@ -0,0 +1,61 @@
+@color: #4D926F;
+
+#header {
+  color: @color;
+}
+
+h2 {
+  color: @color;
+}
+
+// Mixins
+
+.rounded-corners (@radius: 5px) {
+  -webkit-border-radius: @radius;
+  -moz-border-radius: @radius;
+  -ms-border-radius: @radius;
+  -o-border-radius: @radius;
+  border-radius: @radius;
+}
+
+#header {
+  .rounded-corners;
+}
+
+#footer {
+  .rounded-corners(10px);
+}
+
+// Nested Rules
+
+#header {
+  h1 {
+    font-size: 26px;
+    font-weight: bold;
+  }
+  p { font-size: 12px;
+    a {
+      text-decoration: none;
+      &:hover {
+        border-width: 1px;
+      }
+    }
+  }
+}
+
+// Functions & Operations
+
+@the-border: 1px;
+@base-color: #111;
+@red:        #842210;
+
+#header {
+  color: (@base-color * 3);
+  border-left: @the-border;
+  border-right: (@the-border * 2);
+}
+
+#footer {
+  color: (@base-color + #003300);
+  border-color: desaturate(@red, 10%);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php b/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php
index 3f00d2c75046bb882450df170fa75fa5cee8e865..ce79f3d644bd8ab5bedd777eaaf541f6e855086d 100644
--- a/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php
+++ b/dev/tests/integration/testsuite/Magento/Core/_files/media_for_change.php
@@ -43,10 +43,17 @@ foreach ($files as $file) {
     touch($themeDir . '/' . $file, $mTime);
 }
 
+
+$appInstallDir = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInstallDir();
+\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(
+    \Magento\App\Filesystem::PARAM_APP_DIRS => array(
+        \Magento\App\Filesystem::THEMES_DIR => array('path' => "$appInstallDir/media_for_change"),
+    )
+));
+
 /** @var $registration \Magento\Core\Model\Theme\Registration */
 $registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
     ->create('Magento\Core\Model\Theme\Registration');
 $registration->register(
-    $designDir,
     '*/*/theme.xml'
 );
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/CacheTest.php b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/CacheTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..594953b9d68a219c6173f1951b103f6cfad62d18
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/CacheTest.php
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor;
+
+class CacheTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Css\PreProcessor\Less
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Css\PreProcessor\Cache\CacheManagerFactory
+     */
+    protected $cacheManagerFactory;
+
+    /**
+     * @var \Magento\App\Filesystem
+     */
+    protected $filesystem;
+
+    /**
+     * @var \Magento\View\Service
+     */
+    protected $viewService;
+
+    public function setUp()
+    {
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+        $this->model = $objectManager->create('Magento\Css\PreProcessor\Less');
+        $this->cacheManagerFactory = $objectManager->create('Magento\Css\PreProcessor\Cache\CacheManagerFactory');
+        $this->filesystem = $objectManager->get('Magento\Filesystem');
+        $this->viewService = $objectManager->get('Magento\View\Service');
+
+        $this->clearCache();
+
+        \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(
+            \Magento\App\Filesystem::PARAM_APP_DIRS => array(
+                \Magento\App\Filesystem::PUB_LIB_DIR => array(
+                    'path' => __DIR__ . '/_files/cache/lib'
+                ),
+            )
+        ));
+    }
+
+    protected function tearDown()
+    {
+        $this->clearCache();
+    }
+
+    public function testProcess()
+    {
+        $sourceFilePath = 'oyejorge.less';
+
+        $designParams = $this->getDesignParams();
+        $targetDirectory = $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::TMP_DIR);
+
+        /**
+         * cache was not initialize yet and will return empty value
+         *
+         * @var \Magento\Css\PreProcessor\Cache\CacheManager $cacheManagerEmpty
+         */
+        $cacheManagerEmpty = $this->cacheManagerFactory->create($sourceFilePath, $designParams);
+        $this->assertEmpty($cacheManagerEmpty->getCachedFile());
+
+        $this->model->process($sourceFilePath, $designParams, $targetDirectory);
+
+        /**
+         * cache initialized and will return cached file
+         *
+         * @var \Magento\Css\PreProcessor\Cache\CacheManager $cacheManagerGenerated
+         */
+        $cacheManagerGenerated = $this->cacheManagerFactory->create($sourceFilePath, $designParams);
+        $this->assertNotEmpty($cacheManagerGenerated->getCachedFile());
+    }
+
+    /**
+     * @return array
+     */
+    protected function getDesignParams()
+    {
+        $designParams = ['area' => 'frontend'];
+        /** @var \Magento\View\Service $viewService */
+        $this->viewService->updateDesignParams($designParams);
+
+        return $designParams;
+    }
+
+    /**
+     * @return $this
+     */
+    protected function clearCache()
+    {
+        /** @var \Magento\Filesystem\Directory\WriteInterface $mapsDirectory */
+        $mapsDirectory = $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::VAR_DIR);
+
+        if ($mapsDirectory->isDirectory(\Magento\Css\PreProcessor\Cache\Import\Map\Storage::MAPS_DIR)) {
+            $mapsDirectory->delete(\Magento\Css\PreProcessor\Cache\Import\Map\Storage::MAPS_DIR);
+        }
+        return $this;
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/cache/lib/nested/import.less b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/cache/lib/nested/import.less
new file mode 100644
index 0000000000000000000000000000000000000000..90124833074c6c935fe02c75b4a815d8b5889337
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/cache/lib/nested/import.less
@@ -0,0 +1 @@
+h1 { background-color: red; }
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/cache/lib/oyejorge.less b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/cache/lib/oyejorge.less
new file mode 100644
index 0000000000000000000000000000000000000000..d8544f2a2a4ab93cf1d886fc356c4aaa10a505f0
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/cache/lib/oyejorge.less
@@ -0,0 +1 @@
+@import "nested/import.less";
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..20044d188904e154ae0a21e955d50d188ccb48c8
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php
@@ -0,0 +1,175 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Account\Dashboard;
+
+class AddressTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Customer\Block\Account\Dashboard\Address
+     */
+    protected $_block;
+
+    /** @var  \Magento\Customer\Model\Session */
+    protected $_customerSession;
+
+    protected function setUp()
+    {
+        $this->_customerSession = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('\Magento\Customer\Model\Session');
+        $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface')
+            ->createBlock(
+                'Magento\Customer\Block\Account\Dashboard\Address',
+                '',
+                array('customerSession' => $this->_customerSession)
+            );
+    }
+
+    protected function tearDown()
+    {
+        $this->_customerSession->unsCustomerId();
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetCustomer()
+    {
+        $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerServiceInterface')
+            ->getCustomer(1);
+
+        $this->_customerSession->setCustomerId(1);
+        $object = $this->_block->getCustomer();
+        $this->assertEquals($customer, $object);
+    }
+
+    public function testGetCustomerMissingCustomer()
+    {
+        $this->assertNull($this->_block->getCustomer());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getPrimaryShippingAddressHtmlDataProvider
+     */
+    public function testGetPrimaryShippingAddressHtml($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $html = $this->_block->getPrimaryShippingAddressHtml();
+        $this->assertEquals($expected, $html);
+    }
+
+    public function getPrimaryShippingAddressHtmlDataProvider()
+    {
+        return [
+            '0' => [0, 'You have not set a default shipping address.'],
+            '1' => [
+                1,
+                "John Smith<br/>\n\nGreen str, 67<br />\n\n\n\nCityM,  Alabama, 75477<br/>\n<br/>\nT: 3468676\n\n"
+            ],
+            '5' => [5, 'You have not set a default shipping address.'],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getPrimaryBillingAddressHtmlDataProvider
+     */
+    public function testGetPrimaryBillingingAddressHtml($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $html = $this->_block->getPrimaryBillingAddressHtml();
+        $this->assertEquals($expected, $html);
+    }
+
+    public function getPrimaryBillingAddressHtmlDataProvider()
+    {
+        return [
+            '0' => [0, 'You have not set a default billing address.'],
+            '1' => [
+                1,
+                "John Smith<br/>\n\nGreen str, 67<br />\n\n\n\nCityM,  Alabama, 75477<br/>\n<br/>\nT: 3468676\n\n"
+            ],
+            '5' => [5, 'You have not set a default billing address.'],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getPrimaryShippingAddressEditUrlDataProvider
+     */
+    public function testGetPrimaryShippingAddressEditUrl($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $url = $this->_block->getPrimaryShippingAddressEditUrl();
+        $this->assertEquals($expected, $url);
+    }
+
+    public function getPrimaryShippingAddressEditUrlDataProvider()
+    {
+        return [
+            '0' => [0, ''],
+            '1' => [1, 'http://localhost/index.php/customer/address/edit/id/1/'],
+            '5' => [5, 'http://localhost/index.php/customer/address/edit/'],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getPrimaryBillingAddressEditUrlDataProvider
+     */
+    public function testGetPrimaryBillingAddressEditUrl($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $url = $this->_block->getPrimaryBillingAddressEditUrl();
+        $this->assertEquals($expected, $url);
+    }
+
+
+    public function getPrimaryBillingAddressEditUrlDataProvider()
+    {
+        return [
+            '0' => [0, ''],
+            '1' => [1, 'http://localhost/index.php/customer/address/edit/id/1/'],
+            '5' => [5, 'http://localhost/index.php/customer/address/edit/'],
+        ];
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/BookTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/BookTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..1cd722e4406602c7580ad278ed6fec27eb32c29f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/BookTest.php
@@ -0,0 +1,227 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Address;
+
+class BookTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Customer\Block\Address\Book
+     */
+    protected $_block;
+
+    /** @var  \Magento\Customer\Model\Session */
+    protected $_customerSession;
+
+    protected function setUp()
+    {
+        /** @var \PHPUnit_Framework_MockObject_MockObject $blockMock */
+        $blockMock = $this->getMockBuilder('\Magento\View\Element\BlockInterface')
+            ->disableOriginalConstructor()
+            ->setMethods(array('setTitle', 'toHtml'))
+            ->getMock();
+        $blockMock->expects($this->any())
+            ->method('setTitle');
+
+        $this->_customerSession = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('\Magento\Customer\Model\Session');
+        /** @var \Magento\View\LayoutInterface $layout */
+        $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface');
+        $layout->setBlock('head', $blockMock);
+        $this->_block = $layout
+            ->createBlock(
+                'Magento\Customer\Block\Address\Book',
+                '',
+                ['customerSession' => $this->_customerSession]
+            );
+    }
+
+    protected function tearDown()
+    {
+        $this->_customerSession->unsCustomerId();
+    }
+
+    public function testGetAddressEditUrl()
+    {
+        $this->assertEquals(
+            'http://localhost/index.php/customer/address/edit/id/1/',
+            $this->_block->getAddressEditUrl(1)
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider hasPrimaryAddressDataProvider
+     */
+    public function testHasPrimaryAddress($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $this->assertEquals($expected, $this->_block->hasPrimaryAddress());
+    }
+
+    public function hasPrimaryAddressDataProvider()
+    {
+        return [
+            '0' => [0, false],
+            '1' => [1, true],
+            '5' => [5, false],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     */
+    public function testGetAdditionalAddresses()
+    {
+        $this->_customerSession->setCustomerId(1);
+        $this->assertNotNull($this->_block->getAdditionalAddresses());
+        $this->assertCount(1, $this->_block->getAdditionalAddresses());
+        $this->assertInstanceOf(
+            '\Magento\Customer\Service\V1\Dto\Address',
+            $this->_block->getAdditionalAddresses()[0]
+        );
+        $this->assertEquals(2, $this->_block->getAdditionalAddresses()[0]->getId());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getAdditionalAddressesDataProvider
+     */
+    public function testGetAdditionalAddressesNegative($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $this->assertEquals($expected, $this->_block->getAdditionalAddresses());
+    }
+
+    public function getAdditionalAddressesDataProvider()
+    {
+        return [
+            '0' => [0, false],
+            '5' => [5, false],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testGetAddressHtml()
+    {
+        $expected = "John Smith<br/>\n\nGreen str, 67<br />\n\n\n\nCityM,  Alabama, 75477<br/>\n<br/>\nT: 3468676\n\n";
+        $address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerAddressServiceInterface')
+            ->getAddressById(1);
+        $html = $this->_block->getAddressHtml($address);
+        $this->assertEquals($expected, $html);
+    }
+
+    public function testGetAddressHtmlWithoutAddress()
+    {
+        $this->assertEquals('', $this->_block->getAddressHtml(null));
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetCustomer()
+    {
+        $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerServiceInterface')->getCustomer(1);
+
+        $this->_customerSession->setCustomerId(1);
+        $object = $this->_block->getCustomer();
+        $this->assertEquals($customer, $object);
+    }
+
+    public function testGetCustomerMissingCustomer()
+    {
+        $this->assertNull($this->_block->getCustomer());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getDefaultBillingDataProvider
+     */
+    public function testGetDefaultBilling($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $this->assertEquals($expected, $this->_block->getDefaultBilling());
+    }
+
+    public function getDefaultBillingDataProvider()
+    {
+        return [
+            '0' => [0, Null],
+            '1' => [1, 1],
+            '5' => [5, Null],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     * @dataProvider getDefaultShippingDataProvider
+     */
+    public function testGetDefaultShipping($customerId, $expected)
+    {
+        if (!empty($customerId)) {
+            $this->_customerSession->setCustomerId($customerId);
+        }
+        $this->assertEquals($expected, $this->_block->getDefaultShipping());
+    }
+
+    public function getDefaultShippingDataProvider()
+    {
+        return [
+            '0' => [0, Null],
+            '1' => [1, 1],
+            '5' => [5, Null],
+        ];
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     */
+    public function testGetAddressById()
+    {
+        $this->assertInstanceOf(
+            '\Magento\Customer\Service\V1\Dto\Address',
+            $this->_block->getAddressById(1)
+        );
+        $this->assertNull($this->_block->getAddressById(5));
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ccecbb84210019d367fc7b7be8509af9a5ac8508
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php
@@ -0,0 +1,117 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Address;
+
+/**
+ * Tests Address Edit Block
+ */
+class EditTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var Edit */
+    protected $_block;
+
+    /** @var  \Magento\Customer\Model\Session */
+    protected $_customerSession;
+
+    /** @var \Magento\Backend\Block\Template\Context */
+    protected $_context;
+
+    /** @var string */
+    protected $_requestId;
+
+    protected function setUp()
+    {
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+
+        $this->_customerSession = $objectManager->get('\Magento\Customer\Model\Session');
+
+        $this->_customerSession->setCustomerId(1);
+
+        $this->_context = $objectManager->get('Magento\Backend\Block\Template\Context');
+        $this->_requestId = $this->_context->getRequest()->getParam('id');
+        $this->_context->getRequest()->setParam('id', '1');
+
+        $objectManager->get('Magento\App\State')->setAreaCode('frontend');
+
+        /** @var $layout \Magento\Core\Model\Layout */
+        $layout = $objectManager->get('Magento\View\LayoutInterface');
+
+        $this->_block = $layout->createBlock(
+            'Magento\Customer\Block\Address\Edit',
+            '',
+            array('customerSession' => $this->_customerSession)
+        );
+    }
+
+    protected function tearDown()
+    {
+        $this->_customerSession->unsCustomerId();
+        $this->_context->getRequest()->setParam('id', $this->_requestId);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetSaveUrl()
+    {
+        $this->assertEquals('http://localhost/index.php/customer/address/formPost/', $this->_block->getSaveUrl());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testGetRegionId()
+    {
+        $this->assertEquals(1, $this->_block->getRegionId());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testCanSetAsDefaultShipping()
+    {
+        $this->assertEquals(0, $this->_block->canSetAsDefaultShipping());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testIsDefaultBilling()
+    {
+        $this->assertFalse($this->_block->isDefaultBilling());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testGetStreetLine()
+    {
+        $this->assertEquals('Green str, 67', $this->_block->getStreetLine(1));
+        $this->assertEquals('', $this->_block->getStreetLine(2));
+    }
+}
+ 
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..f1bffc5bd5b6a81a5315ea4568b2039bf54d2b48
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Address\Renderer;
+
+use Magento\Eav\Model\AttributeDataFactory;
+
+/**
+ * DefaultRenderer
+ */
+class DefaultRendererTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Customer\Model\Address\Config
+     */
+    protected $_addressConfig;
+
+    public function setUp()
+    {
+        $this->_addressConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Model\Address\Config');
+    }
+
+    /**
+     * @dataProvider renderDataProvider
+     */
+    public function testRender($addressAttributes, $format, $expected)
+    {
+        /** @var DefaultRenderer $renderer */
+        $renderer = $this->_addressConfig->getFormatByCode($format)->getRenderer();
+        $actual = $renderer->renderArray($addressAttributes);
+        $this->assertEquals($expected, $actual);
+    }
+
+    public function renderDataProvider()
+    {
+        $addressAttributes = [
+            'city' => 'CityM',
+            'country_id' => 'US',
+            'firstname' => 'John',
+            'lastname' => 'Smith',
+            'postcode' => '75477',
+            'region' => [
+                'region' => 'Alabama',
+                'region_id' => '1',
+            ],
+            'street' => ['Green str, 67'],
+            'telephone' => '3468676',
+        ];
+
+        return [
+            [
+                $addressAttributes,
+                AttributeDataFactory::OUTPUT_FORMAT_HTML,
+                "John Smith<br/>\n\nGreen str, 67<br />\n\n\n\nCityM,  Alabama, 75477<br/>\n<br/>\nT: 3468676\n\n"
+            ],
+            [
+                $addressAttributes,
+                AttributeDataFactory::OUTPUT_FORMAT_PDF,
+                "John Smith|\n\nGreen str, 67\n\n\n\n\nCityM,|\nAlabama, 75477|\n|\nT: 3468676|\n|\n|"
+            ],
+            [
+                $addressAttributes,
+                AttributeDataFactory::OUTPUT_FORMAT_ONELINE,
+                "John Smith, Green str, 67, CityM, Alabama 75477, "
+            ],
+            [
+                $addressAttributes,
+                AttributeDataFactory::OUTPUT_FORMAT_TEXT,
+                "John Smith\n\nGreen str, 67\n\n\n\n\nCityM,  Alabama, 75477\n\nT: 3468676\n\n"
+            ],
+        ];
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..38f87244eb8fc1930f6be1cf6d4ba009c369cded
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php
@@ -0,0 +1,272 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Adminhtml\Edit\Tab;
+
+use Magento\Core\Model\LocaleInterface;
+use Magento\Customer\Model\Customer as CustomerModel;
+
+/**
+ * Magento\Customer\Block\Adminhtml\Edit\Tab\View
+ *
+ * @magentoAppArea adminhtml
+ */
+class ViewTest extends \PHPUnit_Framework_TestCase
+{
+    const CURRENT_CUSTOMER = 'current_customer';
+
+    /** @var  \Magento\Backend\Block\Template\Context */
+    private $_context;
+
+    /** @var  \Magento\Core\Model\Registry */
+    private $_coreRegistry;
+
+    /** @var  \Magento\Customer\Model\CustomerFactory */
+    private $_customerFactory;
+
+    /** @var  \Magento\Customer\Service\V1\CustomerGroupServiceInterface */
+    private $_groupService;
+
+    /** @var \Magento\Core\Model\StoreManagerInterface */
+    private $_storeManager;
+
+    /** @var  View */
+    private $_block;
+
+    public function setUp()
+    {
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+
+        $this->_storeManager = $objectManager->get('Magento\Core\Model\StoreManager');
+        $this->_context = $objectManager
+            ->get(
+                'Magento\Backend\Block\Template\Context',
+                array('storeManager' => $this->_storeManager)
+            );
+
+        $this->_customerFactory = $objectManager->get('Magento\Customer\Model\CustomerFactory');
+        $this->_coreRegistry = $objectManager->get('Magento\Core\Model\Registry');
+        $this->_groupService = $objectManager->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface');
+
+        $this->_block = $objectManager->get('Magento\View\LayoutInterface')
+            ->createBlock(
+                'Magento\Customer\Block\Adminhtml\Edit\Tab\View',
+                '',
+                array(
+                    'context' => $this->_context,
+                    'groupService' => $this->_groupService,
+                    'registry' => $this->_coreRegistry
+                )
+            );
+    }
+
+    public function tearDown()
+    {
+        $this->_coreRegistry->unregister(self::CURRENT_CUSTOMER);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetCustomer()
+    {
+        $this->assertSame($this->_loadCustomer(), $this->_block->getCustomer());
+    }
+
+    public function testGetCustomerEmpty()
+    {
+        $this->assertSame($this->_createCustomer(), $this->_block->getCustomer());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetGroupName()
+    {
+        $groupName = $this->_groupService->getGroup($this->_loadCustomer()->getGroupId())->getCode();
+        $this->assertEquals($groupName, $this->_block->getGroupName());
+    }
+
+    public function testGetGroupNameNull()
+    {
+        $this->_createCustomer();
+        $this->assertNull($this->_block->getGroupName());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetCreateDate()
+    {
+        $createdAt = $this->_block
+            ->formatDate($this->_loadCustomer()->getCreatedAt(), LocaleInterface::FORMAT_TYPE_MEDIUM, true);
+        $this->assertEquals($createdAt, $this->_block->getCreateDate());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetStoreCreateDate()
+    {
+        $customer = $this->_loadCustomer();
+        $date = $this->_context
+            ->getLocale()->storeDate($customer->getStoreId(), $customer->getCreatedAtTimestamp(), true);
+        $storeCreateDate = $this->_block->formatDate($date, LocaleInterface::FORMAT_TYPE_MEDIUM, true);
+        $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetStoreCreateDateTimezone()
+    {
+        $timezone = $this->_context
+            ->getStoreConfig()
+            ->getConfig(LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, $this->_loadCustomer()->getStoreId());
+        $this->assertEquals($timezone, $this->_block->getStoreCreateDateTimezone());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testIsConfirmedStatusConfirmed()
+    {
+        $this->_loadCustomer()->setConfirmation(false);
+        $this->assertEquals('Confirmed', $this->_block->getIsConfirmedStatus());
+    }
+
+    public function testIsConfirmedStatusConfirmationIsRequired()
+    {
+        $customer = $this->getMock(
+            'Magento\Customer\Model\Customer', ['getConfirmation', 'isConfirmationRequired'], [], '', false
+        );
+        $customer->expects($this->once())->method('getConfirmation')->will($this->returnValue(true));
+        $customer->expects($this->once())->method('isConfirmationRequired')->will($this->returnValue(true));
+        $this->_coreRegistry->register(self::CURRENT_CUSTOMER, $customer);
+        $this->assertEquals('Not confirmed, cannot login', $this->_block->getIsConfirmedStatus());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testIsConfirmedStatusConfirmationIsNotRequired()
+    {
+        $customer = $this->_loadCustomer();
+        $customer->setConfirmation(true);
+        $customer->setSkipConfirmationIfEmail($customer->getEmail());
+        $this->assertEquals('Not confirmed, can login', $this->_block->getIsConfirmedStatus());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetCreatedInStore()
+    {
+        $storeName = $this->_storeManager->getStore($this->_loadCustomer()->getStoreId())->getName();
+        $this->assertEquals($storeName, $this->_block->getCreatedInStore());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testGetStoreId()
+    {
+        $this->assertEquals($this->_loadCustomer()->getStoreId(), $this->_block->getStoreId());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testGetBillingAddressHtml()
+    {
+        $html = $this->_loadCustomer()->getPrimaryBillingAddress()->format('html');
+        $this->assertEquals($html, $this->_block->getBillingAddressHtml());
+    }
+
+    public function testGetBillingAddressHtmlNoDefaultAddress()
+    {
+        $this->_createCustomer();
+        $this->assertEquals(
+            __('The customer does not have default billing address.'), $this->_block->getBillingAddressHtml()
+        );
+    }
+
+    public function testGetTabLabel()
+    {
+        $this->assertEquals(__('Customer View'), $this->_block->getTabLabel());
+    }
+
+    public function testGetTabTitle()
+    {
+        $this->assertEquals(__('Customer View'), $this->_block->getTabTitle());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testCanShowTab()
+    {
+        $this->_loadCustomer();
+        $this->assertTrue($this->_block->canShowTab());
+    }
+
+    public function testCanShowTabNot()
+    {
+        $this->_createCustomer();
+        $this->assertFalse($this->_block->canShowTab());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testIsHidden()
+    {
+        $this->_loadCustomer();
+        $this->assertFalse($this->_block->isHidden());
+    }
+
+    public function testIsHiddenNot()
+    {
+        $this->_createCustomer();
+        $this->assertTrue($this->_block->isHidden());
+    }
+
+    /**
+     * @return CustomerModel
+     */
+    private function _createCustomer()
+    {
+        $customer = $this->_customerFactory->create();
+        $this->_coreRegistry->register(self::CURRENT_CUSTOMER, $customer);
+        return $customer;
+    }
+
+    /**
+     * @return CustomerModel
+     */
+    private function _loadCustomer()
+    {
+        return $this->_createCustomer()->load(1);
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..5eec60717f643535a08916792eb1d903593534fc
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Adminhtml;
+
+use Magento\Backend\App\Area\FrontNameResolver;
+use Magento\Core\Model\LocaleInterface;
+use Magento\Customer\Service\V1\CustomerService;
+use Magento\Stdlib\DateTime;
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\View\LayoutInterface;
+
+/**
+ * Magento\Customer\Block\Adminhtml\Grid
+ *
+ * @magentoAppArea adminhtml
+ */
+class GridTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var LayoutInterface */
+    private $layout;
+
+    /** @var CustomerService */
+    private $customerService;
+
+    /** @var LocaleInterface */
+    private $locale;
+
+
+    public function setUp()
+    {
+        $this->layout = Bootstrap::getObjectManager()->create(
+            'Magento\Core\Model\Layout',
+            ['area' => FrontNameResolver::AREA_CODE]
+        );
+        $this->customerService = Bootstrap::getObjectManager()->create(
+            'Magento\Customer\Service\V1\CustomerService'
+        );
+        $this->locale = Bootstrap::getObjectManager()->create(
+            'Magento\Core\Model\LocaleInterface'
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture Magento/Customer/_files/customer_no_address.php
+     */
+    public function testGetCsv()
+    {
+        /** @var $block Grid */
+        $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Grid', 'block');
+        $csv = $block->getCsv();
+        $customer5ca = $this->formatDatetime($this->customerService->getCustomer(5)->getCreatedAt());
+        $customer1ca = $this->formatDatetime($this->customerService->getCustomer(1)->getCreatedAt());
+        // @codingStandardsIgnoreStart
+        $expected = <<<EOT
+"ID","Name","Email","Group","Phone","ZIP","Country","State/Province","Customer Since","Web Site"
+"5","Firstname Lastname","customer5@example.com","General","","","","","$customer5ca","Main Website"
+"1","Firstname Lastname","customer@example.com","General","3468676","75477","United States","Alabama","$customer1ca","Main Website"
+
+EOT;
+        // @codingStandardsIgnoreEnd
+        $this->assertEquals($expected, $csv);
+    }
+
+    public function testGetCsvNoData()
+    {
+        /** @var $block Grid */
+        $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Grid', 'block');
+        $csv = $block->getCsv();
+
+        $expected = <<<EOT
+"ID","Name","Email","Group","Phone","ZIP","Country","State/Province","Customer Since","Web Site"
+
+EOT;
+        $this->assertEquals($expected, $csv);
+    }
+
+    private function formatDatetime($date)
+    {
+        $format = $this->locale->getDateTimeFormat(
+            LocaleInterface::FORMAT_TYPE_MEDIUM
+        );
+        return $this->locale->date($date, DateTime::DATETIME_INTERNAL_FORMAT)->toString($format);
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..af5bd97ba0145a4f1778cd3958248d9396197044
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Adminhtml\Group\Edit;
+
+use Magento\Backend\App\Area\FrontNameResolver;
+use Magento\Customer\Service\V1\Dto\CustomerGroup;
+use Magento\Customer\Service\V1\Dto\Filter;
+use Magento\Customer\Service\V1\Dto\SearchCriteria;
+use Magento\TestFramework\Helper\Bootstrap;
+
+/**
+ * Magento\Customer\Block\Adminhtml\Group\Edit\Form
+ *
+ * @magentoAppArea adminhtml
+ */
+class FormTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\View\LayoutInterface */
+    private $layout;
+
+    /** @var \Magento\Customer\Service\V1\CustomerGroupService */
+    private $customerGroupService;
+
+    /** @var \Magento\Core\Model\Registry */
+    private $registry;
+
+    public function setUp()
+    {
+        parent::setUp();
+        $this->layout = Bootstrap::getObjectManager()->create(
+            'Magento\Core\Model\Layout',
+            ['area' => FrontNameResolver::AREA_CODE]
+        );
+        $this->customerGroupService = Bootstrap::getObjectManager()->get(
+            'Magento\Customer\Service\V1\CustomerGroupServiceInterface'
+        );
+
+        $this->registry = Bootstrap::getObjectManager()->get('Magento\Core\Model\Registry');
+    }
+
+    public function tearDown()
+    {
+        $this->registry->unregister('current_group');
+    }
+
+    public function testGetForm()
+    {
+        $customerGroup = $this->customerGroupService->getDefaultGroup(0);
+        $this->registry->register('current_group', $customerGroup);
+
+        /** @var $block Form */
+        $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit\Form', 'block');
+        $form = $block->getForm();
+
+        $this->assertEquals('edit_form', $form->getId());
+        $baseFieldSet = $form->getElement('base_fieldset');
+        $this->assertNotNull($baseFieldSet);
+        $groupCodeElement = $form->getElement('customer_group_code');
+        $this->assertNotNull($groupCodeElement);
+        $taxClassIdElement = $form->getElement('tax_class_id');
+        $this->assertNotNull($taxClassIdElement);
+        $idElement = $form->getElement('id');
+        $this->assertNotNull($idElement);
+        $this->assertEquals('1', $idElement->getValue());
+        $this->assertEquals('3', $taxClassIdElement->getValue());
+        $this->assertEquals('General', $groupCodeElement->getValue());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer_group.php
+     */
+    public function testGetFormExistInCustomGroup()
+    {
+        $searchCriteria = new SearchCriteria([
+            'filters' => [new Filter([
+                'field'             => 'customer_group_code',
+                'value'             => 'custom_group',
+                'condition_type'    => 'or',
+            ])]
+        ]);
+        /** @var CustomerGroup $customerGroup */
+        $customerGroup = $this->customerGroupService->searchGroups($searchCriteria)->getItems()[0];
+        $this->registry->register('current_group', $customerGroup);
+
+        /** @var $block Form */
+        $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit\Form', 'block');
+        $form = $block->getForm();
+
+        $this->assertEquals('edit_form', $form->getId());
+        $baseFieldSet = $form->getElement('base_fieldset');
+        $this->assertNotNull($baseFieldSet);
+        $groupCodeElement = $form->getElement('customer_group_code');
+        $this->assertNotNull($groupCodeElement);
+        $taxClassIdElement = $form->getElement('tax_class_id');
+        $this->assertNotNull($taxClassIdElement);
+        $idElement = $form->getElement('id');
+        $this->assertNotNull($idElement);
+        $this->assertEquals($customerGroup->getId(), $idElement->getValue());
+        $this->assertEquals($customerGroup->getTaxClassId(), $taxClassIdElement->getValue());
+        $this->assertEquals($customerGroup->getCode(), $groupCodeElement->getValue());
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..a4b61d68863d46ef64bfb424157bba9b74b9cae2
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Adminhtml\Group;
+
+use Magento\Backend\App\Area\FrontNameResolver;
+use Magento\Customer\Service\V1\Dto\CustomerGroup;
+use Magento\Customer\Service\V1\Dto\Filter;
+use Magento\Customer\Service\V1\Dto\SearchCriteria;
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\TestCase\AbstractController;
+
+/**
+ * Magento\Customer\Block\Adminhtml\Group\Edit
+ *
+ * @magentoAppArea adminhtml
+ */
+class EditTest extends AbstractController
+{
+    /** @var \Magento\View\LayoutInterface */
+    private $layout;
+
+    /** @var \Magento\Customer\Service\V1\CustomerGroupService */
+    private $customerGroupService;
+
+    /** @var \Magento\Core\Model\Registry */
+    private $registry;
+
+    public function setUp()
+    {
+        parent::setUp();
+        $this->layout = Bootstrap::getObjectManager()->create(
+            'Magento\Core\Model\Layout',
+            ['area' => FrontNameResolver::AREA_CODE]
+        );
+        $this->customerGroupService = Bootstrap::getObjectManager()->create(
+            'Magento\Customer\Service\V1\CustomerGroupService'
+        );
+
+        $this->registry = Bootstrap::getObjectManager()->get('Magento\Core\Model\Registry');
+    }
+
+    public function tearDown()
+    {
+        $this->registry->unregister('current_group');
+    }
+
+    public function testDeleteButtonNotExistInDefaultGroup()
+    {
+        $customerGroup = $this->customerGroupService->getDefaultGroup(0);
+        $this->registry->register('current_group', $customerGroup);
+        $this->getRequest()->setParam('id', $customerGroup->getId());
+
+        /** @var $block Edit */
+        $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'block');
+        $buttonsHtml = $block->getButtonsHtml();
+
+        $this->assertNotContains('delete', $buttonsHtml);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer_group.php
+     */
+    public function testDeleteButtonExistInCustomGroup()
+    {
+        $searchCriteria = new SearchCriteria([
+            'filters' => [new Filter([
+                'field'             => 'customer_group_code',
+                'value'             => 'custom_group',
+                'condition_type'    => 'or',
+            ])]
+        ]);
+        /** @var CustomerGroup $customerGroup */
+        $customerGroup = $this->customerGroupService->searchGroups($searchCriteria)->getItems()[0];
+        $this->getRequest()->setParam('id', $customerGroup->getId());
+        $this->registry->register('current_group', $customerGroup);
+
+        /** @var $block Edit */
+        $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'block');
+        $buttonsHtml = $block->getButtonsHtml();
+
+        $this->assertContains('delete', $buttonsHtml);
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index f9df1d9c488474565524360a605b818a719b64a2..ca3a38687ea6134d81fb7fe61f61323bf9f68ecc 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -19,8 +19,6 @@
  * needs please refer to http://www.magentocommerce.com for more information.
  *
  * @category    Magento
- * @package     Magento_Customer
- * @subpackage  integration_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -29,8 +27,20 @@ namespace Magento\Customer\Controller;
 
 class AccountTest extends \Magento\TestFramework\TestCase\AbstractController
 {
+    /**
+     * Login the user
+     */
+    protected function _login()
+    {
+        $logger = $this->getMock('Magento\Logger', array(), array(), '', false);
+        $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Customer\Model\Session', array($logger));
+        $session->login('customer@example.com', 'password');
+    }
+
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
      */
     public function testIndexAction()
     {
@@ -39,7 +49,33 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController
             ->create('Magento\Customer\Model\Session', array($logger));
         $session->login('customer@example.com', 'password');
         $this->dispatch('customer/account/index');
-        $this->assertContains('<div class="block dashboard welcome">', $this->getResponse()->getBody());
+
+        $body = $this->getResponse()->getBody();
+        $this->assertContains('<div class="block dashboard welcome">', $body);
+        $this->assertContains('Hello, Firstname Lastname!', $body);
+        $this->assertContains('Green str, 67', $body);
+    }
+
+    public function testCreateAction()
+    {
+        $this->dispatch('customer/account/create');
+        $body = $this->getResponse()->getBody();
+        $this->assertContains('<input type="text" id="firstname"', $body);
+        $this->assertContains('<input type="text" id="lastname"', $body);
+        $this->assertContains('<input type="email" name="email" id="email_address"', $body);
+        $this->assertContains('<input type="checkbox" name="is_subscribed"', $body);
+        $this->assertContains('<input type="password" name="password" id="password"', $body);
+        $this->assertContains('<input type="password" name="confirmation" title="Confirm Password"', $body);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testLogoutAction()
+    {
+        $this->_login();
+        $this->dispatch('customer/account/logout');
+        $this->assertRedirect($this->stringContains('customer/account/logoutSuccess'));
     }
 
     /**
@@ -63,6 +99,161 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController
         $this->assertTrue((bool)preg_match('/' . $token . '/m', $text));
     }
 
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testCreatepasswordActionInvalidToken()
+    {
+        /** @var \Magento\Customer\Model\Customer $customer */
+        $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Customer\Model\Customer')->load(1);
+
+        $token = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Helper\Data')
+            ->generateResetPasswordLinkToken();
+        $customer->changeResetPasswordLinkToken($token);
+
+        $this->getRequest()->setParam('token', 'INVALIDTOKEN');
+        $this->getRequest()->setParam('id', $customer->getId());
+
+        $this->dispatch('customer/account/createpassword');
+
+        // should be redirected to forgotpassword page
+        $response = $this->getResponse();
+        $this->assertEquals(302, $response->getHttpResponseCode());
+        $this->assertContains('customer/account/forgotpassword', $response->getHeader('Location')['value']);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testConfirmActionAlreadyActive()
+    {
+        /** @var \Magento\Customer\Model\Customer $customer */
+        $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Customer\Model\Customer')->load(1);
+
+        $this->getRequest()->setParam('key', 'abc');
+        $this->getRequest()->setParam('id', $customer->getId());
+
+        $this->dispatch('customer/account/confirm');
+        $this->getResponse()->getBody();
+    }
+
+    /**
+     * @magentoDbIsolation enabled
+     * @magentoAppIsolation enabled
+     * @magentoConfigFixture current_store customer/create_account/confirm 0
+     */
+    public function testNoConfirmCreatePostAction()
+    {
+        // Setting data for request
+        $this->getRequest()
+            ->setServer(array('REQUEST_METHOD' => 'POST'))
+            ->setParam('firstname', 'firstname1')
+            ->setParam('lastname', 'lastname1')
+            ->setParam('company', '')
+            ->setParam('email', 'test1@email.com')
+            ->setParam('password', 'password')
+            ->setParam('confirmation', 'password')
+            ->setParam('telephone', '5123334444')
+            ->setParam('street', array('1234 fake street', ''))
+            ->setParam('city', 'Austin')
+            ->setParam('region_id', 57)
+            ->setParam('region', '')
+            ->setParam('postcode', '78701')
+            ->setParam('country_id', 'US')
+            ->setParam('default_billing', '1')
+            ->setParam('default_shipping', '1')
+            ->setParam('is_subscribed', '0')
+            ->setPost('create_address', true);
+
+        $this->dispatch('customer/account/createPost');
+        $this->assertRedirect($this->stringContains('customer/account/index/'));
+        $this->assertSessionMessages(
+            $this->equalTo(['Thank you for registering with Main Website Store.']),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
+
+    /**
+     * @magentoDbIsolation enabled
+     * @magentoAppIsolation enabled
+     * @magentoConfigFixture current_store customer/create_account/confirm 1
+     */
+    public function testWithConfirmCreatePostAction()
+    {
+        // Setting data for request
+        $email = 'test2@email.com';
+        $this->getRequest()
+            ->setServer(array('REQUEST_METHOD' => 'POST'))
+            ->setParam('firstname', 'firstname2')
+            ->setParam('lastname', 'lastname2')
+            ->setParam('company', '')
+            ->setParam('email', $email)
+            ->setParam('password', 'password')
+            ->setParam('confirmation', 'password')
+            ->setParam('telephone', '5123334444')
+            ->setParam('street', array('1234 fake street', ''))
+            ->setParam('city', 'Austin')
+            ->setParam('region_id', 57)
+            ->setParam('region', '')
+            ->setParam('postcode', '78701')
+            ->setParam('country_id', 'US')
+            ->setParam('default_billing', '1')
+            ->setParam('default_shipping', '1')
+            ->setParam('is_subscribed', '1')
+            ->setPost('create_address', true);
+
+        $this->dispatch('customer/account/createPost');
+        $this->assertRedirect($this->stringContains('customer/account/index/'));
+        $this->assertSessionMessages(
+            $this->equalTo([
+                'Account confirmation is required. Please, check your email for the confirmation link. ' .
+                'To resend the confirmation email please ' .
+                '<a href="http://localhost/index.php/customer/account/confirmation/email/' .
+                $email . '/">click here</a>.'
+            ]),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testExistingEmailCreatePostAction()
+    {
+        // Setting data for request
+        $this->getRequest()
+            ->setServer(array('REQUEST_METHOD' => 'POST'))
+            ->setParam('firstname', 'firstname')
+            ->setParam('lastname', 'lastname')
+            ->setParam('company', '')
+            ->setParam('email', 'customer@example.com')
+            ->setParam('password', 'password')
+            ->setParam('confirmation', 'password')
+            ->setParam('telephone', '5123334444')
+            ->setParam('street', array('1234 fake street', ''))
+            ->setParam('city', 'Austin')
+            ->setParam('region_id', 57)
+            ->setParam('region', '')
+            ->setParam('postcode', '78701')
+            ->setParam('country_id', 'US')
+            ->setParam('default_billing', '1')
+            ->setParam('default_shipping', '1')
+            ->setParam('is_subscribed', '1')
+            ->setPost('create_address', true);
+
+        $this->dispatch('customer/account/createPost');
+        $this->assertRedirect($this->stringContains('customer/account/create/'));
+        $this->assertSessionMessages(
+            $this->equalTo(['There is already an account with this email address. ' .
+                'If you are sure that it is your email address, ' .
+                '<a href="http://localhost/index.php/customer/account/forgotpassword/">click here</a>' .
+                ' to get your password and access your account.']),
+            \Magento\Message\MessageInterface::TYPE_ERROR
+        );
+    }
+
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      */
@@ -92,4 +283,118 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController
         }
         $this->assertFalse($failed, 'Action is closed');
     }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/inactive_customer.php
+     */
+    public function testInactiveUserConfirmationAction()
+    {
+        $this->getRequest()
+            ->setServer(['REQUEST_METHOD' => 'POST'])
+            ->setPost(['email' => 'customer@needAconfirmation.com']);
+
+        $this->dispatch('customer/account/confirmation');
+        $this->assertRedirect($this->stringContains('customer/account/index'));
+        $this->assertSessionMessages(
+            $this->equalTo(['Please, check your email for confirmation key.']),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testActiveUserConfirmationAction()
+    {
+        $this->getRequest()
+            ->setServer(['REQUEST_METHOD' => 'POST'])
+            ->setPost([
+                'email' => 'customer@example.com'
+            ]);
+
+        $this->dispatch('customer/account/confirmation');
+        $this->assertRedirect($this->stringContains('customer/account/index'));
+        $this->assertSessionMessages(
+            $this->equalTo(['This email does not require confirmation.']),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
+
+    public function testForgotPasswordPostAction()
+    {
+        $email = 'customer@example.com';
+
+        $this->getRequest()
+            ->setPost([
+                'email' => $email
+            ]);
+
+        $this->dispatch('customer/account/forgotPasswordPost');
+        $this->assertRedirect($this->stringContains('customer/account/'));
+        $this->assertSessionMessages(
+            $this->equalTo([
+                "If there is an account associated with {$email} you will receive an email " .
+                'with a link to reset your password.'
+            ]),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
+
+    public function testForgotPasswordPostWithBadEmailAction()
+    {
+        $this->getRequest()
+            ->setPost([
+                'email' => 'bad@email'
+            ]);
+
+        $this->dispatch('customer/account/forgotPasswordPost');
+        $this->assertRedirect($this->stringContains('customer/account/forgotpassword'));
+        $this->assertSessionMessages(
+            $this->equalTo(['Please correct the email address.']),
+            \Magento\Message\MessageInterface::TYPE_ERROR
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     */
+    public function testResetPasswordPostNoTokenAction()
+    {
+        $this->getRequest()
+            ->setParam('id', 1)
+            ->setParam('token', '8ed8677e6c79e68b94e61658bd756ea5')
+            ->setPost([
+                'password' => 'new-password',
+                'confirmation' => 'new-password'
+            ]);
+
+        $this->dispatch('customer/account/resetPasswordPost');
+        $this->assertRedirect($this->stringContains('customer/account/'));
+        $this->assertSessionMessages(
+            $this->equalTo(['There was an error saving the new password.']),
+            \Magento\Message\MessageInterface::TYPE_ERROR
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer_rp_token.php
+     * @magentoConfigFixture customer/password/reset_link_expiration_period 10
+     */
+    public function testResetPasswordPostAction()
+    {
+        $this->getRequest()
+            ->setQuery('id', 1)
+            ->setQuery('token', '8ed8677e6c79e68b94e61658bd756ea5')
+            ->setPost([
+                'password' => 'new-password',
+                'confirmation' => 'new-password'
+            ]);
+
+        $this->dispatch('customer/account/resetPasswordPost');
+        $this->assertRedirect($this->stringContains('customer/account/login'));
+        $this->assertSessionMessages(
+            $this->equalTo(['Your password has been updated.']),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..a73cf8e0badaa8cd13b6f15586c134ab9043a5ac
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php
@@ -0,0 +1,179 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Controller;
+
+use Magento\TestFramework\Helper\Bootstrap;
+
+class AddressTest extends \Magento\TestFramework\TestCase\AbstractController
+{
+    protected function setUp()
+    {
+        parent::setUp();
+
+        $logger = $this->getMock('Magento\Logger', array(), array(), '', false);
+        $session = Bootstrap::getObjectManager()
+            ->create('Magento\Customer\Model\Session', array($logger));
+        $session->login('customer@example.com', 'password');
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testIndexAction()
+    {
+        $this->dispatch('customer/address/index');
+
+        $body = $this->getResponse()->getBody();
+        $this->assertContains('Default Billing Address', $body);
+        $this->assertContains('Default Shipping Address', $body);
+        $this->assertContains('Green str, 67', $body);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testFormAction()
+    {
+        $this->dispatch('customer/address/edit');
+
+        $body = $this->getResponse()->getBody();
+        $this->assertContains('value="Firstname"', $body);
+        $this->assertContains('value="Lastname"', $body);
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     */
+    public function testFormPostAction()
+    {
+        $this->getRequest()
+            ->setParam('id', 2)
+            ->setServer(['REQUEST_METHOD' => 'POST'])
+            ->setPost([
+                'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(),
+                'firstname' => 'James',
+                'lastname' => 'Bond',
+                'company' => 'Ebay',
+                'telephone' => '1112223333',
+                'fax' => '2223334444',
+                'street' => ['1234 Monterey Rd', 'Apt 13'],
+                'city' => 'Kyiv',
+                'region' => 'Kiev',
+                'postcode' => '55555',
+                'country_id' => 'UA',
+                'success_url' => '',
+                'error_url' => ''
+            ]);
+        // we are overwriting the address coming from the fixture
+        $this->dispatch('customer/address/formPost');
+
+        $this->assertRedirect($this->stringContains('customer/address/index'));
+        $this->assertSessionMessages(
+            $this->equalTo(['The address has been saved.']),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+        /** @var \Magento\Customer\Service\V1\CustomerAddressService $addressService */
+        $addressService = Bootstrap::getObjectManager()->create('Magento\Customer\Service\V1\CustomerAddressService');
+        $address = $addressService->getAddressById(2);
+
+        $this->assertEquals('UA', $address->getCountryId());
+        $this->assertEquals('Kyiv', $address->getCity());
+        $this->assertEquals('Kiev', $address->getRegion()->getRegion());
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testFailedFormPostAction()
+    {
+        $this->getRequest()
+            ->setParam('id', 1)
+            ->setServer(['REQUEST_METHOD' => 'POST'])
+            ->setPost([
+                'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(),
+                'firstname' => 'James',
+                'lastname' => 'Bond',
+                'company' => 'Ebay',
+                'telephone' => '1112223333',
+                'fax' => '2223334444',
+                // omit street and city to fail validation
+                'region_id' => '12',
+                'region' => 'California',
+                'postcode' => '55555',
+                'country_id' => 'US',
+                'success_url' => '',
+                'error_url' => ''
+            ]);
+        // we are overwriting the address coming from the fixture
+        $this->dispatch('customer/address/formPost');
+
+        $this->assertRedirect($this->stringContains('customer/address/edit'));
+        $this->assertSessionMessages(
+            $this->equalTo(['street is a required field.', 'city is a required field.']),
+            \Magento\Message\MessageInterface::TYPE_ERROR
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testDeleteAction()
+    {
+        $this->getRequest()
+            ->setParam('id', 1);
+        // we are overwriting the address coming from the fixture
+        $this->dispatch('customer/address/delete');
+
+        $this->assertRedirect($this->stringContains('customer/address/index'));
+        $this->assertSessionMessages(
+            $this->equalTo(['The address has been deleted.']),
+            \Magento\Message\MessageInterface::TYPE_SUCCESS
+        );
+    }
+
+    /**
+     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     */
+    public function testWrongAddressDeleteAction()
+    {
+        $this->getRequest()
+            ->setParam('id', 555);
+        // we are overwriting the address coming from the fixture
+        $this->dispatch('customer/address/delete');
+
+        $this->assertRedirect($this->stringContains('customer/address/index'));
+        $this->assertSessionMessages(
+            $this->equalTo(['An error occurred while deleting the address.']),
+            \Magento\Message\MessageInterface::TYPE_ERROR
+        );
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php
index ee6d367f4f2e5cd491583cf7a0bdf43a7af0cd06..4f4cd62d74ccc82e6c39e1934cdc5f9392d3233b 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php
@@ -18,37 +18,44 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
- * @subpackage  integration_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Customer\Controller\Adminhtml;
 
+use Magento\Message\MessageInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+
 /**
  * @magentoAppArea adminhtml
- * @magentoDataFixture customerGroupDataFixture
  */
 class GroupTest extends \Magento\Backend\Utility\Controller
 {
+    const TAX_CLASS_ID = 3;
+    const CUSTOMER_GROUP_CODE = 'New Customer Group';
+
     protected static $_customerGroupId;
 
-    public static function customerGroupDataFixture()
+    public static function setUpBeforeClass()
     {
-        /** @var \Magento\Customer\Model\Group $group */
-        $group = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\Customer\Model\Group');
+        /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */
+        $groupService = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface');
 
-        $groupData = array(
-            'customer_group_code' => 'New Customer Group',
-            'tax_class_id' => 3
-        );
-        $group->setData($groupData);
-        $group->save();
-        self::$_customerGroupId = $group->getId();
+        $group = new \Magento\Customer\Service\V1\Dto\CustomerGroup([
+          'id' => null,
+          'code' => self::CUSTOMER_GROUP_CODE,
+          'tax_class_id' => self::TAX_CLASS_ID
+        ]);
+        self::$_customerGroupId = $groupService->saveGroup($group);;
+    }
+
+    public static function tearDownAfterClass()
+    {
+        /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */
+        $groupService = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface');
+        $groupService->deleteGroup(self::$_customerGroupId);
     }
 
     public function testNewAction()
@@ -58,6 +65,9 @@ class GroupTest extends \Magento\Backend\Utility\Controller
         $this->assertRegExp('/<h1 class\="title">\s*New Customer Group\s*<\/h1>/', $responseBody);
     }
 
+    /**
+     * @magentoDbIsolation enabled
+     */
     public function testDeleteActionExistingGroup()
     {
         $this->getRequest()->setParam('id', self::$_customerGroupId);
@@ -67,8 +77,7 @@ class GroupTest extends \Magento\Backend\Utility\Controller
          * Check that success message is set
          */
         $this->assertSessionMessages(
-            $this->equalTo(array('The customer group has been deleted.')),
-            \Magento\Message\MessageInterface::TYPE_SUCCESS
+            $this->equalTo(['The customer group has been deleted.']), MessageInterface::TYPE_SUCCESS
         );
     }
 
@@ -81,7 +90,101 @@ class GroupTest extends \Magento\Backend\Utility\Controller
          * Check that error message is set
          */
         $this->assertSessionMessages(
-            $this->equalTo(array('The customer group no longer exists.')), \Magento\Message\MessageInterface::TYPE_ERROR
+            $this->equalTo(['The customer group no longer exists.']), MessageInterface::TYPE_ERROR
+        );
+    }
+
+    /**
+     * @magentoDbIsolation enabled
+     */
+    public function testSaveActionExistingGroup()
+    {
+        $this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
+        $this->getRequest()->setParam('id', self::$_customerGroupId);
+        $this->getRequest()->setParam('code', self::CUSTOMER_GROUP_CODE);
+
+        $this->dispatch('backend/customer/group/save');
+
+        $this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_ERROR);
+        $this->assertSessionMessages($this->logicalNot($this->isEmpty()), MessageInterface::TYPE_SUCCESS);
+
+        $this->assertSessionMessages(
+            $this->equalTo(['The customer group has been saved.']), MessageInterface::TYPE_SUCCESS
+        );
+
+        /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */
+        $groupService = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface');
+        $customerGroupData = $groupService->getGroup(self::$_customerGroupId)->__toArray();
+        ksort($customerGroupData);
+
+        $this->assertEquals(
+            [
+                'code' => self::CUSTOMER_GROUP_CODE,
+                'id' => self::$_customerGroupId,
+                'tax_class_id' => self::TAX_CLASS_ID
+            ],
+            $customerGroupData
         );
     }
+
+    /**
+     * @magentoDbIsolation enabled
+     */
+    public function testSaveActionExistingGroupWithEmptyGroupCode()
+    {
+        $this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
+        $this->getRequest()->setParam('id', self::$_customerGroupId);
+        $this->getRequest()->setParam('code', '');
+
+        $this->dispatch('backend/customer/group/save');
+
+        $this->assertSessionMessages(
+            $this->equalTo(['The customer group has been saved.']), MessageInterface::TYPE_SUCCESS
+        );
+
+        /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */
+        $groupService = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface');
+
+        $this->assertEmpty($groupService->getGroup(self::$_customerGroupId)->getCode());
+    }
+
+    public function testSaveActionForwardNewCreateNewGroup()
+    {
+        $this->dispatch('backend/customer/group/save');
+        $responseBody = $this->getResponse()->getBody();
+        $this->assertRegExp('/<h1 class\="title">\s*New Customer Group\s*<\/h1>/', $responseBody);
+    }
+
+    public function testSaveActionForwardNewEditExistingGroup()
+    {
+        $this->getRequest()->setParam('id', self::$_customerGroupId);
+        $this->dispatch('backend/customer/group/save');
+
+        /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */
+        $groupService = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface');
+        $customerGroupCode = $groupService->getGroup(self::$_customerGroupId)->getCode();
+
+        $responseBody = $this->getResponse()->getBody();
+        $this->assertRegExp('/<h1 class\="title">\s*' . $customerGroupCode . '\s*<\/h1>/', $responseBody);
+    }
+
+    public function testSaveActionNonExistingGroupId()
+    {
+        $this->getRequest()->setParam('id', 10000);
+        $this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
+
+        $this->dispatch('backend/customer/group/save');
+
+        $this->assertSessionMessages($this->logicalNot($this->isEmpty()), MessageInterface::TYPE_ERROR);
+        $this->assertSessionMessages(
+            $this->equalTo(['No such entity with groupId = 10000']), MessageInterface::TYPE_ERROR
+        );
+
+        /** @var \Magento\Session\SessionManagerInterface $sessionManager */
+        $sessionManager = Bootstrap::getObjectManager()->get('Magento\Session\SessionManagerInterface');
+        $this->assertEmpty($sessionManager->getCustomerGroupData());
+    }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
index c0871e542f278ff72b5da2dae2d74036441c2326..2df3308bd7310e4dcf0aa6d848d3b9a68f5beee3 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
@@ -95,6 +95,9 @@ class IndexTest extends \Magento\Backend\Utility\Controller
         $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new'));
     }
 
+    /**
+     * @magentoDbIsolation enabled
+     */
     public function testSaveActionWithInvalidCustomerAddressData()
     {
         $post = array(
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..64e4bcecd2ca966c9517549cd700d42562748483
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Config\Source\Group;
+
+use Magento\TestFramework\Helper\Bootstrap;
+
+/**
+ * Class \Magento\Customer\Model\Config\Source\Group\Multiselect
+ */
+class MultiselectTest extends \PHPUnit_Framework_TestCase
+{
+    public function testToOptionArray()
+    {
+        /** @var Multiselect $multiselect */
+        $multiselect = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Model\Config\Source\Group\Multiselect');
+        $this->assertEquals(
+            [
+                ['value' => 1, 'label' => 'General'],
+                ['value' => 2, 'label' => 'Wholesale'],
+                ['value' => 3, 'label' => 'Retailer']
+            ],
+            $multiselect->toOptionArray()
+        );
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/GroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/GroupTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..e019b637827f018e2084608ec254a49abf0970d1
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/GroupTest.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Config\Source;
+
+use Magento\TestFramework\Helper\Bootstrap;
+
+/**
+ * Class \Magento\Customer\Model\Config\Source\Group
+ */
+class GroupTest extends \PHPUnit_Framework_TestCase
+{
+    public function testToOptionArray()
+    {
+        /** @var Group $group */
+        $group = Bootstrap::getObjectManager()
+            ->get('Magento\Customer\Model\Config\Source\Group');
+        $this->assertEquals(
+            [
+                ['value' => '', 'label' => '-- Please Select --'],
+                ['value' => 1, 'label' => 'General'],
+                ['value' => 2, 'label' => 'Wholesale'],
+                ['value' => 3, 'label' => 'Retailer']
+            ],
+            $group->toOptionArray()
+        );
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/GroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/GroupTest.php
index 0c923d144f7b9162f5ff985002a8db8f9ac92705..a063757ee385cf4fca8ec2867c8364f2e5333674 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/GroupTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/GroupTest.php
@@ -42,7 +42,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase
 
     public function testCRUD()
     {
-        $this->_model->setCustomerGroupCode('test');
+        $this->_model->setCode('test');
         $crud = new \Magento\TestFramework\Entity($this->_model, array('customer_group_code' => uniqid()));
         $crud->testCrud();
     }
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..45d967aedbabbd8f267b860460200da0f86463cb
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata;
+
+use Magento\TestFramework\Helper\Bootstrap;
+
+class FormFactoryTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var array */
+    private $_requestData;
+
+    /** @var array */
+    private $_expectedData;
+
+    public function setUp()
+    {
+        $this->_requestData = [
+            'id' => 13,
+            'default_shipping' => true,
+            'default_billing' => false,
+            'company' => 'eBay Inc.',
+            'fax' => '(444) 444-4444',
+            'middlename' => 'MiddleName',
+            'prefix' => 'Mr.',
+            'suffix' => 'Esq.',
+            'vat_id' => 'S46',
+            'firstname' => 'John',
+            'lastname' => 'Doe',
+            'street' => ['2211 North First Street'],
+            'city' => 'San Jose',
+            'country_id' => 'US',
+            'postcode' => '95131',
+            'telephone' => '5135135135',
+            'region_id' => 12,
+            'region' => 'California'
+        ];
+
+        $this->_expectedData = $this->_requestData;
+
+        unset($this->_expectedData['id']);
+        unset($this->_expectedData['default_shipping']);
+        unset($this->_expectedData['default_billing']);
+        unset($this->_expectedData['middlename']);
+        unset($this->_expectedData['prefix']);
+        unset($this->_expectedData['suffix']);
+    }
+
+    public function testCreate()
+    {
+        /** @var FormFactory $formFactory */
+        $formFactory = Bootstrap::getObjectManager()
+            ->create('Magento\Customer\Model\Metadata\FormFactory');
+        $form = $formFactory->create('customer_address', 'customer_address_edit');
+
+        $this->assertInstanceOf('\Magento\Customer\Model\Metadata\Form', $form);
+        $this->assertNotEmpty($form->getAttributes());
+
+        /** @var \Magento\App\RequestInterface $request */
+        $request = Bootstrap::getObjectManager()->get('Magento\App\RequestInterface');
+        $request->setParams($this->_requestData);
+
+        $this->assertEquals($this->_expectedData, $form->restoreData($form->extractData($request)));
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php
index 06d02c8b2a54fa18f92536057692f289854a4f51..19b6d62e0663ae72f9eef4a63f67262fd93ad147 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php
@@ -18,64 +18,63 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Customer
- * @subpackage  integration_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Customer\Model\Metadata;
 
+use Magento\TestFramework\Helper\Bootstrap;
+
 class FormTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Customer\Model\Metadata\FormFactory
+     * @var Form
      */
-    protected $_formFactory;
+    protected $_form;
 
-    /**
-     * @var array
-     */
-    protected $_attributes = [];
+    /** @var array */
+    protected $_attributes;
 
-    /**
-     * @var \Magento\App\RequestInterface
-     */
+    /** @var \Magento\App\RequestInterface */
     protected $_request;
 
     /** @var array */
-    protected $_expected = [];
+    protected $_expected;
+
+    /** @var array */
+    protected $_requestData = [];
 
     public function setUp()
     {
-        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-        $this->_formFactory = $objectManager
-            ->create('Magento\Customer\Model\Metadata\FormFactory');
+        $objectManager = Bootstrap::getObjectManager();
+
+        /** @var FormFactory $formFactory */
+        $formFactory = $objectManager->create('Magento\Customer\Model\Metadata\FormFactory');
+        $this->_form = $formFactory->create('customer_address', 'customer_address_edit');
 
-        $this->_requestData = [
+        $this->_attributes = [
             'id' => 14,
-            'default_shipping' => true,
-            'default_billing' => false,
+            'default_shipping' => 1,
+            'default_billing' => 0,
             'company' => 'Company Name',
             'fax' => '(555) 555-5555',
             'middlename' => 'Mid',
             'prefix' => 'Mr.',
             'suffix' => 'Esq.',
-            'vat_id' => 'S45',
+            'vat_id' => '',
             'firstname' => 'Jane',
             'lastname' => 'Doe',
-            'street' => ['7700 W Parmer Ln'],
-            'city' => 'Austin',
+            'street' => ['2211 North First Street'],
+            'city' => 'San Jose',
             'country_id' => 'US',
-            'postcode' => '78620',
+            'postcode' => '95131',
             'telephone' => '5125125125',
-            'region_id' => 0,
-            'region' => 'Texas',
+            'region_id' => 12,
+            'region' => 'California'
         ];
 
-        $this->_expected = $this->_requestData;
-        /** Unset data which is not part of the form */
+        $this->_expected = $this->_attributes;
+
         unset($this->_expected['id']);
         unset($this->_expected['default_shipping']);
         unset($this->_expected['default_billing']);
@@ -84,18 +83,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
         unset($this->_expected['suffix']);
 
         $this->_request = $objectManager->get('Magento\App\RequestInterface');
-        $this->_request->setParams($this->_requestData);
+        $this->_request->setParams($this->_attributes);
     }
 
     public function testCompactData()
     {
-        $addressForm = $this->_formFactory->create(
-            'customer_address',
-            'customer_address_edit',
-            []
-        );
-        $addressData = $addressForm->extractData($this->_request);
-        $attributeValues = $addressForm->compactData($addressData);
+        $attributeValues = $this->_form->compactData($this->_form->extractData($this->_request));
         $this->assertEquals($this->_expected, $attributeValues);
     }
 
@@ -105,22 +98,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
             'prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city', 'country_id',
             'region', 'region_id', 'postcode', 'telephone', 'fax', 'vat_id'
         ];
-        $addressForm = $this->_formFactory->create(
-            'customer_address',
-            'customer_address_edit',
-            []
-        );
-        $this->assertEquals($expectedAttributes, array_keys($addressForm->getAttributes()));
+        $this->assertEquals($expectedAttributes, array_keys($this->_form->getAttributes()));
     }
 
     public function testGetSystemAttributes()
     {
-        $addressForm = $this->_formFactory->create(
-            'customer_address',
-            'customer_address_edit',
-            []
-        );
-        $this->assertCount(15, $addressForm->getSystemAttributes());
+        $this->assertCount(15, $this->_form->getSystemAttributes());
     }
 
     /**
@@ -129,11 +112,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
     public function testGetUserAttributes()
     {
         $expectedAttributes = ['user_attribute'];
-        $addressForm = $this->_formFactory->create(
-            'customer_address',
-            'customer_address_edit',
-            []
-        );
-        $this->assertEquals($expectedAttributes, array_keys($addressForm->getUserAttributes()));
+        $this->assertEquals($expectedAttributes, array_keys($this->_form->getUserAttributes()));
+    }
+
+    public function testRestoreData()
+    {
+        $attributeValues = $this->_form->restoreData($this->_form->extractData($this->_request));
+        $this->assertEquals($this->_expected, $attributeValues);
     }
-}
\ No newline at end of file
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php
index 1589d285eebc70a788aa94ff66a1aeeb65243448..c98f4ad6ee2084c7c72387e114ecc7ba5f916ce3 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php
@@ -2,10 +2,12 @@
 
 namespace Magento\Customer\Service\V1;
 use Magento\Customer\Service\V1;
-use Magento\Customer\Service\Entity\V1\Exception;
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+use Magento\Exception\StateException;
 
 /**
- * Integration test for service layer \Magento\Customer\Service\CustomerV1
+ * Integration test for service layer \Magento\Customer\Service\V1\CustomerAccountService
  *
  * Magento
  *
@@ -116,7 +118,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
+     * @expectedException \Magento\Exception\AuthenticationException
      * @expectedExceptionMessage Invalid login or password
      */
     public function testLoginWrongPassword()
@@ -128,7 +130,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
+     * @expectedException \Magento\Exception\AuthenticationException
      * @expectedExceptionMessage Invalid login or password
      */
     public function testLoginWrongUsername()
@@ -159,8 +161,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/inactive_customer.php
      *
-     * @expectedException \Magento\Core\Exception
-     * @expectedExceptionMessage Wrong confirmation key
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH
      */
     public function testActivateAccountWrongKey()
     {
@@ -169,14 +171,23 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerModel->load(1);
         $key = $customerModel->getConfirmation();
 
-        $this->_service->activateAccount($customerModel->getId(), $key . $key);
+        try {
+            $this->_service->activateAccount($customerModel->getId(), $key . $key);
+            $this->fail('Expected exception was not thrown');
+        } catch (InputException $ie) {
+            $expectedParams = [
+                [
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                    'fieldName' => 'confirmation',
+                    'value' => $key . $key,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $ie->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/inactive_customer.php
-     *
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionMessage No customer with customerId 12341 exists.
      */
     public function testActivateAccountWrongAccount()
     {
@@ -184,16 +195,23 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerModel = $this->_objectManager->create('Magento\Customer\Model\Customer');
         $customerModel->load(1);
         $key = $customerModel->getConfirmation();
-
-        $this->_service->activateAccount('1234' . $customerModel->getId(), $key);
+        try {
+            $this->_service->activateAccount('1234' . $customerModel->getId(), $key);
+            $this->fail('Expected exception not thrown.');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'customerId' => '12341',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/inactive_customer.php
      * @magentoAppArea frontend
      *
-     * @expectedException  \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionMessage Customer account is already active
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INVALID_STATE
      */
     public function testActivateAccountAlreadyActive()
     {
@@ -224,50 +242,90 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::EXPIRED
      */
     public function testValidateResetPasswordLinkTokenExpired()
     {
-        $this->_service->validateResetPasswordLinkToken(1, 'some_token');
+        $resetToken = 'lsdj579slkj5987slkj595lkj';
+
+        $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [
+            'rp_token' => $resetToken,
+            'rp_token_created_at' => '1970-01-01',
+        ]));
+        $this->_customerService->saveCustomer($this->_customerBuilder->create());
+
+        $this->_service->validateResetPasswordLinkToken(1, $resetToken);
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_RESET_TOKEN
      */
     public function testValidateResetPasswordLinkTokenInvalid()
     {
-        $this->_service->validateResetPasswordLinkToken(0, null);
+        $resetToken = 'lsdj579slkj5987slkj595lkj';
+        $invalidToken = 0;
+
+        $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [
+            'rp_token' => $resetToken,
+            'rp_token_created_at' => date('Y-m-d')
+        ]));
+        $this->_customerService->saveCustomer($this->_customerBuilder->create());
+
+        try {
+            $this->_service->validateResetPasswordLinkToken(1, $invalidToken);
+            $this->fail('Expected exception not thrown.');
+        } catch (InputException $ie) {
+            $expectedParams = [
+                [
+                    'value' => $invalidToken,
+                    'fieldName' => 'resetPasswordLinkToken',
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $ie->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_CUSTOMER_ID
-     * @expectedExceptionMessage No customer with customerId 4200 exists
      */
     public function testValidateResetPasswordLinkTokenWrongUser()
     {
         $resetToken = 'lsdj579slkj5987slkj595lkj';
 
-
-        $this->_service->validateResetPasswordLinkToken(4200, $resetToken);
+        try {
+            $this->_service->validateResetPasswordLinkToken(4200, $resetToken);
+            $this->fail('Expected exception not thrown.');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'customerId' => '4200',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_RESET_TOKEN
-     * @expectedExceptionMessage Invalid password reset token
      */
     public function testValidateResetPasswordLinkTokenNull()
     {
-        $this->_service->validateResetPasswordLinkToken(null, null);
+        try {
+            $this->_service->validateResetPasswordLinkToken(1, null);
+            $this->fail('Expected exception not thrown.');
+        } catch (InputException $ie) {
+            $expectedParams = [
+                [
+                    'value' => null,
+                    'fieldName' => 'resetPasswordLinkToken',
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $ie->getParams());
+        }
     }
 
     /**
@@ -284,15 +342,21 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_EMAIL_NOT_FOUND
-     * @expectedExceptionMessage No customer found for the provided email and website ID
      */
     public function testSendPasswordResetLinkBadEmailOrWebsite()
     {
         $email = 'foo@example.com';
 
-        $this->_service->sendPasswordResetLink($email, 0);
+        try {
+            $this->_service->sendPasswordResetLink($email, 0);
+            $this->fail('Expected exception not thrown.');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'email' => $email,
+                'websiteId' => 0,
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+        }
     }
 
     /**
@@ -315,9 +379,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
-     * @expectedExceptionMessage Your password reset link has expired.
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::EXPIRED
      */
     public function testResetPasswordTokenExpired()
     {
@@ -326,7 +389,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [
             'rp_token' => $resetToken,
-            'rp_token_created_at' => '1970-01-01'
+            'rp_token_created_at' => '1970-01-01',
         ]));
         $this->_customerService->saveCustomer($this->_customerBuilder->create());
 
@@ -336,14 +399,11 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
-     * @expectedExceptionMessage Your password reset link has expired.
      */
     public function testResetPasswordTokenInvalid()
     {
         $resetToken = 'lsdj579slkj5987slkj595lkj';
-        $invalidToken = $resetToken . 'invalid';
+        $invalidToken = 0;
         $password = 'password_secret';
 
         $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [
@@ -352,15 +412,23 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         ]));
         $this->_customerService->saveCustomer($this->_customerBuilder->create());
 
-        $this->_service->resetPassword(1, $password, $invalidToken);
+        try {
+            $this->_service->resetPassword(1, $password, $invalidToken);
+            $this->fail('Expected exception not thrown.');
+        } catch (InputException $ie) {
+            $expectedParams = [
+                [
+                    'value' => $invalidToken,
+                    'fieldName' => 'resetPasswordLinkToken',
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $ie->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_CUSTOMER_ID
-     * @expectedExceptionMessage No customer with customerId 4200 exists
      */
     public function testResetPasswordTokenWrongUser()
     {
@@ -372,16 +440,19 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             'rp_token_created_at' => date('Y-m-d')
         ]));
         $this->_customerService->saveCustomer($this->_customerBuilder->create());
-
-        $this->_service->resetPassword(4200, $password, $resetToken);
+        try {
+            $this->_service->resetPassword(4200, $password, $resetToken);
+            $this->fail('Expected exception not thrown.');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'customerId' => '4200',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_RESET_TOKEN
-     * @expectedExceptionMessage Invalid password reset token
      */
     public function testResetPasswordTokenInvalidUserId()
     {
@@ -393,8 +464,20 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             'rp_token_created_at' => date('Y-m-d')
         ]));
         $this->_customerService->saveCustomer($this->_customerBuilder->create());
+        try {
+            $this->_service->resetPassword(0, $password, $resetToken);
+            $this->fail('Expected exception not thrown.');
+        } catch (InputException $ie) {
+            $expectedParams = [
+                [
+                    'value' => 0,
+                    'fieldName' => 'customerId',
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $ie->getParams());
+        }
 
-        $this->_service->resetPassword(0, $password, $resetToken);
     }
 
     /**
@@ -409,26 +492,29 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_EMAIL_NOT_FOUND
      */
     public function testSendConfirmationNoEmail()
     {
-        $this->_service->sendConfirmation('wrongemail@example.com');
+        try {
+            $this->_service->sendConfirmation('wrongemail@example.com');
+            $this->fail('Expected exception not thrown.');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'email' => 'wrongemail@example.com',
+                'websiteId' => '1',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+        }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
      *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_CONFIRMATION_NOT_NEEDED
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INVALID_STATE
      */
     public function testSendConfirmationNotNeeded()
     {
         $this->_service->sendConfirmation('customer@example.com');
     }
-
-
-
 }
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
index 79fe6c642b857f1b20b059974b6f47977f75e906..d65bdb8d28e83cbc51abf566efb5a9a5762ca143 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
@@ -1,9 +1,4 @@
 <?php
-
-namespace Magento\Customer\Service\V1;
-use Magento\Customer\Service\V1;
-use Magento\Customer\Service\Entity\V1\Exception;
-
 /**
  * Integration test for service layer \Magento\Customer\Service\V1\CustomerAddressService
  *
@@ -27,7 +22,14 @@ use Magento\Customer\Service\Entity\V1\Exception;
  *
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- *
+ */
+namespace Magento\Customer\Service\V1;
+
+use Magento\Customer\Service\V1;
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+
+/**
  * @SuppressWarnings(PHPMD.TooManyMethods)
  * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  */
@@ -62,11 +64,13 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->setDefaultBilling(true)
             ->setDefaultShipping(true)
             ->setPostcode('75477')
-            ->setRegion(new V1\Dto\Region([
-                'region_code' => 'AL',
-                'region' => 'Alabama',
-                'region_id' => 1
-            ]))
+            ->setRegion(
+                new V1\Dto\Region([
+                    'region_code' => 'AL',
+                    'region'      => 'Alabama',
+                    'region_id'   => 1
+                ])
+            )
             ->setStreet(['Green str, 67'])
             ->setTelephone('3468676')
             ->setCity('CityM')
@@ -81,11 +85,13 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->setDefaultBilling(false)
             ->setDefaultShipping(false)
             ->setPostcode('47676')
-            ->setRegion(new V1\Dto\Region([
-                'region_code' => 'AL',
-                'region' => 'Alabama',
-                'region_id' => 1
-            ]))
+            ->setRegion(
+                new V1\Dto\Region([
+                    'region_code' => 'AL',
+                    'region'      => 'Alabama',
+                    'region_id'   => 1
+                ])
+            )
             ->setStreet(['Black str, 48'])
             ->setCity('CityX')
             ->setTelephone('3234676')
@@ -97,15 +103,15 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
      * @magentoAppIsolation enabled
      */
     public function testSaveAddressChanges()
     {
         $customerId = 1;
-        $address = $this->_service->getAddressById($customerId, 2);
+        $address = $this->_service->getAddressById(2);
         $proposedAddressBuilder = $this->_addressBuilder->populate($address);
         $proposedAddressBuilder->setTelephone('555' . $address->getTelephone());
         $proposedAddress = $proposedAddressBuilder->create();
@@ -119,9 +125,9 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
      * @magentoAppIsolation enabled
      */
     public function testSaveAddressesIdSetButNotAlreadyExisting()
@@ -145,17 +151,17 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
      * @magentoAppIsolation enabled
      */
     public function testGetAddresses()
     {
         $customerId = 1;
         $addresses = $this->_service->getAddresses($customerId);
-        $this->assertEquals(2, count($this->_expectedAddresses) );
-        $this->assertEquals(2, count($addresses) );
+        $this->assertEquals(2, count($this->_expectedAddresses));
+        $this->assertEquals(2, count($addresses));
         $this->_assertAddressAndRegionArrayEquals(
             $this->_expectedAddresses[0]->__toArray(),
             $addresses[0]->__toArray()
@@ -167,9 +173,9 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
      * @magentoAppIsolation enabled
      */
     public function testGetDefaultBillingAddress()
@@ -180,34 +186,41 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
      * @magentoAppIsolation enabled
      */
     public function testGetAddressById()
     {
-        $customerId = 1;
         $addressId = 2;
-        $addresses = $this->_service->getAddressById($customerId, $addressId);
+        $addresses = $this->_service->getAddressById($addressId);
         $this->assertEquals($this->_expectedAddresses[1], $addresses);
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_ADDRESS_NOT_FOUND
      */
     public function testGetAddressByIdBadAddrId()
     {
-        // Should throw the address not found excetion
-        $this->_service->getAddressById(1, 12345);
+        // Should throw the address not found exception
+        try {
+            $this->_service->getAddressById(12345);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (NoSuchEntityException $exception) {
+            $this->assertSame($exception->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $exception->getParams(),
+                [
+                    'addressId' => 12345
+                ]
+            );
+        }
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
      * @magentoAppIsolation enabled
      */
     public function testSaveNewAddress()
@@ -227,17 +240,22 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
      * @magentoAppIsolation enabled
      */
     public function testSaveNewAddressWithAttributes()
     {
-        $this->_addressBuilder->populateWithArray(array_merge($this->_expectedAddresses[1]->__toArray(), [
-            'firstname' => 'Jane',
-            'id' => 4200,
-            'weird' => 'something_strange_with_hair'
-        ]))->setId(null);
+        $this->_addressBuilder->populateWithArray(
+            array_merge(
+                $this->_expectedAddresses[1]->__toArray(),
+                [
+                    'firstname' => 'Jane',
+                    'id'        => 4200,
+                    'weird'     => 'something_strange_with_hair'
+                ]
+            )
+        )->setId(null);
         $proposedAddress = $this->_addressBuilder->create();
 
         $customerId = 1;
@@ -250,45 +268,58 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
      * @magentoAppIsolation enabled
      */
     public function testSaveNewInvalidAddresses()
     {
         $firstAddressBuilder = $this->_addressBuilder->populateWithArray(
-            array_merge($this->_expectedAddresses[0]->__toArray(), [
-                'firstname' => null
-            ])
+            array_merge(
+                $this->_expectedAddresses[0]->__toArray(),
+                [
+                    'firstname' => null
+                ]
+            )
         )->setId(null);
         $firstAddress = $firstAddressBuilder->create();
         $secondAddressBuilder = $this->_addressBuilder->populateWithArray(
-            array_merge($this->_expectedAddresses[0]->__toArray(), [
-                'lastname' => null
-            ])
+            array_merge(
+                $this->_expectedAddresses[0]->__toArray(),
+                [
+                    'lastname' => null
+                ]
+            )
         )->setId(null);
         $secondAddress = $secondAddressBuilder->create();
         $customerId = 1;
         try {
             $this->_service->saveAddresses($customerId, [$firstAddress, $secondAddress]);
-        } catch (\Magento\Customer\Service\Entity\V1\AggregateException $ae) {
-            $failures = $ae->getExceptions();
-            $firstAddressError = $failures[0];
-            $this->assertInstanceOf('\Magento\Customer\Service\Entity\V1\Exception', $firstAddressError);
-            $this->assertInstanceOf('\Magento\Validator\ValidatorException', $firstAddressError->getPrevious());
-            $this->assertSame('Please enter the first name.', $firstAddressError->getPrevious()->getMessage());
-
-            $secondAddressError = $failures[1];
-            $this->assertInstanceOf('\Magento\Customer\Service\Entity\V1\Exception', $secondAddressError);
-            $this->assertInstanceOf('\Magento\Validator\ValidatorException', $secondAddressError->getPrevious());
-            $this->assertSame('Please enter the last name.', $secondAddressError->getPrevious()->getMessage());
-            return;
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (InputException $exception) {
+            $this->assertSame($exception->getCode(), \Magento\Exception\InputException::INPUT_EXCEPTION);
+            $this->assertSame(
+                $exception->getParams(),
+                [
+                    [
+                        'index' => 0,
+                        'fieldName' => 'firstname',
+                        'code'      => 'REQUIRED_FIELD',
+                        'value'     => null
+                    ],
+                    [
+                        'index' => 1,
+                        'fieldName' => 'lastname',
+                        'code'      => 'REQUIRED_FIELD',
+                        'value'     => null
+                    ]
+                ]
+            );
         }
-        $this->fail('Expected AggregateException not caught.');
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
      * @magentoAppIsolation enabled
      */
     public function testSaveNewAddressDefaults()
@@ -315,8 +346,8 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
      * @magentoAppIsolation enabled
      */
     public function testSaveSeveralNewAddressesSameDefaults()
@@ -363,8 +394,8 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
      * @magentoAppIsolation enabled
      */
     public function testSaveSeveralNewAddressesDifferentDefaults()
@@ -419,9 +450,9 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
+     * @magentoDataFixture  Magento/Customer/_files/customer.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_address.php
+     * @magentoDataFixture  Magento/Customer/_files/customer_two_addresses.php
      * @magentoAppIsolation enabled
      */
     public function testSaveAddressesNoAddresses()
@@ -433,24 +464,34 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($this->_expectedAddresses, $addresses);
     }
 
-    /**
-     * @expectedException Exception
-     * @expectedExceptionMessage No customer with customerId 4200 exists
-     */
     public function testSaveAddressesCustomerIdNotExist()
     {
         $proposedAddress = $this->_createSecondAddressBuilder()->create();
-        $this->_service->saveAddresses(4200, [$proposedAddress]);
+        try {
+            $this->_service->saveAddresses(4200, [$proposedAddress]);
+            $this->fail('Expected exception not thrown');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'customerId' => '4200',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+            $this->assertEquals('No such entity with customerId = 4200', $nsee->getMessage());
+        }
     }
 
-    /**
-     * @expectedException Exception
-     * @expectedExceptionMessage No customer with customerId this_is_not_a_valid_id exists
-     */
     public function testSaveAddressesCustomerIdInvalid()
     {
         $proposedAddress = $this->_createSecondAddressBuilder()->create();
-        $this->_service->saveAddresses('this_is_not_a_valid_id', [$proposedAddress]);
+        try {
+            $this->_service->saveAddresses('this_is_not_a_valid_id', [$proposedAddress]);
+            $this->fail('Expected exception not thrown');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'customerId' => 'this_is_not_a_valid_id',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+            $this->assertEquals('No such entity with customerId = this_is_not_a_valid_id', $nsee->getMessage());
+        }
     }
 
     /**
@@ -459,58 +500,47 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
      */
     public function testDeleteAddressFromCustomer()
     {
-        $customerId = 1;
         $addressId = 1;
         // See that customer already has an address with expected addressId
-        $addressDto = $this->_service->getAddressById($customerId, $addressId);
+        $addressDto = $this->_service->getAddressById($addressId);
         $this->assertEquals($addressDto->getId(), $addressId);
 
         // Delete the address from the customer
-        $this->_service->deleteAddressFromCustomer($customerId, $addressId);
+        $this->_service->deleteAddress($addressId);
 
         // See that address is deleted
         try {
-            $addressDto = $this->_service->getAddressById($customerId, $addressId);
-            $this->fail('Did not catch expected exception');
-        } catch (Exception $e) {
-            $this->assertEquals($e->getCode(), Exception::CODE_ADDRESS_NOT_FOUND);
+            $addressDto = $this->_service->getAddressById($addressId);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (NoSuchEntityException $exception) {
+            $this->assertSame($exception->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $exception->getParams(),
+                [
+                    'addressId' => $addressId
+                ]
+            );
         }
     }
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_ADDRESS_NOT_FOUND
      */
     public function testDeleteAddressFromCustomerBadAddrId()
     {
         // Should throw the address not found exception
-        $this->_service->deleteAddressFromCustomer(1, 12345);
-    }
-
-    /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     *
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_ADDRESS_ID
-     */
-    public function testDeleteAddressFromCustomerAddrIdNotSet()
-    {
-        // Should throw the address not found exception
-        $this->_service->deleteAddressFromCustomer(1, 0);
-    }
-
-    /**
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
-     * @expectedException Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_CUSTOMER_ID_MISMATCH
-     */
-    public function testDeleteAddressFromCustomerBadCustMismatch()
-    {
-        // Should throw the address not found excetion
-        $this->_service->deleteAddressFromCustomer(2, 1);
+        try {
+            $this->_service->deleteAddress(12345);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (NoSuchEntityException $exception) {
+            $this->assertSame($exception->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $exception->getParams(),
+                [
+                    'addressId' => 12345
+                ]
+            );
+        }
     }
 
     /**
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php
index 5395bf9aacffc51fb4dd91a467a06769187be376..36cc56b724513d0fa3c4cb62c17d22ef510170bb 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php
@@ -1,12 +1,5 @@
 <?php
-
-namespace Magento\Customer\Service\V1;
-use Magento\Customer\Service\Entity\V1\Exception;
-use Magento\Customer\Service\V1;
-
 /**
- * Integration test for service layer \Magento\Customer\Service\CustomerV1
- *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -27,6 +20,15 @@ use Magento\Customer\Service\V1;
  *
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Service\V1;
+
+use Magento\Customer\Service\V1;
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+
+/**
+ * Integration test for service layer \Magento\Customer\Service\V1\CustomerService
  *
  * @SuppressWarnings(PHPMD.TooManyMethods)
  * @SuppressWarnings(PHPMD.ExcessivePublicCount)
@@ -104,7 +106,7 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @param mixed $custId
      * @dataProvider invalidCustomerIdsDataProvider
-     * @expectedException Exception
+     * @expectedException \Magento\Exception\NoSuchEntityException
      * @expectedExceptionMessage customerId
      */
     public function testInvalidCustomerIds($custId)
@@ -152,14 +154,19 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('Lastname', $customer->getLastname());
     }
 
-    /**
-     * @expectedException Exception
-     * @expectedExceptionMessage No customer with customerId 1 exists.
-     */
     public function testGetCustomerNotExist()
     {
-        // No fixture, so customer with id 1 shouldn't exist, exception should be thrown
-        $this->_service->getCustomer(1);
+        try {
+            // No fixture, so customer with id 1 shouldn't exist, exception should be thrown
+            $this->_service->getCustomer(1);
+            $this->fail('Did not throw expected exception.');
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'customerId' => '1',
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+            $this->assertEquals('No such entity with customerId = 1', $nsee->getMessage());
+        }
     }
 
     /**
@@ -353,8 +360,6 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @magentoDbIsolation enabled
-     * @expectedException \Magento\Validator\ValidatorException
-     * @expectedExceptionMessage Please correct this email address
      */
     public function testSaveCustomerException()
     {
@@ -367,10 +372,26 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
 
         try {
             $this->_service->saveCustomer($customerEntity);
-        } catch (Exception $e) {
-            $this->assertEquals('There were one or more errors validating the customer object.', $e->getMessage());
-            $this->assertEquals(Exception::CODE_VALIDATION_FAILED, $e->getCode());
-            throw $e->getPrevious();
+            $this->fail('Expected exception not thrown');
+        } catch (InputException $ie) {
+            $expectedParams = [
+                [
+                    'fieldName' => 'firstname',
+                    'value' => '',
+                    'code' => InputException::REQUIRED_FIELD,
+                ],
+                [
+                    'fieldName' => 'lastname',
+                    'value' => '',
+                    'code' => InputException::REQUIRED_FIELD,
+                ],
+                [
+                    'fieldName' => 'email',
+                    'value' => '',
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                ],
+            ];
+            $this->assertEquals($expectedParams, $ie->getParams());
         }
     }
 
@@ -481,12 +502,10 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
         $this->assertNotNull($customerId);
         $savedCustomer = $this->_service->getCustomer($customerId);
         $dataInService = $savedCustomer->getAttributes();
+        $expectedDifferences = ['created_at', 'updated_at', 'email', 'is_active', 'entity_id', 'password_hash',
+            'attribute_set_id', 'confirmation'];
         foreach ($dataInModel as $key => $value) {
-            if (!in_array(
-                $key,
-                array('created_at', 'updated_at', 'email', 'is_active', 'entity_id', 'password_hash',
-                     'attribute_set_id')
-            )) {
+            if (!in_array($key, $expectedDifferences)) {
                 if (is_null($value)) {
                     $this->assertArrayNotHasKey($key, $dataInService);
                 } else {
@@ -593,4 +612,33 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('Firstname', $customer->getFirstname());
         $this->assertNull($customer->getAttribute('rp_token'));
     }
+
+    /**
+     * @magentoDbIsolation enabled
+     */
+    public function testSaveCustomerNewThenUpdateFirstName()
+    {
+        $email = 'first_last@example.com';
+        $storeId = 1;
+        $firstname = 'Tester';
+        $lastname = 'McTest';
+        $groupId = 1;
+
+        $this->_customerBuilder->setStoreId($storeId)
+            ->setEmail($email)
+            ->setFirstname($firstname)
+            ->setLastname($lastname)
+            ->setGroupId($groupId);
+        $newCustomerEntity = $this->_customerBuilder->create();
+        $customerId = $this->_service->saveCustomer($newCustomerEntity, 'aPassword');
+
+        $this->_customerBuilder->populate($this->_service->getCustomer($customerId));
+        $this->_customerBuilder->setFirstname('Tested');
+        $this->_service->saveCustomer($this->_customerBuilder->create());
+
+        $customer = $this->_service->getCustomer($customerId);
+
+        $this->assertEquals('Tested', $customer->getFirstname());
+        $this->assertEquals($lastname, $customer->getLastname());
+    }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_address.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_address.php
index 5b8aac69eed224d42fd5a53c3fe877546cb2a040..af41246a7657af1344d86d0b311c05bb18d3c4b7 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_address.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_address.php
@@ -36,7 +36,7 @@ $customerAddress->setCustomerId(1)
         'postcode' => 75477,
         'country_id' => 'US',
         'city' => 'CityM',
-        'street' => 'Green str, 67',
+        'street' => array('Green str, 67'),
         'lastname' => 'Smith',
         'firstname' => 'John',
         'parent_id' => 1,
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_group.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_group.php
new file mode 100644
index 0000000000000000000000000000000000000000..f3d595d3696d4ebd7a48071d3fdf6f75d3448a46
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_group.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+/** @var \Magento\Customer\Service\V1\CustomerGroupService $customerGroupService */
+$customerGroupService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+    ->create('Magento\Customer\Service\V1\CustomerGroupService');
+$customerGroup = new Magento\Customer\Service\V1\Dto\CustomerGroup([
+    'code'          => 'custom_group',
+    'tax_class_id'  => 3,
+]);
+$customerGroupService->saveGroup($customerGroup);
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_no_address.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_no_address.php
new file mode 100644
index 0000000000000000000000000000000000000000..d08812417bebe6a18a8d1ee55dbe92564c91a3f7
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_no_address.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Customer
+ * @subpackage  integration_tests
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+    ->create('Magento\Customer\Model\Customer');
+$customer
+    ->setWebsiteId(1)
+    ->setId(5)
+    ->setEntityTypeId(1)
+    ->setAttributeSetId(1)
+    ->setEmail('customer5@example.com')
+    ->setPassword('password')
+    ->setGroupId(1)
+    ->setStoreId(1)
+    ->setIsActive(1)
+    ->setFirstname('Firstname')
+    ->setLastname('Lastname')
+;
+$customer->isObjectNew(true);
+$customer->save();
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_rp_token.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_rp_token.php
new file mode 100644
index 0000000000000000000000000000000000000000..b65269ce55d4c819f021764e7fcc793751f79c17
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_rp_token.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+    ->create('Magento\Customer\Model\Customer');
+$customer
+    ->setWebsiteId(1)
+    ->setId(1)
+    ->setEntityTypeId(1)
+    ->setAttributeSetId(1)
+    ->setEmail('customer@example.com')
+    ->setPassword('password')
+    ->setGroupId(1)
+    ->setStoreId(1)
+    ->setIsActive(1)
+    ->setFirstname('Firstname')
+    ->setLastname('Lastname')
+    ->setDefaultBilling(1)
+    ->setDefaultShipping(1)
+    ->setRpToken('8ed8677e6c79e68b94e61658bd756ea5')
+    ->setRpTokenCreatedAt(date('Y-m-d H:i:s'))
+;
+$customer->isObjectNew(true);
+$customer->save();
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/session.php b/dev/tests/integration/testsuite/Magento/Customer/_files/session.php
deleted file mode 100644
index 8bacff0c49cf1d3b25e64c524157a7f7265c53d2..0000000000000000000000000000000000000000
--- a/dev/tests/integration/testsuite/Magento/Customer/_files/session.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Customer
- * @subpackage  integration_tests
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-namespace Magento\Core\Model\Session;
-
-/**
- * Mock headers_sent function to prevent check whether headers have been already sent
- *
- * @see \Magento\Core\Model\Session\AbstractSession
- */
-function headers_sent()
-{
-    return false;
-}
-
-/**
- * Mock session_regenerate_id function to prevent check whether headers have been already sent
- *
- * @see \Magento\Core\Model\Session\AbstractSession
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
-function session_regenerate_id($delete_old_session = false)
-{
-    $sessionId = hexdec(session_id());
-    $sessionId++;  //Change Session Id value
-    session_id(dechex($sessionId));
-    return true;
-}
-
-
-/**
- * Mock session_start function to prevent check whether headers have been already sent
- *
- * @see \Magento\Core\Model\Session\AbstractSession
- */
-function session_start()
-{
-    return true;
-}
diff --git a/dev/tests/integration/testsuite/Magento/Filesystem/FilesystemTest.php b/dev/tests/integration/testsuite/Magento/Filesystem/FilesystemTest.php
index 9cd9b18489cfc4b897baf54e53caeed635aeadd4..71415e1fbf4fa55e6880c57bcc124c52ea858950 100644
--- a/dev/tests/integration/testsuite/Magento/Filesystem/FilesystemTest.php
+++ b/dev/tests/integration/testsuite/Magento/Filesystem/FilesystemTest.php
@@ -73,14 +73,6 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
         $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::THEMES_DIR);
     }
 
-    /**
-     * Test getPath returns right path
-     */
-    public function testGetPath()
-    {
-        $this->assertContains('design', $this->filesystem->getPath(\Magento\App\Filesystem::THEMES_DIR));
-    }
-
     /**
      * Test getUri returns right uri
      */
diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/_files/products_to_import_invalid_attribute_set.csv b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/_files/products_to_import_invalid_attribute_set.csv
index 598100edcd648cd4b3d6c52c8ffdcebd6c8c9e43..8976e7f7f246ef98cfcdd5df61246a7caa9537aa 100644
--- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/_files/products_to_import_invalid_attribute_set.csv
+++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/_files/products_to_import_invalid_attribute_set.csv
@@ -1,4 +1,4 @@
 sku,price,name,_type,_attribute_set,_links_upsell_sku,description
 simple1,25,"Simple Product",simple,Default,,description
-simple2,NULL,"Simple Product2",invalid attribute set,Default,,Hi
There
+simple2,NULL,"Simple Product2",invalid attribute set,Default,,HiThere
 simple3,58,"Simple Product 3",simple,Default,simple2,description
diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php b/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php
index 026cedae4229e2f53c17fa394b377b8652567da9..1a2c67509d6a450fb8f01a0a23db615e7fa0a836 100644
--- a/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php
+++ b/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php
@@ -76,10 +76,12 @@ class ShellTest extends \PHPUnit_Framework_TestCase
         $this->assertNotContains('testme.php', $result);
         $this->assertNotContains('Usage:', $result);
 
-        /** @var \Magento\Indexer\Model\Config $config */
-        $config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Indexer\Model\Config');
-        foreach ($config->getAll() as $indexerData) {
-            $this->assertContains($indexerData['title'], $result);
+        /** @var \Magento\Indexer\Model\Indexer\Collection $indexerCollection */
+        $indexerCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('Magento\Indexer\Model\Indexer\Collection');
+        foreach ($indexerCollection->getItems() as $indexer) {
+            /** @var \Magento\Indexer\Model\IndexerInterface $indexer */
+            $this->assertContains($indexer->getTitle(), $result);
         }
     }
 
diff --git a/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php b/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php
index 338b380c4da36afb16fb5b8f8e5d414c9181af2d..ae37acaed408a3c00dcf4e58cd2776a8798cd5fe 100644
--- a/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php
@@ -59,7 +59,10 @@ class PreProcessorTest extends \PHPUnit_Framework_TestCase
         $filesystem = $this->objectManager->get('Magento\Filesystem');
         $targetDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::TMP_DIR);
         $designParams = array('area' => 'frontend', 'theme' => 'test_pre_process');
-        $cssTargetFile = $this->model->process('source.css', $designParams, $targetDirectory);
+        /** @var \Magento\View\Service $viewService */
+        $viewService = $this->objectManager->get('Magento\View\Service');
+        $viewService->updateDesignParams($designParams);
+        $cssTargetFile = $this->model->process('source/source.css', $designParams, $targetDirectory);
         /** @var $viewFilesystem \Magento\View\FileSystem */
         $viewFilesystem = $this->objectManager->get('Magento\View\FileSystem');
         $this->assertFileEquals($viewFilesystem->getViewFile('source.css', $designParams), $cssTargetFile);
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less
index b4478b6c352c65a8dc63194fff2dfd2c72c12801..a21373b262cb532b7d642cb2787223812e8587dd 100644
--- a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less
@@ -1,4 +1,4 @@
 .class {
-  @import "less/import1/import1-1.less" screen and (max-width: 400px);
+  @import "import1/source/import1-1.less";
   font-size: @importedSize; // use imported variable
 }
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less
index f8f0233a38035eaa0f10785bffebfa2d5113345e..175ff8d6aba0c296e4cd29b81ff1c419cfd50833 100644
--- a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less
@@ -1,2 +1,3 @@
 @importedSize: 12pt;
 h1 { color: green; }
+
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/source/import1-1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/source/import1-1.less
new file mode 100644
index 0000000000000000000000000000000000000000..d3086f6d3e4369af7368202873989815d37c8a40
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/source/import1-1.less
@@ -0,0 +1 @@
+@import "../import1-1.less";
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less
deleted file mode 100644
index 3a4243a100d7e573aabc57a9a35695f61baefe0a..0000000000000000000000000000000000000000
--- a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less
+++ /dev/null
@@ -1,10 +0,0 @@
-@import "less/import1.less";
-@import (less) "less/import2";
-@import "Magento_Test3::import";
-@import "less/not_existed_file.less";
-//@magento_import "magento_import.less";
-//@magento_import "not_existed_magento_import.less";
-
-.end_class {
-  color: white;
-}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source/source.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source/source.less
new file mode 100644
index 0000000000000000000000000000000000000000..66720b2c364f6d7435ad31fc4d37e01fc0e173f6
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source/source.less
@@ -0,0 +1,10 @@
+@import "../less/import1";
+@import (less) "../less/import2";
+@import "Magento_Test3::import";
+@import "../less/not_existed_file.less";
+//@magento_import "../magento_import.less";
+//@magento_import "../not_existed_magento_import.less";
+
+.end_class {
+  color: white;
+}
diff --git a/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php b/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php
index 92f93b46412c3f83157db15fe372adccbd430321..2894e3d2524c8b2472163ccb168c8fd23f23a399 100644
--- a/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php
+++ b/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php
@@ -41,7 +41,7 @@ class MemoryUsageTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->_helper = new \Magento\TestFramework\Helper\Memory(new \Magento\Shell);
+        $this->_helper = new \Magento\TestFramework\Helper\Memory(new \Magento\Shell(new \Magento\OSInfo()));
     }
 
     /**
diff --git a/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php
index 953b3e8fff0be4f02a5f7b4bda0d1d23337d4835..5136e43f9bc18c60a9eda7e3eedfce2c917947b3 100644
--- a/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php
+++ b/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php
@@ -72,10 +72,11 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
      */
     public function testCreateAndDrop()
     {
+        /** @var \Magento\Mview\View\Changelog $model */
         $model = $this->objectManager->create('Magento\Mview\View\Changelog', array(
             'resource' => $this->resource));
         $model->setViewId('test_view_id_2');
-        $changelogName = $this->connection->getTableName($model->getName());
+        $changelogName = $this->resource->getTableName($model->getName());
         $this->assertFalse($this->connection->isTableExists($changelogName));
         $model->create();
         $this->assertTrue($this->connection->isTableExists($changelogName));
@@ -93,7 +94,7 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
         $model->setViewId('test_view_id_2');
         $model->create();
         $this->assertEquals(0, $model->getVersion());
-        $changelogName = $this->connection->getTableName($model->getName());
+        $changelogName = $this->resource->getTableName($model->getName());
         $this->connection->insert(
             $changelogName,
             array($model->getColumnName() => mt_rand(1, 200))
@@ -108,7 +109,7 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
     public function testClear()
     {
         $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty
-        $changelogName = $this->connection->getTableName($this->model->getName());
+        $changelogName = $this->resource->getTableName($this->model->getName());
         $this->connection->insert(
             $changelogName,
             array('version_id' => 1, 'entity_id' => 1)
@@ -124,7 +125,7 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
     public function testGetList()
     {
         $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty
-        $changelogName = $this->connection->getTableName($this->model->getName());
+        $changelogName = $this->resource->getTableName($this->model->getName());
         $testChengelogData =  array(
             array('version_id' => 1, 'entity_id' => 1),
             array('version_id' => 2, 'entity_id' => 1),
diff --git a/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/VarnishTest.php b/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/VarnishTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..0924bcac56645d7db90d1606e8cdf8d5b4934ddc
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/PageCache/Model/System/Config/Backend/VarnishTest.php
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @subpackage  integration_tests
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\PageCache\Model\System\Config\Backend;
+
+class VarnishTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\PageCache\Model\System\Config\Backend\Varnish
+     */
+    protected $_model;
+
+    /**
+     * @var \Magento\App\ConfigInterface
+     */
+    protected $_config;
+
+    protected function setUp()
+    {
+        $this->_config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\App\ConfigInterface');
+        $data = array(
+            'access_list' => 'localhost',
+            'backend_host' => 'localhost',
+            'backend_port' => 8080,
+            'ttl' => 120,
+        );
+        $this->_config->setValue('system/full_page_cache/default', $data);
+        $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\PageCache\Model\System\Config\Backend\Varnish');
+    }
+
+    /**
+     * @dataProvider beforeSaveDataProvider
+     *
+     * @param $value
+     * @param $path
+     * @param $expected
+     * @param $needUpdate
+     */
+    public function testBeforeSave($value, $path, $expected, $needUpdate)
+    {
+        if ($needUpdate) {
+            $this->_model->load($path, 'path');
+        }
+
+        $this->_model->setValue($value);
+        $this->_model->setPath($path);
+        $this->_model->setField($path);
+        $this->_model->save();
+        $value = $this->_model->getValue();
+
+        $this->assertEquals($value, $expected);
+    }
+
+    public function beforeSaveDataProvider()
+    {
+        return array(
+            array('localhost', 'access_list', 'localhost', false),
+            array('localhost', 'backend_host', 'localhost', false),
+            array(8081, 'backend_port', 8081, false),
+            array(125, 'ttl', 125, false),
+
+            array('localhost', 'access_list', 'localhost', true),
+            array('', 'backend_host', 'localhost', true),
+            array(0, 'backend_port', 8080, true),
+            array(0, 'ttl', 120, true),
+        );
+    }
+
+    /**
+     * @dataProvider afterLoadDataProvider
+     *
+     * @param $path
+     * @param $expected
+     * @param $needUpdate
+     */
+    public function testAfterLoad($path, $expected, $needUpdate)
+    {
+        if ($needUpdate) {
+            $this->_model->load($path, 'path');
+        }
+        $this->_model->setValue('');
+        $this->_model->setPath($path);
+        $this->_model->setField($path);
+        $this->_model->save();
+        $value = $this->_model->getValue();
+
+        $this->assertEquals($value, $expected);
+    }
+
+    public function afterLoadDataProvider()
+    {
+        return array(
+            array('access_list', 'localhost', true),
+            array('backend_host', 'localhost', true),
+            array('backend_port', 8080, true),
+            array('ttl', 120, true),
+        );
+    }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Adminhtml/Paypal/ReportsTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Adminhtml/Paypal/ReportsTest.php
index 869c950481c04028e594b41de77d9d982b014a7c..70283ea080f3aab390c318a274ee17d979c1e232 100644
--- a/dev/tests/integration/testsuite/Magento/Paypal/Adminhtml/Paypal/ReportsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Adminhtml/Paypal/ReportsTest.php
@@ -40,7 +40,7 @@ class ReportsTest extends \Magento\Backend\Utility\Controller
      */
     public function testFetchAction()
     {
-        $this->dispatch('backend/admin/paypal_reports/fetch');
+        $this->dispatch('backend/paypal/paypal_reports/fetch');
         $this->assertSessionMessages(
             $this->equalTo(array("We couldn't fetch reports from 'login@127.0.0.1'.")),
             \Magento\Message\MessageInterface::TYPE_ERROR
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
similarity index 80%
rename from dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
rename to dev/tests/integration/testsuite/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
index 3681157a1edf7adeddfd7c873f73edfea47fb1cd..bf630757e4d3511f73b5121182ef256ec47188bc 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
@@ -25,22 +25,22 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab;
+namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab;
 
 class InfoTest extends \Magento\Backend\Utility\Controller
 {
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+     * @magentoDataFixture Magento/Paypal/_files/billing_agreement.php
      */
     public function testCustomerGridAction()
     {
-        /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
+        /** @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
         $billingAgreementCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection')
+            ->create('Magento\Paypal\Model\Resource\Billing\Agreement\Collection')
             ->load();
         $agreementId = $billingAgreementCollection->getFirstItem()->getId();
-        $this->dispatch('backend/sales/billing_agreement/view/agreement/' . $agreementId);
+        $this->dispatch('backend/paypal/billing_agreement/view/agreement/' . $agreementId);
 
         $this->assertSelectCount('a[name="billing_agreement_info"]', 1, $this->getResponse()->getBody(),
            'Response for billing agreement info doesn\'t contain billing agreement info tab');
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Block/Billing/Agreement/ViewTest.php
similarity index 86%
rename from dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php
rename to dev/tests/integration/testsuite/Magento/Paypal/Block/Billing/Agreement/ViewTest.php
index 465c31d5ddb3ed003d1ab16b5e760df1d700b7f9..e1d2465cede2418339bcb812d740a2dac928b69c 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Block/Billing/Agreement/ViewTest.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Test for \Magento\Sales\Block\Billing\Agreement\View
+ * Test for \Magento\Paypal\Block\Billing\Agreement\View
  *
  * Magento
  *
@@ -24,18 +24,18 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Billing\Agreement;
+namespace Magento\Paypal\Block\Billing\Agreement;
 
 use \Magento\TestFramework\Helper\Bootstrap;
 
 class ViewTest extends \Magento\Backend\Utility\Controller
 {
-    /** @var \Magento\Sales\Block\Billing\Agreement\View */
+    /** @var \Magento\Paypal\Block\Billing\Agreement\View */
     protected $_block;
 
     protected function setUp()
     {
-        $this->_block = Bootstrap::getObjectManager()->create('Magento\Sales\Block\Billing\Agreement\View');
+        $this->_block = Bootstrap::getObjectManager()->create('Magento\Paypal\Block\Billing\Agreement\View');
         parent::setUp();
     }
 
@@ -45,7 +45,7 @@ class ViewTest extends \Magento\Backend\Utility\Controller
      * Create two identical orders, associate one of them with billing agreement and invoke testGetRelatedOrders()
      *
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+     * @magentoDataFixture Magento/Paypal/_files/billing_agreement.php
      * @magentoDataFixture Magento/Sales/_files/order.php
      * @magentoDbIsolation enabled
      * @magentoAppIsolation enabled
@@ -75,10 +75,10 @@ class ViewTest extends \Magento\Backend\Utility\Controller
         $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session');
         $customerSession->setCustomerId($customerId);
 
-        /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
+        /** @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
         $billingAgreementCollection = Bootstrap::getObjectManager()
-            ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection');
-        /** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */
+            ->create('Magento\Paypal\Model\Resource\Billing\Agreement\Collection');
+        /** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */
         $billingAgreement = $billingAgreementCollection->getFirstItem();
         $billingAgreement->addOrderRelation($orderA->getId())->save();
 
diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/ReviewTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/ReviewTest.php
index 1d92337b870d0f5ca002fd4475dbd8b5cdd8e21d..78243ee065199d57963c388942ad096970b23bec 100644
--- a/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/ReviewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/ReviewTest.php
@@ -32,14 +32,22 @@ namespace Magento\Paypal\Block\Express;
 
 class ReviewTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @magentoDataFixture Magento/Sales/_files/quote.php
+     */
     public function testRenderAddress()
     {
+        $quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->create('Magento\Sales\Model\Quote');
+        $quote->load('test01', 'reserved_order_id');
+
         $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface')
             ->createBlock('Magento\Paypal\Block\Express\Review');
         $addressData = include(__DIR__ . '/../../../Sales/_files/address_data.php');
         $address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
             ->create('Magento\Sales\Model\Quote\Address', array('data' => $addressData));
         $address->setAddressType('billing');
+        $address->setQuote($quote);
         $this->assertContains('Los Angeles', $block->renderAddress($address));
     }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Controller/Adminhtml/Billing/AgreementTest.php
similarity index 79%
rename from dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php
rename to dev/tests/integration/testsuite/Magento/Paypal/Controller/Adminhtml/Billing/AgreementTest.php
index 624fa891809723747ac40bc0cd2715082869e81d..42cb9e96bedfacaa28abc413b2f5170e09faa1f1 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Controller/Adminhtml/Billing/AgreementTest.php
@@ -22,12 +22,12 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Controller\Adminhtml\Billing;
+namespace Magento\Paypal\Controller\Adminhtml\Billing;
 
 use Magento\TestFramework\Helper\Bootstrap;
 
 /**
- * Test class for \Magento\Sales\Controller\Adminhtml\Billing\Agreement
+ * Test class for \Magento\Paypal\Controller\Adminhtml\Billing\Agreement
  *
  * @magentoAppArea adminhtml
  */
@@ -35,14 +35,14 @@ class AgreementTest extends \Magento\Backend\Utility\Controller
 {
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+     * @magentoDataFixture Magento/Paypal/_files/billing_agreement.php
      */
     public function testCustomerGridAction()
     {
         /** @var $session \Magento\Backend\Model\Session */
         Bootstrap::getObjectManager()->create('Magento\Backend\Model\Session');
 
-        $this->dispatch('backend/sales/billing_agreement/grid');
+        $this->dispatch('backend/paypal/billing_agreement/grid');
         $response = $this->getResponse();
 
         $this->assertSelectCount('button[type="button"][title="Reset Filter"]', 1, $response->getBody(),
@@ -54,15 +54,15 @@ class AgreementTest extends \Magento\Backend\Utility\Controller
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+     * @magentoDataFixture Magento/Paypal/_files/billing_agreement.php
      */
     public function testCustomerInfoTabs()
     {
-        /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
+        /** @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
         $billingAgreementCollection = Bootstrap::getObjectManager()
-            ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection');
+            ->create('Magento\Paypal\Model\Resource\Billing\Agreement\Collection');
         $agreementId = $billingAgreementCollection->getFirstItem()->getId();
-        $this->dispatch('backend/sales/billing_agreement/view/agreement/' . $agreementId);
+        $this->dispatch('backend/paypal/billing_agreement/view/agreement/' . $agreementId);
 
         $this->assertSelectCount('a[name="billing_agreement_info"]', 1, $this->getResponse()->getBody(),
             "Response for billing agreement info doesn't contain billing agreement info tab");
@@ -73,11 +73,11 @@ class AgreementTest extends \Magento\Backend\Utility\Controller
 
     /**
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+     * @magentoDataFixture Magento/Paypal/_files/billing_agreement.php
      */
     public function testCustomerGrid()
     {
-        $this->dispatch('backend/sales/billing_agreement/customergrid/id/1');
+        $this->dispatch('backend/paypal/billing_agreement/customergrid/id/1');
         $this->assertSelectCount('td[class="col-reference_id"]', 1, $this->getResponse()->getBody(),
             "Response for billing agreement orders doesn't contain billing agreement customers grid");
         $this->assertSelectRegExp('td', '/REF-ID-TEST-678/', 1, $this->getResponse()->getBody(),
diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/IpnTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/IpnTest.php
index 81ac5a927e40559d6c6495af4892ef3b78b20194..281ccabccb7cdcc60daa56f7cbfbac6c5a1be5cb 100644
--- a/dev/tests/integration/testsuite/Magento/Paypal/Model/IpnTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/IpnTest.php
@@ -106,7 +106,7 @@ class IpnTest extends \PHPUnit_Framework_TestCase
         $this->_model->processIpnRequest($ipnData, $this->_createMockedHttpAdapter());
 
         $recurringProfile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\Sales\Model\Recurring\Profile');
+            ->create('Magento\RecurringProfile\Model\Profile');
         $recurringProfile->loadByInternalReferenceId('5-33949e201adc4b03fbbceafccba893ce');
         $orderIds = $recurringProfile->getChildOrderIds();
         $this->assertEquals(1, count($orderIds));
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/billing_agreement.php
similarity index 86%
rename from dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php
rename to dev/tests/integration/testsuite/Magento/Paypal/_files/billing_agreement.php
index 60a9392e4f98f786ca3baa883052c3728a23c8af..52e4a4d655735b741c560a84550907d32130af7b 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/billing_agreement.php
@@ -24,13 +24,13 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-/** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */
+/** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */
 $billingAgreement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-    ->create('Magento\Sales\Model\Billing\Agreement')
+    ->create('Magento\Paypal\Model\Billing\Agreement')
     ->setAgreementLabel('TEST')
     ->setCustomerId(1)
     ->setMethodCode('paypal_express')
     ->setReferenceId('REF-ID-TEST-678')
-    ->setStatus(Magento\Sales\Model\Billing\Agreement::STATUS_ACTIVE)
+    ->setStatus(Magento\Paypal\Model\Billing\Agreement::STATUS_ACTIVE)
     ->setStoreId(1)
     ->save();
diff --git a/dev/tests/integration/testsuite/Magento/Paypal/_files/recurring_profile.php b/dev/tests/integration/testsuite/Magento/Paypal/_files/recurring_profile.php
index 6c86ac7f85355be89e64c1279ad5c7c1f0a81e72..6fc5934adcb5affff75ad28755c438f990715b11 100644
--- a/dev/tests/integration/testsuite/Magento/Paypal/_files/recurring_profile.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/_files/recurring_profile.php
@@ -26,7 +26,7 @@
  */
 
 $recurringProfile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-    ->create('Magento\Sales\Model\Recurring\Profile');
+    ->create('Magento\RecurringProfile\Model\Profile');
 $recurringProfile->addData(array(
     'store_id'                => 1,
     'method_code'             => \Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS,
diff --git a/dev/tests/integration/testsuite/Magento/Payment/Block/Catalog/Product/View/ProfileTest.php b/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php
similarity index 89%
rename from dev/tests/integration/testsuite/Magento/Payment/Block/Catalog/Product/View/ProfileTest.php
rename to dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php
index b5bcca1b4e5aba6d2b6d3287c847ff1f9848cc43..a01885230c87e269f7cd41a8b393482083ad027d 100644
--- a/dev/tests/integration/testsuite/Magento/Payment/Block/Catalog/Product/View/ProfileTest.php
+++ b/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php
@@ -18,17 +18,15 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Payment
  * @subpackage  integration_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 /**
- * Test class for \Magento\Payment\Block\Catalog\Product\View\Profile
+ * Test class for \Magento\RecurringProfile\Block\Catalog\Product\View\Profile
  */
-namespace Magento\Payment\Block\Catalog\Product\View;
+namespace Magento\RecurringProfile\Block\Catalog\Product\View;
 
 class ProfileTest extends \PHPUnit_Framework_TestCase
 {
@@ -45,7 +43,7 @@ class ProfileTest extends \PHPUnit_Framework_TestCase
         $product->setIsRecurring('1');
         $product->setRecurringProfile(array('start_date_is_editable' => true));
         $objectManager->get('Magento\Core\Model\Registry')->register('current_product', $product);
-        $block = $objectManager->create('Magento\Payment\Block\Catalog\Product\View\Profile');
+        $block = $objectManager->create('Magento\RecurringProfile\Block\Catalog\Product\View\Profile');
         $block->setLayout($objectManager->create('Magento\Core\Model\Layout'));
 
         $html = $block->getDateHtml();
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Recurring/Profile/ViewTest.php b/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Profile/ViewTest.php
similarity index 89%
rename from dev/tests/integration/testsuite/Magento/Sales/Block/Recurring/Profile/ViewTest.php
rename to dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Profile/ViewTest.php
index 4681277910b8e70bdef91d160587132b77981cfd..a7620c082250d36136996ca325cdb3404eabcd85 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Block/Recurring/Profile/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Profile/ViewTest.php
@@ -25,12 +25,12 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Block\Recurring\Profile;
+namespace Magento\RecurringProfile\Block\Profile;
 
 class ViewTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View
+     * @var \Magento\RecurringProfile\Block\Profile\View
      */
     protected $_block;
 
@@ -40,21 +40,21 @@ class ViewTest extends \PHPUnit_Framework_TestCase
     protected $_layout;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
     protected function setUp()
     {
         $this->_profile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\Sales\Model\Recurring\Profile');
+            ->create('Magento\RecurringProfile\Model\Profile');
         /** @var $objectManager \Magento\TestFramework\ObjectManager */
         $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
         $objectManager->get('Magento\Core\Model\Registry')->register('current_recurring_profile', $this->_profile);
 
         $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
             ->get('Magento\View\LayoutInterface');
-        $this->_block = $this->_layout->createBlock('Magento\Sales\Block\Recurring\Profile\View', 'block');
+        $this->_block = $this->_layout->createBlock('Magento\RecurringProfile\Block\Profile\View', 'block');
     }
 
     protected function tearDown()
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php b/dev/tests/integration/testsuite/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfileTest.php
similarity index 77%
rename from dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php
rename to dev/tests/integration/testsuite/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfileTest.php
index 068332d50b90eda656909372167f3b55062e9818..c2c0870f3a633d30aaac82943179f1b7cbf61aae 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php
+++ b/dev/tests/integration/testsuite/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfileTest.php
@@ -21,19 +21,19 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Controller\Adminhtml\Recurring;
+namespace Magento\RecurringProfile\Controller\Adminhtml;
 
-class ProfileTest extends \Magento\Backend\Utility\Controller
+class RecurringProfileTest extends \Magento\Backend\Utility\Controller
 {
     /**
      * @magentoDataFixture Magento/Sales/_files/quote.php
      * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Sales/_files/recurring_profile.php
+     * @magentoDataFixture Magento/RecurringProfile/_files/recurring_profile.php
      */
     public function testCustomerGridAction()
     {
-        $this->getRequest()->setParam(Profile::PARAM_CUSTOMER_ID, 1);
-        $this->dispatch('backend/sales/recurring_profile/customerGrid');
+        $this->getRequest()->setParam(RecurringProfile::PARAM_CUSTOMER_ID, 1);
+        $this->dispatch('backend/sales/recurringProfile/customerGrid');
         $this->assertContains(FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION, $this->getResponse()->getBody());
     }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php b/dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php
similarity index 91%
rename from dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php
rename to dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php
index 82f8242f12db579c6debbb3505d3160d7af2c0f9..03767572806c11fae0d08deed5028f889fa3cdfb 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php
+++ b/dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php
@@ -28,8 +28,8 @@ use Magento\TestFramework\Helper\Bootstrap;
 
 define('FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION', 'fixture-recurring-profile-schedule');
 
-/** @var Magento\Sales\Model\Recurring\Profile $profile */
-$profile = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Recurring\Profile');
+/** @var Magento\RecurringProfile\Model\Profile $profile */
+$profile = Bootstrap::getObjectManager()->create('Magento\RecurringProfile\Model\Profile');
 $profile
     ->setQuote(Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote')->load(1))
     ->setPeriodUnit('year')
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CrontabConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CrontabConfigFilesTest.php
index ca74056ac1cd0cbda9a032a7a4a3aff059201b8c..471bca75f1b336e347a946f1c6549f963daf78b2 100644
--- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CrontabConfigFilesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CrontabConfigFilesTest.php
@@ -32,7 +32,8 @@ class CrontabConfigFilesTest extends \PHPUnit_Framework_TestCase
      * @var array
      */
     protected $_idAttributes = array(
-        '/config/job' => 'name'
+        '/config/group'     => 'id',
+        '/config/group/job' => 'name',
     );
 
     /**
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php
index 2eb1fc4b62c75996575dbeef2b750d1c0ce5cd08..e10b0f57841c64cd8ce4342d85d2ea9c5f783092 100644
--- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php
@@ -34,31 +34,30 @@ class MviewConfigFilesTest extends \PHPUnit_Framework_TestCase
      *
      * @var array
      */
-    protected $_fileList = array();
+    protected $fileList = array();
 
     /**
      * Path to scheme file
      *
      * @var string
      */
-    protected $_schemeFile;
+    protected $schemeFile;
 
     protected function setUp()
     {
-        $this->markTestIncomplete('Will enable after first indexer will be implemented');
-        $this->_schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+        $this->schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Filesystem')
             ->getPath(\Magento\App\Filesystem::LIB_DIR) . '/Magento/Mview/etc/mview.xsd';
     }
 
     /**
      * Test each acl configuration file
      * @param string $file
+     * @dataProvider mviewConfigFileDataProvider
      */
     public function testIndexerConfigFile($file)
     {
-        $this->markTestIncomplete('Will enable after first indexer will be implemented');
         $domConfig = new \Magento\Config\Dom(file_get_contents($file));
-        $result = $domConfig->validate($this->_schemeFile, $errors);
+        $result = $domConfig->validate($this->schemeFile, $errors);
         $message = "Invalid XML-file: {$file}\n";
         foreach ($errors as $error) {
             $message .= "$error\n";
@@ -69,10 +68,10 @@ class MviewConfigFilesTest extends \PHPUnit_Framework_TestCase
     /**
      * @return array
      */
-    public function indexerConfigFileDataProvider()
+    public function mviewConfigFileDataProvider()
     {
         $fileList = glob(
-            \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+            \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Filesystem')
                 ->getPath(\Magento\App\Filesystem::APP_DIR) . '/*/*/*/etc/mview.xml'
         );
         $dataProviderResult = array();
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php
index e674c4ec5614c6ecf81934b1f404196b229ca903..80b388426a82e31f9fa6790b173a07594d226292 100644
--- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php
@@ -34,30 +34,30 @@ class NewIndexerConfigFilesTest extends \PHPUnit_Framework_TestCase
      *
      * @var array
      */
-    protected $_fileList = array();
+    protected $fileList = array();
 
     /**
      * Path to scheme file
      *
      * @var string
      */
-    protected $_schemeFile;
+    protected $schemeFile;
 
     protected function setUp()
     {
-        $this->markTestIncomplete('Will enable after first indexer will be implemented');
-        $this->_schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+        $this->schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Filesystem')
             ->getPath(\Magento\App\Filesystem::APP_DIR) . '/code/Magento/Indexer/etc/indexer.xsd';
     }
 
     /**
      * Test each acl configuration file
      * @param string $file
+     * @dataProvider indexerConfigFileDataProvider
      */
     public function testIndexerConfigFile($file)
     {
         $domConfig = new \Magento\Config\Dom(file_get_contents($file));
-        $result = $domConfig->validate($this->_schemeFile, $errors);
+        $result = $domConfig->validate($this->schemeFile, $errors);
         $message = "Invalid XML-file: {$file}\n";
         foreach ($errors as $error) {
             $message .= "$error\n";
@@ -71,7 +71,7 @@ class NewIndexerConfigFilesTest extends \PHPUnit_Framework_TestCase
     public function indexerConfigFileDataProvider()
     {
         $fileList = glob(
-            \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+            \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Filesystem')
                 ->getPath(\Magento\App\Filesystem::APP_DIR) . '/*/*/*/etc/indexer.xml'
         );
         $dataProviderResult = array();
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/ViewFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/ViewFilesTest.php
index 0d765ba18a656013e1ac39366bf132d0f098bd8c..a8941508add8fed12b82fa53eb0f0fb7a816ff4e 100644
--- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/ViewFilesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/ViewFilesTest.php
@@ -29,57 +29,117 @@ namespace Magento\Test\Integrity\Theme;
 
 class ViewFilesTest extends \Magento\TestFramework\TestCase\AbstractIntegrity
 {
-    public function testViewFilesFromThemes()
+    /**
+     * @var \Magento\TestFramework\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * @var \Magento\View\FileSystem
+     */
+    protected $viewFileSystem;
+
+    /**
+     * @var \Magento\App\Filesystem
+     */
+    protected $filesystem;
+
+    protected function setUp()
+    {
+        $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectmanager();
+        $this->viewFileSystem = $this->objectManager->get('Magento\View\FileSystem');
+        $this->filesystem = $this->objectManager->get('Magento\App\Filesystem');
+        $this->objectManager->configure(array(
+            'preferences' => array('Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data')
+        ));
+    }
+
+    /**
+     * @magentoAppIsolation enabled
+     */
+    public function testViewLessFilesPreProcessing()
     {
-        \Magento\TestFramework\Helper\Bootstrap::getObjectmanager()->configure(array(
-            'preferences' => array(
-                'Magento\Core\Model\Theme' => 'Magento\Core\Model\Theme\Data'
-            )
+        $errorHandlerMock = $this->getMock('Magento\Less\PreProcessor\ErrorHandlerInterface',
+            array('processException'));
+        $this->objectManager->addSharedInstance($errorHandlerMock, 'Magento\Less\PreProcessor\ErrorHandler');
+        $errorHandlerMock->expects($this->any())->method('processException')->will($this->returnCallback(
+            function ($exception) {
+                /** @var $exception \Exception */
+                $this->fail($exception->getMessage());
+            }
         ));
+        /** @var $lessPreProcessor \Magento\Less\PreProcessor */
+        $lessPreProcessor = $this->objectManager->create('Magento\Less\PreProcessor');
+        $directoryRead = $this->filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR);
+        /**
+         * Solution for \Magento\View\Layout\File\Source\Base aggregator, it depends on theme and area
+         */
+        $theme = $this->objectManager->create('Magento\View\Design\ThemeInterface');
+        $theme->setArea('frontend');
         $invoker = new \Magento\TestFramework\Utility\AggregateInvoker($this);
         $invoker(
             /**
+             * @param string $file
              * @param string $area
-             * @param string $themeId
+             */
+            function ($file, $area) use ($lessPreProcessor, $directoryRead, $theme) {
+                $fileInfo = pathinfo($file);
+                if ($fileInfo['extension'] == 'css') {
+                    $lessFile = "{$fileInfo['dirname']}/{$fileInfo['filename']}.less";
+                    $params = array('area' => $area, 'themeModel' => $theme);
+                    $cssSourceFile = $this->viewFileSystem->getViewFile($file, $params);
+                    $lessSourceFile = $this->viewFileSystem->getViewFile($lessFile, $params);
+                    if ($directoryRead->isExist($directoryRead->getRelativePath($cssSourceFile))
+                        && $directoryRead->isExist($directoryRead->getRelativePath($lessSourceFile))
+                    ) {
+                        $this->fail("Duplicate files: '{$lessSourceFile}', '{$cssSourceFile}'");
+                    } elseif ($directoryRead->isExist($directoryRead->getRelativePath($lessSourceFile))) {
+                        $this->assertFileExists($lessPreProcessor->processLessInstructions($lessFile, $params));
+                    }
+                }
+            },
+            $this->viewFilesFromThemesDataProvider([$theme])
+        );
+    }
+
+    /**
+     * @magentoAppIsolation enabled
+     */
+    public function testViewFilesFromThemes()
+    {
+        $invoker = new \Magento\TestFramework\Utility\AggregateInvoker($this);
+        $invoker(
+            /**
              * @param string $file
-             * @throws \PHPUnit_Framework_AssertionFailedError|Exception
+             * @param string $area
+             * @param string $themeId
              */
-            function ($area, $themeId, $file) {
-                try {
-                    $params = array('area' => $area, 'themeId' => $themeId);
-                    $viewFile = \Magento\TestFramework\Helper\Bootstrap::getObjectmanager()
-                        ->get('Magento\View\FileSystem')
-                        ->getViewFile($file, $params);
-                    $this->assertFileExists($viewFile);
+            function ($file, $area, $themeId) {
+                $params = array('area' => $area, 'themeId' => $themeId);
+                $viewFile = $this->viewFileSystem->getViewFile($file, $params);
+                $this->assertFileExists($viewFile);
 
-                    $fileParts = explode(\Magento\View\Service::SCOPE_SEPARATOR, $file);
-                    if (count($fileParts) > 1) {
-                        $params['module'] = $fileParts[0];
-                    }
-                    if (pathinfo($file, PATHINFO_EXTENSION) == 'css') {
-                        $errors = array();
-                        $content = file_get_contents($viewFile);
-                        preg_match_all(\Magento\View\Url\CssResolver::REGEX_CSS_RELATIVE_URLS, $content, $matches);
-                        foreach ($matches[1] as $relativePath) {
-                            $path = $this->_addCssDirectory($relativePath, $file);
-                            $pathFile = \Magento\TestFramework\Helper\Bootstrap::getObjectmanager()
-                                ->get('Magento\View\FileSystem')
-                                ->getViewFile($path, $params);
-                            if (!is_file($pathFile)) {
-                                $errors[] = $relativePath;
-                            }
-                        }
-                        if (!empty($errors)) {
-                            $this->fail('Cannot find file(s): ' . implode(', ', $errors));
+                $fileParts = explode(\Magento\View\Service::SCOPE_SEPARATOR, $file);
+                if (count($fileParts) > 1) {
+                    $params['module'] = $fileParts[0];
+                }
+                if (pathinfo($file, PATHINFO_EXTENSION) == 'css') {
+                    $files = array();
+                    $content = file_get_contents($viewFile);
+                    preg_match_all(\Magento\View\Url\CssResolver::REGEX_CSS_RELATIVE_URLS, $content, $matches);
+                    foreach ($matches[1] as $relativePath) {
+                        $path = $this->_addCssDirectory($relativePath, $file);
+                        $pathFile = $this->viewFileSystem->getViewFile($path, $params);
+                        if (!is_file($pathFile)) {
+                            $files[] = $relativePath;
                         }
                     }
-                } catch (\PHPUnit_Framework_AssertionFailedError $e) {
-                    throw $e;
-                } catch (\Exception $e) {
-                    $this->fail($e->getMessage());
+                    if (!empty($files)) {
+                        $this->fail('Cannot find file(s): ' . implode(', ', $files));
+                    }
                 }
             },
-            $this->viewFilesFromThemesDataProvider()
+            $this->viewFilesFromThemesDataProvider($this->_getDesignThemes())
         );
     }
 
@@ -115,64 +175,76 @@ class ViewFilesTest extends \Magento\TestFramework\TestCase\AbstractIntegrity
     /**
      * Collect getViewUrl() and similar calls from themes
      *
+     * @param \Magento\Core\Model\Theme[] $themes
      * @return array
      */
-    public function viewFilesFromThemesDataProvider()
+    public function viewFilesFromThemesDataProvider($themes)
     {
-        $themes = $this->_getDesignThemes();
-
         // Find files, declared in views
         $files = array();
-        /** @var $theme \Magento\View\Design\ThemeInterface */
         foreach ($themes as $theme) {
-            $this->_collectGetViewUrlInvokes($theme, $files);
+            $this->_collectViewUrlInvokes($theme, $files);
+            $this->_collectViewLayoutDeclarations($theme, $files);
         }
 
         // Populate data provider in correspondence of themes to view files
         $result = array();
-        /** @var $theme \Magento\View\Design\ThemeInterface */
         foreach ($themes as $theme) {
             if (!isset($files[$theme->getId()])) {
                 continue;
             }
             foreach (array_unique($files[$theme->getId()]) as $file) {
-                $result["{$theme->getId()}/{$file}"] = array($theme->getArea(), $theme->getId(), $file);
+                $result["{$theme->getId()}/{$file}"] = array(
+                    'file'  => $file,
+                    'area'  => $theme->getArea(),
+                    'theme' => $theme->getId()
+                );
             }
         }
         return array_values($result);
     }
 
     /**
-     * Collect getViewUrl() from theme templates
+     * Collect getViewFileUrl() from theme templates
      *
-     * @param \Magento\View\Design\ThemeInterface $theme
+     * @param \Magento\Core\Model\Theme $theme
      * @param array &$files
      */
-    protected function _collectGetViewUrlInvokes($theme, &$files)
+    protected function _collectViewUrlInvokes($theme, &$files)
     {
         $searchDir = $theme->getCustomization()->getThemeFilesPath();
+        if (empty($searchDir)) {
+            return;
+        }
         $dirLength = strlen($searchDir);
         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($searchDir)) as $fileInfo) {
             // Check that file path is valid
             $relativePath = substr($fileInfo->getPath(), $dirLength);
-            if (!$this->_validateTemplatePath($relativePath)) {
-                continue;
-            }
-
-            // Scan file for references to other files
-            foreach ($this->_findReferencesToViewFile($fileInfo) as $file) {
-                $files[$theme->getId()][] = $file;
+            if ($this->_validateTemplatePath($relativePath)) {
+                // Scan file for references to other files
+                foreach ($this->_findReferencesToViewFile($fileInfo) as $file) {
+                    $files[$theme->getId()][] = $file;
+                }
             }
         }
+    }
 
+    /**
+     * Collect view files declarations into layout
+     *
+     * @param \Magento\Core\Model\Theme $theme
+     * @param array &$files
+     */
+    protected function _collectViewLayoutDeclarations($theme, &$files)
+    {
         // Collect "addCss" and "addJs" from theme layout
         /** @var \Magento\View\Layout\ProcessorInterface $layoutUpdate */
-        $layoutUpdate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Layout\ProcessorInterface', array('theme' => $theme));
+        $layoutUpdate = $this->objectManager->create('Magento\View\Layout\ProcessorInterface',
+            array('theme' => $theme));
         $fileLayoutUpdates = $layoutUpdate->getFileLayoutUpdatesXml();
         $elements = $fileLayoutUpdates->xpath(
             '//block[@class="Magento\Theme\Block\Html\Head\Css" or @class="Magento\Theme\Block\Html\Head\Script"]'
-                . '/arguments/argument[@name="file"]'
+            . '/arguments/argument[@name="file"]'
         );
         if ($elements) {
             foreach ($elements as $filenameNode) {
@@ -213,14 +285,14 @@ class ViewFilesTest extends \Magento\TestFramework\TestCase\AbstractIntegrity
     /**
      * Scan specified file for getViewUrl() pattern
      *
-     * @param SplFileInfo $fileInfo
+     * @param \SplFileInfo $fileInfo
      * @return array
      */
-    protected function _findReferencesToViewFile(SplFileInfo $fileInfo)
+    protected function _findReferencesToViewFile(\SplFileInfo $fileInfo)
     {
         $result = array();
         if (preg_match_all(
-            '/\$this->getViewUrl\(\'([^\']+?)\'\)/', file_get_contents($fileInfo->getRealPath()), $matches)
+            '/\$this->getViewFileUrl\(\'([^\']+?)\'\)/', file_get_contents($fileInfo->getRealPath()), $matches)
         ) {
             foreach ($matches[1] as $viewFile) {
                 if ($this->_isFileForDisabledModule($viewFile)) {
diff --git a/dev/tests/integration/testsuite/Magento/Tools/View/GeneratorTest.php b/dev/tests/integration/testsuite/Magento/Tools/View/GeneratorTest.php
index 5427541b197989a7a2e783f3602971bb33e19e4d..6ea5300b1fb7528f3a8eae4ba6575ce087c0034c 100644
--- a/dev/tests/integration/testsuite/Magento/Tools/View/GeneratorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Tools/View/GeneratorTest.php
@@ -46,7 +46,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase
     protected function setUp()
     {
         $this->tmpDir = BP . '/var/static';
-        $this->shell = new \Magento\Shell();
+        $this->shell = new \Magento\Shell(new \Magento\OSInfo());
         $this->filesystem = new \Magento\Filesystem\Driver\File();
         if (!$this->filesystem->isExists($this->tmpDir)) {
             $this->filesystem->createDirectory($this->tmpDir, 0777);
diff --git a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php
index 1ec8929ad5fce95ab962dff72b5b8d9a75154f4f..ed613756028ed6c3d0a3531e551b21e9762e3ff7 100644
--- a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php
+++ b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php
@@ -49,7 +49,6 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->markTestSkipped();
         $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
         $objectManager->get('Magento\App\State')->setAreaCode('frontend');
         $this->_viewService = $objectManager->create('Magento\View\Service');
@@ -60,7 +59,7 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
 
     protected function tearDown()
     {
-        /** @var \Magento\App\Filesystem $filesystem */
+        /** @var Filesystem $filesystem */
         $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\App\Filesystem');
         $publicDir = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::STATIC_VIEW_DIR);
         $publicDir->delete('adminhtml');
@@ -73,7 +72,7 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
      */
     public function testGetPublicDir()
     {
-        /** @var $filesystem \Magento\App\Filesystem */
+        /** @var $filesystem Filesystem */
         $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Filesystem');
         $expectedPublicDir = $filesystem->getPath(\Magento\App\Filesystem::STATIC_VIEW_DIR);
         $this->assertEquals($expectedPublicDir, $this->_viewService->getPublicDir());
@@ -244,7 +243,6 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
      */
     public function testGetPublicFilePath($file, $designParams, $expectedFile)
     {
-        $this->markTestSkipped('Task: MAGETWO-18162');
         $this->_initTestTheme();
 
         $expectedFile = $this->_viewService->getPublicDir() . '/' . $expectedFile;
@@ -259,7 +257,9 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
         $this->assertFileExists($expectedFile);
 
         // as soon as the files are published, they must have the same mtime as originals
-        $this->assertEquals(filemtime($originalFile), filemtime($expectedFile),
+        $this->assertEquals(
+            filemtime($originalFile),
+            filemtime($expectedFile),
             "These files mtime must be equal: {$originalFile} / {$expectedFile}"
         );
     }
@@ -288,6 +288,53 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @param string $file
+     * @param array $designParams
+     * @param string $expectedFile
+     * @param string $contentFile
+     * @magentoDataFixture Magento/Core/Model/_files/design/themes.php
+     * @magentoAppIsolation enabled
+     * @dataProvider getPublicFilePathLessDataProvider
+     */
+    public function testGetPublicFilePathLess($file, $designParams, $expectedFile, $contentFile)
+    {
+        $this->_initTestTheme();
+
+        $expectedFile = $this->_viewService->getPublicDir() . '/' . $expectedFile;
+
+        // test doesn't make sense if the original file doesn't exist or the target file already exists
+        $originalFile = $this->_fileSystem->getViewFile($file, $designParams);
+        $this->assertFileNotExists($originalFile);
+
+        // getViewUrl() will trigger publication in development mode
+        $this->assertFileNotExists($expectedFile, 'Please verify isolation from previous test(s).');
+        $this->_viewUrl->getViewFileUrl($file, $designParams);
+        $this->assertFileExists($expectedFile);
+
+        $this->assertEquals(
+            trim(file_get_contents($this->_fileSystem->getViewFile($contentFile, $designParams))),
+            file_get_contents($expectedFile)
+        );
+    }
+
+    public function getPublicFilePathLessDataProvider()
+    {
+        $designParams = array(
+            'area'    => 'frontend',
+            'theme'   => 'test_default',
+            'locale'  => 'en_US'
+        );
+        return array(
+            'view file' => array(
+                'source.css',
+                $designParams,
+                'frontend/test_default/en_US/source.css',
+                'result_source.css'
+            )
+        );
+    }
+
     /**
      * Publication of CSS files located in the theme (development mode)
      * @magentoAppIsolation enabled
@@ -295,7 +342,6 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
      */
     public function testPublishCssFileFromTheme()
     {
-        $this->markTestSkipped('Task: MAGETWO-18162');
         $this->_initTestTheme();
         $expectedFiles = array(
             'css/file.css',
@@ -331,7 +377,6 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
     public function testPublishCssFileFromModule(
         $cssViewFile, $designParams, $expectedCssFile, $expectedCssContent, $expectedRelatedFiles
     ) {
-        $this->markTestSkipped('Task: MAGETWO-18162');
         \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')
             ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND);
         $this->_viewUrl->getViewFileUrl($cssViewFile, $designParams);
@@ -439,25 +484,19 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
     protected function _testPublishResourcesAndCssWhenChangedCss($expectedPublished)
     {
         $appInstallDir = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInstallDir();
-        \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(
-            \Magento\App\Filesystem::PARAM_APP_DIRS => array(
-                \Magento\App\Filesystem::THEMES_DIR => array('path' => "$appInstallDir/media_for_change"),
-            )
-        ));
-        \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend');
 
-        $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->get('Magento\View\DesignInterface');
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+        $objectManager->get('Magento\App\State')->setAreaCode('frontend');
+
+        $this->_model = $objectManager->get('Magento\View\DesignInterface');
         $this->_model->setDesignTheme('test_default');
 
-        $this->_viewService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Service');
-        $this->_fileSystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\FileSystem');
-        $this->_viewUrl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Url');
+        $this->_viewService = $objectManager->create('Magento\View\Service');
+        $this->_fileSystem = $objectManager->create('Magento\View\FileSystem');
+        $this->_viewUrl = $objectManager->create('Magento\View\Url');
 
         $themePath = $this->_model->getDesignTheme()->getFullPath();
+        
         $fixtureViewPath = "$appInstallDir/media_for_change/$themePath/";
         $publishedPath = $this->_viewService->getPublicDir() . "/$themePath/en_US/";
 
@@ -496,8 +535,7 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
      */
     public function testPublishChangedResourcesWhenUnchangedCssDevMode()
     {
-        $mode = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')
-            ->getMode();
+        $mode = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->getMode();
         if ($mode != \Magento\App\State::MODE_DEVELOPER) {
             $this->markTestSkipped('Valid in developer mode only');
         }
@@ -535,18 +573,16 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
                 \Magento\App\Filesystem::THEMES_DIR => array('path' => "$appInstallDir/media_for_change"),
             )
         ));
-        \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend');
 
-        $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->get('Magento\View\DesignInterface');
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+        $objectManager->get('Magento\App\State')->setAreaCode('frontend');
+
+        $this->_model = $objectManager->get('Magento\View\DesignInterface');
         $this->_model->setDesignTheme('test_default');
 
-        $this->_viewService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Service');
-        $this->_fileSystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\FileSystem');
-        $this->_viewUrl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Url');
+        $this->_viewService = $objectManager->create('Magento\View\Service');
+        $this->_fileSystem = $objectManager->create('Magento\View\FileSystem');
+        $this->_viewUrl = $objectManager->create('Magento\View\Url');
 
         $themePath = $this->_model->getDesignTheme()->getFullPath();
         $fixtureViewPath = "$appInstallDir/media_for_change/$themePath/";
@@ -583,10 +619,10 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
                 \Magento\App\Filesystem::THEMES_DIR => array('path' => dirname(__DIR__) . '/Core/Model/_files/design/')
             )
         ));
-        \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend');
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+        $objectManager->get('Magento\App\State')->setAreaCode('frontend');
 
         if ($allowDuplication !== null) {
-            $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
             $publisher = $objectManager->create(
                 'Magento\View\Publisher',
                 array('allowDuplication' => $allowDuplication)
@@ -595,16 +631,12 @@ class PublicationTest extends \PHPUnit_Framework_TestCase
         }
 
         // Reinit model with new directories
-        $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->get('Magento\View\DesignInterface');
+        $this->_model = $objectManager->get('Magento\View\DesignInterface');
         $this->_model->setDesignTheme('test_default');
 
-        $this->_viewService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Service');
-        $this->_fileSystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\FileSystem');
-        $this->_viewUrl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
-            ->create('Magento\View\Url');
+        $this->_viewService = $objectManager->create('Magento\View\Service');
+        $this->_fileSystem = $objectManager->create('Magento\View\FileSystem');
+        $this->_viewUrl = $objectManager->create('Magento\View\Url');
     }
 
     /**
diff --git a/dev/tests/integration/testsuite/Magento/View/RelatedFileTest.php b/dev/tests/integration/testsuite/Magento/View/RelatedFileTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..d0c1ef7f5bf4e99b392655b4e066c20cbaf761da
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/View/RelatedFileTest.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @subpackage  integration_tests
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\View;
+
+class RelatedFileTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var RelatedFile
+     */
+    protected $model;
+
+    public function setUp()
+    {
+        $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+        $this->model = $objectManager->get('Magento\View\RelatedFile');
+    }
+
+    /**
+     * @dataProvider buildPathDataProvider
+     */
+    public function testBuildPath($arguments, $expected)
+    {
+        $path = $this->model->buildPath(
+            $arguments['relatedFilePath'],
+            $arguments['parentPath'],
+            $arguments['parentRelativePath'],
+            $arguments['params']
+        );
+        $this->assertEquals($expected['path'], $path);
+        $this->assertEquals($expected['params'], $arguments['params']);
+    }
+
+    /**
+     * @return array
+     */
+    public function buildPathDataProvider()
+    {
+        $themesPath = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+            ->get('Magento\App\Filesystem')->getPath(\Magento\App\Filesystem::THEMES_DIR);
+
+        return array(
+            array(
+                'arguments' => array(
+                    'relatedFilePath' => '../directory/file.css',
+                    'parentPath' => '/root/app/design/frontend/magento_plushe/css/source.css',
+                    'parentRelativePath' => 'css/source.css',
+                    'params' => ['module' => false]
+                ),
+                'expected' => array(
+                    'path' => 'directory/file.css',
+                    'params' => ['module' => false]
+                )
+            ),
+            array(
+                'arguments' => array(
+                    'relatedFilePath' => '../some_dir/file.css',
+                    'parentPath' => ($themesPath . '/frontend/magento_plushe/css/source.css'),
+                    'parentRelativePath' => 'css/source.css',
+                    'params' => ['module' => 'Magento_Theme']
+                ),
+                'expected' => array(
+                    'path' => 'some_dir/file.css',
+                    'params' => ['module' => 'Magento_Theme']
+                )
+            ),
+            array(
+                'arguments' => array(
+                    'relatedFilePath' => 'Magento_Theme::some_dir/file.css',
+                    'parentPath' => ($themesPath . '/frontend/magento_plushe/css/source.css'),
+                    'parentRelativePath' => 'css/source.css',
+                    'params' => ['module' => false]
+                ),
+                'expected' => array(
+                    'path' => 'some_dir/file.css',
+                    'params' => ['module' => 'Magento_Theme']
+                )
+            )
+        );
+    }
+}
diff --git a/dev/tests/js/pj b/dev/tests/js/pj
deleted file mode 160000
index 260f44b9f697a668c0c1952a6da1572849aac3bc..0000000000000000000000000000000000000000
--- a/dev/tests/js/pj
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 260f44b9f697a668c0c1952a6da1572849aac3bc
diff --git a/dev/tests/js/pj b/dev/tests/js/pj
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/dev/tests/js/testsuite/mage/mage-test.js b/dev/tests/js/testsuite/mage/mage-test.js
index f656edccb23964e08f7b8ea5e8f32df74ed499d3..0486c30caf4f71cd6711d51ba0847366455247bc 100644
--- a/dev/tests/js/testsuite/mage/mage-test.js
+++ b/dev/tests/js/testsuite/mage/mage-test.js
@@ -58,7 +58,7 @@ MageTest.prototype.testCustomizeOptions = function() {
 };
 
 MageTest.prototype.testDataAttribute = function() {
-    /*:DOC += <div id="main" data-mage-init="{button: [], tabs: []}"></div>*/
+    /*:DOC += <div id="main" data-mage-init='{"button":[], "tabs":[]}'></div>*/
     jQuery.mage
         .component('button', [])
         .component('tabs', [])
@@ -132,9 +132,12 @@ MageTest.prototype.testContentUpdated = function() {
         .component('button', [])
         .init();
     jQuery('body')
-        .append('<div id="test" data-mage-init="{tabs: []}">' +
-            '<button data-mage-init="{button: []}"></button>' +
-            '</div>');
+        .append(
+            jQuery('<div>')
+                .attr('id', 'test')
+                .attr('data-mage-init', '{"tabs":[]}')
+                .append(jQuery('<button>').attr('data-mage-init', '{"button":[]}'))
+        );
     jQuery('#test').trigger('contentUpdated');
     assertTrue(!!jQuery('#test').data('tabs'));
     assertTrue(!!jQuery('#test button').data('button'));
diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php
index 8851c6f64839aee48ddfe046d9bb12787c94bd20..fccdc7b5aa51442a619b6c2a9a015a6c74fc3605 100644
--- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php
+++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php
@@ -77,7 +77,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
         $this->_config = new \Magento\TestFramework\Performance\Config(
             $this->_fixtureConfigData, $this->_fixtureDir, $this->_fixtureDir . '/app_base_dir'
         );
-        $this->_shell = $this->getMock('Magento\Shell', array('execute'));
+        $this->_shell = $this->getMock('Magento\Shell', array('execute'), array(), '', false);
 
         $this->_object = $this->getMock(
             'Magento\TestFramework\Application',
diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/JmeterTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/JmeterTest.php
index 30bc7b4511aedc8c4503d3f41391f369a472b779..17455fa937ddc1e4e54d4bf5df26f3d4d3c7b907 100644
--- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/JmeterTest.php
+++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/JmeterTest.php
@@ -67,7 +67,7 @@ class JmeterTest extends \PHPUnit_Framework_TestCase
             $scenarioArgs, array(), array());
 
         $this->_reportFile = realpath(__DIR__ . '/../../_files') . '/scenario.jtl';
-        $this->_shell = $this->getMock('Magento\Shell', array('execute'));
+        $this->_shell = $this->getMock('Magento\Shell', array('execute'), array(), '', false);
         $this->_object = new \Magento\TestFramework\Performance\Scenario\Handler\Jmeter($this->_shell, false);
     }
 
diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/PhpTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/PhpTest.php
index b77f2cf6416af2eb75964f712a65b6be7dfddeef..80327aacdd6f8251cefddee320ad878bb8ee2d60 100644
--- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/PhpTest.php
+++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/Scenario/Handler/PhpTest.php
@@ -66,7 +66,7 @@ class PhpTest extends \PHPUnit_Framework_TestCase
             $scenarioArgs, array(), array());
 
         $this->_reportFile = realpath(__DIR__ . '/../../_files/scenario.jtl');
-        $this->_shell = $this->getMock('Magento\Shell', array('execute'));
+        $this->_shell = $this->getMock('Magento\Shell', array('execute'), array(), '', false);
         $this->_object = new \Magento\TestFramework\Performance\Scenario\Handler\Php($this->_shell, false);
     }
 
diff --git a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php
index eaeb2db18ea0bae5c85b756115db81f6f6ec660b..6f13f0bb6636fdcb320b6061bc304cd5a51d4732 100644
--- a/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php
+++ b/dev/tests/performance/framework/tests/unit/testsuite/Magento/Test/Performance/TestsuiteTest.php
@@ -77,7 +77,7 @@ class TestsuiteTest extends \PHPUnit_Framework_TestCase
         $this->_fixtureDir = __DIR__ . '/_files';
         $fixtureConfigData = include($this->_fixtureDir . '/config_data.php');
 
-        $shell = $this->getMock('Magento\Shell', array('execute'));
+        $shell = $this->getMock('Magento\Shell', array('execute'), array(), '', false);
         $this->_config = new \Magento\TestFramework\Performance\Config(
             $fixtureConfigData,
             $this->_fixtureDir,
diff --git a/dev/tests/performance/run_scenarios.php b/dev/tests/performance/run_scenarios.php
index 8a79bd381f5f7ced022606dfa9670948697ee470..7fbe74c2ca32e3c2252cf0b50d37afa8620ce323 100755
--- a/dev/tests/performance/run_scenarios.php
+++ b/dev/tests/performance/run_scenarios.php
@@ -33,7 +33,7 @@ $logWriter = new \Zend_Log_Writer_Stream('php://output');
 $logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL));
 $logger = new \Zend_Log($logWriter);
 
-$shell = new \Magento\Shell($logger);
+$shell = new \Magento\Shell(new \Magento\OSInfo(), $logger);
 $scenarioHandler = new \Magento\TestFramework\Performance\Scenario\Handler\FileFormat();
 $scenarioHandler
     ->register('jmx', new \Magento\TestFramework\Performance\Scenario\Handler\Jmeter($shell))
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php
index 3438fbe93c13c24fe9b4ebfc7f8d3e4b1ff932b5..779cb56c58c9fa62cdf7ca3cc270aaa83700290c 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php
@@ -67,7 +67,7 @@ class CompilerTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->_shell = new \Magento\Shell();
+        $this->_shell = new \Magento\Shell(new \Magento\OSInfo());
         $basePath = \Magento\TestFramework\Utility\Files::init()->getPathToSource();
         $basePath = str_replace('\\', '/', $basePath);
 
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php
index 349012feacf08296da864c584e5a5907c765f82d..d71f5d9ac12a77d166391160e5c74a2a239b6df0 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php
@@ -269,8 +269,8 @@ return array (
     'sales_bestsellers_aggregated_daily' => 'Magento_Sales',
     'sales_bestsellers_aggregated_monthly' => 'Magento_Sales',
     'sales_bestsellers_aggregated_yearly' => 'Magento_Sales',
-    'sales_billing_agreement' => 'Magento_Sales',
-    'sales_billing_agreement_order' => 'Magento_Sales',
+    'paypal_billing_agreement' => 'Magento_Paypal',
+    'paypal_billing_agreement_order' => 'Magento_Paypal',
     'sales_flat_creditmemo' => 'Magento_Sales',
     'sales_flat_creditmemo_comment' => 'Magento_Sales',
     'sales_flat_creditmemo_grid' => 'Magento_Sales',
@@ -302,8 +302,8 @@ return array (
     'sales_flat_quote_item' => 'Magento_Sales',
     'sales_flat_quote_item_option' => 'Magento_Sales',
     'sales_flat_quote_payment' => 'Magento_Sales',
-    'sales_recurring_profile' => 'Magento_Sales',
-    'sales_recurring_profile_order' => 'Magento_Sales',
+    'recurring_profile' => 'Magento_RecurringProfile',
+    'recurring_profile_order' => 'Magento_RecurringProfile',
     'sales_refunded_aggregated' => 'Magento_Sales',
     'sales_refunded_aggregated_order' => 'Magento_Sales',
     'sales_flat_shipment' => 'Magento_Sales',
diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt
index 3abb2660b655521f14a00690f05f8aae1698703d..fc49bd3a9e879e2b5da6a695a41cb076ef71eb7c 100644
--- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt
@@ -1,3 +1,4 @@
+app/code/Magento/Authorizenet/view/adminhtml/js/direct-post.js
 app/code/Magento/Backend/view/adminhtml/variables.js
 app/code/Magento/Captcha/view/frontend/onepage.js
 app/code/Magento/Catalog/view/adminhtml/catalog/category/edit.js
@@ -15,6 +16,5 @@ app/code/Magento/Theme/view/frontend/menu.js
 pub/lib/mage/adminhtml
 pub/lib/mage/backend/editablemultiselect.js
 pub/lib/mage/captcha.js
-pub/lib/mage/directpost.js
 pub/lib/mage/flex.js
 pub/lib/mage/jquery-no-conflict.js
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
index d36e5d29a613fef02675571cf94c77440dd1f29f..da2a50cfe60f79d8995d190bfc66cc4c9a8261df 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
@@ -300,10 +300,8 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
             'setIsEnabled',
             'setIsGuestNote',
             'setIsHandle',
-            'setIsInCatalogProduct',
             'setIsLinkMode',
             'setIsPlaneMode',
-            'setIsQuoteAllowed',
             'setIsTitleHidden',
             'setIsViewCurrent',
             'setItemLimit',
@@ -327,7 +325,6 @@ class LayoutTest extends \PHPUnit_Framework_TestCase
             'setRewardMessage',
             'setRewardQtyLimitationMessage',
             'setShouldPrepareInfoTabs',
-            'setShowOrPosition',
             'setShowPart',
             'setSignupLabel',
             'setSourceField',
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php
index 5005cea86c1b4e1b8b28cd53e4cd1eaad1a0ae26..bc5ac0715dd65e6ba0679795c56f1dd2c02cbb51 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php
@@ -396,7 +396,8 @@ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
             list($constant, $class, $replacement) = $row;
             if ($class) {
                 $fullyQualified = "{$class}::{$constant}";
-                $regex = preg_quote($fullyQualified, '/');
+                $fullyQualified = strtr($fullyQualified, array('\\' => '\\\\'));
+                $regex = preg_quote($fullyQualified);
                 if ($this->_isClassOrInterface($content, $class)) {
                     $regex .= '|' . $this->_getClassConstantDefinitionRegExp($constant)
                         . '|' . preg_quote("self::{$constant}", '/')
@@ -412,7 +413,7 @@ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
                 $fullyQualified = $constant;
                 $regex = preg_quote($constant, '/');
             }
-            $this->_assertNotRegExp('/[^a-z\d_]' . $regex . '[^a-z\d_]/iS', $content,
+            $this->_assertNotRegExp('/[^a-z\d_](' . $regex . ')[^a-z\d_]/iS', $content,
                 $this->_suggestReplacement(sprintf("Constant '%s' is obsolete.", $fullyQualified), $replacement)
             );
         }
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php
index d3f1f58b232ed2f50a27ca888281b2e284798e56..6cffade461be1d57d4aa7a818b72740ff1ff800d 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php
@@ -1064,6 +1064,9 @@ return array(
     array('Magento\Backup\Model\Resource\Helper\Mysql4', 'Magento\Backup\Model\Resource\Helper'),
     array('Magento\Sales\Model\CarrierFactory', 'Magento\Shipping\Model\CarrierFactory'),
     array('Magento\Sales\Model\Order\Pdf\Shipment\Packaging', 'Magento\Shipping\Model\Order\Pdf\Packaging'),
+    array(
+        'Magento\Sales\Model\Observer\Backend\RecurringProfile\FormRenderer', 'Magento\RecurringProfile\Model\Observer'
+    ),
     array('Magento\Sales\Model\ResourceFactory'),
     array('Magento\Sales\Model\Resource\Helper\Mysql4', 'Magento\Sales\Model\Resource\Helper'),
     array('Magento\Core\Model\Resource\Helper\Mysql4', 'Magento\Core\Model\Resource\Helper'),
@@ -1075,6 +1078,8 @@ return array(
     array('Magento\Sales\Model\Resource\Helper\HelperInterface', 'Magento\Sales\Model\Resource\HelperInterface'
     ),
     array('Magento\Reports\Model\Resource\Helper\HelperInterface', 'Magento\Reports\Model\Resource\HelperInterface'),
+    array('Magento\Payment\Block\Catalog\Product\View\Profile',
+        'Magento\RecurringProfile\Block\Catalog\Product\View\Profile'),
     array('Magento\Poll\Block\ActivePoll'),
     array('Magento\Poll\Controller\Vote'),
     array('Magento\Poll\Helper\Data'),
@@ -1847,10 +1852,50 @@ return array(
         'Magento\Catalog\Block\Product\View\Type\Grouped',
         'Magento\GroupedProduct\Block\Product\View\Type\Grouped'
     ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring\Profile',
+        'Magento\RecurringProfile\Block\Adminhtml\Customer\Edit\Tab\RecurringProfile'
+    ),
     array(
         'Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped',
         'Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped'
     ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\Edit\Form',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\Edit\Form'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\Grid',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\Grid'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\View',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\View'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Getawayinfo',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\View\Getawayinfo'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Info',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\View\Info'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Items',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\View\Info'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Info',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Info'
+    ),
+    array(
+        'Magento\Sales\Block\Adminhtml\Recurring\Profile\View\Tab\Orders',
+        'Magento\RecurringProfile\Block\Adminhtml\Profile\View\Tab\Orders'
+    ),
     array(
         'Magento\Sales\Model\Order\Pdf\Items\Invoice\Grouped',
         'Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice\Grouped'
@@ -1859,6 +1904,46 @@ return array(
         'Magento\Sales\Block\Order\Item\Renderer\Grouped',
         'Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped'
     ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\Related\Orders\Grid',
+        'Magento\RecurringProfile\Block\Profile\Related\Orders\Grid'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profiles',
+        'Magento\RecurringProfile\Block\Profiles'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\Grid',
+        'Magento\RecurringProfile\Block\Profile\Grid'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View',
+        'Magento\RecurringProfile\Block\Profile\View'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View\Address',
+        'Magento\RecurringProfile\Block\Profile\View\Address'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View\Data',
+        'Magento\RecurringProfile\Block\Profile\View\Data'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View\Fees',
+        'Magento\RecurringProfile\Block\Profile\View\Fees'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View\Item',
+        'Magento\RecurringProfile\Block\Profile\View\Item'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View\Reference',
+        'Magento\RecurringProfile\Block\Profile\View\Reference'
+    ),
+    array(
+        'Magento\Sales\Block\Recurring\Profile\View\Schedule',
+        'Magento\RecurringProfile\Block\Profile\View\Schedule'
+    ),
     array(
         'Magento\ImportExport\Model\Export\Entity\Product\Type\Grouped',
         'Magento\GroupedProduct\Model\Export\Entity\Product\Type\Grouped'
@@ -1877,12 +1962,24 @@ return array(
     ],
     ['Magento\Shipping\Model\Rate\Request', 'Magento\Sales\Model\Quote\Address\RateRequest'],
     array('Magento\PageCache\Block\Adminhtml\Cache\Additional'),
-    array('Magento\PageCache\Controller\Adminhtml\PageCache'),
     array('Magento\PageCache\Model\Control\ControlInterface'),
     array('Magento\PageCache\Model\Control\Zend'),
     array('Magento\PageCache\Model\System\Config\Source\Controls'),
     array('Magento\PageCache\Model\CacheControlFactory'),
+    array('Magento\Catalog\Block\Adminhtml\System\Config\Form\Field\Select\Flatcatalog'),
+    array('Magento\Catalog\Helper\Category\Flat'),
+    array('Magento\Catalog\Model\Category\Indexer\Flat'),
     array('Magento\Config\Dom\Converter\ArrayConverter'),
     array('Magento\Acl\Resource\Config\Dom'),
+    array('Magento\Sales\Model\Recurring\Profile', 'Magento\RecurringProfile\Model\Profile'),
+    array('Magento\Sales\Model\Resource\Recurring\Profile', 'Magento\RecurringProfile\Model\Resource\Profile'),
+    array(
+        'Magento\Sales\Model\Resource\Recurring\Profile\Collection',
+        'Magento\RecurringProfile\Model\Resource\Profile\Collection'
+    ),
+    ['Magento\Payment\Model\Recurring\Profile', 'Magento\RecurringProfile\Model\RecurringProfile'],
+    ['Magento\Validator\Composite\VarienObject', 'Magento\Validator\Object'],
     array('Magento\GoogleShopping\Helper\Price', 'Magento\Catalog\Model\Product\CatalogPrice'),
+    ['Magento\Sales\Controller\Adminhtml\Recurring\Profile', 'Magento\RecurringProfile\Controller\Adminhtml\Profile'],
+    ['Magento\Sales\Controller\Recurring\Profile', 'Magento\RecurringProfile\Controller\Profile'],
 );
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 a92aa0502174e6984213968869cd22a7de3ce006..e75ac2ad079810868a5a1f9ebe93f8090d315414 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
@@ -574,4 +574,27 @@ return array(
     array('GENERATION', '\Magento\Filesystem', '\Magento\App\Filesystem::GENERATION_DIR'),
     array('UPLOAD', '\Magento\Filesystem', '\Magento\App\Filesystem::UPLOAD_DIR'),
     array('SYS_TMP', '\Magento\Filesystem', '\Magento\App\Filesystem::SYS_TMP_DIR'),
+    ['PERIOD_UNIT_DAY', '\Magento\Payment\Model\Recurring\Profile', '\Magento\RecurringProfile\Model\PeriodUnits::DAY'],
+    [
+        'PERIOD_UNIT_WEEK',
+        '\Magento\Payment\Model\Recurring\Profile',
+        '\Magento\RecurringProfile\Model\PeriodUnits::WEEK'
+    ],
+    [
+        'PERIOD_UNIT_SEMI_MONTH',
+        '\Magento\Payment\Model\Recurring\Profile',
+        '\Magento\RecurringProfile\Model\PeriodUnits::SEMI_MONTH'
+    ],
+    [
+        'PERIOD_UNIT_MONTH',
+        '\Magento\Payment\Model\Recurring\Profile',
+        '\Magento\RecurringProfile\Model\PeriodUnits::MONTH'
+    ],
+    [
+        'PERIOD_UNIT_YEAR',
+        '\Magento\Payment\Model\Recurring\Profile',
+        '\Magento\RecurringProfile\Model\PeriodUnits::YEAR'
+    ],
+    array('XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY', '\Magento\Catalog\Helper\Category\Flat',
+        '\Magento\Catalog\Model\Indexer\Category\Flat\Config::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY'),
 );
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
index 47489e0f5125a8416523783e5faab271bd8b316c..269180b520acde22356f1bf6cb65c81eb72859e4 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
@@ -320,6 +320,7 @@ return array(
     array('getAclPrivilegeSet', 'Magento\Admin\Model\Config'),
     array('getAclResourceList', 'Magento\Admin\Model\Config'),
     array('getAclResourceTree', 'Magento\Admin\Model\Config'),
+    array('getAddress', 'Magento\Customer\Block\Form\Register'),
     array('getAddNewButtonHtml', 'Magento\Backend\Block\Catalog\Product'),
     array('getAddNewButtonHtml', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'),
     array('getAddToCartItemUrl', 'Magento\Wishlist\Block\Customer\Sidebar'),
@@ -331,6 +332,12 @@ return array(
     array('getAnonSuffix'),
     array('getAttributeDataModelFactory', 'Magento\Eav\Model\Validator\Attribute\Data'),
     array('getAttributesJson', 'Magento\Backend\Block\Catalog\Product\Edit\Tab\Super\Config', 'getAttributes'),
+    array(
+        'getAllStates',
+        'Magento\Sales\Model\Recurring\Profile',
+        'Magento\RecurringProfile\Model\States::toOptionArray()'
+    ),
+    array('getStateLabel', 'Magento\Sales\Model\Recurring\Profile'),
     array('getBaseTaxAmount', 'Magento\Sales\Model\Quote\Item\AbstractItem'),
     array('getBlockClassName', 'Magento\Core\Model\Config'),
     array('getButtonsHtml', 'Magento_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Search'),
@@ -462,6 +469,8 @@ return array(
     array('getPriceFormatted', 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales'),
     array('getPrices', 'Magento\Bundle\Model\Product\Price', 'getTotalPrices()'),
     array('getPricesDependingOnTax', 'Magento\Bundle\Model\Product\Price', 'getTotalPrices()'),
+    array('getPrimaryBillingAddress', 'Magento\Customer\Block\Address\Book', 'getDefaultBilling'),
+    array('getPrimaryShippingAddress', 'Magento\Customer\Block\Address\Book', 'getDefaultShipping'),
     array('getPrintUrl', 'Magento\Checkout\Block\Onepage\Success'),
     array('getPrintUrl', 'Magento\Sales\Block\Order\Info'),
     array('getProduct', 'Magento\Catalog\Model\Product\Type\AbstractType'),
@@ -656,7 +665,7 @@ return array(
     array('prepareRedirect', 'Magento\Core\Controller\Varien\Exception'),
     array('prepareItemInfo', 'Magento\Sales\Block\Recurring\Profile\View'),
     array('preparePriceAlertData', 'Magento\ProductAlert\Block\Product\View'),
-    array('prepareProfilesGrid', 'Magento\Sales\Block\Recurring\Profiles'),
+    array('prepareProfilesGrid', 'Magento\Sales\Block\Recurring\Profile'),
     array('prepareReferenceInfo', 'Magento\Sales\Block\Recurring\Profile\View'),
     array('prepareRelatedOrdersFrontendGrid', 'Magento\Sales\Block\Recurring\Profile\View'),
     array('prepareScheduleInfo', 'Magento\Sales\Block\Recurring\Profile\View'),
@@ -781,7 +790,11 @@ return array(
     ),
     array(
         'prepareProductEditFormRecurringProfile', 'Magento\Sales\Model\Observer',
-        'Magento_Sales_Model_Observer_Backend_RecurringProfile_FormRenderer::render'
+        'Magento\RecurringProfile\Model\Observer::addFieldsToProductEditForm'
+    ),
+    array(
+        'prepareProductRecurringProfileOptions', 'Magento\Payment\Model\Observer',
+        'Magento\RecurringProfile\Model\Observer::prepareProductRecurringProfileOptions'
     ),
     array(
         'restrictAdminBillingAgreementUsage', 'Magento\Sales\Model\Observer',
@@ -1178,6 +1191,40 @@ return array(
     array('copyInventoryData', 'Magento\CatalogInventory\Model\Observer',
         '\Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory::build'
     ),
+    array('isEnabled', '\Magento\Catalog\Helper\Category\Flat',
+        '\Magento\Catalog\Model\Indexer\Category\Flat\Config::isFlatEnabled'),
+    array('categorySaveAfter', '\Magento\Catalog\Model\Observer'),
+    array('storeDelete', '\Magento\Catalog\Model\Observer'),
+    array('categoryMove', '\Magento\Catalog\Model\Observer'),
+    array('storeGroupSave', '\Magento\Catalog\Model\Observer'),
+    array('catalogProductImportAfter', '\Magento\Catalog\Model\Observer'),
+    array('storeEdit', '\Magento\Catalog\Model\Observer'),
+    array('storeAdd', '\Magento\Catalog\Model\Observer'),
+    array('removeStores', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('deleteStores', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_deleteTable', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('getStoresRootCategories', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('moveold', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_getAttributeTypeValues', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_getAttributeValues', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_prepareDataForAllFields', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_synchronize', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_getStaticColumns', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_getEavColumns', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_getAttributes', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_createTable', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('createTable', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_createTables', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_prepareValuesToInsert', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_populateFlatTables', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('rebuild', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('isRebuilt', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('isBuilt', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('move', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('synchronize', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('reindexAll', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('getDesignUpdateData', '\Magento\Catalog\Model\Resource\Category\Flat'),
+    array('getUseStoreTables', '\Magento\Catalog\Model\Resource\Category\Flat'),
     ['getTrackingAjaxUrl', 'Magento\Shipping\Helper\Data'],
     ['isFreeMethod', 'Magento\Shipping\Helper\Data'],
     ['_initOrder', 'Magento\Shipping\Controller\Tracking'],
@@ -1196,7 +1243,31 @@ return array(
     array('getFileIdentifier', 'Magento\View\Layout\File\FileList', 'Magento\View\Layout\File'),
     array('_getInitialXml', 'Magento\Config\Theme'),
     array('_getIdAttributes', 'Magento\Config\Theme'),
+    [
+        'getAllPeriodUnits',
+        'Magento\Payment\Model\Recurring\Profile',
+        'Magento\RecurringProfile\Model\PeriodUnits::toOptionArray'
+    ],
+    [
+        'getPeriodUnitLabel',
+        'Magento\Payment\Model\Recurring\Profile',
+        'Magento\RecurringProfile\Model\PeriodUnits::toOptionArray()[\Magento\RecurringProfile\Model\PeriodUnits::DAY]'
+    ],
+    [
+        'getFieldComment',
+        'Magento\Payment\Model\Recurring\Profile',
+        'Magento\RecurringProfile\Block\Fields::getFieldComment',
+    ],
+    [
+        'getFieldLabel',
+        'Magento\Payment\Model\Recurring\Profile',
+        'Magento\RecurringProfile\Block\Fields::getFieldLabel',
+    ],
+    ['_ensureLocaleAndStore', 'Magento\Payment\Model\Recurring\Profile'],
+    ['setLocale', 'Magento\Payment\Model\Recurring\Profile', 'Locale instance injected via constructor'],
     array('_getSession', 'Magento\CatalogSearch\Controller\Result'),
     array('addPriceBlockType', 'Magento\Rss\Block\Catalog\AbstractCatalog'),
     array('getAttributeDisabledTypes', 'Magento\Catalog\Helper\Data'),
+    array('cleanAction', 'Magento\PageCache\Controller\Adminhtml\PageCache'),
+    array('_isAllowed', 'Magento\PageCache\Controller\Adminhtml\PageCache')
 );
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php
index 27369667fcae29d25a595fee90d36256a161814d..4fde419a4dd5fb9e44a5046fe27ea6b392e47873 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php
@@ -272,5 +272,17 @@ return array(
     array('_messagesBlock', 'Magento\View\Element\AbstractBlock'),
     array('_messagesBlock', 'Magento\Connect\Helper\Data'),
     array('escapeMessageFlag', 'Magento\View\Block\Messages'),
+    array('_flatResourceFactory', 'Magento\Catalog\Model\Observer'),
+    array('_catalogCategoryFlat', 'Magento\Catalog\Model\Observer'),
+    array('_catalogCategoryFlat', 'Magento\Catalog\Block\Navigation'),
+    array('_catalogCategoryFlat', 'Magento\Catalog\Model\Category'),
+    array('_storesRootCategories', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_resourceHelper', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_catalogCategory', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_isRebuilt', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_isBuilt', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_attributeCodes', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_columnsSql', 'Magento\Catalog\Model\Resource\Category\Flat'),
+    array('_columns', 'Magento\Catalog\Model\Resource\Category\Flat'),
     array('fileIteratorFactory', 'Magento\Core\Model\Theme\Collection')
 );
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt
index 5d72f476bdc778ce1a809bbd392961e85d7c3d6b..29027b3e37346841f3ead0da36b7ce77d4077fd7 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt
@@ -15,6 +15,7 @@ app/code/Magento/Theme/view
 app/code/Magento/User/view
 app/code/Magento/Webapi/view
 app/code/Magento/GroupedProduct/view
+app/code/Magento/RecurringProfile/view
 dev/tests/integration/framework/Magento/TestFramework/Db/Mysql.php
 dev/tests/integration/framework/Magento/TestFramework/Db/Adapter/Mysql.php
 dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
index 4ebad2069b10d9c20e3a17dd0a3de802ec21142d..b33ac56c1ffc7cda3ccb170c590380d09c369bb2 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
@@ -63,6 +63,7 @@ app/code/Magento/Customer/Block/Account/{Authorization,Register}Link.php
 app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php
 app/code/Magento/Customer/Model/Address/Config
 app/code/Magento/Customer/Model/Address/Config.php
+app/code/Magento/Customer/Service
 app/code/Magento/Directory/Model/Currency/DefaultLocator.php
 app/code/Magento/Directory/Model/Resource/Region
 app/code/Magento/Eav/Model/Cache/Type.php
@@ -95,6 +96,7 @@ app/code/Magento/Log/Model/Shell.php
 app/code/Magento/Log/Model/Shell
 app/code/Magento/Theme/Block/Html/Head
 app/code/Magento/ProductAlert/Block/Product/View
+app/code/Magento/RecurringProfile
 app/code/Magento/Reports/Block/Adminhtml/Customer
 app/code/Magento/Reports/Block/Adminhtml/Product
 app/code/Magento/Reports/Controller/Adminhtml/Report/Customer.php
@@ -105,9 +107,6 @@ app/code/Magento/Reports/Model/Resource/Customer
 app/code/Magento/Reports/Model/Resource/Report/Collection.php
 app/code/Magento/Sales/Block/Guest/Link.php
 app/code/Magento/Sales/Block/Order/Link.php
-app/code/Magento/Sales/Block/Recurring/Profile/Grid.php
-app/code/Magento/Sales/Block/Recurring/Profile/Related/Orders/Grid.php
-app/code/Magento/Sales/Block/Recurring/Profile/View
 app/code/Magento/Sales/Model/Order/Pdf/Config
 app/code/Magento/Sales/Model/Order/Pdf/Config.php
 app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php
@@ -134,9 +133,11 @@ lib/Magento/Backup/Db
 lib/Magento/Backup/Factory.php
 lib/Magento/Cache/Core.php
 lib/Magento/Convert
+lib/Magento/Exception
 lib/Magento/Stdlib/DateTime.php
 lib/Magento/Object.php
 lib/Magento/App
 lib/Magento/ObjectManager
+lib/Magento/Service
 lib/Magento/Url/SecurityInfoInterface.php
 lib/Magento/View
diff --git a/dev/tests/unit/framework/Magento/TestFramework/Matcher/MethodInvokedAtIndex.php b/dev/tests/unit/framework/Magento/TestFramework/Matcher/MethodInvokedAtIndex.php
new file mode 100644
index 0000000000000000000000000000000000000000..f546d8b64fc2b8352ad70853c57d94d71141b148
--- /dev/null
+++ b/dev/tests/unit/framework/Magento/TestFramework/Matcher/MethodInvokedAtIndex.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\TestFramework\Matcher;
+
+class MethodInvokedAtIndex extends \PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
+{
+    /**
+     * @var array
+     */
+    protected $indexes = array();
+
+    /**
+     * @param  \PHPUnit_Framework_MockObject_Invocation $invocation
+     * @return boolean
+     */
+    public function matches(\PHPUnit_Framework_MockObject_Invocation $invocation)
+    {
+        if (!isset($this->indexes[$invocation->methodName])) {
+            $this->indexes[$invocation->methodName] = 0;
+        } else {
+            $this->indexes[$invocation->methodName]++;
+        }
+        $this->currentIndex++;
+
+        return $this->indexes[$invocation->methodName] == $this->sequenceIndex;
+    }
+}
\ No newline at end of file
diff --git a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ae48bff7c46243aed58b8ddb8be907da1eb5bb1a
--- /dev/null
+++ b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Matcher/MethodInvokedAtIndexTest.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     unit_tests
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\TestFramework\Matcher;
+
+use Magento\TestFramework\Matcher\MethodInvokedAtIndex as MethodInvokedAtIndex;
+
+class MethodInvokedAtIndexTest extends \PHPUnit_Framework_TestCase
+{
+    public function testMatches()
+    {
+        $invocationObject = new \PHPUnit_Framework_MockObject_Invocation_Object(
+            'ClassName',
+            'ValidMethodName',
+            array(),
+            new \StdClass()
+        );
+        $matcher = new MethodInvokedAtIndex(0);
+        $this->assertTrue($matcher->matches($invocationObject));
+
+        $matcher = new MethodInvokedAtIndex(1);
+        $matcher->matches($invocationObject);
+        $this->assertTrue($matcher->matches($invocationObject));
+    }
+}
+ 
\ No newline at end of file
diff --git a/dev/tests/unit/phpunit.xml.dist b/dev/tests/unit/phpunit.xml.dist
index c8890b51978dbbcb7c0f2ed61c38df0606489877..1ef1caddfa677afc240905561143d18bf0a7e452 100755
--- a/dev/tests/unit/phpunit.xml.dist
+++ b/dev/tests/unit/phpunit.xml.dist
@@ -50,5 +50,8 @@
         <!--coverage_html_placeholder
             <log type="coverage-html" target="{{coverage_dir}}/test-reports/coverage" charset="UTF-8" yui="true" highlight="true"/>
         coverage_html_placeholder-->
+        <!--coverage_clover_placeholder
+            <log type="coverage-clover" target="{{coverage_dir}}/test-reports/phpunit.coverage.xml"/>
+        coverage_clover_placeholder-->
     </logging>
 </phpunit>
diff --git a/dev/tests/unit/testsuite/Magento/App/CronTest.php b/dev/tests/unit/testsuite/Magento/App/CronTest.php
index e5d3aaa24e765bbc6fbd77c36f47b73d45599da3..1191645f36f9cd00269feb3008ecafb4139b9b33 100644
--- a/dev/tests/unit/testsuite/Magento/App/CronTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/CronTest.php
@@ -45,6 +45,11 @@ class CronTest extends \PHPUnit_Framework_TestCase
      */
     protected $_stateMock;
 
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_request;
+
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject
      */
@@ -54,10 +59,12 @@ class CronTest extends \PHPUnit_Framework_TestCase
     {
         $this->_eventManagerMock = $this->getMock('Magento\Event\ManagerInterface');
         $this->_stateMock = $this->getMock('Magento\App\State', array(), array(), '', false);
+        $this->_request = $this->getMock('Magento\App\Console\Request', array(), array(), '', false);
         $this->_responseMock = $this->getMock('Magento\App\Console\Response', array(), array(), '', false);
         $this->_model = new Cron(
             $this->_eventManagerMock,
             $this->_stateMock,
+            $this->_request,
             $this->_responseMock
         );
     }
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..c37f7b141bc112ebd7371e07c196ac47f080ac19
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\State|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $stateMock;
+
+    /**
+     * @var \Magento\Code\Plugin\InvocationChain|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $chainMock;
+
+    protected function setUp()
+    {
+        $this->stateMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\State', array('isFlatEnabled'), array(), '', false
+        );
+
+        $this->chainMock = $this->getMock(
+            'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false
+        );
+
+        $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData(
+            $this->stateMock
+        );
+    }
+
+    /**
+     * @param bool $isFlat
+     * @param array $arguments
+     * @param array $inputData
+     * @param array $outputData
+     * @dataProvider aroundGetDataProvider
+     */
+    public function testAroundGet($isFlat, array $arguments, $inputData, $outputData)
+    {
+        $this->stateMock->expects($this->once())
+            ->method('isFlatEnabled')
+            ->will($this->returnValue($isFlat));
+
+        $this->chainMock->expects($this->once())
+            ->method('proceed')
+            ->with($arguments)
+            ->will($this->returnValue($inputData));
+
+        $this->assertEquals($outputData, $this->model->aroundGet($arguments, $this->chainMock));
+    }
+
+    public function aroundGetDataProvider()
+    {
+        $flatIndexerData = array(
+            'indexer_id' => 'catalog_category_flat',
+            'action' => '\Action\Class',
+            'title' => 'Title',
+            'description' => 'Description',
+        );
+        $otherIndexerData = array(
+            'indexer_id' => 'other_indexer',
+            'action' => '\Action\Class',
+            'title' => 'Title',
+            'description' => 'Description',
+        );
+        return array(
+            // flat is enabled, nothing is being changed
+            array(
+                true,
+                array(),
+                array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData),
+                array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData),
+            ),
+            // flat is disabled, path is absent, flat indexer is being removed
+            array(
+                false,
+                array(),
+                array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData),
+                array('other_indexer' => $otherIndexerData),
+            ),
+            // flat is disabled, path is null, flat indexer is being removed
+            array(
+                false,
+                array('path' => null),
+                array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData),
+                array('other_indexer' => $otherIndexerData),
+            ),
+            // flat is disabled, path is flat indexer, flat indexer is being removed
+            array(
+                false,
+                array('path' => 'catalog_category_flat'),
+                $flatIndexerData,
+                null,
+            ),
+            // flat is disabled, path is flat indexer, default is array(), flat indexer is being array()
+            array(
+                false,
+                array('path' => 'catalog_category_flat', 'default' => array()),
+                $flatIndexerData,
+                array(),
+            ),
+            // flat is disabled, path is other indexer, nothing is being changed
+            array(
+                false,
+                array('path' => 'other_indexer'),
+                $otherIndexerData,
+                $otherIndexerData,
+            ),
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..e39760928d8d48e0378c016ae678d286fb33c62d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php
@@ -0,0 +1,153 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class StoreGroupTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface
+     */
+    protected $indexerMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State
+     */
+    protected $stateMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Plugin\InvocationChain
+     */
+    protected $pluginMock;
+
+    /**
+     * @var StoreView
+     */
+    protected $model;
+
+    protected function setUp()
+    {
+        $this->pluginMock = $this->getMock(
+            'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false
+        );
+        $this->indexerMock = $this->getMockForAbstractClass(
+            'Magento\Indexer\Model\IndexerInterface',
+            array(), '', false, false, true, array('getId', 'getState', '__wakeup')
+        );
+        $this->stateMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\State', array('isFlatEnabled'), array(), '', false
+        );
+        $this->model = new StoreGroup(
+            $this->indexerMock,
+            $this->stateMock
+        );
+    }
+
+    public function testAroundSave()
+    {
+        $this->mockConfigFlatEnabled();
+        $this->mockIndexerMethods();
+        $groupMock = $this->getMock(
+            'Magento\Core\Model\Store\Group', array('dataHasChangedFor', 'isObjectNew', '__wakeup'), array(), '', false
+        );
+        $groupMock->expects($this->once())
+            ->method('dataHasChangedFor')
+            ->with('root_category_id')
+            ->will($this->returnValue(true));
+        $groupMock->expects($this->once())
+            ->method('isObjectNew')
+            ->will($this->returnValue(false));
+
+        $arguments = array($groupMock);
+        $this->mockPluginProceed($arguments);
+        $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock));
+    }
+
+    public function testAroundSaveNotNew()
+    {
+        $this->mockConfigFlatEnabledNever();
+        $groupMock = $this->getMock(
+            'Magento\Core\Model\Store\Group', array('dataHasChangedFor', 'isObjectNew', '__wakeup'), array(), '', false
+        );
+        $groupMock->expects($this->once())
+            ->method('dataHasChangedFor')
+            ->with('root_category_id')
+            ->will($this->returnValue(true));
+        $groupMock->expects($this->once())
+            ->method('isObjectNew')
+            ->will($this->returnValue(true));
+
+        $arguments = array($groupMock);
+        $this->mockPluginProceed($arguments);
+        $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock));
+    }
+
+    /**
+     * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Indexer\State
+     */
+    protected function getStateMock()
+    {
+        $stateMock = $this->getMock(
+            'Magento\Indexer\Model\Indexer\State', array('setStatus', 'save', '__wakeup'), array(), '', false
+        );
+        $stateMock->expects($this->once())
+            ->method('setStatus')
+            ->with('invalid')
+            ->will($this->returnSelf());
+        $stateMock->expects($this->once())
+            ->method('save')
+            ->will($this->returnSelf());
+
+        return $stateMock;
+    }
+
+    protected function mockIndexerMethods()
+    {
+        $this->indexerMock->expects($this->once())
+            ->method('getId')
+            ->will($this->returnValue(1));
+        $this->indexerMock->expects($this->once())
+            ->method('invalidate');
+    }
+
+    protected function mockConfigFlatEnabled()
+    {
+        $this->stateMock->expects($this->once())
+            ->method('isFlatEnabled')
+            ->will($this->returnValue(true));
+    }
+
+    protected function mockPluginProceed($arguments, $returnValue = false)
+    {
+        $this->pluginMock->expects($this->once())
+            ->method('proceed')
+            ->with($arguments)
+            ->will($this->returnValue($returnValue));
+    }
+
+    protected function mockConfigFlatEnabledNever()
+    {
+        $this->stateMock->expects($this->never())
+            ->method('isFlatEnabled');
+    }
+}
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..158f3ed4b02196e8016a8350e7e9372ddf9e2a18
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php
@@ -0,0 +1,158 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;
+
+class StoreViewTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\IndexerInterface
+     */
+    protected $indexerMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State
+     */
+    protected $stateMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Plugin\InvocationChain
+     */
+    protected $pluginMock;
+
+    /**
+     * @var StoreView
+     */
+    protected $model;
+
+    protected function setUp()
+    {
+        $this->pluginMock = $this->getMock(
+            'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false
+        );
+        $this->indexerMock = $this->getMockForAbstractClass(
+            'Magento\Indexer\Model\IndexerInterface',
+            array(), '', false, false, true, array('getId', 'getState', '__wakeup')
+        );
+        $this->stateMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\State', array('isFlatEnabled'), array(), '', false
+        );
+        $this->model = new StoreView(
+            $this->indexerMock,
+            $this->stateMock
+        );
+    }
+
+    public function testAroundSaveNewObject()
+    {
+        $this->mockConfigFlatEnabled();
+        $this->mockIndexerMethods();
+        $storeMock = $this->getMock(
+            'Magento\Core\Model\Store', array('isObjectNew', 'dataHasChangedFor', '__wakeup'), array(), '', false
+        );
+        $storeMock->expects($this->once())
+            ->method('isObjectNew')
+            ->will($this->returnValue(true));
+        $arguments = array($storeMock);
+        $this->mockPluginProceed($arguments);
+        $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock));
+    }
+
+    public function testAroundSaveHasChanged()
+    {
+        $storeMock = $this->getMock(
+            'Magento\Core\Model\Store', array('isObjectNew', 'dataHasChangedFor', '__wakeup'), array(), '', false
+        );
+        $storeMock->expects($this->once())
+            ->method('dataHasChangedFor')
+            ->with('group_id')
+            ->will($this->returnValue(true));
+        $arguments = array($storeMock);
+        $this->mockPluginProceed($arguments);
+        $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock));
+    }
+
+    public function testAroundSaveNoNeed()
+    {
+        $this->mockConfigFlatEnabledNeever();
+        $storeMock = $this->getMock(
+            'Magento\Core\Model\Store', array('isObjectNew', 'dataHasChangedFor', '__wakeup'), array(), '', false
+        );
+        $storeMock->expects($this->once())
+            ->method('dataHasChangedFor')
+            ->with('group_id')
+            ->will($this->returnValue(false));
+        $arguments = array($storeMock);
+        $this->mockPluginProceed($arguments);
+        $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock));
+    }
+
+    /**
+     * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Indexer\State
+     */
+    protected function getStateMock()
+    {
+        $stateMock = $this->getMock(
+            'Magento\Indexer\Model\Indexer\State', array('setStatus', 'save', '__wakeup'), array(), '', false
+        );
+        $stateMock->expects($this->once())
+            ->method('setStatus')
+            ->with('invalid')
+            ->will($this->returnSelf());
+        $stateMock->expects($this->once())
+            ->method('save')
+            ->will($this->returnSelf());
+
+        return $stateMock;
+    }
+
+    protected function mockIndexerMethods()
+    {
+        $this->indexerMock->expects($this->once())
+            ->method('getId')
+            ->will($this->returnValue(1));
+        $this->indexerMock->expects($this->once())
+            ->method('invalidate');
+    }
+
+    protected function mockConfigFlatEnabled()
+    {
+        $this->stateMock->expects($this->once())
+            ->method('isFlatEnabled')
+            ->will($this->returnValue(true));
+    }
+
+    protected function mockConfigFlatEnabledNeever()
+    {
+        $this->stateMock->expects($this->never())
+            ->method('isFlatEnabled');
+    }
+
+    protected function mockPluginProceed($arguments, $returnValue = false)
+    {
+        $this->pluginMock->expects($this->once())
+            ->method('proceed')
+            ->with($arguments)
+            ->will($this->returnValue($returnValue));
+    }
+}
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..82eb412f43b7709d1dd8cdcf89532d4bcfc4ab64
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/StateTest.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer\Category\Flat;
+
+class StateTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\State
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Core\Model\Store\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $storeConfigMock;
+
+    /**
+     * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $flatIndexerMock;
+
+    protected function setUp()
+    {
+        $this->storeConfigMock = $this->getMockForAbstractClass(
+            'Magento\Core\Model\Store\ConfigInterface',
+            array(), '', false, false, true, array('getConfigFlag', '__wakeup')
+        );
+
+        $this->flatIndexerMock = $this->getMockForAbstractClass(
+            'Magento\Indexer\Model\IndexerInterface',
+            array(), '', false, false, true, array('getId', 'getState', '__wakeup')
+        );
+    }
+
+    public function testIsFlatEnabled()
+    {
+        $this->storeConfigMock->expects($this->once())
+            ->method('getConfigFlag')
+            ->with('catalog/frontend/flat_catalog_category')
+            ->will($this->returnValue(true));
+
+        $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State(
+            $this->storeConfigMock, $this->flatIndexerMock
+        );
+        $this->assertEquals(true, $this->model->isFlatEnabled());
+    }
+
+    /**
+     * @param $isAvailable
+     * @param $isFlatEnabled
+     * @param $isValid
+     * @param $result
+     * @dataProvider isAvailableDataProvider
+     */
+    public function testIsAvailable($isAvailable, $isFlatEnabled, $isValid, $result)
+    {
+        $this->flatIndexerMock->expects($this->any())
+            ->method('getId')
+            ->will($this->returnValue(null));
+        $this->flatIndexerMock->expects($this->any())
+            ->method('load')
+            ->with('catalog_category_flat');
+        $this->flatIndexerMock->expects($this->any())
+            ->method('isValid')
+            ->will($this->returnValue($isValid));
+
+        $this->storeConfigMock->expects($this->any())
+            ->method('getConfigFlag')
+            ->with('catalog/frontend/flat_catalog_category')
+            ->will($this->returnValue($isFlatEnabled));
+
+        $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State(
+            $this->storeConfigMock, $this->flatIndexerMock, $isAvailable
+        );
+        $this->assertEquals($result, $this->model->isAvailable());
+    }
+
+    public function isAvailableDataProvider()
+    {
+        return array(
+            array(false, true, true, false),
+            array(true, false, true, false),
+            array(true, true, false, false),
+            array(true, true, true, true),
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..8424363c6246daffd1a599eca8be3ec671b83f4a
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/FlatTest.php
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Catalog\Model\Indexer\Category;
+
+class FlatTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $fullMock;
+
+    /**
+     * @var \Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $rowsMock;
+
+    /**
+     * @var \Magento\Indexer\Model\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $indexerMock;
+
+    protected function setUp()
+    {
+        $this->fullMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\Action\FullFactory',
+            array('create'), array(), '', false
+        );
+
+        $this->rowsMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\Action\RowsFactory',
+            array('create'), array(), '', false
+        );
+
+        $this->indexerMock = $this->getMockForAbstractClass(
+            'Magento\Indexer\Model\IndexerInterface',
+            array(), '', false, false, true, array('getId', 'load', 'isInvalid', 'isWorking', '__wakeup')
+        );
+
+        $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat(
+            $this->fullMock, $this->rowsMock, $this->indexerMock
+        );
+    }
+
+    public function testExecuteWithIndexerInvalid()
+    {
+        $this->indexerMock->expects($this->once())
+            ->method('load')
+            ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)
+            ->will($this->returnSelf());
+        $this->indexerMock->expects($this->once())
+            ->method('isInvalid')
+            ->will($this->returnValue(true));
+
+        $this->rowsMock->expects($this->never())
+            ->method('create');
+
+        $this->model->execute(array(1, 2, 3));
+    }
+
+    public function testExecuteWithIndexerWorking()
+    {
+        $ids = array(1, 2, 3);
+
+        $this->indexerMock->expects($this->once())
+            ->method('load')
+            ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)
+            ->will($this->returnSelf());
+        $this->indexerMock->expects($this->once())
+            ->method('isInvalid')
+            ->will($this->returnValue(false));
+        $this->indexerMock->expects($this->once())
+            ->method('isWorking')
+            ->will($this->returnValue(true));
+
+        $rowMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows', array('reindex'), array(), '', false
+        );
+        $rowMock->expects($this->at(0))
+            ->method('reindex')
+            ->with($ids, true)
+            ->will($this->returnSelf());
+        $rowMock->expects($this->at(1))
+            ->method('reindex')
+            ->with($ids, false)
+            ->will($this->returnSelf());
+
+        $this->rowsMock->expects($this->once())
+            ->method('create')
+            ->will($this->returnValue($rowMock));
+
+        $this->model->execute($ids);
+    }
+
+    public function testExecuteWithIndexerNotWorking()
+    {
+        $ids = array(1, 2, 3);
+
+        $this->indexerMock->expects($this->once())
+            ->method('load')
+            ->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)
+            ->will($this->returnSelf());
+        $this->indexerMock->expects($this->once())
+            ->method('isInvalid')
+            ->will($this->returnValue(false));
+        $this->indexerMock->expects($this->once())
+            ->method('isWorking')
+            ->will($this->returnValue(false));
+
+        $rowMock = $this->getMock(
+            'Magento\Catalog\Model\Indexer\Category\Flat\Action\Rows', array('reindex'), array(), '', false
+        );
+        $rowMock->expects($this->once())
+            ->method('reindex')
+            ->with($ids, false)
+            ->will($this->returnSelf());
+
+        $this->rowsMock->expects($this->once())
+            ->method('create')
+            ->will($this->returnValue($rowMock));
+
+        $this->model->execute($ids);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php
index e1f2b361e93820080e40d0433cfaf6b577e68110..4e0a0c528743487184f46295d6e70f9f16206a65 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php
@@ -57,25 +57,21 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
     protected function setUp()
     {
         $this->_objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
-        $this->_catalogCategory = $this->getMock('Magento\Catalog\Helper\Category', array(), array(), '', false);
-        $this->_catalogData = $this->getMock('Magento\Catalog\Helper\Data', array(), array(), '', false);
+        $catalogCategory = $this->getMock('Magento\Catalog\Helper\Category', array(), array(), '', false);
+        $catalogData = $this->getMock('Magento\Catalog\Helper\Data', array(), array(), '', false);
         $urlFactoryMock = $this->getMock('Magento\Catalog\Model\UrlFactory', array(), array(), '', false);
-        $catFlatFactoryMock = $this->getMock('Magento\Catalog\Model\Resource\Category\FlatFactory', array(),
-            array(), '', false);
         $productFactoryMock = $this->getMock('Magento\Catalog\Model\Resource\ProductFactory', array(),
             array(), '', false);
-        $this->_catalogCategoryFlat = $this->getMock(
-            'Magento\Catalog\Helper\Category\Flat', array(), array(), '', false
-        );
+        $categoryFlatState = $this->getMock('Magento\Catalog\Model\Indexer\Category\Flat\State', array(),
+            array(), '', false);
         $coreConfig = $this->getMock('Magento\App\ReinitableConfigInterface', array(), array(), '', false);
         $this->_model = $this->_objectHelper->getObject('Magento\Catalog\Model\Observer', array(
-            'catalogCategory' => $this->_catalogCategory,
-            'catalogData' => $this->_catalogData,
-            'catalogCategoryFlat' => $this->_catalogCategoryFlat,
+            'catalogCategory' => $catalogCategory,
+            'catalogData' => $catalogData,
             'coreConfig' => $coreConfig,
             'urlFactory' => $urlFactoryMock,
-            'flatResourceFactory' => $catFlatFactoryMock,
             'productResourceFactory' => $productFactoryMock,
+            'categoryFlatState' => $categoryFlatState,
         ));
         $this->_requestMock = $this->getMock('Magento\App\RequestInterface', array(), array(), '', false);
     }
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Category/FlatTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Category/FlatTest.php
deleted file mode 100644
index ed133bf24f73ff91e35eaea9024528122aa19e6a..0000000000000000000000000000000000000000
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Category/FlatTest.php
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Catalog
- * @subpackage  unit_tests
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-namespace Magento\Catalog\Model\Resource\Category;
-
-class FlatTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\DB\Adapter\Pdo\Mysql|PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_dbAdapterMock;
-
-    protected function setUp()
-    {
-        $this->_dbAdapterMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array(), array(), '', false);
-    }
-
-    /**
-     * @param array $methods
-     * @return \Magento\Catalog\Model\Resource\Category\Flat|PHPUnit_Framework_MockObject_MockObject
-     */
-    protected function _getModelMock(array $methods = array())
-    {
-        return $this->getMockBuilder('Magento\Catalog\Model\Resource\Category\Flat')
-            ->setMethods(array_merge($methods, array('__wakeup')))
-            ->disableOriginalConstructor()
-            ->getMock();
-    }
-
-    public function testCreateTableDoesNotInvokeDdlOperationsIfTheyAreNotAllowed()
-    {
-        $model = $this->_getModelMock(array('_createTable', '_getWriteAdapter'));
-
-        // Pretend that some transaction has been started
-        $this->_dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(1));
-        $model->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($this->_dbAdapterMock));
-
-        $model->expects($this->never())->method('_createTable');
-        $model->createTable(1);
-    }
-
-    public function testCreateTableInvokesDdlOperationsIfTheyAreAllowed()
-    {
-        $model = $this->_getModelMock(array('_createTable', '_getWriteAdapter'));
-
-        // Pretend that no transactions have been started
-        $this->_dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(0));
-        $model->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($this->_dbAdapterMock));
-
-        $model->expects($this->atLeastOnce())->method('_createTable');
-        $model->createTable(1);
-    }
-
-    public function testReindexAllCreatesFlatTablesAndInvokesRebuildProcessWithoutArguments()
-    {
-        $model = $this->_getModelMock(array('_createTables', 'rebuild', 'commit', 'beginTransaction', 'rollBack'));
-        $model->expects($this->once())->method('_createTables');
-        $model->expects($this->once())->method('rebuild')->with($this->isNull());
-        $model->reindexAll();
-    }
-
-    public function testRebuildDoesNotInvokeDdlOperationsIfTheyAreNotAllowed()
-    {
-        $model = $this->_getModelMock(array('_createTable', '_getWriteAdapter', '_populateFlatTables'));
-
-        // Pretend that some transaction has been started
-        $this->_dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(1));
-        $model->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($this->_dbAdapterMock));
-
-        $model->expects($this->never())->method('_createTable');
-
-        $store = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
-        $store->expects($this->any())->method('getId')->will($this->returnValue(1));
-
-        $model->rebuild(array($store));
-    }
-
-    public function testRebuildInvokesDdlOperationsIfTheyAreAllowed()
-    {
-        $model = $this->_getModelMock(array('_createTable', '_getWriteAdapter', '_populateFlatTables'));
-
-        // Pretend that no transactions have been started
-        $this->_dbAdapterMock->expects($this->any())->method('getTransactionLevel')->will($this->returnValue(0));
-        $model->expects($this->any())->method('_getWriteAdapter')->will($this->returnValue($this->_dbAdapterMock));
-
-        $model->expects($this->atLeastOnce())->method('_createTable');
-
-        $store = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
-        $store->expects($this->any())->method('getId')->will($this->returnValue(1));
-
-        $model->rebuild(array($store));
-    }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php b/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php
index 7ec135263921cb3673eef9823992bffad656df30..6ab9ab35d8ff8217fa1ccec96592075172940df8 100644
--- a/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php
@@ -40,7 +40,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
             ->method('getUrl')
             ->with(
                 $this->equalTo('url_prefix/authenticationstart'),
-                $this->equalTo(array('_secure' => true, '_current' => false, 'isIframe' => true))
+                $this->equalTo(array('_secure' => true, '_current' => false, 'form_key' => false, 'isIframe' => true))
             )
             ->will($this->returnValue('some value'));
 
diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Onepage/SuccessTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Onepage/SuccessTest.php
index 4cccab2b778f240d637f934f710cc44f32b3ef39..8c5ad490b20d2ea4c3e8e996f4c370c2843583e5 100644
--- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Onepage/SuccessTest.php
+++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Onepage/SuccessTest.php
@@ -53,7 +53,7 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
             ->method('getLastRecurringProfileIds')
             ->will($this->returnValue([1, 2, 3]));
         $collection = $this->getMock(
-            'Magento\Sales\Model\Resource\Recurring\Profile\Collection',
+            'Magento\RecurringProfile\Model\Resource\Profile\Collection',
             ['addFieldToFilter'],
             [],
             '',
@@ -62,7 +62,7 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
         $collection->expects($this->once())->method('addFieldToFilter')
             ->with('profile_id', ['in' => [1, 2, 3]])->will($this->returnValue([]));
         $recurringProfileCollectionFactory = $this->getMock(
-            'Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory',
+            'Magento\RecurringProfile\Model\Resource\Profile\CollectionFactory',
             ['create'],
             [],
             '',
@@ -81,4 +81,17 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
         );
         $this->assertEquals('', $block->toHtml());
     }
+
+    public function testGetAdditionalInfoHtml()
+    {
+        /** @var \Magento\Checkout\Block\Onepage\Success $block */
+        $block = $this->objectManager->getObject('Magento\Checkout\Block\Onepage\Success');
+        $layout = $this->getMock('Magento\View\LayoutInterface', [], [], '', false);
+        $layout->expects($this->once())
+            ->method('renderElement')
+            ->with('order.success.additional.info')
+            ->will($this->returnValue('AdditionalInfoHtml'));
+        $block->setLayout($layout);
+        $this->assertEquals('AdditionalInfoHtml', $block->getAdditionalInfoHtml());
+    }
 }
diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php
index 1c2b769315dd235ebf43d9196260987ce110083e..7463263f0e5f78ef31449d2b15e782cf9fc3f313 100644
--- a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php
+++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php
@@ -30,6 +30,16 @@ include(__DIR__ . '/../_files/session.php');
 
 class SessionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @var \Magento\TestFramework\Helper\ObjectManager
+     */
+    protected $_helper;
+
+    public function setUp()
+    {
+        $this->_helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+    }
+
     /**
      * @param int|null $orderId
      * @param int|null $incrementId
@@ -59,8 +69,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
         $request = $this->getMock('\Magento\App\Request\Http', array(), array(), '', false);
         $request->expects($this->any())->method('getHttpHost')->will($this->returnValue(array()));
 
-        $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
-        $constructArguments = $objectManager->getConstructArguments(
+        $constructArguments = $this->_helper->getConstructArguments(
             'Magento\Checkout\Model\Session',
             array(
                 'request' => $this->getMock('Magento\App\RequestInterface', array(), array(), '', false),
@@ -71,7 +80,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
             )
         );
         /** @var \Magento\Checkout\Model\Session $session */
-        $session = $objectManager->getObject('Magento\Checkout\Model\Session', $constructArguments);
+        $session = $this->_helper->getObject('Magento\Checkout\Model\Session', $constructArguments);
         $session->setLastRealOrderId($orderId);
 
         $this->assertSame($orderMock, $session->getLastRealOrder());
@@ -123,4 +132,34 @@ class SessionTest extends \PHPUnit_Framework_TestCase
 
         return $order;
     }
+
+    /**
+     * @param $paramToClear
+     * @dataProvider clearHelperDataDataProvider
+     */
+    public function testClearHelperData($paramToClear)
+    {
+        $storage = new \Magento\Session\Storage('default', array($paramToClear => 'test_data'));
+        $session = $this->_helper->getObject(
+            'Magento\Checkout\Model\Session',
+            array('storage' => $storage)
+        );
+
+        $session->clearHelperData();
+        $this->assertNull($session->getData($paramToClear));
+    }
+
+    /**
+     * @return array
+     */
+    public function clearHelperDataDataProvider()
+    {
+        return array(
+            array('redirect_url'),
+            array('last_order_id'),
+            array('last_real_order_id'),
+            array('last_recurring_profile_ids'),
+            array('additional_messages')
+        );
+    }
 }
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ab01a5102e1ceb9f1f84072aebcd9bb1bc769daa
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/LayoutTest.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Core\Model;
+
+class LayoutTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Core\Model\Layout
+     */
+    protected $_model;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_structureMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_blockFactoryMock;
+
+    protected function setUp()
+    {
+        $this->_structureMock = $this->getMockBuilder('Magento\Data\Structure')
+            ->setMethods(array('createElement'))
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_blockFactoryMock  = $this->getMockBuilder('Magento\View\Element\BlockFactory')
+            ->setMethods(array('createBlock'))
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_model = $objectManagerHelper->getObject(
+            'Magento\Core\Model\Layout',
+            array(
+                'structure' => $this->_structureMock,
+                'blockFactory' => $this->_blockFactoryMock
+            )
+        );
+    }
+
+    /**
+     * @expectedException \Magento\Core\Exception
+     */
+    public function testCreateBlockException()
+    {
+        $this->_model->createBlock('type', 'blockname', array());
+    }
+
+
+    public function testCreateBlockSuccess()
+    {
+        $blockMock = $this->getMockBuilder('Magento\View\Element\AbstractBlock')
+            ->disableOriginalConstructor()
+            ->getMockForAbstractClass();
+        $this->_blockFactoryMock->expects($this->once())
+            ->method('createBlock')
+            ->will($this->returnValue($blockMock));
+
+        $this->_model->createBlock('type', 'blockname', array());
+        $this->assertInstanceOf('Magento\View\Element\AbstractBlock', $this->_model->getBlock('blockname'));
+    }
+}
+ 
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Converter/XmlTest.php b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Converter/XmlTest.php
index 5bfa9d53d1450fc8a839915243be3890bc816155..5ae302129a74a4fc66e9e49cc7b98d7acc26fb02 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Converter/XmlTest.php
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Converter/XmlTest.php
@@ -65,18 +65,20 @@ class XmlTest extends \PHPUnit_Framework_TestCase
     public function testConvert()
     {
         $expected = array(
-            'job1' => array(
-                'name' => 'job1',
-                'schedule' => '30 2 * * *',
-                'instance' => 'Model1',
-                'method' => 'method1'
-            ),
-            'job2' => array(
-                'name' => 'job2',
-                'schedule' => '* * * * *',
-                'instance' => 'Model2',
-                'method' => 'method2'
-            ),
+            'default' => array(
+                'job1' => array(
+                    'name' => 'job1',
+                    'schedule' => '30 2 * * *',
+                    'instance' => 'Model1',
+                    'method' => 'method1'
+                ),
+                'job2' => array(
+                    'name' => 'job2',
+                    'schedule' => '* * * * *',
+                    'instance' => 'Model2',
+                    'method' => 'method2'
+                ),
+            )
         );
 
         $xmlFile = __DIR__ . '/../_files/crontab_valid.xml';
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid.xml
index ec8bf33b985e7a52e1565a4b41035cba7fd9ef80..a525b93d472164cd4eb816ae42814649f051f85c 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job wrongName="job1" wrongInstance="Model1" wrongMethod="method1">
-        <wrongSchedule>30 2 * * *</wrongSchedule>
-    </job>
+    <group id="default">
+        <job wrongName="job1" wrongInstance="Model1" wrongMethod="method1">
+            <wrongSchedule>30 2 * * *</wrongSchedule>
+        </job>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_duplicates.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_duplicates.xml
index 11109a97cddaff3ddf14842cc9ccb2d479df75c7..1fd335c3f9abada8a87dd29e70644ddbc9a4449c 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_duplicates.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_duplicates.xml
@@ -24,10 +24,12 @@
  */
 -->
 <config>
-    <job name="job1" instance="Model1" method="method1">
-        <schedule>30 2 * * *</schedule>
-    </job>
-    <job name="job1" instance="Model1" method="method1">
-        <schedule>30 2 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="job1" instance="Model1" method="method1">
+            <schedule>30 2 * * *</schedule>
+        </job>
+        <job name="job1" instance="Model1" method="method1">
+            <schedule>30 2 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_node_typo.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_node_typo.xml
index 42528b8739c787e95a20cc40a4fb639ff32a6d80..ebcb79831fac8f34271ab3d48df4118e5e3fa436 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_node_typo.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_node_typo.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <typo name="job1" instance="Model1" method="method1">
-        <schedule>30 2 * * *</schedule>
-    </typo>
+    <group id="default">
+        <typo name="job1" instance="Model1" method="method1">
+            <schedule>30 2 * * *</schedule>
+        </typo>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_instance.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_instance.xml
index 98fadc5703e0f51c627277177618674725482c80..148828086dc5543ef02945cac811ee028247c4ac 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_instance.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_instance.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="job1" method="method1">
-        <schedule>30 2 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="job1" method="method1">
+            <schedule>30 2 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_method.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_method.xml
index fcabb89e6c0ad1815b39eb55cfa3decb9c053ea4..ea4e00e6403484093c8f04f5762eeb7beff2ee65 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_method.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_method.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job name="job1" instance="Model1">
-        <schedule>30 2 * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="job1" instance="Model1">
+            <schedule>30 2 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_name.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_name.xml
index 09e521c230149569e95f4f5f998489dabf1b84db..521957dcab3b8819635d59d9256919bd54fec39e 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_name.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_invalid_without_name.xml
@@ -24,7 +24,9 @@
  */
 -->
 <config>
-    <job instance="Model1" method="method1">
-        <schedule>30 2 * * *</schedule>
-    </job>
+    <group id="default">
+        <job instance="Model1" method="method1">
+            <schedule>30 2 * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid.xml
index 72d44657721618bd1a803aab268515f0cdb6a3f2..cae7782e8c5cba232bd8bd5ff731a9e49d541803 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid.xml
@@ -24,10 +24,12 @@
  */
 -->
 <config>
-    <job name="job1" instance="Model1" method="method1">
-        <schedule>30 2 * * *</schedule>
-    </job>
-    <job name="job2" instance="Model2" method="method2">
-        <schedule>* * * * *</schedule>
-    </job>
+    <group id="default">
+        <job name="job1" instance="Model1" method="method1">
+            <schedule>30 2 * * *</schedule>
+        </job>
+        <job name="job2" instance="Model2" method="method2">
+            <schedule>* * * * *</schedule>
+        </job>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid_without_schedule.xml b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid_without_schedule.xml
index 117392658ce0b3863ea66724c2bbfd90cfec2556..26ff6d9eaa6c6c936e639bf480893c55997800eb 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid_without_schedule.xml
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/_files/crontab_valid_without_schedule.xml
@@ -24,5 +24,7 @@
  */
 -->
 <config>
-    <job name="job1" instance="Model1" method="method1"/>
+    <group id="default">
+        <job name="job1" instance="Model1" method="method1"/>
+    </group>
 </config>
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Groups/Config/Converter/XmlTest.php b/dev/tests/unit/testsuite/Magento/Cron/Model/Groups/Config/Converter/XmlTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..e38e759da76946a5385b6d4a255f9d648509044f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Groups/Config/Converter/XmlTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Cron
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Cron\Model\Groups\Config\Converter;
+
+class XmlTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Cron\Model\Groups\Config\Converter\Xml
+     */
+    protected $object;
+
+    public function setUp()
+    {
+        $this->object = new \Magento\Cron\Model\Groups\Config\Converter\Xml();
+    }
+
+    public function testConvert()
+    {
+        $xmlExample = <<<XML
+<config>
+    <group id="test">
+        <schedule_generate_every>1</schedule_generate_every>
+    </group>
+</config>
+XML;
+
+        $xml = new \DOMDocument();
+        $xml->loadXML($xmlExample);
+
+        $results = $this->object->convert($xml);
+        $this->assertArrayHasKey('test', $results);
+        $this->assertArrayHasKey('schedule_generate_every', $results['test']);
+        $this->assertEquals('1', $results['test']['schedule_generate_every']);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php
index 4991e483a2e21618ef126c3f60c8b326457ee481..cbd51b9d406db594e8afc331d95e0581d5a6ae2e 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php
+++ b/dev/tests/unit/testsuite/Magento/Cron/Model/ObserverTest.php
@@ -27,6 +27,7 @@ namespace Magento\Cron\Model;
 
 /**
  * Class \Magento\Cron\Model\ObserverTest
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class ObserverTest extends \PHPUnit_Framework_TestCase
 {
@@ -50,14 +51,34 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
      */
     protected $_config;
 
+    /**
+     * @var \Magento\Cron\Model\ScheduleFactory
+     */
+    protected $_scheduleFactory;
+
     /**
      * @var \Magento\Core\Model\Store\Config|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $_coreStoreConfig;
 
+    /**
+     * @var \Magento\App\Console\Request|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_request;
+
+    /**
+     * @var \Magento\Shell|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_shell;
+
     /** @var \Magento\Cron\Model\Resource\Schedule\Collection|\PHPUnit_Framework_MockObject_MockObject */
     protected $_collection;
 
+    /**
+     * @var \Magento\Cron\Model\Groups\Config\Data
+     */
+    protected $_cronGroupConfig;
+
     /**
      * Prepare parameters
      */
@@ -85,9 +106,26 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
         $this->_collection->expects($this->any())
             ->method('load')
             ->will($this->returnSelf());
+        $this->_scheduleFactory = $this->getMockBuilder('Magento\Cron\Model\ScheduleFactory')
+            ->setMethods(array('create'))
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_request = $this->getMockBuilder('Magento\App\Console\Request')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_shell = $this->getMockBuilder('Magento\Shell')
+            ->disableOriginalConstructor()
+            ->setMethods(array('execute'))
+            ->getMock();
 
         $this->_observer = new \Magento\Cron\Model\Observer(
-            $this->_objectManager, $this->_app, $this->_config, $this->_coreStoreConfig
+            $this->_objectManager,
+            $this->_scheduleFactory,
+            $this->_app,
+            $this->_config,
+            $this->_coreStoreConfig,
+            $this->_request,
+            $this->_shell
         );
     }
 
@@ -112,9 +150,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->once())
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $this->_observer->dispatch('');
@@ -133,6 +170,10 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->method('getConfig')
             ->will($this->returnValue(0));
 
+        $this->_config->expects($this->once())
+            ->method('getJobs')
+            ->will($this->returnValue(array('test_job1' => array('test_data'))));
+
         $schedule = $this->getMock('Magento\Cron\Model\Schedule', array('getJobCode', '__wakeup'), array(), '', false);
         $schedule->expects($this->once())
             ->method('getJobCode')
@@ -148,9 +189,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->once())
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $this->_observer->dispatch('');
@@ -187,15 +227,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
 
         $this->_config->expects($this->once())
             ->method('getJobs')
-            ->will($this->returnValue(array('test_job1' => array('test_data'))));
+            ->will($this->returnValue(array('test_group' => array('test_job1' => array('test_data')))));
 
         $scheduleMock = $this->getMockBuilder('Magento\Cron\Model\Schedule')
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->once())
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $this->_observer->dispatch('');
@@ -245,15 +284,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
 
         $this->_config->expects($this->once())
             ->method('getJobs')
-            ->will($this->returnValue(array('test_job1' => array('test_data'))));
+            ->will($this->returnValue(array('test_group' => array('test_job1' => array('test_data')))));
 
         $scheduleMock = $this->getMockBuilder('Magento\Cron\Model\Schedule')
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->once())
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $this->_observer->dispatch('');
@@ -293,9 +331,17 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
 
         $this->_collection->addItem($schedule);
 
+        $jobConfig = array(
+            'test_group' => array(
+                'test_job1' => array(
+                    'instance' => 'Some_Class',
+                ),
+            ),
+        );
+
         $this->_config->expects($this->once())
             ->method('getJobs')
-            ->will($this->returnValue(array('test_job1' => array('test_data'))));
+            ->will($this->returnValue($jobConfig));
 
         $lastRun = time() + 10000000;
         $this->_app->expects($this->any())
@@ -310,9 +356,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->once())
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $this->_observer->dispatch('');
@@ -324,11 +369,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
     public function testDispatchExceptionNotExecutable()
     {
         $jobConfig = array(
-            'test_job1' => array(
-                'instance' => 'Not_Existed_Class',
-                'method' => 'notExistedMethod'
-            )
+            'test_group' => array(
+                'test_job1' => array(
+                    'instance' => 'Not_Existed_Class',
+                    'method' => 'notExistedMethod'
+                ),
+            ),
         );
+
         $exceptionMessage = 'Invalid callback: Not_Existed_Class::notExistedMethod can\'t be called';
 
         $schedule = $this->getMockBuilder('Magento\Cron\Model\Schedule')
@@ -374,11 +422,10 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->at(0))
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
-        $this->_objectManager->expects($this->at(1))
+        $this->_objectManager->expects($this->once())
             ->method('create')
             ->with($this->equalTo('Not_Existed_Class'))
             ->will($this->returnValue(''));
@@ -395,10 +442,12 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
         $testCronJob = new \Magento\Cron\Model\CronJob();
 
         $jobConfig = array(
-            'test_job1' => array(
-                'instance' => 'CronJob',
-                'method' => 'execute'
-            )
+            'test_group' => array(
+                'test_job1' => array(
+                    'instance' => 'CronJob',
+                    'method' => 'execute'
+                ),
+            ),
         );
 
         $scheduleMethods = array(
@@ -464,11 +513,10 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->at(0))
+        $this->_scheduleFactory->expects($this->once())
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
-        $this->_objectManager->expects($this->at(1))
+        $this->_objectManager->expects($this->once())
             ->method('create')
             ->with($this->equalTo('CronJob'))
             ->will($this->returnValue($testCronJob));
@@ -483,12 +531,21 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
      */
     public function testDispatchNotGenerate()
     {
+        $jobConfig = array(
+            'test_group' => array(
+                'test_job1' => array(
+                    'instance' => 'CronJob',
+                    'method' => 'execute'
+                ),
+            ),
+        );
+
         $this->_config->expects($this->at(0))
             ->method('getJobs')
-            ->will($this->returnValue(array()));
+            ->will($this->returnValue($jobConfig));
         $this->_config->expects($this->at(1))
             ->method('getJobs')
-            ->will($this->returnValue(array()));
+            ->will($this->returnValue(array('test_group' => array())));
 
         $this->_app->expects($this->at(0))
             ->method('loadCache')
@@ -523,11 +580,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->any())
+        $this->_scheduleFactory->expects($this->at(0))
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
+        $this->_scheduleFactory->expects($this->at(1))
+            ->method('create')
+            ->will($this->returnValue($schedule));
+
         $this->_observer->dispatch('');
     }
 
@@ -536,18 +596,29 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
      */
     public function testDispatchGenerate()
     {
+        $jobConfig = array(
+            'test_group' => array(
+                'test_job1' => array(
+                    'instance' => 'CronJob',
+                    'method' => 'execute'
+                ),
+            ),
+        );
+
         $this->_config->expects($this->at(0))
             ->method('getJobs')
-            ->will($this->returnValue(array()));
+            ->will($this->returnValue($jobConfig));
         $jobs = array(
-            'job1' => array(
-                'config_path' => 'test/path'
-            ),
-            'job2' => array(
-                'schedule' => ''
-            ),
-            'job3' => array(
-                'schedule' => '* * * * *'
+            'test_group' => array(
+                'job1' => array(
+                    'config_path' => 'test/path'
+                ),
+                'job2' => array(
+                    'schedule' => ''
+                ),
+                'job3' => array(
+                    'schedule' => '* * * * *'
+                )
             )
         );
         $this->_config->expects($this->at(1))
@@ -570,9 +641,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
         $scheduleMethods = array(
             'getJobCode',
             'getScheduledAt',
-            'setJobCode',
-            'setCronExpr',
-            'setStatus',
             'trySchedule',
             'unsScheduleId',
             'save',
@@ -605,11 +673,14 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->setMethods(array('getCollection', '__wakeup'))
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->any())
+        $this->_scheduleFactory->expects($this->at(0))
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
+        $this->_scheduleFactory->expects($this->at(1))
+            ->method('create')
+            ->will($this->returnValue($schedule));
+
         $this->_observer->dispatch('');
     }
 
@@ -618,6 +689,15 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
      */
     public function testDispatchCleanup()
     {
+        $jobConfig = array(
+            'test_group' => array(
+                'test_job1' => array(
+                    'instance' => 'CronJob',
+                    'method' => 'execute'
+                ),
+            ),
+        );
+
         $schedule = $this->getMockBuilder('Magento\Cron\Model\Schedule')
             ->disableOriginalConstructor()
             ->setMethods(array('getExecutedAt', 'getStatus', 'delete', '__wakeup'))
@@ -629,7 +709,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
 
         $this->_config->expects($this->once())
             ->method('getJobs')
-            ->will($this->returnValue(array()));
+            ->will($this->returnValue($jobConfig));
 
         $this->_app->expects($this->at(0))
             ->method('loadCache')
@@ -646,9 +726,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection));
-        $this->_objectManager->expects($this->at(0))
+        $this->_scheduleFactory->expects($this->at(0))
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $collection = $this->getMockBuilder('Magento\Cron\Model\Resource\Schedule\Collection')
@@ -667,9 +746,8 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($collection));
-        $this->_objectManager->expects($this->at(1))
+        $this->_scheduleFactory->expects($this->at(1))
             ->method('create')
-            ->with($this->equalTo('Magento\Cron\Model\Schedule'))
             ->will($this->returnValue($scheduleMock));
 
         $this->_observer->dispatch('');
diff --git a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/CacheManagerTest.php b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/CacheManagerTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..32ead741cf19b9a7af8db1ff5dba9901a6c1f36d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/CacheManagerTest.php
@@ -0,0 +1,251 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache;
+
+use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
+
+class CacheManagerTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\Css\PreProcessor\Cache\CacheManager */
+    protected $cacheManager;
+
+    /** @var ObjectManagerHelper */
+    protected $objectManagerHelper;
+
+    /** @var \Magento\Css\PreProcessor\Cache\Import\Map\Storage|\PHPUnit_Framework_MockObject_MockObject */
+    protected $storageMock;
+
+    /** @var \Magento\Css\PreProcessor\Cache\Import\ImportEntityFactory|\PHPUnit_Framework_MockObject_MockObject */
+    protected $importEntityFactoryMock;
+
+    protected function setUp()
+    {
+        $this->storageMock = $this->getMock('Magento\Css\PreProcessor\Cache\Import\Map\Storage', [], [], '', false);
+        $this->importEntityFactoryMock = $this->getMock(
+            'Magento\Css\PreProcessor\Cache\Import\ImportEntityFactory',
+            [],
+            [],
+            '',
+            false
+        );
+
+        $this->objectManagerHelper = new ObjectManagerHelper($this);
+        $this->cacheManager = $this->objectManagerHelper->getObject(
+            'Magento\Css\PreProcessor\Cache\CacheManager',
+            [
+                'storage' => $this->storageMock,
+                'importEntityFactory' => $this->importEntityFactoryMock,
+                'filePath' => 'Magento_Core::style.css',
+                'params' => ['theme' => 'some_theme', 'area' => 'frontend', 'locale' => 'en_US']
+            ]
+        );
+    }
+
+    public function testClearCache()
+    {
+        $expectedKey = 'Magento_Core::style.css|frontend|en_US|some_theme';
+
+        $fileKeyProperty = new \ReflectionProperty($this->cacheManager, 'uniqueFileKey');
+        $fileKeyProperty->setAccessible(true);
+        $this->assertEquals($expectedKey, $fileKeyProperty->getValue($this->cacheManager));
+
+        $cachedFileProperty = new \ReflectionProperty($this->cacheManager, 'cachedFile');
+        $cachedFileProperty->setAccessible(true);
+        $cachedFileProperty->setValue($this->cacheManager, 'some_cachedFile');
+
+        $importEntitiesProperty = new \ReflectionProperty($this->cacheManager, 'importEntities');
+        $importEntitiesProperty->setAccessible(true);
+        $this->assertEquals([], $importEntitiesProperty->getValue($this->cacheManager));
+        $importEntitiesProperty->setValue($this->cacheManager, ['some_import_1', 'some_import_2']);
+
+        $this->storageMock->expects($this->once())
+            ->method('delete')
+            ->with($this->equalTo($expectedKey))
+            ->will($this->returnSelf());
+
+        $this->assertEquals($this->cacheManager, $this->cacheManager->clearCache());
+        $this->assertNull($cachedFileProperty->getValue($this->cacheManager));
+        $this->assertEquals([], $importEntitiesProperty->getValue($this->cacheManager));
+    }
+
+    public function testGetCachedFile()
+    {
+        $property = new \ReflectionProperty($this->cacheManager, 'cachedFile');
+        $property->setAccessible(true);
+        $this->assertNull($property->getValue($this->cacheManager));
+        $property->setValue($this->cacheManager, 'test');
+        $this->assertEquals('test', $this->cacheManager->getCachedFile());
+    }
+
+    /**
+     * @param array $params
+     * @param array $expectedResult
+     * @dataProvider addEntityToCacheDataProvider
+     */
+    public function testAddEntityToCache($params, $expectedResult)
+    {
+        $importEntitiesProperty = new \ReflectionProperty($this->cacheManager, 'importEntities');
+        $importEntitiesProperty->setAccessible(true);
+        $this->assertEquals([], $importEntitiesProperty->getValue($this->cacheManager));
+
+        $this->importEntityFactoryMock->expects($this->any())->method('create')
+            ->with($this->anything(), $this->anything())->will($this->returnValue('entity_object_here'));
+        foreach ($params as $value) {
+            $this->assertEquals(
+                $this->cacheManager,
+                $this->cacheManager->addEntityToCache($value['filePath'], $value['viewParams'])
+            );
+        }
+        $this->assertEquals($expectedResult, $importEntitiesProperty->getValue($this->cacheManager));
+    }
+
+    /**
+     * @return array
+     */
+    public function addEntityToCacheDataProvider()
+    {
+        $themeModelMockId = $this->getMock('Magento\Core\Model\Theme', [], [], '', false);
+        $themeModelMockId->expects($this->once())->method('getId')->will($this->returnValue('1'));
+
+        $themeModelMockPath = $this->getMock('Magento\Core\Model\Theme', [], [], '', false);
+        $themeModelMockPath->expects($this->once())->method('getThemePath')->will($this->returnValue('mocked_path'));
+        return [
+            'one import' => [
+                'params' => [
+                    [
+                        'filePath' => 'css\some_file.css',
+                        'viewParams' => ['theme' => 'other_theme', 'area' => 'backend', 'locale' => 'fr_FR']
+                    ]
+                ],
+                'expectedResult' => ['css\some_file.css|backend|fr_FR|other_theme' => 'entity_object_here']
+            ],
+            'one import with theme id' => [
+                'params' => [
+                    [
+                        'filePath' => 'css\theme_id\some_file.css',
+                        'viewParams' => ['themeModel' => $themeModelMockId, 'area' => 'backend', 'locale' => 'en_En']
+                    ]
+                ],
+                'expectedResult' => ['css\theme_id\some_file.css|backend|en_En|1' => 'entity_object_here']
+            ],
+            'one import with theme path' => [
+                'params' => [
+                    [
+                        'filePath' => 'css\some_file.css',
+                        'viewParams' => ['themeModel' => $themeModelMockPath, 'area' => 'frontend']
+                    ]
+                ],
+                'expectedResult' => ['css\some_file.css|frontend|088d309371332feb12bad4dbf93cfb5d'
+                    => 'entity_object_here']
+            ],
+            'list of imports' => [
+                'params' => [
+                    [
+                        'filePath' => 'Magento_Core::folder\file.css',
+                        'viewParams' => ['theme' => 'theme_path', 'area' => 'backend']
+                    ],
+                    [
+                        'filePath' => 'calendar\button.css',
+                        'viewParams' => ['theme' => 'theme_path', 'area' => 'backend', 'locale' => 'en_US']
+                    ],
+                ],
+                'expectedResult' => [
+                    'Magento_Core::folder\file.css|backend|theme_path' => 'entity_object_here',
+                    'calendar\button.css|backend|en_US|theme_path' => 'entity_object_here',
+                ]
+            ],
+        ];
+    }
+
+    /**
+     * @param string $uniqueFileKey
+     * @param array $expected
+     * @dataProvider saveCacheDataProvider
+     */
+    public function testSaveCache($uniqueFileKey, $expected)
+    {
+        $importEntitiesProperty = new \ReflectionProperty($this->cacheManager, 'importEntities');
+        $importEntitiesProperty->setAccessible(true);
+        $this->assertEquals([], $importEntitiesProperty->getValue($this->cacheManager));
+        $importEntitiesProperty->setValue($this->cacheManager, $expected['imports']);
+
+        $this->storageMock->expects($this->once())
+            ->method('save')
+            ->with($this->equalTo($uniqueFileKey), $this->equalTo(serialize($expected)))
+            ->will($this->returnSelf());
+        $this->assertEquals($this->cacheManager, $this->cacheManager->saveCache($expected['cached_file']));
+    }
+
+    /**
+     * @return array
+     */
+    public function saveCacheDataProvider()
+    {
+        return [
+            [
+                'Magento_Core::style.css|frontend|en_US|some_theme',
+                [
+                    'cached_file' => 'file-to-save.css',
+                    'imports' => ['import1', 'import2', 'import3']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @param Import\ImportEntity[] $importData
+     * @param bool $expected
+     * @dataProvider isValidDataProvider
+     */
+    public function testIsValid($importData, $expected)
+    {
+        $importEntitiesProperty = new \ReflectionProperty($this->cacheManager, 'importEntities');
+        $importEntitiesProperty->setAccessible(true);
+        $this->assertEquals([], $importEntitiesProperty->getValue($this->cacheManager));
+        $importEntitiesProperty->setValue($this->cacheManager, $importData);
+
+        $method = new \ReflectionMethod('Magento\Css\PreProcessor\Cache\CacheManager', 'isValid');
+        $method->setAccessible(true);
+
+        $this->assertEquals($expected, $method->invoke($this->cacheManager));
+    }
+
+    /**
+     * @return array
+     */
+    public function isValidDataProvider()
+    {
+        $importEntityTrue = $this->getMock('Magento\Css\PreProcessor\Cache\Import\ImportEntity', [], [], '', false);
+        $importEntityTrue->expects($this->once())->method('isValid')->will($this->returnValue(true));
+
+        $importEntityFalse = $this->getMock('Magento\Css\PreProcessor\Cache\Import\ImportEntity', [], [], '', false);
+        $importEntityFalse->expects($this->once())->method('isValid')->will($this->returnValue(false));
+        return [
+            [[$importEntityTrue], true],
+            [[$importEntityFalse], false],
+            [[], false]
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Import/ImportEntityTest.php b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Import/ImportEntityTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..3d007b11862b6ed2d983f84ab0e991fb18a5e1b6
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Import/ImportEntityTest.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache\Import;
+
+use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
+
+class ImportEntityTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\Css\PreProcessor\Cache\Import\ImportEntity */
+    protected $importEntity;
+
+    /**
+     * @var \Magento\Filesystem\Directory\ReadInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $rootDirectory;
+
+    /** @var ObjectManagerHelper */
+    protected $objectManagerHelper;
+
+    /** @var \Magento\Filesystem|\PHPUnit_Framework_MockObject_MockObject */
+    protected $filesystemMock;
+
+    /** @var \Magento\View\FileSystem|\PHPUnit_Framework_MockObject_MockObject */
+    protected $fileSystemMock;
+
+    /**
+     * @var string
+     */
+    protected $absolutePath;
+
+    /**
+     * @param string $relativePath
+     * @param int $originalMtime
+     */
+    protected function createMock($relativePath, $originalMtime)
+    {
+        $filePath = 'someFile';
+        $params = ['some', 'params'];
+        $this->absoluteFilePath = 'some_absolute_path';
+
+        $this->rootDirectory = $this->getMock('Magento\Filesystem\Directory\ReadInterface', [], [], '', false);
+        $this->rootDirectory->expects($this->once())
+            ->method('getRelativePath')
+            ->with($this->equalTo($this->absoluteFilePath))
+            ->will($this->returnValue($relativePath));
+
+        $this->rootDirectory->expects($this->atLeastOnce())
+            ->method('stat')
+            ->with($this->equalTo($relativePath))
+            ->will($this->returnValue(['mtime' => $originalMtime]));
+
+        $this->filesystemMock = $this->getMock('Magento\Filesystem', [], [], '', false);
+        $this->filesystemMock->expects($this->once())
+            ->method('getDirectoryRead')
+            ->with($this->equalTo(\Magento\App\Filesystem::ROOT_DIR))
+            ->will($this->returnValue($this->rootDirectory));
+
+        $this->fileSystemMock = $this->getMock('Magento\View\FileSystem', [], [], '', false);
+        $this->fileSystemMock->expects($this->once())
+            ->method('getViewFile')
+            ->with($this->equalTo($filePath), $this->equalTo($params))
+            ->will($this->returnValue($this->absoluteFilePath));
+
+        $this->objectManagerHelper = new ObjectManagerHelper($this);
+        /** @var \Magento\Css\PreProcessor\Cache\Import\ImportEntity importEntity */
+        $this->importEntity = $this->objectManagerHelper->getObject(
+            'Magento\Css\PreProcessor\Cache\Import\ImportEntity',
+            [
+                'filesystem' => $this->filesystemMock,
+                'viewFileSystem' => $this->fileSystemMock,
+                'filePath' => $filePath,
+                'params' => $params
+            ]
+        );
+        $rootDirectoryProperty = new \ReflectionProperty($this->importEntity, 'rootDirectory');
+        $rootDirectoryProperty->setAccessible(true);
+        $this->assertEquals($this->rootDirectory, $rootDirectoryProperty->getValue($this->importEntity));
+    }
+
+    public function testGetOriginalFile()
+    {
+        $mtime = rand();
+        $relativePath = '/some/relative/path/to/file.less';
+        $this->createMock($relativePath, $mtime);
+        $this->assertEquals($relativePath, $this->importEntity->getOriginalFile());
+    }
+
+    public function testGetOriginalMtime()
+    {
+        $mtime = rand();
+        $relativePath = '/some/relative/path/to/file2.less';
+        $this->createMock($relativePath, $mtime);
+        $this->assertEquals($mtime, $this->importEntity->getOriginalMtime());
+    }
+
+    /**
+     * @param bool $isFile
+     * @dataProvider isValidDataProvider
+     */
+    public function testIsValid($isFile)
+    {
+        $mtime = rand();
+        $relativePath = '/some/relative/path/to/file3.less';
+        $this->createMock($relativePath, $mtime);
+        $this->rootDirectory->expects($this->once())
+            ->method('isFile')
+            ->with($this->equalTo($relativePath))
+            ->will($this->returnValue($isFile));
+        $this->assertEquals($isFile, $this->importEntity->isValid());
+    }
+
+    /**
+     * @return array
+     */
+    public function isValidDataProvider()
+    {
+        return [
+            [true],
+            [false]
+        ];
+    }
+
+    public function test__sleep()
+    {
+        $mtime = rand();
+        $relativePath = '/some/relative/path/to/file3.less';
+        $this->createMock($relativePath, $mtime);
+        $this->assertEquals(['originalFile', 'originalMtime'], $this->importEntity->__sleep());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Import/Map/StorageTest.php b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Import/Map/StorageTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..32fb8f7d3fdbf64dd7eb44480a58560ae55e8341
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Import/Map/StorageTest.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache\Import\Map;
+
+use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
+
+class StorageTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\Css\PreProcessor\Cache\Import\Map\Storage */
+    protected $storage;
+
+    /** @var ObjectManagerHelper */
+    protected $objectManagerHelper;
+
+    /** @var \Magento\App\Filesystem|\PHPUnit_Framework_MockObject_MockObject */
+    protected $filesystemMock;
+
+    /** @var \Magento\Filesystem\Directory\WriteInterface|\PHPUnit_Framework_MockObject_MockObject */
+    protected $mapsDirectoryMock;
+
+    protected function setUp()
+    {
+        $this->mapsDirectoryMock = $this->getMock('Magento\Filesystem\Directory\WriteInterface', [], [], '', false);
+        $this->mapsDirectoryMock->expects($this->once())
+            ->method('isDirectory')
+            ->with($this->equalTo(\Magento\Css\PreProcessor\Cache\Import\Map\Storage::MAPS_DIR))
+            ->will($this->returnValue(false));
+        $this->mapsDirectoryMock->expects($this->once())
+            ->method('create')
+            ->with($this->equalTo(\Magento\Css\PreProcessor\Cache\Import\Map\Storage::MAPS_DIR))
+            ->will($this->returnSelf());
+
+
+        $this->filesystemMock = $this->getMock('Magento\App\Filesystem', [], [], '', false);
+        $this->filesystemMock->expects($this->once())
+            ->method('getDirectoryWrite')
+            ->with($this->equalTo(\Magento\App\Filesystem::VAR_DIR))
+            ->will($this->returnValue($this->mapsDirectoryMock));
+
+        $this->objectManagerHelper = new ObjectManagerHelper($this);
+        $this->storage = $this->objectManagerHelper->getObject(
+            'Magento\Css\PreProcessor\Cache\Import\Map\Storage',
+            [
+                'filesystem' => $this->filesystemMock
+            ]
+        );
+    }
+
+    /**
+     * @param string $key
+     * @param bool $isFile
+     * @param string $mapFileName
+     * @param bool|string $expected
+     * @dataProvider loadDataProvider
+     */
+    public function testLoad($key, $isFile, $mapFileName, $expected)
+    {
+        $this->mapsDirectoryMock->expects($this->once())
+            ->method('isFile')
+            ->with($this->equalTo($mapFileName))
+            ->will($this->returnValue($isFile));
+        if ($isFile) {
+            $this->mapsDirectoryMock->expects($this->once())
+                ->method('readFile')
+                ->with($this->equalTo($mapFileName))
+                ->will($this->returnValue($expected));
+        }
+        $this->assertEquals($expected, $this->storage->load($key));
+    }
+
+    /**
+     * @return array
+     */
+    public function loadDataProvider()
+    {
+        return [
+            ['some_key', false, 'maps/less/3d70412c7e9ea2d96fa23d4f1f1f0a1c.ser', false],
+            ['some_other_key', true, 'maps/less/26df19b852b11fb4b4b845134d13f6fa.ser', 'file_found']
+        ];
+    }
+
+    /**
+     * @param string $key
+     * @param string $mapFileName
+     * @param array $data
+     * @dataProvider saveDataProvider
+     */
+    public function testSave($key, $mapFileName, $data)
+    {
+        $this->mapsDirectoryMock->expects($this->once())
+            ->method('writeFile')
+            ->with($this->equalTo($mapFileName), $this->equalTo($data))
+            ->will($this->returnSelf());
+        $this->assertEquals($this->storage, $this->storage->save($key, $data));
+    }
+
+    /**
+     * @return array
+     */
+    public function saveDataProvider()
+    {
+        return [
+            ['some-key-to-save', 'maps/less/96760c434adbc683b503ca866784a17e.ser', ['data1', 'data2']]
+        ];
+    }
+
+    /**
+     * @param string $key
+     * @param string $mapFileName
+     * @dataProvider deleteDataProvider
+     */
+    public function testDelete($key, $mapFileName)
+    {
+        $this->mapsDirectoryMock->expects($this->once())
+            ->method('writeFile')
+            ->with($this->equalTo($mapFileName), $this->equalTo(''))
+            ->will($this->returnSelf());
+        $this->assertEquals($this->storage, $this->storage->delete($key));
+    }
+
+    /**
+     * @return array
+     */
+    public function deleteDataProvider()
+    {
+        return [
+            ['some-key-to-delete', 'maps/less/bf8aef83aab96deb7dbd66579b389794.ser']
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/PluginTest.php b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/PluginTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..1944fed557f1f4fa2d9eda65dcfb0d95289af12e
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/PluginTest.php
@@ -0,0 +1,211 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache;
+
+use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
+
+class PluginTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\Css\PreProcessor\Cache\Plugin */
+    protected $plugin;
+
+    /** @var ObjectManagerHelper */
+    protected $objectManagerHelper;
+
+    /** @var \Magento\Css\PreProcessor\Cache\CacheManagerFactory|\PHPUnit_Framework_MockObject_MockObject */
+    protected $cacheManagerFactoryMock;
+
+    /** @var \Magento\Css\PreProcessor\Cache\CacheManager|\PHPUnit_Framework_MockObject_MockObject */
+    protected $cacheManager;
+
+    /** @var \Magento\Logger|\PHPUnit_Framework_MockObject_MockObject */
+    protected $loggerMock;
+
+    /** @var \Magento\Filesystem\Directory\WriteInterface|\PHPUnit_Framework_MockObject_MockObject */
+    protected $targetDirMock;
+
+    protected function setUp()
+    {
+        $this->targetDirMock = $this->getMock('Magento\Filesystem\Directory\WriteInterface', [], [], '', false);
+        $this->cacheManagerFactoryMock = $this->getMock(
+            'Magento\Css\PreProcessor\Cache\CacheManagerFactory',
+            [],
+            [],
+            '',
+            false
+        );
+        $this->cacheManager = $this->getMock('Magento\Css\PreProcessor\Cache\CacheManager', [], [], '', false);
+        $this->cacheManagerFactoryMock->expects($this->any())
+            ->method('create')
+            ->with($this->anything(), $this->anything())
+            ->will($this->returnValue($this->cacheManager));
+        $this->loggerMock = $this->getMock('Magento\Logger', [], [], '', false);
+
+        $this->objectManagerHelper = new ObjectManagerHelper($this);
+        $this->plugin = $this->objectManagerHelper->getObject(
+            'Magento\Css\PreProcessor\Cache\Plugin',
+            [
+                'cacheManagerFactory' => $this->cacheManagerFactoryMock,
+                'logger' => $this->loggerMock
+            ]
+        );
+    }
+
+    /**
+     * @param array $arguments
+     * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @param array $cacheManagerData
+     * @param string|null $expected
+     * @dataProvider aroundProcessDataProvider
+     */
+    public function testAroundProcess($arguments, $invocationChain, $cacheManagerData, $expected)
+    {
+        if (!empty($cacheManagerData)) {
+            foreach ($cacheManagerData as $method => $info) {
+                if ($method === 'getCachedFile') {
+                    $this->cacheManager->expects($this->once())
+                        ->method($method)
+                        ->will($this->returnValue($info['result']));
+                } else {
+                    $this->cacheManager->expects($this->once())
+                        ->method($method)
+                        ->with($this->equalTo($info['with']))
+                        ->will($this->returnValue($info['result']));
+                }
+
+            }
+        }
+        $this->assertEquals($expected, $this->plugin->aroundProcess($arguments, $invocationChain));
+    }
+
+    /**
+     * @return array
+     */
+    public function aroundProcessDataProvider()
+    {
+        $argFirst = [
+            'css\style.less', // lessFilePath
+            [], // params
+            $this->targetDirMock, // target directory
+            'css\style.css' // sourceFile
+        ];
+        $expectedFirst = 'expectedFirst';
+        $invChainFirst = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false);
+        $invChainFirst->expects($this->once())
+            ->method('proceed')
+            ->with($this->equalTo($argFirst))
+            ->will($this->returnValue($expectedFirst));
+
+        $invChainSecond = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false);
+        $argSecond = [
+            'css\style.less', // lessFilePath
+            [], // params
+            $this->targetDirMock, // target directory
+            null // sourceFile
+        ];
+
+        $expectedThird = 'expectedThird';
+        $argThird = [
+            'css\style.less', // lessFilePath
+            [], // params
+            $this->targetDirMock, // target directory
+            null // sourceFile
+        ];
+
+        $invChainThird = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false);
+        $invChainThird->expects($this->once())
+            ->method('proceed')
+            ->with($this->equalTo($argThird))
+            ->will($this->returnValue($expectedThird));
+
+        return [
+            'source path already exist' => [
+                'arguments' => $argFirst,
+                'invocationChain' => $invChainFirst,
+                'cacheManagerData' => [],
+                'expected' => $expectedFirst
+            ],
+            'cached value exists' => [
+                'arguments' => $argSecond,
+                'invocationChain' => $invChainSecond,
+                'cacheManagerData' => ['getCachedFile' => ['result' => 'cached-value']],
+                'expected' => 'cached-value'
+            ],
+            'cached value does not exist' => [
+                'arguments' => $argThird,
+                'invocationChain' => $invChainThird,
+                'cacheManagerData' => [
+                    'getCachedFile' => ['result' => null],
+                    'saveCache' => ['with' => $expectedThird, 'result' => 'self']
+                ],
+                'expected' => $expectedThird
+            ],
+        ];
+    }
+
+    public function testAroundProcessException()
+    {
+        $arguments = [
+            'css\style.less', // lessFilePath
+            [], // params
+            $this->targetDirMock, // target directory
+            null // sourceFile
+        ];
+
+        $this->cacheManager->expects($this->once())
+            ->method('getCachedFile')
+            ->will($this->returnValue(null));
+
+        $exception = new \Magento\Filesystem\FilesystemException('Test Message');
+        $invocationChain = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false);
+        $invocationChain->expects($this->once())
+            ->method('proceed')
+            ->with($this->equalTo($arguments))
+            ->will($this->throwException($exception));
+        $this->loggerMock->expects($this->once())
+            ->method('logException')
+            ->with($this->equalTo($exception))
+            ->will($this->returnSelf());
+        $this->assertNull($this->plugin->aroundProcess($arguments, $invocationChain));
+    }
+
+
+    public function testBeforeProcessLessInstructions()
+    {
+        $arguments = ['some\less\filePth.less', ['some', 'kind', 'of' ,'params']];
+        list($lessFilePath, $params) = $arguments;
+
+        $method = new \ReflectionMethod('Magento\Css\PreProcessor\Cache\Plugin', 'initializeCacheManager');
+        $method->setAccessible(true);
+        $this->assertEquals($this->plugin, $method->invoke($this->plugin, $lessFilePath, $params));
+
+        $this->cacheManager->expects($this->once())
+            ->method('addEntityToCache')
+            ->with($this->equalTo($lessFilePath), $this->equalTo($params))
+            ->will($this->returnSelf());
+
+        $this->assertEquals($arguments, $this->plugin->beforeProcessLessInstructions($arguments));
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/CompositeTest.php b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/CompositeTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..e6dfc5fa9ee8eddd4fb1715fc5956ca9ad270cf3
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/CompositeTest.php
@@ -0,0 +1,173 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor;
+
+use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
+
+class CompositeTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\Css\PreProcessor\Composite */
+    protected $composite;
+
+    /** @var ObjectManagerHelper */
+    protected $objectManagerHelper;
+
+    /** @var \Magento\View\Asset\PreProcessorFactory|\PHPUnit_Framework_MockObject_MockObject */
+    protected $preProcessorFactoryMock;
+
+    /**
+     * @var array
+     */
+    protected $callMap = [];
+
+    protected function setUp()
+    {
+        $this->preProcessorFactoryMock = $this->getMock('Magento\View\Asset\PreProcessorFactory', [], [], '', false);
+        $this->objectManagerHelper = new ObjectManagerHelper($this);
+    }
+
+    /**
+     * @param array $params
+     * @param array $preProcessors
+     * @param array $createMap
+     * @param string $expectedResult
+     * @dataProvider processDataProvider
+     */
+    public function testProcess($params, $preProcessors, $createMap, $expectedResult)
+    {
+        $targetDir = $this->getMock($params['targetDirectory'], array(), array(), '', false);
+
+        foreach ($createMap as $className) {
+            $this->callMap[$className] = $this->getMock($className, array('process'), array(), '', false);
+            $this->callMap[$className]->expects($this->once())
+                ->method('process')
+                ->with(
+                    $this->equalTo($params['filePath']),
+                    $this->equalTo($params['params']),
+                    $this->equalTo($targetDir),
+                    $this->equalTo($params['sourcePath'])
+                )
+                ->will($this->returnValue($expectedResult));
+        }
+
+        $this->preProcessorFactoryMock->expects($this->any())
+            ->method('create')
+            ->will($this->returnCallback(array($this, 'createProcessor')));
+
+        $this->composite = $this->objectManagerHelper->getObject(
+            'Magento\Css\PreProcessor\Composite',
+            [
+                'preProcessorFactory' => $this->preProcessorFactoryMock,
+                'preProcessors' => $preProcessors
+            ]
+        );
+
+        $result = $this->composite->process(
+            $params['filePath'],
+            $params['params'],
+            $targetDir,
+            $params['sourcePath']
+        );
+        $this->assertEquals($expectedResult, $result);
+    }
+
+    /**
+     * Create pre-processor callback
+     *
+     * @param string $className
+     * @return \Magento\View\Asset\PreProcessor\PreProcessorInterface[]
+     */
+    public function createProcessor($className)
+    {
+        return $this->callMap[$className];
+    }
+
+    /**
+     * @return array
+     */
+    public function processDataProvider()
+    {
+        return [
+            'one processor - LESS' => [
+                'params' => [
+                    'filePath' => '/some/file/path_one.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => 'result_source_path_one'
+                ],
+                'preProcessors' => [
+                    'css_source_processor' => 'Magento\Css\PreProcessor\Less',
+                ],
+                'createMap' => [
+                    'Magento\Css\PreProcessor\Less',
+                ],
+                'expectedResult' => 'result_source_path_one'
+            ],
+            'list of pre-processors' => [
+                'params' => [
+                    'filePath' => '/some/file/path.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => 'result_source_path_two'
+                ],
+                'preProcessors' => [
+                    'css_source_processor' => 'Magento\Css\PreProcessor\Less',
+                    'css_source_processor2' => 'Magento\Css\PreProcessor\Less2',
+                ],
+                'createMap' => [
+                    'Magento\Css\PreProcessor\Less',
+                    'Magento\Css\PreProcessor\Less2',
+                ],
+                'expectedResult' => 'result_source_path_two'
+            ],
+            'no result' => [
+                'params' => [
+                    'filePath' => '/some/file/path_other.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => null
+                ],
+                'preProcessors' => [
+                    'css_source_processor' => 'Magento\Css\PreProcessor\Less',
+                ],
+                'createMap' => [
+                    'Magento\Css\PreProcessor\Less',
+                ],
+                'expectedResult' => null
+            ],
+            'no processors' => [
+                'params' => [
+                    'filePath' => '/some/file/some_path.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => null
+                ],
+                'preProcessors' => [],
+                'createMap' => [],
+                'expectedResult' => null
+            ],
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..cdb833d7a173d51de241bce9f2a9f4ff7d0e8845
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php
@@ -0,0 +1,248 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Account\Dashboard;
+
+use Magento\Exception\NoSuchEntityException;
+
+/**
+ * Test class for \Magento\Customer\Block\Account\Dashboard\Info.
+ */
+class InfoTest extends \PHPUnit_Framework_TestCase
+{
+    /** Constant values used for testing */
+    const CUSTOMER_ID = 1;
+    const CHANGE_PASSWORD_URL = 'http://localhost/index.php/account/edit/changepass/1';
+    const EMAIL_ADDRESS = 'john.doe@ebay.com';
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\View\Element\Template\Context */
+    private $_context;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */
+    private $_customerSession;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerServiceInterface */
+    private $_customerService;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Customer */
+    private $_customer;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
+     */
+    private $_metadataService;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Newsletter\Model\Subscriber */
+    private $_subscriber;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Newsletter\Model\SubscriberFactory */
+    private $_subscriberFactory;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Block\Form\Register */
+    private $_formRegister;
+
+    /** @var Info */
+    private $_block;
+
+    public function setUp()
+    {
+        $urlBuilder = $this->getMockForAbstractClass('Magento\UrlInterface', array(), '', false);
+        $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue(self::CHANGE_PASSWORD_URL));
+
+        $layout = $this->getMockForAbstractClass('Magento\View\LayoutInterface', array(), '', false);
+        $this->_formRegister = $this->getMock('Magento\Customer\Block\Form\Register', array(), array(), '', false);
+        $layout->expects($this->any())
+            ->method('getBlockSingleton')
+            ->with('Magento\Customer\Block\Form\Register')->will($this->returnValue($this->_formRegister));
+
+        $this->_context = $this->getMock('Magento\View\Element\Template\Context', array(), array(), '', false);
+        $this->_context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder));
+        $this->_context->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
+
+        $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', array(), array(), '', false);
+        $this->_customerSession->expects($this->any())->method('getId')->will($this->returnValue(self::CUSTOMER_ID));
+
+        $this->_customerService = $this->getMockForAbstractClass(
+            'Magento\Customer\Service\V1\CustomerServiceInterface', array(), '', false
+        );
+        $this->_customer = $this->getMock('Magento\Customer\Service\V1\Dto\Customer', array(), array(), '', false);
+        $this->_customer->expects($this->any())->method('getEmail')->will($this->returnValue(self::EMAIL_ADDRESS));
+        $this->_customerService
+            ->expects($this->any())->method('getCustomer')->will($this->returnValue($this->_customer));
+
+        $this->_metadataService = $this->getMockForAbstractClass(
+            'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', array(), '', false
+        );
+        $this->_subscriberFactory =
+            $this->getMock('Magento\Newsletter\Model\SubscriberFactory', array('create'), array(), '', false);
+        $this->_subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', array(), array(), '', false);
+        $this->_subscriber->expects($this->any())->method('loadByEmail')->will($this->returnSelf());
+        $this->_subscriberFactory
+            ->expects($this->any())->method('create')->will($this->returnValue($this->_subscriber));
+
+        $this->_block = new Info(
+            $this->_context,
+            $this->_customerSession,
+            $this->_customerService,
+            $this->_metadataService,
+            $this->_subscriberFactory
+        );
+    }
+
+    public function testGetCustomer()
+    {
+        $this->_customer->expects($this->once())->method('getCustomerId')->will($this->returnValue(self::CUSTOMER_ID));
+        $customer = $this->_block->getCustomer();
+        $this->assertEquals(self::CUSTOMER_ID, $customer->getCustomerId());
+    }
+
+    public function testGetCustomerException()
+    {
+        $this->_customerService
+            ->expects($this->once())
+            ->method('getCustomer')->will($this->throwException(new NoSuchEntityException('customerId', 1)));
+        $this->assertNull($this->_block->getCustomer());
+    }
+
+    /**
+     * Tests variations of Account\Dashboard\Info::getName() by controlling the visibility of the prefix,
+     * middlename, and suffix Customer attributes. Also tests variations based on whether the Customer has
+     * values for these attributes. All Customers have a first and last name.
+     *
+     * @param array $isVisible Determines the visibility of the prefix, middlename, and suffix attriubtes
+     * @param string $prefix Customer prefix attribute value
+     * @param string $firstname Customer firstname attribute value
+     * @param string $middlename Customer middlename attribute value
+     * @param string $lastname Customer lastname attribute value
+     * @param string $suffix Customer suffix attribute value
+     * @param string $expectedValue Concatenation of all visible Customer attribute values
+     *
+     * @dataProvider getNameProvider
+     */
+    public function testGetName(
+        array $isVisible, $prefix, $firstname, $middlename, $lastname, $suffix, $expectedValue
+    ) {
+        $attributeMetadata =
+            $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', array(), array(), '', false);
+
+        /**
+         * Called three times, once for each attribute (i.e. prefix, middlename, and suffix)
+         */
+        $this->_metadataService
+            ->expects($this->any())
+            ->method('getCustomerAttributeMetadata')->will($this->returnValue($attributeMetadata));
+
+        /**
+         * Sets the value of AttributeMetadata::isVisible() for the prefix at(0), middlename at(1) and
+         * suffix at(2) Customer attributes.
+         */
+        foreach ($isVisible as $index => $boolean) {
+            $attributeMetadata
+                ->expects($this->at($index))->method('isVisible')->will($this->returnValue($boolean));
+        }
+
+        /**
+         * The AttributeMetadata::{getPrefix() | getMiddlename() | getSuffix()} methods are called twice,
+         * while getFirstname() and getLastname() are only called once. Hence the use of any() vs. once().
+         */
+        $this->_customer->expects($this->any())->method('getPrefix')->will($this->returnValue($prefix));
+        $this->_customer->expects($this->once())->method('getFirstname')->will($this->returnValue($firstname));
+        $this->_customer->expects($this->any())->method('getMiddlename')->will($this->returnValue($middlename));
+        $this->_customer->expects($this->once())->method('getLastname')->will($this->returnValue($lastname));
+        $this->_customer->expects($this->any())->method('getSuffix')->will($this->returnValue($suffix));
+
+        $this->assertEquals($expectedValue, $this->_block->getName());
+    }
+
+    /**
+     * @return array
+     */
+    public function getNameProvider()
+    {
+        return array(
+            array([false, true,  true],  'Mr', 'John', 'Q',  'Doe', 'Jr', 'John Q Doe Jr'),
+            array([true,  false, true],  'Mr', 'John', 'Q',  'Doe', 'Jr', 'Mr John Doe Jr'),
+            array([true,  true,  false], 'Mr', 'John', 'Q',  'Doe', 'Jr', 'Mr John Q Doe'),
+            array([false, false, false], 'Mr', 'John', 'Q',  'Doe', 'Jr', 'John Doe'),
+            array([true,  true,  true],  null, 'John', 'Q',  'Doe', 'Jr', 'John Q Doe Jr'),
+            array([true,  true,  true],  'Mr', 'John', null, 'Doe', 'Jr', 'Mr John Doe Jr'),
+            array([true,  true,  true],  'Mr', 'John', 'Q',  'Doe', null, 'Mr John Q Doe'),
+            array([true,  true,  true],  null, 'John', null, 'Doe', null, 'John Doe')
+        );
+    }
+
+    public function testGetChangePasswordUrl()
+    {
+        $this->assertEquals(self::CHANGE_PASSWORD_URL, $this->_block->getChangePasswordUrl());
+    }
+
+    public function testGetSubscriptionObject()
+    {
+        $this->assertSame($this->_subscriber, $this->_block->getSubscriptionObject());
+    }
+
+    /**
+     * @param bool $isSubscribed Is the subscriber subscribed?
+     * @param bool $expectedValue The expected value - Whether the subscriber is subscribed or not.
+     *
+     * @dataProvider getIsSubscribedProvider
+     */
+    public function testGetIsSubscribed($isSubscribed, $expectedValue)
+    {
+        $this->_subscriber->expects($this->once())->method('isSubscribed')->will($this->returnValue($isSubscribed));
+        $this->assertEquals($expectedValue, $this->_block->getIsSubscribed());
+    }
+
+    /**
+     * @return array
+     */
+    public function getIsSubscribedProvider()
+    {
+        return array(
+            array(true, true),
+            array(false, false)
+        );
+    }
+
+    /**
+     * @param bool $isNewsletterEnabled Determines if the newsletter is enabled
+     * @param bool $expectedValue The expected value - Whether the newsletter is enabled or not
+     *
+     * @dataProvider isNewsletterEnabledProvider
+     */
+    public function testIsNewsletterEnabled($isNewsletterEnabled, $expectedValue)
+    {
+        $this->_formRegister
+            ->expects($this->once())
+            ->method('isNewsletterEnabled')->will($this->returnValue($isNewsletterEnabled));
+        $this->assertEquals($expectedValue, $this->_block->isNewsletterEnabled());
+    }
+
+    public function isNewsletterEnabledProvider()
+    {
+        return array(
+            array(true, true),
+            array(false, false)
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Form/RegisterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Form/RegisterTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ae26139ea6fa6950da35d6ea078444011d2f2efe
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Form/RegisterTest.php
@@ -0,0 +1,307 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Form;
+
+/**
+ * Test class for \Magento\Customer\Block\Form\Register.
+ */
+class RegisterTest extends \PHPUnit_Framework_TestCase
+{
+    /** Constants used by the various unit tests */
+    const POST_ACTION_URL = 'http://localhost/index.php/customer/account/createpost';
+    const LOGIN_URL = 'http://localhost/index.php/customer/account/login';
+    const COUNTRY_ID = 'US';
+    const FORM_DATA = 'form_data';
+    const REGION_ATTRIBUTE_VALUE = 'California';
+    const REGION_ID_ATTRIBUTE_CODE = 'region_id';
+    const REGION_ID_ATTRIBUTE_VALUE = '12';
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Helper\Data */
+    private $_coreData;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\Store\Config */
+    private $_storeConfig;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */
+    private $_customerSession;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Module\Manager */
+    private $_moduleManager;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Helper\Data */
+    private $_customerHelper;
+
+    /** @var Register */
+    private $_block;
+
+    public function setUp()
+    {
+        $this->_storeConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false);
+        $this->_moduleManager = $this->getMock('Magento\Module\Manager', array(), array(), '', false);
+        $this->_coreData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false);
+        $this->_customerHelper = $this->getMock('Magento\Customer\Helper\Data', array(), array(), '', false);
+        $this->_customerSession =
+            $this->getMock('Magento\Customer\Model\Session', array('getCustomerFormData'), array(), '', false);
+
+        $context = $this->getMock('Magento\View\Element\Template\Context', array(), array(), '', false);
+        $context->expects($this->any())->method('getStoreConfig')->will($this->returnValue($this->_storeConfig));
+
+        $this->_block = new Register(
+            $context,
+            $this->_coreData,
+            $this->getMockForAbstractClass('Magento\Json\EncoderInterface', array(), '', false),
+            $this->getMock('Magento\App\Cache\Type\Config', array(), array(), '', false),
+            $this->getMock('Magento\Directory\Model\Resource\Region\CollectionFactory', array(), array(), '', false),
+            $this->getMock('Magento\Directory\Model\Resource\Country\CollectionFactory', array(), array(), '', false),
+            $this->_moduleManager,
+            $this->_customerSession,
+            $this->_customerHelper
+        );
+    }
+
+    /**
+     * @param string $path
+     * @param mixed $configValue
+     *
+     * @dataProvider getConfigProvider
+     */
+    public function testGetConfig($path, $configValue)
+    {
+        $this->_storeConfig->expects($this->once())->method('getConfig')->will($this->returnValue($configValue));
+        $this->assertEquals($configValue, $this->_block->getConfig($path));
+    }
+
+    /**
+     * @return array
+     */
+    public function getConfigProvider()
+    {
+        return array(
+            array('/path/to/config/value', 'config value'),
+            array('/path/to/config/value/that/does/not/exist', null)
+        );
+    }
+
+    public function testGetPostActionUrl()
+    {
+        $this->_customerHelper
+            ->expects($this->once())->method('getRegisterPostUrl')->will($this->returnValue(self::POST_ACTION_URL));
+        $this->assertEquals(self::POST_ACTION_URL, $this->_block->getPostActionUrl());
+    }
+
+    /**
+     * Tests the use case where 'back_url' has not been set on the block.
+     */
+    public function testGetBackUrlNullData()
+    {
+        $this->_customerHelper
+            ->expects($this->once())->method('getLoginUrl')->will($this->returnValue(self::LOGIN_URL));
+        $this->assertEquals(self::LOGIN_URL, $this->_block->getBackUrl());
+    }
+
+    /**
+     * Tests the use case where 'back_url' has been set on the block.
+     */
+    public function testGetBackUrlNotNullData()
+    {
+        $this->_block->setData('back_url', self::LOGIN_URL);
+        $this->assertEquals(self::LOGIN_URL, $this->_block->getBackUrl());
+    }
+
+    /**
+     * Form data has been set on the block so Form\Register::getFormData() simply returns it.
+     */
+    public function testGetFormDataNotNullFormData()
+    {
+        $data = new \Magento\Object();
+        $this->_block->setData(self::FORM_DATA, $data);
+        $this->assertSame($data, $this->_block->getFormData());
+    }
+    /**
+     * Form data has not been set on the block and there is no customer data in the customer session. So
+     * we expect an empty \Magento\Object.
+     */
+    public function testGetFormDataNullFormData()
+    {
+        $data = new \Magento\Object();
+        $this->_customerSession
+            ->expects($this->once())->method('getCustomerFormData')->will($this->returnValue(null));
+        $this->assertEquals($data, $this->_block->getFormData());
+        $this->assertEquals($data, $this->_block->getData(self::FORM_DATA));
+    }
+
+    /**
+     * Form data has not been set on the block, but there is customer data from the customer session.
+     * The customer data is something other than 'region_id' so that code path is skipped.
+     */
+    public function testGetFormDataNullFormDataCustomerFormData()
+    {
+        $data = new \Magento\Object();
+        $data->setFirstname('John');
+        $data->setCustomerData(1);
+        $customerFormData = array('firstname' => 'John');
+        $this->_customerSession
+            ->expects($this->once())->method('getCustomerFormData')->will($this->returnValue($customerFormData));
+        $this->assertEquals($data, $this->_block->getFormData());
+        $this->assertEquals($data, $this->_block->getData(self::FORM_DATA));
+    }
+
+    /**
+     * Form data has not been set on the block, but there is customer data from the customer session.
+     * The customer data is the 'region_id' so that code path is executed.
+     */
+    public function testGetFormDataCustomerFormDataRegionId()
+    {
+        $data = new \Magento\Object();
+        $data->setRegionId(self::REGION_ID_ATTRIBUTE_VALUE);
+        $data->setCustomerData(1);
+        $data[self::REGION_ID_ATTRIBUTE_CODE] = (int)self::REGION_ID_ATTRIBUTE_VALUE;
+        $customerFormData = array(self::REGION_ID_ATTRIBUTE_CODE => self::REGION_ID_ATTRIBUTE_VALUE);
+        $this->_customerSession
+            ->expects($this->once())->method('getCustomerFormData')->will($this->returnValue($customerFormData));
+        $formData = $this->_block->getFormData();
+        $this->assertEquals($data, $formData);
+        $this->assertTrue(isset($formData[self::REGION_ID_ATTRIBUTE_CODE]));
+        $this->assertSame((int)self::REGION_ID_ATTRIBUTE_VALUE, $formData[self::REGION_ID_ATTRIBUTE_CODE]);
+    }
+
+    /**
+     * Tests the Form\Register::getCountryId() use case where CountryId has been set on the form data
+     * Object that has been set on the block.
+     */
+    public function testGetCountryIdFormData()
+    {
+        $formData = new \Magento\Object();
+        $formData->setCountryId(self::COUNTRY_ID);
+        $this->_block->setData(self::FORM_DATA, $formData);
+        $this->assertEquals(self::COUNTRY_ID, $this->_block->getCountryId());
+    }
+
+    /**
+     * Tests the default country use case of parent::getCountryId() where CountryId has not been set
+     * and the 'country_id' attribute has also not been set.
+     */
+    public function testGetCountryIdParentNullData()
+    {
+        $this->_coreData
+            ->expects($this->once())->method('getDefaultCountry')->will($this->returnValue(self::COUNTRY_ID));
+        $this->assertEquals(self::COUNTRY_ID, $this->_block->getCountryId());
+    }
+
+    /**
+     * Tests the parent::getCountryId() use case where CountryId has not been set and the 'country_id'
+     * attribute code has been set on the block.
+     */
+    public function testGetCountryIdParentNotNullData()
+    {
+        $this->_block->setData('country_id', self::COUNTRY_ID);
+        $this->assertEquals(self::COUNTRY_ID, $this->_block->getCountryId());
+    }
+
+    /**
+     * Tests the first if conditional of Form\Register::getRegion(), which checks to see if Region has
+     * been set on the form data Object that's set on the block.
+     */
+    public function testGetRegionByRegion()
+    {
+        $formData = new \Magento\Object();
+        $formData->setRegion(self::REGION_ATTRIBUTE_VALUE);
+        $this->_block->setData(self::FORM_DATA, $formData);
+        $this->assertSame(self::REGION_ATTRIBUTE_VALUE, $this->_block->getRegion());
+    }
+
+    /**
+     * Tests the second if conditional of Form\Register::getRegion(), which checks to see if RegionId
+     * has been set on the form data Object that's set on the block.
+     */
+    public function testGetRegionByRegionId()
+    {
+        $formData = new \Magento\Object();
+        $formData->setRegionId(self::REGION_ID_ATTRIBUTE_VALUE);
+        $this->_block->setData(self::FORM_DATA, $formData);
+        $this->assertSame(self::REGION_ID_ATTRIBUTE_VALUE, $this->_block->getRegion());
+    }
+
+    /**
+     * Neither Region, nor RegionId have been set on the form data Object that's set on the block so a
+     * null value is expected.
+     */
+    public function testGetRegionNull()
+    {
+        $formData = new \Magento\Object();
+        $this->_block->setData(self::FORM_DATA, $formData);
+        $this->assertNull($this->_block->getRegion());
+    }
+
+    /**
+     * @param $isNewsletterEnabled
+     * @param $expectedValue
+     *
+     * @dataProvider isNewsletterEnabledProvider
+     */
+    public function testIsNewsletterEnabled($isNewsletterEnabled, $expectedValue)
+    {
+        $this->_moduleManager
+            ->expects($this->once())
+            ->method('isOutputEnabled')->with('Magento_Newsletter')->will($this->returnValue($isNewsletterEnabled));
+        $this->assertEquals($expectedValue, $this->_block->isNewsletterEnabled());
+    }
+
+    /**
+     * @return array
+     */
+    public function isNewsletterEnabledProvider()
+    {
+        return array(
+            array(true, true),
+            array(false, false)
+        );
+    }
+
+    /**
+     * This test is designed to execute all code paths of Form\Register::getFormData() when testing the
+     * Form\Register::restoreSessionData() method.
+     */
+    public function testRestoreSessionData()
+    {
+        $data = new \Magento\Object();
+        $data->setRegionId(self::REGION_ID_ATTRIBUTE_VALUE);
+        $data->setCustomerData(1);
+        $data[self::REGION_ID_ATTRIBUTE_CODE] = (int)self::REGION_ID_ATTRIBUTE_VALUE;
+        $customerFormData = array(self::REGION_ID_ATTRIBUTE_CODE => self::REGION_ID_ATTRIBUTE_VALUE);
+        $this->_customerSession
+            ->expects($this->once())->method('getCustomerFormData')->will($this->returnValue($customerFormData));
+        $form = $this->getMock('Magento\Customer\Model\Metadata\Form', array(), array(), '', false);
+        $request = $this->getMockForAbstractClass('Magento\App\RequestInterface', array(), '', false);
+        $formData = $this->_block->getFormData();
+        $form->expects($this->once())
+            ->method('prepareRequest')->with($formData->getData())->will($this->returnValue($request));
+        $form->expects($this->once())
+            ->method('extractData')->with($request, null, false)->will($this->returnValue($customerFormData));
+        $form->expects($this->once())->method('restoreData')->will($this->returnValue($customerFormData));
+        $block = $this->_block->restoreSessionData($form, null, false);
+        $this->assertSame($this->_block, $block);
+        $this->assertEquals($data, $block->getData(self::FORM_DATA));
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/AbstractWidgetTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/AbstractWidgetTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..357fb79959e5b04089415a9957a5da0c1808c6ae
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/AbstractWidgetTest.php
@@ -0,0 +1,172 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Widget;
+
+class AbstractWidgetTest extends \PHPUnit_Framework_TestCase
+{
+    /** Constants used in the various unit tests. */
+    const KEY_FIELD_ID_FORMAT = 'field_id_format';
+    const KEY_FIELD_NAME_FORMAT = 'field_name_format';
+    const FORMAT_D = '%d';
+    const FORMAT_S = '%s';
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Helper\Address */
+    private $_addressHelper;
+
+    /** @var AbstractWidget */
+    private $_block;
+
+    public function setUp()
+    {
+        $this->_addressHelper = $this->getMock('Magento\Customer\Helper\Address', [], [], '', false);
+
+        $this->_block = new AbstractWidget(
+            $this->getMock('Magento\View\Element\Template\Context', [], [], '', false),
+            $this->_addressHelper,
+            $this->getMockForAbstractClass(
+                'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false
+            )
+        );
+    }
+
+    /**
+     * @param string $key
+     * @param string|null $expectedValue
+     *
+     * @dataProvider getConfigDataProvider
+     */
+    public function testGetConfig($key, $expectedValue)
+    {
+        $this->_addressHelper
+            ->expects($this->once())->method('getConfig')->with($key)->will($this->returnValue($expectedValue));
+        $this->assertEquals($expectedValue, $this->_block->getConfig($key));
+    }
+
+    /**
+     * @return array
+     */
+    public function getConfigDataProvider()
+    {
+        return [
+            ['key', 'value'],
+            [null, null]
+        ];
+    }
+
+    /**
+     * The default field id format is '%s' so we set it to '%d' to verify that '%d' gets returned when
+     * AbstractWidget::getFieldIdFormat() is called.
+     */
+    public function testGetFieldIdFormatHasData()
+    {
+        $this->_block->setData(self::KEY_FIELD_ID_FORMAT, self::FORMAT_D);
+        $this->assertEquals(self::FORMAT_D, $this->_block->getFieldIdFormat());
+    }
+
+    /**
+     * Returns the default '%s' field id format when the block has no data for it.
+     */
+    public function testGetFieldIdFormatHasNoData()
+    {
+        $this->assertEquals(self::FORMAT_S, $this->_block->getFieldIdFormat());
+    }
+
+    /**
+     * The default field name format is '%s' so we set it to '%d' to verify that '%d' gets returned when
+     * AbstractWidget::getFieldNameFormat() is called.
+     */
+    public function testGetFieldNameFormatHasData()
+    {
+        $this->_block->setData(self::KEY_FIELD_NAME_FORMAT, self::FORMAT_D);
+        $this->assertEquals(self::FORMAT_D, $this->_block->getFieldNameFormat());
+    }
+
+    /**
+     * Returns the default '%s' field name format when the block has no data for it.
+     */
+    public function testGetFieldNameFormatHasNoData()
+    {
+        $this->assertEquals(self::FORMAT_S, $this->_block->getFieldNameFormat());
+    }
+
+    /**
+     * Test '%s' and '%d' formats to verify that '%s' returns a string and '%d' returns a numeric
+     * string when AbstractWidget::getFieldId() is invoked.
+     *
+     * @param string $format Field id format (e.g. '%s' or '%d')
+     * @param string $fieldId Field id
+     * @param string $expectedValue The value we expect from AbstractWidget::getFieldId()
+     * @param string $method The method to invoke on the result from getFieldId() should return true
+     *
+     * @dataProvider getFieldIdDataProvider
+     */
+    public function testGetFieldId($format, $fieldId, $expectedValue, $method)
+    {
+        $this->_block->setData(self::KEY_FIELD_ID_FORMAT, $format);
+        $this->assertTrue(call_user_func($method, $blockFieldId = $this->_block->getFieldId($fieldId)));
+        $this->assertSame($expectedValue, $blockFieldId);
+    }
+
+    /**
+     * @return array
+     */
+    public function getFieldIdDataProvider()
+    {
+        return [
+            [self::FORMAT_S, 'Id', 'Id', 'is_string'],
+            [self::FORMAT_D, '123', '123', 'is_numeric'],
+            [self::FORMAT_D, 'Id', '0', 'is_numeric']
+        ];
+    }
+
+    /**
+     * Test '%s' and '%d' formats to verify that '%s' returns a string and '%d' returns a numeric
+     * string when AbstractWidget::getFieldName() is invoked.
+     *
+     * @param string $format Field name format (e.g. '%s' or '%d')
+     * @param string $fieldName The field name
+     * @param string $expectedValue The value we expect from AbstractWidget::getFieldName
+     * @param string $method The method to invoke on the result from getFieldName() should return true
+     *
+     * @dataProvider getFieldNameDataProvider
+     */
+    public function testGetFieldName($format, $fieldName, $expectedValue, $method)
+    {
+        $this->_block->setData(self::KEY_FIELD_NAME_FORMAT, $format);
+        $this->assertTrue(call_user_func($method, $blockFieldName = $this->_block->getFieldName($fieldName)));
+        $this->assertEquals($expectedValue, $blockFieldName);
+    }
+
+    /**
+     * @return array
+     */
+    public function getFieldNameDataProvider()
+    {
+        return [
+            [self::FORMAT_S, 'Name', 'Name', 'is_string'],
+            [self::FORMAT_D, '123', '123', 'is_numeric'],
+            [self::FORMAT_D, 'Name', '0', 'is_numeric']
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..55188e186f199400afae7d01659bb77b3f0da5ce
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php
@@ -0,0 +1,298 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Widget;
+
+use Magento\Core\Model\LocaleInterface;
+
+class DobTest extends \PHPUnit_Framework_TestCase
+{
+    /** Constants used in the unit tests */
+    const MIN_DATE = '01/01/2010';
+    const MAX_DATE = '01/01/2020';
+    const DATE = '01/01/2014';
+    const DAY = '01';    // Value of date('d', strtotime(self::DATE))
+    const MONTH = '01';  // Value of date('m', strtotime(self::DATE))
+    const YEAR = '2014'; // Value of date('Y', strtotime(self::DATE))
+    const DATE_FORMAT = 'M/d/yy';
+
+    /** Constants used by Dob::setDateInput($code, $html) */
+    const DAY_HTML =
+        '<div><label for="day"><span>d</span></label><input type="text" id="day" name="Day" value="1"></div>';
+    const MONTH_HTML =
+        '<div><label for="month"><span>M</span></label><input type="text" id="month" name="Month" value="jan"></div>';
+    const YEAR_HTML =
+        '<div><label for="year"><span>yy</span></label><input type="text" id="year" name="Year" value="14"></div>';
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+    private $_attribute;
+
+    /** @var Dob */
+    private $_block;
+
+    public function setUp()
+    {
+        $zendCacheCore = new \Zend_Cache_Core();
+        $zendCacheCore->setBackend(new \Zend_Cache_Backend_BlackHole());
+
+        $frontendCache = $this->getMockForAbstractClass('Magento\Cache\FrontendInterface', [], '', false);
+        $frontendCache->expects($this->any())
+            ->method('getLowLevelFrontend')->will($this->returnValue($zendCacheCore));
+        $app = $this->getMock('Magento\Core\Model\App', [], [], '', false);
+        $app->expects($this->any())->method('getCache')->will($this->returnValue($frontendCache));
+
+        $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $locale = $objectManager
+            ->getObject('Magento\Core\Model\Locale', ['app' => $app, 'locale' => LocaleInterface::DEFAULT_LOCALE]);
+
+        $context = $this->getMock('Magento\View\Element\Template\Context', [], [], '', false);
+        $context->expects($this->any())->method('getLocale')->will($this->returnValue($locale));
+
+        $this->_attribute = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false);
+        $attributeMetadata =
+            $this->getMockForAbstractClass(
+                'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false
+            );
+        $attributeMetadata
+            ->expects($this->any())->method('getAttributeMetadata')->will($this->returnValue($this->_attribute));
+
+        date_default_timezone_set('America/Los_Angeles');
+
+        $this->_block = new Dob(
+            $context,
+            $this->getMock('Magento\Customer\Helper\Address', [], [], '', false),
+            $attributeMetadata
+        );
+    }
+
+    /**
+     * @param bool $isVisible Determines whether the 'dob' attribute is visible or enabled
+     * @param bool $expectedValue The value we expect from Dob::isEnabled()
+     *
+     * @dataProvider isEnabledDataProvider
+     */
+    public function testIsEnabled($isVisible, $expectedValue)
+    {
+        $this->_attribute->expects($this->once())->method('isVisible')->will($this->returnValue($isVisible));
+        $this->assertSame($expectedValue, $this->_block->isEnabled());
+    }
+
+    /**
+     * @return array
+     */
+    public function isEnabledDataProvider()
+    {
+        return [
+            [true, true],
+            [false, false]
+        ];
+    }
+
+    /**
+     * @param bool $isRequired Determines whether the 'dob' attribute is required
+     * @param bool $expectedValue The value we expect from Dob::isRequired()
+     *
+     * @dataProvider isRequiredDataProvider
+     */
+    public function testIsRequired($isRequired, $expectedValue)
+    {
+        $this->_attribute->expects($this->once())->method('isRequired')->will($this->returnValue($isRequired));
+        $this->assertSame($expectedValue, $this->_block->isRequired());
+    }
+
+    /**
+     * @return array
+     */
+    public function isRequiredDataProvider()
+    {
+        return [
+            [true, true],
+            [false, false]
+        ];
+    }
+
+    /**
+     * @param string|bool $date Date (e.g. '01/01/2020' or false for no date)
+     * @param int|bool $expectedTime The value we expect from Dob::getTime()
+     * @param string|bool $expectedDate The value we expect from Dob::getData('date')
+     *
+     * @dataProvider setDateDataProvider
+     */
+    public function testSetDate($date, $expectedTime, $expectedDate)
+    {
+        $this->assertSame($this->_block, $this->_block->setDate($date));
+        $this->assertEquals($expectedTime, $this->_block->getTime());
+        $this->assertEquals($expectedDate, $this->_block->getData('date'));
+    }
+
+    /**
+     * @return array
+     */
+    public function setDateDataProvider()
+    {
+        return [
+            [self::DATE, strtotime(self::DATE), self::DATE],
+            [false, false, false]
+        ];
+    }
+
+    /**
+     * @param string|bool $date The date (e.g. '01/01/2020' or false for no date)
+     * @param string $expectedDay The value we expect from Dob::getDay()
+     *
+     * @dataProvider getDayDataProvider
+     */
+    public function testGetDay($date, $expectedDay)
+    {
+        $this->_block->setDate($date);
+        $this->assertEquals($expectedDay, $this->_block->getDay());
+    }
+
+    /**
+     * @return array
+     */
+    public function getDayDataProvider()
+    {
+        return [
+            [self::DATE, self::DAY],
+            [false, '']
+        ];
+    }
+
+    /**
+     * @param string|bool $date The date (e.g. '01/01/2020' or false for no date)
+     * @param string $expectedMonth The value we expect from Dob::getMonth()
+     *
+     * @dataProvider getMonthDataProvider
+     */
+    public function testGetMonth($date, $expectedMonth)
+    {
+        $this->_block->setDate($date);
+        $this->assertEquals($expectedMonth, $this->_block->getMonth());
+    }
+
+    /**
+     * @return array
+     */
+    public function getMonthDataProvider()
+    {
+        return [
+            [self::DATE, self::MONTH],
+            [false, '']
+        ];
+    }
+
+    /**
+     * @param string|bool $date The date (e.g. '01/01/2020' or false for no date)
+     * @param string $expectedYear The value we expect from Dob::getYear()
+     *
+     * @dataProvider getYearDataProvider
+     */
+    public function testGetYear($date, $expectedYear)
+    {
+        $this->_block->setDate($date);
+        $this->assertEquals($expectedYear, $this->_block->getYear());
+    }
+
+    /**
+     * @return array
+     */
+    public function getYearDataProvider()
+    {
+        return [
+            [self::DATE, self::YEAR],
+            [false, '']
+        ];
+    }
+
+    /**
+     * The LocaleInterface::DEFAULT_LOCALE is used to derive the Locale that is used to determine the
+     * value of Dob::getDateFormat() for that Locale.
+     */
+    public function testGetDateFormat()
+    {
+        $this->assertEquals(self::DATE_FORMAT, $this->_block->getDateFormat());
+    }
+
+    /**
+     * This tests the Dob::setDateInput() method. The Dob::getSortedDateInputs() uses the value of
+     * Dob::getDateFormat() to derive the return value, which is equivalent to self::DATE_FORMAT.
+     */
+    public function testGetSortedDateInputs()
+    {
+        $this->_block->setDateInput('d', self::DAY_HTML);
+        $this->_block->setDateInput('m', self::MONTH_HTML);
+        $this->_block->setDateInput('y', self::YEAR_HTML);
+
+        $this->assertEquals(
+            self::MONTH_HTML . self::DAY_HTML . self::YEAR_HTML, $this->_block->getSortedDateInputs());
+    }
+
+    /**
+     * @param array $validationRules The date Min/Max validation rules
+     * @param int $expectedValue The value we expect from Dob::getMinDateRange()
+     *
+     * @dataProvider getMinDateRangeDataProvider
+     */
+    public function testGetMinDateRange($validationRules, $expectedValue)
+    {
+        $this->_attribute
+            ->expects($this->once())->method('getValidationRules')->will($this->returnValue($validationRules));
+        $this->assertEquals($expectedValue, $this->_block->getMinDateRange());
+    }
+
+    /**
+     * @return array
+     */
+    public function getMinDateRangeDataProvider()
+    {
+        return [
+            [[Dob::MIN_DATE_RANGE_KEY => strtotime(self::MIN_DATE)], date('Y/m/d', strtotime(self::MIN_DATE))],
+            [[], null]
+        ];
+    }
+
+    /**
+     * @param array $validationRules The date Min/Max validation rules
+     * @param int $expectedValue The value we expect from Dob::getMaxDateRange()
+     *
+     * @dataProvider getMaxDateRangeDataProvider
+     */
+    public function testGetMaxDateRange($validationRules, $expectedValue)
+    {
+        $this->_attribute
+            ->expects($this->once())->method('getValidationRules')->will($this->returnValue($validationRules));
+        $this->assertEquals($expectedValue, $this->_block->getMaxDateRange());
+    }
+
+    /**
+     * @return array
+     */
+    public function getMaxDateRangeDataProvider()
+    {
+        return [
+            [[Dob::MAX_DATE_RANGE_KEY => strtotime(self::MAX_DATE)], date('Y/m/d', strtotime(self::MAX_DATE))],
+            [[], null]
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ce34f43068327939b3469664af37dccebc39fc17
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php
@@ -0,0 +1,178 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Widget;
+
+class GenderTest extends \PHPUnit_Framework_TestCase
+{
+    /** Constants used in the unit tests */
+    const CUSTOMER_ENTITY_TYPE = 'customer';
+    const GENDER_ATTRIBUTE_CODE = 'gender';
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
+    private $_abstractAttribute;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
+     */
+    private $_attributeMetadata;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+    private $_attribute;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */
+    private $_customerSession;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Resource\Customer */
+    private $_customerResource;
+
+    /** @var Gender */
+    private $_block;
+
+    public function setUp()
+    {
+        $this->_attribute = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false);
+
+        $this->_abstractAttribute =
+            $this->getMockForAbstractClass(
+                'Magento\Eav\Model\Entity\Attribute\AbstractAttribute',
+                [], '', false, true, true, ['__wakeup', 'getSource']
+            );
+
+        $this->_attributeMetadata =
+            $this->getMockForAbstractClass(
+                'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false
+            );
+        $this->_attributeMetadata->expects($this->any())->method('getAttributeMetadata')
+            ->with(self::CUSTOMER_ENTITY_TYPE, self::GENDER_ATTRIBUTE_CODE)
+            ->will($this->returnValue($this->_attribute));
+
+        $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false);
+        $this->_customerResource =
+            $this->getMock('Magento\Customer\Model\Resource\Customer', [], [], '', false);
+
+        $this->_block = new Gender(
+            $this->getMock('Magento\View\Element\Template\Context', [], [], '', false),
+            $this->getMock('Magento\Customer\Helper\Address', [], [], '', false),
+            $this->_attributeMetadata,
+            $this->_customerSession,
+            $this->_customerResource
+        );
+    }
+
+    /**
+     * @param bool $isVisible Determines whether the 'gender' attribute is visible or enabled
+     * @param bool $expectedValue The value we expect from Gender::isEnabled()
+     * @return void
+     *
+     * @dataProvider isEnabledDataProvider
+     */
+    public function testIsEnabled($isVisible, $expectedValue)
+    {
+        $this->_attribute->expects($this->once())->method('isVisible')->will($this->returnValue($isVisible));
+        $this->assertSame($expectedValue, $this->_block->isEnabled());
+    }
+
+    /**
+     * @return array
+     */
+    public function isEnabledDataProvider()
+    {
+        return [
+            [true, true],
+            [false, false]
+        ];
+    }
+
+    /**
+     * @param bool $isRequired Determines whether the 'gender' attribute is required
+     * @param bool $expectedValue The value we expect from Gender::isRequired()
+     * @return void
+     *
+     * @dataProvider isRequiredDataProvider
+     */
+    public function testIsRequired($isRequired, $expectedValue)
+    {
+        $this->_attribute->expects($this->once())->method('isRequired')->will($this->returnValue($isRequired));
+        $this->assertSame($expectedValue, $this->_block->isRequired());
+    }
+
+    /**
+     * @return array
+     */
+    public function isRequiredDataProvider()
+    {
+        return [
+            [true, true],
+            [false, false]
+        ];
+    }
+
+    public function testGetCustomer()
+    {
+        /** Do not include prefix, middlename, and suffix attributes when calling Customer::getName() */
+        $this->_abstractAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
+
+        $config = $this->getMock('Magento\Eav\Model\Config', [], [], '', false);
+        $config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->_abstractAttribute));
+
+        $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+
+        $data = ['firstname' => 'John', 'lastname' => 'Doe'];
+        $customerModel = $objectManager
+            ->getObject('Magento\Customer\Model\Customer', ['config' => $config, 'data' => $data]);
+        $this->_customerSession
+            ->expects($this->once())->method('getCustomer')->will($this->returnValue($customerModel));
+
+        $customer = $this->_block->getCustomer();
+        $this->assertSame($customerModel, $customer);
+
+        $this->assertEquals('John Doe', $customer->getName());
+    }
+
+    public function testGetGenderOptions()
+    {
+        $options = [
+            [
+                'label' => __('Male'),
+                'value' => 'M'
+            ],
+            [
+                'label' => __('Female'),
+                'value' => 'F'
+            ]
+        ];
+
+        $this->_customerResource->expects($this->once())->method('getAttribute')
+            ->with(self::GENDER_ATTRIBUTE_CODE)->will($this->returnValue($this->_abstractAttribute));
+
+        $source = $this->getMockForAbstractClass(
+            'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource', [], '', false
+        );
+        $source->expects($this->once())->method('getAllOptions')->will($this->returnValue($options));
+
+        $this->_abstractAttribute->expects($this->once())->method('getSource')->will($this->returnValue($source));
+
+        $this->assertSame($options, $this->_block->getGenderOptions());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..eb4aba85b6827169db9075c27af672efb16456df
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php
@@ -0,0 +1,329 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Block\Widget;
+
+use Magento\Customer\Service\V1\Dto\Customer;
+
+/**
+ * Test class for \Magento\Customer\Block\Widget\Name.
+ */
+class NameTest extends \PHPUnit_Framework_TestCase
+{
+    /**#@+
+     * Constant values used throughout the various unit tests.
+     */
+    const PREFIX = 'Mr';
+    const MIDDLENAME = 'Middle';
+    const SUFFIX = 'Jr';
+    const KEY_CLASS_NAME = 'class_name';
+    const DEFAULT_CLASS_NAME = 'customer-name';
+    const CUSTOM_CLASS_NAME = 'my-class-name';
+    const CONTAINER_CLASS_NAME_PREFIX = '-prefix';
+    const CONTAINER_CLASS_NAME_MIDDLENAME = '-middlename';
+    const CONTAINER_CLASS_NAME_SUFFIX = '-suffix';
+    const PREFIX_ATTRIBUTE_CODE = 'prefix';
+    const INVALID_ATTRIBUTE_CODE = 'invalid attribute code';
+    const PREFIX_STORE_LABEL = 'Prefix';
+    /**#@-*/
+
+    /** @var  \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+    private $_attributeMetadata;
+
+    /** @var  \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Helper\Data */
+    private $_customerHelper;
+
+    /** @var  \PHPUnit_Framework_MockObject_MockObject | \Magento\Escaper */
+    private $_escaper;
+
+    /** @var  Name */
+    private $_block;
+
+    public function setUp()
+    {
+        $this->_escaper = $this->getMock('Magento\Escaper', array(), array(), '', false);
+        $context = $this->getMock('Magento\View\Element\Template\Context', array(), array(), '', false);
+        $context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->_escaper));
+
+        $addressHelper = $this->getMock('Magento\Customer\Helper\Address', array(), array(), '', false);
+        $metadataService = $this->getMockForAbstractClass(
+            'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', array(), '', false
+        );
+        $this->_customerHelper = $this->getMock('Magento\Customer\Helper\Data', array(), array(), '', false);
+        $this->_attributeMetadata =
+            $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', array(), array(), '', false);
+        $metadataService
+            ->expects($this->any())
+            ->method('getAttributeMetadata')->will($this->returnValue($this->_attributeMetadata));
+
+        $this->_block = new Name($context, $addressHelper, $metadataService, $this->_customerHelper);
+    }
+
+    /**
+     * @see self::_setUpShowAttribute()
+     */
+    public function testShowPrefix()
+    {
+        $this->_setUpShowAttribute(array(Customer::PREFIX => self::PREFIX));
+        $this->assertTrue($this->_block->showPrefix());
+
+        $this->_attributeMetadata->expects($this->at(0))->method('isVisible')->will($this->returnValue(false));
+        $this->assertFalse($this->_block->showPrefix());
+    }
+
+    /**
+     * @see self::_setUpIsAttributeRequired()
+     */
+    public function testIsPrefixRequired()
+    {
+        $this->_setUpIsAttributeRequired();
+        $this->assertTrue($this->_block->isPrefixRequired());
+    }
+
+    public function testShowMiddlename()
+    {
+        $this->_setUpShowAttribute(array(Customer::MIDDLENAME, self::MIDDLENAME));
+        $this->assertTrue($this->_block->showMiddlename());
+    }
+
+    public function testIsMiddlenameRequired()
+    {
+        $this->_setUpIsAttributeRequired();
+        $this->assertTrue($this->_block->isMiddlenameRequired());
+    }
+
+    public function testShowSuffix()
+    {
+        $this->_setUpShowAttribute(array(Customer::SUFFIX => self::SUFFIX));
+        $this->assertTrue($this->_block->showSuffix());
+    }
+
+    public function testIsSuffixRequired()
+    {
+        $this->_setUpIsAttributeRequired();
+        $this->assertTrue($this->_block->isSuffixRequired());
+    }
+
+    public function testGetPrefixOptionsNotEmpty()
+    {
+        /**
+         * Added some padding so that the trim() call on Customer::getPrefix() will remove it. Also added
+         * special characters so that the escapeHtml() method returns a htmlspecialchars translated value.
+         */
+        $customer = new Customer(array(Customer::PREFIX => '  <' . self::PREFIX . '>  '));
+        $this->_block->setObject($customer);
+
+        $prefixOptions = array(
+            'Mrs' => 'Mrs',
+            'Ms' => 'Ms',
+            'Miss' => 'Miss'
+        );
+
+        $prefix = '&lt;' . self::PREFIX . '&gt;';
+        $expectedOptions = $prefixOptions;
+        $expectedOptions[$prefix] = $prefix;
+
+        $this->_customerHelper
+            ->expects($this->once())->method('getNamePrefixOptions')->will($this->returnValue($prefixOptions));
+        $this->_escaper->expects($this->once())->method('escapeHtml')->will($this->returnValue($prefix));
+
+        $this->assertSame($expectedOptions, $this->_block->getPrefixOptions());
+    }
+
+    public function testGetPrefixOptionsEmpty()
+    {
+        $customer = new Customer(array(Customer::PREFIX => self::PREFIX));
+        $this->_block->setObject($customer);
+
+        $this->_customerHelper
+            ->expects($this->once())->method('getNamePrefixOptions')->will($this->returnValue(array()));
+
+        $this->assertEmpty($this->_block->getPrefixOptions());
+    }
+
+    public function testGetSuffixOptionsNotEmpty()
+    {
+        /**
+         * Added padding and special characters to show that trim() works on Customer::getSuffix() and that
+         * a properly htmlspecialchars translated value is returned.
+         */
+        $customer = new Customer(array(Customer::SUFFIX => '  <' . self::SUFFIX . '>  '));
+        $this->_block->setObject($customer);
+
+        $suffixOptions = array(
+            'Sr' => 'Sr'
+        );
+
+        $suffix = '&lt;' . self::SUFFIX . '&gt;';
+        $expectedOptions = $suffixOptions;
+        $expectedOptions[$suffix] = $suffix;
+
+        $this->_customerHelper
+            ->expects($this->once())->method('getNameSuffixOptions')->will($this->returnValue($suffixOptions));
+        $this->_escaper->expects($this->once())->method('escapeHtml')->will($this->returnValue($suffix));
+
+        $this->assertSame($expectedOptions, $this->_block->getSuffixOptions());
+    }
+
+    public function testGetSuffixOptionsEmpty()
+    {
+        $customer = new Customer(array(Customer::SUFFIX => self::SUFFIX));
+        $this->_block->setObject($customer);
+
+        $this->_customerHelper
+            ->expects($this->once())->method('getNameSuffixOptions')->will($this->returnValue(array()));
+
+        $this->assertEmpty($this->_block->getSuffixOptions());
+    }
+
+    public function testGetClassName()
+    {
+        /** Test the default case when the block has no data set for the class name. */
+        $this->assertEquals(self::DEFAULT_CLASS_NAME, $this->_block->getClassName());
+
+        /** Set custom data for the class name and verify that the Name::getClassName() method returns it. */
+        $this->_block->setData(self::KEY_CLASS_NAME, self::CUSTOM_CLASS_NAME);
+        $this->assertEquals(self::CUSTOM_CLASS_NAME, $this->_block->getClassName());
+    }
+
+    /**
+     * @param bool $isPrefixVisible Value returned by Name::showPrefix()
+     * @param bool $isMiddlenameVisible Value returned by Name::showMiddlename()
+     * @param bool $isSuffixVisible Value returned by Name::showSuffix()
+     * @param string $expectedValue The expected value of Name::getContainerClassName()
+     *
+     * @dataProvider getContainerClassNameProvider
+     */
+    public function testGetContainerClassName(
+        $isPrefixVisible, $isMiddlenameVisible, $isSuffixVisible, $expectedValue
+    ) {
+        $this->_attributeMetadata
+            ->expects($this->at(0))->method('isVisible')->will($this->returnValue($isPrefixVisible));
+        $this->_attributeMetadata
+            ->expects($this->at(1))->method('isVisible')->will($this->returnValue($isMiddlenameVisible));
+        $this->_attributeMetadata
+            ->expects($this->at(2))->method('isVisible')->will($this->returnValue($isSuffixVisible));
+
+        $this->assertEquals($expectedValue, $this->_block->getContainerClassName());
+    }
+
+    /**
+     * This data provider provides enough data sets to test both ternary operator code paths for each one
+     * that's used in Name::getContainerClassName().
+     *
+     * @return array
+     */
+    public function getContainerClassNameProvider()
+    {
+        return array(
+            array(false, false, false, self::DEFAULT_CLASS_NAME),
+            array(true,  false, false, self::DEFAULT_CLASS_NAME . self::CONTAINER_CLASS_NAME_PREFIX),
+            array(false, true,  false, self::DEFAULT_CLASS_NAME . self::CONTAINER_CLASS_NAME_MIDDLENAME),
+            array(false, false, true,  self::DEFAULT_CLASS_NAME . self::CONTAINER_CLASS_NAME_SUFFIX),
+            array(true,  true,  true,
+                self::DEFAULT_CLASS_NAME . self::CONTAINER_CLASS_NAME_PREFIX .
+                self::CONTAINER_CLASS_NAME_MIDDLENAME . self::CONTAINER_CLASS_NAME_SUFFIX
+            )
+        );
+    }
+
+    /**
+     * @param string $attributeCode An attribute code
+     * @param string $storeLabel The attribute's store label
+     * @param string $expectedValue The expected value of Name::getStoreLabel()
+     *
+     * @dataProvider getStoreLabelProvider
+     */
+    public function testGetStoreLabel($attributeCode, $storeLabel, $expectedValue)
+    {
+        $this->_attributeMetadata
+            ->expects($this->once())->method('getStoreLabel')->will($this->returnValue($storeLabel));
+        $this->assertEquals($expectedValue, $this->_block->getStoreLabel($attributeCode));
+    }
+
+    /**
+     * This data provider provides two data sets. One tests that an empty string is returned for an invalid
+     * attribute code instead of an exception being thrown. The second tests that the correct store label is
+     * returned for a valid attribute code.
+     *
+     * @return array
+     */
+    public function getStoreLabelProvider()
+    {
+        return array(
+            array(self::INVALID_ATTRIBUTE_CODE, '', ''),
+            array(self::PREFIX_ATTRIBUTE_CODE, self::PREFIX_STORE_LABEL, self::PREFIX_STORE_LABEL)
+        );
+    }
+
+    /**
+     * Helper method for testing all show*() methods.
+     *
+     * @param array $data Customer attribute(s)
+     */
+    private function _setUpShowAttribute(array $data)
+    {
+        $customer = new Customer($data);
+
+        /**
+         * These settings cause the first code path in Name::_getAttribute() to be executed, which
+         * basically just returns the value of parent::_getAttribute().
+         */
+        $this->_block->setForceUseCustomerAttributes(true);
+        $this->_block->setObject($customer);
+
+        /**
+         * The show*() methods return true for the attribute returned by parent::_getAttribute() for the
+         * first call to the method. Subsequent calls may return true or false depending on the returnValue
+         * of the at({0, 1, 2, 3, ...}), etc. calls as set and configured in a particular test.
+         */
+        $this->_attributeMetadata
+            ->expects($this->at(0))->method('isVisible')->will($this->returnValue(true));
+    }
+
+    /**
+     * Helper method for testing all is*Required() methods.
+     */
+    private function _setUpIsAttributeRequired()
+    {
+        /**
+         * These settings cause the first code path in Name::_getAttribute() to be skipped so that the rest of
+         * the code in the other code path(s) can be executed.
+         */
+        $this->_block->setForceUseCustomerAttributes(false);
+        $this->_block->setForceUseCustomerRequiredAttributes(true);
+        $this->_block->setObject(new \StdClass());
+
+        /**
+         * The first call to isRequired() is false so that the second if conditional in the other code path
+         * of Name::_getAttribute() will evaluate to true, which causes the if's code block to be executed.
+         * The second isRequired() call causes the code in the nested if conditional to be executed. Thus,
+         * all code paths in Name::_getAttribute() will be executed. Returning true for the third isRequired()
+         * call causes the is*Required() method of the block to return true for the attribute.
+         */
+        $this->_attributeMetadata->expects($this->at(0))->method('isRequired')->will($this->returnValue(false));
+        $this->_attributeMetadata->expects($this->at(1))->method('isRequired')->will($this->returnValue(true));
+        $this->_attributeMetadata->expects($this->at(2))->method('isRequired')->will($this->returnValue(true));
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..204b5fe808a9e67ac29aaf77ac3cb070acdfa184
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php
@@ -0,0 +1,143 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Block\Widget;
+
+class TaxvatTest extends \PHPUnit_Framework_TestCase
+{
+    /** Constants used in the unit tests */
+    const CUSTOMER_ENTITY_TYPE = 'customer';
+    const TAXVAT_ATTRIBUTE_CODE = 'taxvat';
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
+     */
+    private $_attributeMetadata;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+    private $_attribute;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */
+    private $_customerSession;
+
+    /** @var Taxvat */
+    private $_block;
+
+    public function setUp()
+    {
+        $this->_attribute =
+            $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false);
+
+        $this->_attributeMetadata =
+            $this->getMockForAbstractClass(
+                'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false
+            );
+        $this->_attributeMetadata->expects($this->any())->method('getAttributeMetadata')
+            ->with(self::CUSTOMER_ENTITY_TYPE, self::TAXVAT_ATTRIBUTE_CODE)
+            ->will($this->returnValue($this->_attribute));
+
+        $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false);
+
+        $this->_block = new Taxvat(
+            $this->getMock('Magento\View\Element\Template\Context', [], [], '', false),
+            $this->getMock('Magento\Customer\Helper\Address', [], [], '', false),
+            $this->_attributeMetadata,
+            $this->_customerSession
+        );
+    }
+
+    /**
+     * @param bool $isVisible Determines whether the 'taxvat' attribute is visible or enabled
+     * @param bool $expectedValue The value we expect from Taxvat::isEnabled()
+     * @return void
+     *
+     * @dataProvider isEnabledDataProvider
+     */
+    public function testIsEnabled($isVisible, $expectedValue)
+    {
+        $this->_attribute->expects($this->once())->method('isVisible')->will($this->returnValue($isVisible));
+        $this->assertSame($expectedValue, $this->_block->isEnabled());
+    }
+
+    /**
+     * @return array
+     */
+    public function isEnabledDataProvider()
+    {
+        return [
+            [true, true],
+            [false, false]
+        ];
+    }
+
+    /**
+     * @param bool $isRequired Determines whether the 'taxvat' attribute is required
+     * @param bool $expectedValue The value we expect from Taxvat::isRequired()
+     * @return void
+     *
+     * @dataProvider isRequiredDataProvider
+     */
+    public function testIsRequired($isRequired, $expectedValue)
+    {
+        $this->_attribute->expects($this->once())->method('isRequired')->will($this->returnValue($isRequired));
+        $this->assertSame($expectedValue, $this->_block->isRequired());
+    }
+
+    /**
+     * @return array
+     */
+    public function isRequiredDataProvider()
+    {
+        return [
+            [true, true],
+            [false, false]
+        ];
+    }
+
+    public function testGetCustomer()
+    {
+        $abstractAttribute =
+            $this->getMockForAbstractClass(
+                'Magento\Eav\Model\Entity\Attribute\AbstractAttribute',
+                [], '', false, true, true, ['__wakeup']
+            );
+        /** Do not include prefix, middlename, and suffix attributes when calling Customer::getName() */
+        $abstractAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
+
+        $config = $this->getMock('Magento\Eav\Model\Config', [], [], '', false);
+        $config->expects($this->any())->method('getAttribute')->will($this->returnValue($abstractAttribute));
+
+        $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+
+        $data = ['firstname' => 'John', 'lastname' => 'Doe'];
+        $customerModel = $objectManager
+            ->getObject('Magento\Customer\Model\Customer', ['config' => $config, 'data' => $data]);
+        $this->_customerSession
+            ->expects($this->once())->method('getCustomer')->will($this->returnValue($customerModel));
+
+        $customer = $this->_block->getCustomer();
+        $this->assertSame($customerModel, $customer);
+
+        $this->assertEquals('John Doe', $customer->getName());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php
index 542059b9ce3f31ca851d6b3431ff36098e9aeeb6..a72fb8f383d4bdc41b91ec5fe9c5d6d06100a50f 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/ConverterTest.php
@@ -110,40 +110,11 @@ class ConverterTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($expectedCustomerDto, $customerDto);
     }
 
-    /**
-     * @dataProvider createCustomerFromModelBadParamDataProvider
-     * @expectedException \InvalidArgumentException
-     * @expectedExceptionMessage customer model is invalid
-     */
-    public function testCreateCustomerFromModelBadParam($param)
-    {
-        $customerBuilder = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\CustomerBuilder')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $customerFactory = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $converter = new Converter($customerBuilder, $customerFactory);
-        $converter->createCustomerFromModel($param);
-    }
-
-    public function createCustomerFromModelBadParamDataProvider()
-    {
-        return [
-            [null],
-            ['a string'],
-            [5],
-            [new \Magento\Object()],
-        ];
-    }
-
     /**
      * @param \PHPUnit_Framework_MockObject_MockObject $mock
      * @param array $valueMap
      */
-    private function _mockReturnValue($mock, $valueMap)
+    private function _mockReturnValue(\PHPUnit_Framework_MockObject_MockObject $mock, $valueMap)
     {
         foreach ($valueMap as $method => $value) {
             $mock->expects($this->any())
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php
index be96f85e5dad3246f7286963cc4e80dcb82b7209..2434dc671d5d28123307c4ea77fba83b35bb1529 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php
@@ -84,7 +84,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase
 
         $this->_config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->_attribute));
 
-        $this->_attribute->expects($this->any())->method('getIsVisible')->will($this->returnValue(false));
+        $this->_attribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
 
         $this->_storeManager->expects($this->once())
             ->method('getWebsite')
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ElementFactoryTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ElementFactoryTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..e7545e52fce05270af21c9f6d2fbd1858549df73
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ElementFactoryTest.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata;
+
+class ElementFactoryTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\ObjectManager | \PHPUnit_Framework_MockObject_MockObject */
+    private $_objectManager;
+
+    /** @var \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata | \PHPUnit_Framework_MockObject_MockObject */
+    private $_attributeMetadata;
+
+    /** @var string */
+    private $_entityTypeCode = 'customer_address';
+
+    /** @var ElementFactory */
+    private $_elementFactory;
+
+    public function setUp()
+    {
+        $this->_objectManager = $this->getMock('Magento\ObjectManager', [], [], '', false);
+        $this->_attributeMetadata =
+            $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false);
+        $this->_elementFactory = new ElementFactory($this->_objectManager, new \Magento\Stdlib\String());
+    }
+
+    /** TODO fix when Validation is implemented MAGETWO-17341 */
+    public function testAttributePostcodeDataModelClass()
+    {
+        $this->_attributeMetadata
+            ->expects($this->once())
+            ->method('getDataModel')
+            ->will($this->returnValue('Magento\Customer\Model\Attribute\Data\Postcode'));
+
+        $dataModel = $this->getMock('Magento\Customer\Model\Metadata\Form\Text', [], [], '', false);
+        $this->_objectManager
+            ->expects($this->once())->method('create')->will($this->returnValue($dataModel));
+
+        $actual = $this->_elementFactory->create($this->_attributeMetadata, '95131', $this->_entityTypeCode);
+        $this->assertSame($dataModel, $actual);
+    }
+
+    public function testAttributeEmptyDataModelClass()
+    {
+        $this->_attributeMetadata
+            ->expects($this->once())->method('getDataModel')->will($this->returnValue(''));
+        $this->_attributeMetadata
+            ->expects($this->once())->method('getFrontendInput')->will($this->returnValue('text'));
+
+        $dataModel = $this->getMock('Magento\Customer\Model\Metadata\Form\Text', [], [], '', false);
+        $params = [
+            'entityTypeCode' => $this->_entityTypeCode,
+            'value' => 'Some Text',
+            'isAjax' => false,
+            'attribute' => $this->_attributeMetadata
+        ];
+        $this->_objectManager
+            ->expects($this->once())
+            ->method('create')
+            ->with('Magento\Customer\Model\Metadata\Form\Text', $params)
+            ->will($this->returnValue($dataModel));
+
+        $actual = $this->_elementFactory->create($this->_attributeMetadata, 'Some Text', $this->_entityTypeCode);
+        $this->assertSame($dataModel, $actual);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..fafcfe5391ad345a418c1082cc454ba6566779ba
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php
@@ -0,0 +1,360 @@
+<?php
+/**
+ * test Magento\Customer\Model\Metadata\Form\AbstractData
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata\Form;
+
+class AbstractDataTest extends \PHPUnit_Framework_TestCase
+{
+    const MODEL = 'MODEL';
+
+    /** @var \Magento\Customer\Model\Metadata\Form\ExtendsAbstractData */
+    protected $_model;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\LocaleInterface */
+    protected $_localeMock;
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Logger */
+    protected $_loggerMock;
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+    protected $_attributeMock;
+
+    /** @var string */
+    protected $_value;
+    /** @var string */
+    protected $_entityTypeCode;
+    /** @var string */
+    protected $_isAjax;
+
+    protected function setUp()
+    {
+        $this->_localeMock = $this->getMockBuilder('Magento\Core\Model\LocaleInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_loggerMock = $this->getMockBuilder('Magento\Logger')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_attributeMock = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_value = 'VALUE';
+        $this->_entityTypeCode = 'ENTITY_TYPE_CODE';
+        $this->_isAjax = false;
+
+        $this->_model = new ExtendsAbstractData(
+            $this->_localeMock,
+            $this->_loggerMock,
+            $this->_attributeMock,
+            $this->_value,
+            $this->_entityTypeCode,
+            $this->_isAjax
+        );
+    }
+
+    public function testGetAttribute()
+    {
+        $this->assertSame($this->_attributeMock, $this->_model->getAttribute());
+    }
+
+    /**
+     * @expectedException \Magento\Core\Exception
+     * @expectedExceptionMessage Attribute object is undefined
+     */
+    public function testGetAttributeException()
+    {
+        $this->_model->setAttribute(false);
+        $this->_model->getAttribute();
+    }
+
+    public function testSetRequestScope()
+    {
+        $this->assertSame($this->_model, $this->_model->setRequestScope('REQUEST_SCOPE'));
+        $this->assertSame('REQUEST_SCOPE', $this->_model->getRequestScope());
+    }
+
+    /**
+     * @param bool $bool
+     * @dataProvider trueFalseDataProvider
+     */
+    public function testSetRequestScopeOnly($bool)
+    {
+        $this->assertSame($this->_model, $this->_model->setRequestScopeOnly($bool));
+        $this->assertSame($bool, $this->_model->isRequestScopeOnly());
+    }
+
+    public function trueFalseDataProvider()
+    {
+        return [[true], [false]];
+    }
+
+    public function testGetSetExtractedData()
+    {
+        $data = ['KEY' => 'VALUE'];
+        $this->assertSame($this->_model, $this->_model->setExtractedData($data));
+        $this->assertSame($data, $this->_model->getExtractedData());
+        $this->assertSame('VALUE', $this->_model->getExtractedData('KEY'));
+        $this->assertSame(null, $this->_model->getExtractedData('BAD_KEY'));
+    }
+
+    /**
+     * @param bool|string $input
+     * @param bool|string $output
+     * @param bool|string $filter
+     * @dataProvider applyInputFilterProvider
+     */
+    public function testApplyInputFilter($input, $output, $filter)
+    {
+        if ($input) {
+            $this->_attributeMock
+                ->expects($this->once())
+                ->method('getInputFilter')
+                ->will($this->returnValue($filter));
+        }
+        $this->assertEquals($output, $this->_model->applyInputFilter($input));
+    }
+
+    public function applyInputFilterProvider()
+    {
+        return [
+            [false, false, false],
+            [true, true, false],
+            ['string', 'string', false],
+            ['2014/01/23', '2014-01-23', 'date'],
+            ['<tag>internal text</tag>', 'internal text', 'striptags']
+        ];
+    }
+
+    /**
+     * @param null|bool|string $format
+     * @param string           $output
+     * @dataProvider dateFilterFormatProvider
+     */
+    public function testDateFilterFormat($format, $output)
+    {
+        // Since model is instantiated in setup, if I use it directly in the dataProvider, it will be null.
+        // I use this value to indicate the model is to be used for output
+        if (self::MODEL == $output) {
+            $output = $this->_model;
+        }
+        if (is_null($format)) {
+            $this->_localeMock
+                ->expects($this->once())
+                ->method('getDateFormat')
+                ->with($this->equalTo(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT))
+                ->will($this->returnValue($output));
+        }
+        $actual = $this->_model->dateFilterFormat($format);
+        $this->assertEquals($output, $actual);
+    }
+
+    public function dateFilterFormatProvider()
+    {
+        return [
+            [null, 'Whatever I put'],
+            [false, self::MODEL],
+            ['something else', self::MODEL]
+        ];
+    }
+
+    /**
+     * @param bool|string $input
+     * @param bool|string $output
+     * @param bool|string $filter
+     * @dataProvider applyOutputFilterDataProvider
+     */
+    public function testApplyOutputFilter($input, $output, $filter)
+    {
+        if ($input) {
+            $this->_attributeMock
+                ->expects($this->once())
+                ->method('getInputFilter')
+                ->will($this->returnValue($filter));
+        }
+        $this->assertEquals($output, $this->_model->applyOutputFilter($input));
+    }
+
+    /**
+     * This is similar to applyInputFilterProvider except for striptags
+     *
+     * @return array
+     */
+    public function applyOutputFilterDataProvider()
+    {
+        return [
+            [false, false, false],
+            [true, true, false],
+            ['string', 'string', false],
+            ['2014/01/23', '2014-01-23', 'date'],
+            ['internal text', 'internal text', 'striptags']
+        ];
+    }
+
+    /**
+     * @param null|string $value
+     * @param null|string $label
+     * @param null|string $inputValidation
+     * @param bool|array  $expectedOutput
+     * @dataProvider validateInputRuleDataProvider
+     */
+    public function testValidateInputRule($value, $label, $inputValidation, $expectedOutput)
+    {
+        $this->_attributeMock
+            ->expects($this->any())
+            ->method('getStoreLabel')
+            ->will($this->returnValue($label));
+        $this->_attributeMock
+            ->expects($this->any())
+            ->method('getValidationRules')
+            ->will($this->returnValue(['input_validation' => $inputValidation]));
+
+        $this->assertEquals($expectedOutput, $this->_model->validateInputRule($value));
+    }
+
+    public function validateInputRuleDataProvider()
+    {
+        return [
+            [null, null, null, true],
+            ['value', null, null, true],
+            [
+                '!@#$',
+                'mylabel',
+                'alphanumeric',
+                [\Zend_Validate_Alnum::NOT_ALNUM => '"mylabel" contains non-alphabetic or non-numeric characters.']
+            ],
+            [
+                '!@#$',
+                'mylabel',
+                'numeric',
+                [\Zend_Validate_Digits::NOT_DIGITS => '"mylabel" contains non-numeric characters.']
+            ],
+            [
+                '1234',
+                'mylabel',
+                'alpha',
+                [\Zend_Validate_Alpha::NOT_ALPHA => '"mylabel" contains non-alphabetic characters.']
+            ],
+            [
+                '!@#$',
+                'mylabel',
+                'email',
+                [
+                    // @codingStandardsIgnoreStart
+                    \Zend_Validate_EmailAddress::INVALID_HOSTNAME => '"mylabel" is not a valid hostname.',
+                    \Zend_Validate_Hostname::INVALID_HOSTNAME     => "'#\$' does not match the expected structure for a DNS hostname",
+                    \Zend_Validate_Hostname::INVALID_LOCAL_NAME   => "'#\$' does not appear to be a valid local network name."
+                    // @codingStandardsIgnoreEnd
+                ]
+            ],
+            [
+                '1234',
+                'mylabel',
+                'url',
+                ['"mylabel" is not a valid URL.']
+            ],
+            [
+                'http://.com',
+                'mylabel',
+                'url',
+                ['"mylabel" is not a valid URL.']
+            ],
+            [
+                '1234',
+                'mylabel',
+                'date',
+                [\Zend_Validate_Date::INVALID_DATE => '"mylabel" is not a valid date.']
+            ],
+        ];
+    }
+
+    /**
+     * @param bool $ajaxRequest
+     * @dataProvider trueFalseDataProvider
+     */
+    public function testGetIsAjaxRequest($ajaxRequest)
+    {
+        $this->_model = new ExtendsAbstractData(
+            $this->_localeMock,
+            $this->_loggerMock,
+            $this->_attributeMock,
+            $this->_value,
+            $this->_entityTypeCode,
+            $ajaxRequest
+        );
+        $this->assertSame($ajaxRequest, $this->_model->getIsAjaxRequest());
+    }
+
+    /**
+     * @param \Magento\App\RequestInterface $request
+     * @param string                        $attributeCode
+     * @param bool|string                   $requestScope
+     * @param bool                          $requestScopeOnly
+     * @param string                        $expectedValue
+     * @dataProvider getRequestValueDataProvider
+     */
+    public function testGetRequestValue($request, $attributeCode, $requestScope, $requestScopeOnly, $expectedValue)
+    {
+        $this->_attributeMock
+            ->expects($this->once())
+            ->method('getAttributeCode')
+            ->will($this->returnValue($attributeCode));
+        $this->_model->setRequestScope($requestScope);
+        $this->_model->setRequestScopeOnly($requestScopeOnly);
+        $this->assertEquals($expectedValue, $this->_model->getRequestValue($request));
+    }
+
+    public function getRequestValueDataProvider()
+    {
+        $expectedValue = 'EXPECTED_VALUE';
+        $requestMockOne = $this->getMockBuilder('\Magento\App\RequestInterface')
+            ->getMock();
+        $requestMockOne->expects($this->any())
+            ->method('getParam')
+            ->with('ATTR_CODE')
+            ->will($this->returnValue($expectedValue));
+
+        $requestMockTwo = $this->getMockBuilder('\Magento\App\RequestInterface')
+            ->getMock();
+        $requestMockTwo->expects($this->at(0))
+            ->method('getParam')
+            ->with('REQUEST_SCOPE')
+            ->will($this->returnValue(['ATTR_CODE' => $expectedValue]));
+        $requestMockTwo->expects($this->at(1))
+            ->method('getParam')
+            ->with('REQUEST_SCOPE')
+            ->will($this->returnValue([]));
+
+        $requestMockThree = $this->getMockBuilder('\Magento\App\Request\Http')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $requestMockThree->expects($this->once())
+            ->method('getParams')
+            ->will($this->returnValue(['REQUEST' => ['SCOPE' => ['ATTR_CODE' => $expectedValue]]]));
+        return [
+            [$requestMockOne, 'ATTR_CODE', false, false, $expectedValue],
+            [$requestMockTwo, 'ATTR_CODE', 'REQUEST_SCOPE', false, $expectedValue],
+            [$requestMockTwo, 'ATTR_CODE', 'REQUEST_SCOPE', false, false],
+            [$requestMockThree, 'ATTR_CODE', 'REQUEST/SCOPE', false, $expectedValue],
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php
new file mode 100644
index 0000000000000000000000000000000000000000..81a5c2ac5c113b5cd3bb140c2776e8ac0d90dc92
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata\Form;
+
+/** Test Magento\Customer\Model\Metadata\Form\Multiline */
+abstract class AbstractFormTestCase extends \PHPUnit_Framework_TestCase
+{
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\LocaleInterface */
+    protected $localeMock;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Logger */
+    protected $loggerMock;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+    protected $attributeMetadataMock;
+
+    protected function setUp()
+    {
+        $this->localeMock = $this->getMockBuilder('Magento\Core\Model\LocaleInterface')->getMock();
+        $this->loggerMock = $this->getMockBuilder('Magento\Logger')->disableOriginalConstructor()->getMock();
+        $this->attributeMetadataMock = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+    }
+}
diff --git a/app/code/Magento/Sales/Model/Observer/Backend/BillingAgreement.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php
similarity index 51%
rename from app/code/Magento/Sales/Model/Observer/Backend/BillingAgreement.php
rename to dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php
index 3cc28f563f9b8c5850834ca22e5d35cc86f8c8b6..c705e81486671dd407b547fab6b323c5c5253b13 100644
--- a/app/code/Magento/Sales/Model/Observer/Backend/BillingAgreement.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php
@@ -1,5 +1,7 @@
 <?php
 /**
+ * test Magento\Customer\Model\Metadata\Form\Boolean
+ *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -21,36 +23,32 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Model\Observer\Backend;
 
-class BillingAgreement
-{
-    /**
-     * @var \Magento\AuthorizationInterface
-     */
-    protected $_authorization;
+namespace Magento\Customer\Model\Metadata\Form;
 
+class BooleanTest extends AbstractFormTestCase
+{
     /**
-     * @param \Magento\AuthorizationInterface $authorization
+     * @param mixed $value to assign to boolean
+     * @param mixed $expected text output
+     * @dataProvider getOptionTextDataProvider
      */
-    public function __construct(\Magento\AuthorizationInterface $authorization)
+    public function testGetOptionText($value, $expected)
     {
-        $this->_authorization = $authorization;
+        // calling outputValue() will cause the protected method getOptionText() to be called
+        $boolean = new Boolean($this->localeMock, $this->loggerMock, $this->attributeMetadataMock, $value, 0);
+        $this->assertSame($expected, $boolean->outputValue());
     }
 
-    /**
-     * Block admin ability to use customer billing agreements
-     *
-     * @param \Magento\Event\Observer $observer
-     */
-    public function dispatch($observer)
+    public function getOptionTextDataProvider()
     {
-        $event = $observer->getEvent();
-        $methodInstance = $event->getMethodInstance();
-        if ($methodInstance instanceof \Magento\Sales\Model\Payment\Method\Billing\AbstractAgreement
-            && false == $this->_authorization->isAllowed('Magento_Sales::use')
-        ) {
-            $event->getResult()->isAvailable = false;
-        }
+        return [
+            '0' => ['0', 'No'],
+            '1' => ['1', 'Yes'],
+            'int 5' => [5, ''],
+            'Null' => [null, ''],
+            'Invalid' => ['Invalid', ''],
+            'Empty string' => ['', ''],
+        ];
     }
 }
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..d0a5fb4cdce243a30cb0b135849cd31b7197370a
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php
@@ -0,0 +1,163 @@
+<?php
+/**
+ * test Magento\Customer\Model\Metadata\Form\Date
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata\Form;
+
+class DateTest extends AbstractFormTestCase
+{
+    /** @var \Magento\Customer\Model\Metadata\Form\Date */
+    protected $date;
+
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getAttributeCode')
+            ->will($this->returnValue('date'));
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getStoreLabel')
+            ->will($this->returnValue('Space Date'));
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getInputFilter')
+            ->will($this->returnValue('date'));
+        $this->date = new Date($this->localeMock, $this->loggerMock, $this->attributeMetadataMock, null, 0);
+    }
+
+    public function testExtractValue()
+    {
+        $requestMock = $this->getMockBuilder('Magento\App\RequestInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $requestMock->expects($this->once())->method('getParam')->will($this->returnValue('1999-1-2'));
+
+        // yyyy-MM-dd
+        $actual = $this->date->extractValue($requestMock);
+        $this->assertEquals('1999-01-02', $actual);
+    }
+
+    /**
+     * @param array|string $value Value to validate
+     * @param array $validation Array of more validation metadata
+     * @param bool $required Whether field is required
+     * @param array|bool $expected Expected output
+     *
+     * @dataProvider validateValueDataProvider
+     */
+    public function testValidateValue($value, $validation, $required, $expected)
+    {
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getValidationRules')
+            ->will($this->returnValue(array_merge(['input_validation' => 'date'], $validation)));
+
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('isRequired')
+            ->will($this->returnValue($required));
+
+        $actual = $this->date->validateValue($value);
+        $this->assertEquals($expected, $actual);
+    }
+
+    public function validateValueDataProvider()
+    {
+        return [
+            'false value, load original' => [false, [], false, true],
+            'Empty value, not required' => ['', [], false, true],
+            'Empty value, required' => ['', [], true, ['"Space Date" is a required value.']],
+            'Valid date, min set' => ['1961-5-5', ['date_range_min' => strtotime('4/12/1961')], false, true],
+            'Below min, only min set' => [
+                '1957-10-4',
+                ['date_range_min' => strtotime('1961/04/12')],
+                false,
+                ['Please enter a valid date equal to or greater than 12/04/1961 at Space Date.'],
+            ],
+            'Below min, min and max set' => [
+                '1957-10-4',
+                ['date_range_min' => strtotime('1961/04/12'), 'date_range_max' => strtotime('12/1/2013')],
+                false,
+                ['Please enter a valid date between 12/04/1961 and 01/12/2013 at Space Date.'],
+            ],
+            'Above max, only max set' => [
+                '2014-1-30',
+                ['date_range_max' => strtotime('12/1/2013')],
+                false,
+                ['Please enter a valid date less than or equal to 01/12/2013 at Space Date.'],
+            ],
+            'Valid, min and max' => [
+                '1961-5-5',
+                [ 'date_range_min' => strtotime('4/12/1961'), 'date_range_max' => strtotime('12/1/2013')],
+                false,
+                true,
+            ],
+            'Invalid date' => [
+                'abc',
+                [],
+                false,
+                ['dateFalseFormat' => '"Space Date" does not fit the entered date format.']
+            ],
+        ];
+    }
+
+    /**
+     * @param array|string $value value to pass to compactValue()
+     * @param array|string|bool $expected expected output
+     *
+     * @dataProvider compactAndRestoreValueDataProvider
+     */
+    public function testCompactValue($value, $expected)
+    {
+        $this->assertSame($expected, $this->date->compactValue($value));
+    }
+
+    public function compactAndRestoreValueDataProvider()
+    {
+        return [
+            [1, 1],
+            [false, false],
+            ['', null],
+            ['test', 'test'],
+            [['element1', 'element2'], ['element1', 'element2']],
+        ];
+    }
+
+    /**
+     * @param array|string $value Value to pass to restoreValue()
+     * @param array|string|bool $expected Expected output
+     *
+     * @dataProvider compactAndRestoreValueDataProvider
+     */
+    public function testRestoreValue($value, $expected)
+    {
+        $this->assertSame($expected, $this->date->restoreValue($value));
+    }
+
+    public function testOutputValue()
+    {
+        $this->assertEquals(null, $this->date->outputValue());
+        $date = new Date($this->localeMock, $this->loggerMock, $this->attributeMetadataMock, '2012/12/31', 0);
+        $this->assertEquals('2012-12-31', $date->outputValue());
+
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ExtendsAbstractData.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ExtendsAbstractData.php
new file mode 100644
index 0000000000000000000000000000000000000000..60ddc4619522718b6d682ede4e9ea144761833a2
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ExtendsAbstractData.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata\Form;
+
+/**
+ * Class ExtendsAbstractData
+ *
+ * This test exists to aid with direct testing of the AbstractData class
+ */
+class ExtendsAbstractData extends AbstractData
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function extractValue(\Magento\App\RequestInterface $request)
+    {
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function validateValue($value)
+    {
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function compactValue($value)
+    {
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function restoreValue($value)
+    {
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
+    {
+    }
+
+    /**
+     * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute
+     */
+    public function setAttribute($attribute)
+    {
+        $this->_attribute = $attribute;
+    }
+
+    /**
+     * @return string
+     */
+    public function getRequestScope()
+    {
+        return $this->_requestScope;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isRequestScopeOnly()
+    {
+        return $this->_requestScopeOnly;
+    }
+
+    /**
+     * @param string $value
+     * @return bool|string
+     */
+    public function applyInputFilter($value)
+    {
+        return $this->_applyInputFilter($value);
+    }
+
+    /**
+     * @param string|null|bool $format
+     * @return AbstractData|string
+     */
+    public function dateFilterFormat($format)
+    {
+        return $this->_dateFilterFormat($format);
+    }
+
+    /**
+     * @param string $value
+     * @return string
+     */
+    public function applyOutputFilter($value)
+    {
+        return $this->_applyOutputFilter($value);
+    }
+
+    /**
+     * @param string $value
+     * @return bool|string
+     */
+    public function validateInputRule($value)
+    {
+        return $this->_validateInputRule($value);
+    }
+
+    /**
+     * @param \Magento\App\RequestInterface $request
+     * @return mixed
+     */
+    public function getRequestValue(\Magento\App\RequestInterface $request)
+    {
+        return $this->_getRequestValue($request);
+    }
+}
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..316cef0d450d5bd95aae2c0ebd13b53d43824fe1
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php
@@ -0,0 +1,342 @@
+<?php
+/**
+ * Magento\Customer\Model\Metadata\Form\File
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata\Form;
+
+use Magento\Customer\Model\Metadata\ElementFactory;
+
+class FileTest extends AbstractFormTestCase
+{
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Helper\Data */
+    protected $coreDataMock;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\File\Validator\NotProtectedExtension */
+    protected $fileValidatorMock;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\App\Filesystem */
+    protected $fileSystemMock;
+
+    /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\App\RequestInterface */
+    protected $requestMock;
+
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->coreDataMock = $this->getMockBuilder('Magento\Core\Helper\Data')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->fileValidatorMock = $this->getMockBuilder('Magento\Core\Model\File\Validator\NotProtectedExtension')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->fileSystemMock = $this->getMockBuilder('Magento\App\Filesystem')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->requestMock = $this->getMockBuilder('Magento\App\RequestInterface')
+            ->disableOriginalConstructor()
+            ->setMethods(
+                ['getParam', 'getParams', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName']
+            )
+            ->getMock();
+    }
+
+    /**
+     * @param array|bool $expected
+     * @param string $attributeCode
+     * @param bool $isAjax
+     * @param string $delete
+     * @dataProvider extractValueNoRequestScopeDataProvider
+     */
+    public function testExtractValueNoRequestScope($expected, $attributeCode = '', $isAjax = false, $delete = '')
+    {
+        $value = 'value';
+        $fileForm = $this->getClass($value, $isAjax);
+
+        $this->requestMock->expects($this->any())
+            ->method('getParam')
+            ->will($this->returnValue(['delete' => $delete]));
+
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getAttributeCode')
+            ->will($this->returnValue($attributeCode));
+        if (!empty($attributeCode)) {
+            $_FILES[$attributeCode] = ['attributeCodeValue'];
+        }
+        $this->assertEquals($expected, $fileForm->extractValue($this->requestMock));
+        if (!empty($attributeCode)) {
+            unset($_FILES[$attributeCode]);
+        }
+    }
+
+    public function extractValueNoRequestScopeDataProvider()
+    {
+        return [
+            'ajax' => [false, '', true],
+            'no_file' => [[],],
+            'delete' => [['delete' => true], '', false, true],
+            'file_delete' => [
+                ['attributeCodeValue', 'delete' => true],
+                'attributeCode',
+                false,
+                true
+            ],
+            'file_!delete' => [
+                ['attributeCodeValue'],
+                'attributeCode',
+                false,
+                false
+            ],
+        ];
+    }
+
+    /**
+     * @param array $expected
+     * @param string $requestScope
+     * @param $mainScope
+     * @dataProvider extractValueWithRequestScopeDataProvider
+     */
+    public function testExtractValueWithRequestScope($expected, $requestScope, $mainScope = false)
+    {
+        $value = 'value';
+        $fileForm = $this->getClass($value, false);
+
+        $this->requestMock->expects($this->any())
+            ->method('getParam')
+            ->will($this->returnValue(['delete' => true]));
+        $this->requestMock->expects($this->any())
+            ->method('getParams')
+            ->will($this->returnValue(['delete' => true]));
+
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getAttributeCode')
+            ->will($this->returnValue('attributeCode'));
+
+        $fileForm->setRequestScope($requestScope);
+
+        if ($mainScope) {
+            $_FILES['mainScope'] = $mainScope;
+        }
+        $this->assertEquals($expected, $fileForm->extractValue($this->requestMock));
+        if ($mainScope) {
+            unset($_FILES['mainScope']);
+        }
+    }
+
+    public function extractValueWithRequestScopeDataProvider()
+    {
+        return [
+            'requestScope' => [[], 'requestScope'],
+            'mainScope' => [
+                ['fileKey' => 'attributeValue'],
+                'mainScope',
+                ['fileKey' => ['attributeCode' => 'attributeValue']],
+            ],
+            'mainScope/scopeName' => [
+                ['fileKey' => 'attributeValue'],
+                'mainScope/scopeName',
+                ['fileKey' => ['scopeName' => ['attributeCode' => 'attributeValue']]],
+            ],
+        ];
+    }
+
+    /**
+     * @param array|bool $expected
+     * @param array $value
+     * @param bool $isAjax
+     * @param bool $isRequired
+     * @dataProvider validateValueNotToUploadDataProvider
+     */
+    public function testValidateValueNotToUpload($expected, $value, $isAjax = false, $isRequired = true)
+    {
+        $fileForm = $this->getClass($value, $isAjax);
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('isRequired')
+            ->will($this->returnValue($isRequired));
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getStoreLabel')
+            ->will($this->returnValue('attributeLabel'));
+
+        $this->assertEquals($expected, $fileForm->validateValue($value));
+    }
+
+    public function validateValueNotToUploadDataProvider()
+    {
+        return [
+            'emptyValue' => [true, [], true],
+            'someValue' => [true, ['some value']],
+            'delete_someValue' => [true, ['delete' => true, 'some value'], false, false],
+            'null' => [['"attributeLabel" is a required value.'], null]
+        ];
+    }
+
+    /**
+     * @param array $expected
+     * @param array $value
+     * @param array $parameters
+     * @dataProvider validateValueToUploadDataProvider
+     */
+    public function testValidateValueToUpload($expected, $value, $parameters = [])
+    {
+        $parameters = array_merge(['uploaded' => true, 'valid' => true], $parameters);
+        $fileForm = $this->getClass($value, false);
+        $fileForm->expects($this->any())
+            ->method('_isUploadedFile')
+            ->will($this->returnValue($parameters['uploaded']));
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('isRequired')
+            ->will($this->returnValue(false));
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('getStoreLabel')
+            ->will($this->returnValue('File Input Field Label'));
+
+        $this->fileValidatorMock->expects($this->any())
+            ->method('getMessages')
+            ->will($this->returnValue(['Validation error message.']));
+        $this->fileValidatorMock->expects($this->any())
+            ->method('isValid')
+            ->will($this->returnValue($parameters['valid']));
+        $this->assertEquals($expected, $fileForm->validateValue($value));
+    }
+
+    public function validateValueToUploadDataProvider()
+    {
+        return [
+            'notValid' => [
+                ['Validation error message.'],
+                ['tmp_name' => 'tempName_0001.bin', 'name' => 'realFileName.bin'],
+                ['valid' => false],
+            ],
+            'notUploaded' => [
+                ['"realFileName.bin" is not a valid file.'],
+                ['tmp_name' => 'tempName_0001.bin', 'name' => 'realFileName.bin'],
+                ['uploaded' => false],
+            ],
+            'isValid' => [
+                true,
+                ['tmp_name' => 'tempName_0001.txt', 'name' => 'realFileName.txt'],
+            ],
+        ];
+    }
+
+    public function testCompactValueIsAjax()
+    {
+        $fileForm = $this->getClass('value', true);
+        $this->assertSame($fileForm, $fileForm->compactValue('aValue'));
+    }
+
+    /**
+     * @param string $expected
+     * @param array $value
+     * @dataProvider compactValueDataProvider
+     */
+    public function testCompactValue($expected, $value)
+    {
+        $fileForm = $this->getClass('value', false);
+        $this->attributeMetadataMock->expects($this->any())
+            ->method('isRequired')
+            ->will($this->returnValue(false));
+        $this->assertSame($expected, $fileForm->compactValue($value));
+    }
+
+    public function compactValueDataProvider()
+    {
+        return [
+            'notDelete' => ['value', []],
+            'delete' => ['', ['delete' => true]],
+        ];
+    }
+
+    public function testRestoreValue()
+    {
+        $value = 'value';
+        $fileForm = $this->getClass($value, false);
+        $this->assertEquals($value, $fileForm->restoreValue('aValue'));
+    }
+
+    /**
+     * @param string $format
+     * @dataProvider outputValueDataProvider
+     */
+    public function testOutputValueNonJson($format)
+    {
+        $fileForm = $this->getClass('value', false);
+        $this->assertSame('', $fileForm->outputValue($format));
+    }
+
+    public function outputValueDataProvider()
+    {
+        return [
+            ElementFactory::OUTPUT_FORMAT_TEXT      => [ElementFactory::OUTPUT_FORMAT_TEXT],
+            ElementFactory::OUTPUT_FORMAT_ARRAY     => [ElementFactory::OUTPUT_FORMAT_ARRAY],
+            ElementFactory::OUTPUT_FORMAT_HTML      => [ElementFactory::OUTPUT_FORMAT_HTML],
+            ElementFactory::OUTPUT_FORMAT_ONELINE   => [ElementFactory::OUTPUT_FORMAT_ONELINE],
+            ElementFactory::OUTPUT_FORMAT_PDF       => [ElementFactory::OUTPUT_FORMAT_PDF],
+        ];
+    }
+
+    public function testOutputValueJson()
+    {
+        $value = 'value';
+        $urlKey = 'url_key';
+        $fileForm = $this->getClass($value, false);
+        $this->coreDataMock->expects($this->once())
+            ->method('urlEncode')
+            ->with($this->equalTo($value))
+            ->will($this->returnValue($urlKey));
+        $expected = [
+            'value' => $value,
+            'url_key' => $urlKey,
+        ];
+        $this->assertSame(
+            $expected,
+            $fileForm->outputValue(ElementFactory::OUTPUT_FORMAT_JSON)
+        );
+    }
+
+    /**
+     * Helper for creating the unit under test.
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     * @param bool $isAjax
+     * @return \PHPUnit_Framework_MockObject_MockObject | File
+     */
+    protected function getClass($value, $isAjax)
+    {
+        $fileForm = $this->getMock('Magento\Customer\Model\Metadata\Form\File',
+            ['_isUploadedFile'], [
+                $this->localeMock,
+                $this->loggerMock,
+                $this->attributeMetadataMock,
+                $value,
+                0,
+                $isAjax,
+                $this->coreDataMock,
+                $this->fileValidatorMock,
+                $this->fileSystemMock
+            ]
+        );
+        return $fileForm;
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..25b8323492d257732e800a28d6d261daf88434f3
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata\Form;
+
+class HiddenTest extends TextTest
+{
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     * @return Hidden
+     */
+    protected function getClass($value)
+    {
+        return new Hidden(
+            $this->localeMock,
+            $this->loggerMock,
+            $this->attributeMetadataMock,
+            $value,
+            0,
+            false,
+            $this->stringHelper
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..439dfbcc0a4d6196f06eb7d839b386a3a14d4b1e
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata\Form;
+
+class ImageTest extends FileTest
+{
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value
+     * @param bool $isAjax
+     * @return Image
+     */
+    protected function getClass($value, $isAjax)
+    {
+        $imageForm = $this->getMock('Magento\Customer\Model\Metadata\Form\Image',
+            ['_isUploadedFile'], [
+                $this->localeMock,
+                $this->loggerMock,
+                $this->attributeMetadataMock,
+                $value,
+                0,
+                $isAjax,
+                $this->coreDataMock,
+                $this->fileValidatorMock,
+                $this->fileSystemMock
+            ]
+        );
+        return $imageForm;
+    }
+
+    public function validateValueToUploadDataProvider()
+    {
+        $imagePath = __DIR__ . '/_files/logo.gif';
+        return [
+            [
+                ['"realFileName" is not a valid file.'],
+                ['tmp_name' => 'tmp_file', 'name' => 'realFileName'],
+                ['valid' => false],
+            ],
+            [
+                true,
+                ['tmp_name' => $imagePath, 'name' => 'logo.gif'],
+            ],
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..0d5a0ca700084c26c228f4f4203c742150b13f58
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php
@@ -0,0 +1,101 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata\Form;
+
+/** Test Magento\Customer\Model\Metadata\Form\Multiline */
+class MultilineTest extends TextTest
+{
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     * @return Multiline
+     */
+    protected function getClass($value)
+    {
+        return new Multiline(
+            $this->localeMock,
+            $this->loggerMock,
+            $this->attributeMetadataMock,
+            $value,
+            0,
+            false,
+            $this->stringHelper
+        );
+    }
+
+    /**
+     * @param string|int|bool|null $value to assign to boolean
+     * @param string|bool|null $expected text output
+     * @dataProvider validateValueRequiredDataProvider
+     */
+    public function testValidateValueRequired($value, $expected)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('getMultilineCount')
+            ->will($this->returnValue(5));
+
+        parent::testValidateValueRequired($value, $expected);
+    }
+
+    public function validateValueRequiredDataProvider()
+    {
+        return array_merge(
+            parent::validateValueRequiredDataProvider(),
+            [
+                'lines'         => [['one', 'two'], true],
+                'mixed lines' => [['one', '', ''], true],
+                'empty lines' => [['', '', ''], true],
+            ]
+        );
+    }
+
+    /**
+     * @param string|int|bool|null $value to assign to boolean
+     * @param string|bool $expected text output
+     * @dataProvider validateValueLengthDataProvider
+     */
+    public function testValidateValueLength($value, $expected)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('getMultilineCount')
+            ->will($this->returnValue(5));
+
+        parent::testValidateValueLength($value, $expected);
+    }
+
+    public function validateValueLengthDataProvider()
+    {
+        return array_merge(
+            parent::validateValueLengthDataProvider(),
+            [
+                'long lines' => [['0123456789', '0123456789'], '"" length must be equal or less than 8 characters.'],
+                'long and short' => [['0123456789', '01'], '"" length must be equal or less than 8 characters.'],
+                'short and long' => [['01', '0123456789'], '"" length must be equal or greater than 4 characters.'],
+            ]
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..3d3482732f5f873cfd0479330bbe37d7936c032c
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php
@@ -0,0 +1,219 @@
+<?php
+/**
+ * test Magento\Customer\Model\Metadata\Form\Multiselect
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata\Form;
+
+use Magento\Customer\Model\Metadata\ElementFactory;
+use Magento\Customer\Service\V1\Dto\Eav\Option;
+
+class MultiselectTest extends AbstractFormTestCase
+{
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     *
+     * @return Multiselect
+     */
+    protected function getClass($value)
+    {
+        return new Multiselect(
+            $this->localeMock,
+            $this->loggerMock,
+            $this->attributeMetadataMock,
+            $value,
+            0
+        );
+    }
+
+    /**
+     * Test the Multiselect->extractValue() method
+     *
+     * @param string|int|bool|array $value to assign to boolean
+     * @param bool $expected text output
+     *
+     * @return void
+     * @dataProvider extractValueDataProvider
+     */
+    public function testExtractValue($value, $expected)
+    {
+        /** @var \PHPUnit_Framework_MockObject_MockObject | Multiselect $multiselect */
+        $multiselect = $this->getMockBuilder('Magento\Customer\Model\Metadata\Form\Multiselect')
+            ->disableOriginalConstructor()
+            ->setMethods(['_getRequestValue'])
+            ->getMock();
+        $multiselect->expects($this->once())
+            ->method('_getRequestValue')
+            ->will($this->returnValue($value));
+
+        $request = $this->getMockBuilder('Magento\App\RequestInterface')->getMock();
+        $actual = $multiselect->extractValue($request);
+        $this->assertEquals($expected, $actual);
+    }
+
+    /**
+     * Data provider for testExtractValue()
+     *
+     * @return array(array)
+     */
+    public function extractValueDataProvider()
+    {
+        return [
+            'false' => [false, false],
+            'int' => [15, [15]],
+            'string' => ['some string', ['some string']],
+            'array' => [[1, 2, 3], [1, 2, 3]]
+        ];
+    }
+
+    /**
+     * Test the Multiselect->compactValue() method
+     *
+     * @param string|int|bool|array $value to assign to boolean
+     * @param bool $expected text output
+     *
+     * @return void
+     * @dataProvider compactValueDataProvider
+     */
+    public function testCompactValue($value, $expected)
+    {
+        $multiselect = $this->getClass($value);
+        $actual = $multiselect->compactValue($value);
+        $this->assertEquals($expected, $actual);
+    }
+
+    /**
+     * Data provider for testCompactValue()
+     *
+     * @return array(array)
+     */
+    public function compactValueDataProvider()
+    {
+        return [
+            'false' => [false, false],
+            'int' => [15, 15],
+            'string' => ['some string', 'some string'],
+            'array' => [[1, 2, 3], '1,2,3']
+        ];
+    }
+
+    /**
+     * Test the Multiselect->outputValue() method with default TEXT format
+     *
+     * @param string|int|null|string[]|int[] $value
+     * @param string $expected
+     *
+     * @return void
+     * @dataProvider outputValueTextDataProvider
+     */
+    public function testOutputValueText($value, $expected)
+    {
+        $this->runOutputValueTest($value, $expected, ElementFactory::OUTPUT_FORMAT_TEXT);
+    }
+
+    /**
+     * Test the Multiselect->outputValue() method with default HTML format
+     *
+     * @param string|int|null|string[]|int[] $value
+     * @param string $expected
+     *
+     * @return void
+     * @dataProvider outputValueTextDataProvider
+     */
+    public function testOutputValueHtml($value, $expected)
+    {
+        $this->runOutputValueTest($value, $expected, ElementFactory::OUTPUT_FORMAT_HTML);
+    }
+
+    /**
+     * Data provider for testOutputValueText()
+     *
+     * @return array(array)
+     */
+    public function outputValueTextDataProvider()
+    {
+        return [
+            'empty' => ['', ''],
+            'null' => [null, ''],
+            'number' => [14, 'fourteen'],
+            'string' => ['some key', 'some string'],
+            'array' => [[14, 'some key'], 'fourteen, some string'],
+            'unknown' => [[14, 'some key', 'unknown'], 'fourteen, some string, '],
+        ];
+    }
+
+    /**
+     * Test the Multiselect->outputValue() method with JSON format
+     *
+     * @param string|int|null|string[]|int[] $value
+     * @param string[] $expected
+     *
+     * @return void
+     * @dataProvider outputValueJsonDataProvider
+     */
+    public function testOutputValueJson($value, $expected)
+    {
+        $this->runOutputValueTest($value, $expected, ElementFactory::OUTPUT_FORMAT_JSON);
+    }
+
+    /**
+     * Data provider for testOutputValueJson()
+     *
+     * @return array(array)
+     */
+    public function outputValueJsonDataProvider()
+    {
+        return [
+            'empty' => ['', ['']],
+            'null' => [null, ['']],
+            'number' => [14, ['14']],
+            'string' => ['some key', ['some key']],
+            'array' => [[14, 'some key'], ['14', 'some key']],
+            'unknown' => [[14, 'some key', 'unknown'], ['14', 'some key', 'unknown']],
+        ];
+    }
+
+    /**
+     * Helper function that runs an outputValue test for a given format.
+     *
+     * @param string|int|null|string[]|int[] $value
+     * @param string|string[] $expected
+     * @param string $format
+     */
+    protected function runOutputValueTest($value, $expected, $format)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('getOptions')
+            ->will($this->returnValue([
+                new Option(['value' => '14', 'label' => 'fourteen']),
+                new Option(['value' => 'some key', 'label' => 'some string']),
+            ]));
+        $multiselect = $this->getClass($value);
+        $actual = $multiselect->outputValue($format);
+        $this->assertEquals($expected, $actual);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..82646f644f2262d650d7961e95a8be6fded65d76
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Customer\Model\Metadata\Form;
+use Magento\Customer\Service\V1\Dto\Eav\Option;
+
+/**
+ * test Magento\Customer\Model\Metadata\Form\Select
+ */
+class SelectTest extends AbstractFormTestCase
+{
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     * @return Select
+     */
+    protected function getClass($value)
+    {
+        return new Select(
+            $this->localeMock,
+            $this->loggerMock,
+            $this->attributeMetadataMock,
+            $value,
+            0
+        );
+    }
+
+    /**
+     * @param string|int|bool|null $value to assign to Select
+     * @param bool $expected text output
+     * @dataProvider validateValueDataProvider
+     */
+    public function testValidateValue($value, $expected)
+    {
+        $select = $this->getClass($value);
+        $actual = $select->validateValue($value);
+        $this->assertEquals($expected, $actual);
+    }
+
+    public function validateValueDataProvider()
+    {
+        return [
+            'empty' => ['', true],
+            '0' => [0, true],
+            'zero' => ['0', true],
+            'string' => ['some text', true],
+            'number' => [123, true],
+            'true' => [true, true],
+            'false' => [false, true]
+        ];
+    }
+
+    /**
+     * @param string|int|bool|null $value to assign to boolean
+     * @param string|bool $expected text output
+     * @dataProvider validateValueRequiredDataProvider
+     */
+    public function testValidateValueRequired($value, $expected)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('isRequired')
+            ->will($this->returnValue(true));
+
+        $select = $this->getClass($value);
+        $actual = $select->validateValue($value);
+
+        if (is_bool($actual)) {
+            $this->assertEquals($expected, $actual);
+        } else {
+            $this->assertContains($expected, $actual);
+        }
+    }
+
+    public function validateValueRequiredDataProvider()
+    {
+        return [
+            'empty' => ['', '"" is a required value.'],
+            'null' => [null, '"" is a required value.'],
+            '0'  => [0, true],
+            'string' => ['some text', true],
+            'number' => [123, true],
+            'true' => [true, true],
+            'false' => [false, '"" is a required value.'],
+        ];
+    }
+
+    /**
+     * @param string|int|bool|null $value
+     * @param string|int $expected
+     * @dataProvider outputValueDataProvider
+     */
+    public function testOutputValue($value, $expected)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('getOptions')
+            ->will($this->returnValue([
+                new Option(['value' => '14', 'label' => 'fourteen']),
+                new Option(['value' => 'some key', 'label' => 'some string']),
+                new Option(['value' => 'true', 'label' => 'True']),
+            ]));
+        $select = $this->getClass($value);
+        $actual = $select->outputValue();
+        $this->assertEquals($expected, $actual);
+    }
+
+    public function outputValueDataProvider()
+    {
+        return [
+            'empty' => ['', ''],
+            'null' => [null, ''],
+            'number' => [14, 'fourteen'],
+            'string' => ['some key', 'some string'],
+            'boolean' => [true, ''],
+            'unknown' => ['unknownKey', ''],
+            'true' => ['true', 'True'],
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..c62d453c35988d0d40930760c940957ef1a71d01
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php
@@ -0,0 +1,159 @@
+<?php
+/**
+ * test Magento\Customer\Model\Metadata\Form\Text
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata\Form;
+
+class TextTest extends AbstractFormTestCase
+{
+    /** @var \Magento\Stdlib\String */
+    protected $stringHelper;
+
+    protected function setUp()
+    {
+        parent::setUp();
+        $this->stringHelper = new \Magento\Stdlib\String();
+    }
+
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     * @return Text
+     */
+    protected function getClass($value)
+    {
+        return new Text(
+            $this->localeMock,
+            $this->loggerMock,
+            $this->attributeMetadataMock,
+            $value,
+            0,
+            false,
+            $this->stringHelper
+        );
+    }
+
+    /**
+     * @param string|int|bool $value to assign to boolean
+     * @param bool $expected text output
+     * @dataProvider validateValueDataProvider
+     */
+    public function testValidateValue($value, $expected)
+    {
+        $sut = $this->getClass($value);
+        $actual = $sut->validateValue($value);
+        $this->assertEquals($expected, $actual);
+    }
+
+    public function validateValueDataProvider()
+    {
+        return [
+            'empty' => ['', true],
+            '0' => [0, true],
+            'zero' => ['0', true],
+            'string' => ['some text', true],
+            'number' => [123, true],
+            'true' => [true, true],
+            'false' => [false, true]
+        ];
+    }
+
+    /**
+     * @param string|int|bool|null $value to assign to boolean
+     * @param string|bool|null $expected text output
+     * @dataProvider validateValueRequiredDataProvider
+     */
+    public function testValidateValueRequired($value, $expected)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('isRequired')
+            ->will($this->returnValue(true));
+
+        $sut = $this->getClass($value);
+        $actual = $sut->validateValue($value);
+
+        if (is_bool($actual)) {
+            $this->assertEquals($expected, $actual);
+        } else {
+            $this->assertContains($expected, $actual);
+        }
+    }
+
+    public function validateValueRequiredDataProvider()
+    {
+        return [
+            'empty' => ['', '"" is a required value.'],
+            'null' => [null, '"" is a required value.'],
+            '0'  => [0, true],
+            'zero'  => ['0', true],
+            'string' => ['some text', true],
+            'number' => [123, true],
+            'true' => [true, true],
+            'false' => [false, '"" is a required value.'],
+        ];
+    }
+
+    /**
+     * @param string|int|bool|null $value to assign to boolean
+     * @param string|bool $expected text output
+     * @dataProvider validateValueLengthDataProvider
+     */
+    public function testValidateValueLength($value, $expected)
+    {
+        $this->attributeMetadataMock
+            ->expects($this->any())
+            ->method('getValidationRules')
+            ->will($this->returnValue(['min_text_length' => 4, 'max_text_length' => 8]));
+
+        $sut = $this->getClass($value);
+        $actual = $sut->validateValue($value);
+
+        if (is_bool($actual)) {
+            $this->assertEquals($expected, $actual);
+        } else {
+            $this->assertContains($expected, $actual);
+        }
+    }
+
+    public function validateValueLengthDataProvider()
+    {
+        return [
+            'false' => [false, true],
+            'empty' => ['', true],
+            'null' => [null, true],
+            'true' => [true, '"" length must be equal or greater than 4 characters.'],
+            'one' => [1, '"" length must be equal or greater than 4 characters.'],
+            'L1' => ['a', '"" length must be equal or greater than 4 characters.'],
+            'L3' => ['abc', '"" length must be equal or greater than 4 characters.'],
+            'L4' => ['abcd', true],
+            'thousand' => [1000, true],
+            'L8' => ['abcdefgh', true],
+            'L9' => ['abcdefghi', '"" length must be equal or less than 8 characters.'],
+            'L12' => ['abcdefghjkl', '"" length must be equal or less than 8 characters.'],
+            'billion' => [1000000000, '"" length must be equal or less than 8 characters.'],
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..b0a03e9ec83fbe0bc4c75355fa6eb0c7f2a1ff4d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata\Form;
+
+class TextareaTest extends TextTest
+{
+    /**
+     * Create an instance of the class that is being tested
+     *
+     * @param string|int|bool|null $value The value undergoing testing by a given test
+     * @return Textarea
+     */
+    protected function getClass($value)
+    {
+        return new Textarea(
+            $this->localeMock,
+            $this->loggerMock,
+            $this->attributeMetadataMock,
+            $value,
+            0,
+            false,
+            $this->stringHelper
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/_files/logo.gif b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/_files/logo.gif
new file mode 100644
index 0000000000000000000000000000000000000000..a4d941679e111f60e1280207683983e9cd0959d9
Binary files /dev/null and b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/_files/logo.gif differ
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..53de16c2b20d1035d0efc740033325d30cd45a10
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php
@@ -0,0 +1,147 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Customer\Model\Metadata;
+
+class ValidatorTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var Validator */
+    protected $validator;
+
+    /** @var string */
+    protected $entityType;
+
+    /** @var \Magento\Customer\Model\Metadata\ElementFactory | \PHPUnit_Framework_MockObject_MockObject */
+    protected $attrDataFactoryMock;
+
+    public function setUp()
+    {
+        $this->attrDataFactoryMock = $this->getMockBuilder('\Magento\Customer\Model\Metadata\ElementFactory')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->validator = new Validator($this->attrDataFactoryMock);
+    }
+
+    public function testValidateDataWithNoDataModel()
+    {
+        $attribute = $this->getMockBuilder('\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->attrDataFactoryMock
+            ->expects($this->never())
+            ->method('create');
+        $this->assertTrue($this->validator->validateData([], [$attribute], 'ENTITY_TYPE'));
+    }
+
+    /**
+     * @param bool $isValid
+     * @dataProvider trueFalseDataProvider
+     */
+    public function testValidateData($isValid)
+    {
+        $attribute = $this->getMockAttribute();
+        $this->mockDataModel($isValid, $attribute);
+        $this->assertEquals($isValid, $this->validator->validateData([], [$attribute], 'ENTITY_TYPE'));
+    }
+
+    public function testIsValidWithNoModel()
+    {
+        $attribute = $this->getMockBuilder('\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->attrDataFactoryMock
+            ->expects($this->never())
+            ->method('create');
+        $this->validator->setAttributes([$attribute]);
+        $this->validator->setEntityType('ENTITY_TYPE');
+        $this->validator->setData(['something']);
+        $this->assertTrue($this->validator->isValid('entity'));
+        $this->validator->setData([]);
+        $this->assertTrue($this->validator->isValid(new \Magento\Object([])));
+    }
+
+    /**
+     * @param bool $isValid
+     * @dataProvider trueFalseDataProvider
+     */
+    public function testIsValid($isValid)
+    {
+        $attribute = $this->getMockAttribute();
+        $this->mockDataModel($isValid, $attribute);
+        $this->validator->setAttributes([$attribute]);
+        $this->validator->setEntityType('ENTITY_TYPE');
+        $this->validator->setData(['something']);
+        $this->assertEquals($isValid, $this->validator->isValid('ENTITY'));
+        $this->validator->setData([]);
+        $this->assertEquals($isValid, $this->validator->isValid(new \Magento\Object([])));
+    }
+
+    public function trueFalseDataProvider()
+    {
+        return [[true], [false]];
+    }
+
+    /**
+     * @return \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata
+     */
+    protected function getMockAttribute()
+    {
+        $attribute = $this->getMockBuilder('\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->setMethods(['__wakeup', 'getAttributeCode', 'getDataModel'])
+            ->getMock();
+        $attribute->expects($this->any())
+            ->method('getAttributeCode')
+            ->will($this->returnValue('ATTR_CODE'));
+        $attribute->expects($this->any())
+            ->method('getDataModel')
+            ->will($this->returnValue('DATA_MODEL'));
+        return $attribute;
+    }
+
+    /**
+     * @param bool                                                   $isValid
+     * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute
+     * @return void
+     */
+    protected function mockDataModel($isValid, \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute)
+    {
+        $dataModel = $this->getMockBuilder('\Magento\Customer\Model\Metadata\Form\Text')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $dataModel->expects($this->any())
+            ->method('validateValue')
+            ->will($this->returnValue($isValid));
+        $this->attrDataFactoryMock
+            ->expects($this->any())
+            ->method('create')
+            ->with(
+                $this->equalTo($attribute),
+                $this->equalTo('ENTITY_TYPE'),
+                $this->equalTo(null)
+            )
+            ->will($this->returnValue($dataModel));
+    }
+}
+ 
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php
index 87f0cd6fefca1af04b779d768a2d1154591e59d6..9c53c92ebcd71ab6162e754b23fc3a35a57f3179 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php
@@ -24,6 +24,10 @@
 
 namespace Magento\Customer\Service\V1;
 
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+use Magento\Exception\StateException;
+
 /**
  * \Magento\Customer\Service\V1\CustomerAccountService
  *
@@ -34,15 +38,6 @@ namespace Magento\Customer\Service\V1;
  */
 class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 {
-
-    const STREET = 'Parmer';
-    const CITY = 'Albuquerque';
-    const POSTCODE = '90014';
-    const TELEPHONE = '7143556767';
-    const REGION = 'Alabama';
-    const REGION_ID = 1;
-    const COUNTRY_ID = 'US';
-
     /** Sample values for testing */
     const ID = 1;
     const FIRSTNAME = 'Jane';
@@ -60,26 +55,11 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
      */
     private $_customerFactoryMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\AddressFactory
-     */
-    private $_addressFactoryMock;
-
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Customer
      */
     private $_customerModelMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Attribute
-     */
-    private $_attributeModelMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
-     */
-    private $_eavMetadataServiceMock;
-
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Event\ManagerInterface
      */
@@ -106,19 +86,18 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     private $_storeMock;
 
     /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\AddressBuilder
+     * @var \Magento\Customer\Model\Metadata\Validator
      */
-    private $_addressBuilder;
+    private $_validator;
 
     /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\CustomerBuilder
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerService
      */
-    private $_customerBuilder;
-
-    private $_validator;
-
     private $_customerServiceMock;
 
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerAddressService
+     */
     private $_customerAddressServiceMock;
 
     public function setUp()
@@ -177,31 +156,11 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             )
             ->getMock();
 
-        $this->_addressFactoryMock = $this->getMockBuilder('Magento\Customer\Model\AddressFactory')
-            ->disableOriginalConstructor()
-            ->setMethods(array('create'))
-            ->getMock();
-
-        $this->_eavMetadataServiceMock =
-            $this->getMockBuilder('Magento\Customer\Service\Eav\AttributeMetadataServiceV1Interface')
-                ->disableOriginalConstructor()
-                ->getMock();
-
         $this->_eventManagerMock =
             $this->getMockBuilder('\Magento\Event\ManagerInterface')
                 ->disableOriginalConstructor()
                 ->getMock();
 
-        $this->_attributeModelMock =
-            $this->getMockBuilder('\Magento\Customer\Model\Attribute')
-                ->disableOriginalConstructor()
-                ->getMock();
-
-        $this->_attributeModelMock
-            ->expects($this->any())
-            ->method('getAttributeCode')
-            ->will($this->returnValue(self::ATTRIBUTE_CODE));
-
         $this->_customerModelMock
             ->expects($this->any())
             ->method('getData')
@@ -223,11 +182,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
 
-        $this->_addressBuilder = new Dto\AddressBuilder(
-            new Dto\RegionBuilder());
-
-        $this->_customerBuilder = new Dto\CustomerBuilder();
-
         $customerBuilder = new Dto\CustomerBuilder();
 
         $this->_converter = new \Magento\Customer\Model\Converter($customerBuilder, $this->_customerFactoryMock);
@@ -277,7 +231,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException  \Magento\Customer\Service\Entity\V1\Exception
+     * @expectedException  \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INVALID_STATE
      */
     public function testActivateAccountAlreadyActive()
     {
@@ -309,10 +264,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY);
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionMessage No customer with customerId 1 exists.
-     */
     public function testActivateAccountDoesntExist()
     {
         $this->_customerModelMock->expects($this->any())
@@ -338,44 +289,23 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY);
-    }
-
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionMessage DB was down
-     */
-    public function testActivateAccountLoadError()
-    {
-        $this->_customerModelMock->expects($this->any())
-            ->method('load')
-            ->will($this->throwException(new \Exception('DB was down')));
-
-        $this->_mockReturnValue(
-            $this->_customerModelMock,
-            array(
-                'getId' => 0,
-            )
-        );
-
-        $this->_customerFactoryMock->expects($this->any())
-            ->method('create')
-            ->will($this->returnValue($this->_customerModelMock));
-
-        // Assertions
-        $this->_customerModelMock->expects($this->never())
-            ->method('save');
-        $this->_customerModelMock->expects($this->never())
-            ->method('setConfirmation');
-
-        $customerService = $this->_createService();
-
-        $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY);
+        try {
+            $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY);
+            $this->fail('Expected exception not thrown.');
+        } catch (\Magento\Exception\NoSuchEntityException $nsee) {
+            $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $nsee->getParams(),
+                [
+                    'customerId' => self::ID,
+                ]
+            );
+        }
     }
 
     /**
-     * @expectedException \Magento\Core\Exception
-     * @expectedExceptionMessage Wrong confirmation key
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH
      */
     public function testActivateAccountBadKey()
     {
@@ -387,7 +317,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             $this->_customerModelMock,
             array(
                 'getId' => self::ID,
-                'getConfirmation' => self::EMAIL_CONFIRMATION_KEY . 'BAD',
+                'getConfirmation' => self::EMAIL_CONFIRMATION_KEY,
             )
         );
 
@@ -403,12 +333,12 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY);
+        $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY . 'BAD');
     }
 
     /**
-     * @expectedException \Magento\Core\Exception
-     * @expectedExceptionMessage Failed to confirm customer account
+     * @expectedException \Exception
+     * @expectedExceptionMessage DB is down
      */
     public function testActivateAccountSaveFailed()
     {
@@ -464,7 +394,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
+     * @expectedException \Magento\Exception\AuthenticationException
      * @expectedExceptionMessage exception message
      */
     public function testLoginAccountWithException()
@@ -513,9 +443,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
-     * @expectedExceptionMessage Your password reset link has expired.
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::EXPIRED
      */
     public function testValidateResetPasswordLinkTokenExpired()
     {
@@ -540,9 +469,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
-     * @expectedExceptionMessage Your password reset link has expired.
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH
      */
     public function testValidateResetPasswordLinkTokenInvalid()
     {
@@ -567,11 +495,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerService->validateResetPasswordLinkToken(self::ID, $invalidToken);
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_CUSTOMER_ID
-     * @expectedExceptionMessage No customer with customerId 1 exists
-     */
     public function testValidateResetPasswordLinkTokenWrongUser()
     {
         $resetToken = 'lsdj579slkj5987slkj595lkj';
@@ -591,14 +514,20 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->validateResetPasswordLinkToken(1, $resetToken);
+        try {
+            $customerService->validateResetPasswordLinkToken(1, $resetToken);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (\Magento\Exception\NoSuchEntityException $nsee) {
+            $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $nsee->getParams(),
+                [
+                    'customerId' => self::ID,
+                ]
+            );
+        }
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_RESET_TOKEN
-     * @expectedExceptionMessage Invalid password reset token
-     */
     public function testValidateResetPasswordLinkTokenNull()
     {
         $resetToken = 'lsdj579slkj5987slkj595lkj';
@@ -618,7 +547,19 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->validateResetPasswordLinkToken(null, null);
+        try {
+            $customerService->validateResetPasswordLinkToken(14, null);
+            $this->fail('Expected exception not thrown.');
+        } catch ( InputException $e) {
+            $expectedParams = [
+                [
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                    'fieldName' => 'resetPasswordLinkToken',
+                    'value' => null,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $e->getParams());
+        }
     }
 
     public function testSendPasswordResetLink()
@@ -644,11 +585,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerService->sendPasswordResetLink($email, self::WEBSITE_ID);
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_EMAIL_NOT_FOUND
-     * @expectedExceptionMessage No customer found for the provided email and website ID
-     */
     public function testSendPasswordResetLinkBadEmailOrWebsite()
     {
         $email = 'foo@example.com';
@@ -669,12 +605,23 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->sendPasswordResetLink($email, 0);
+        try {
+            $customerService->sendPasswordResetLink($email, 0);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (\Magento\Exception\NoSuchEntityException $nsee) {
+            $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $nsee->getParams(),
+                [
+                    'email' => $email,
+                    'websiteId' => 0
+                ]
+            );
+        }
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_UNKNOWN
+     * @expectedException \Magento\Core\Exception
      * @expectedExceptionMessage Invalid transactional email code: 0
      */
     public function testSendPasswordResetLinkSendException()
@@ -774,9 +721,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
-     * @expectedExceptionMessage Your password reset link has expired.
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::EXPIRED
      */
     public function testResetPasswordTokenExpired()
     {
@@ -809,9 +755,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_RESET_TOKEN_EXPIRED
-     * @expectedExceptionMessage Your password reset link has expired.
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH
      */
     public function testResetPasswordTokenInvalid()
     {
@@ -844,11 +789,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerService->resetPassword(self::ID, $password, $invalidToken);
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_CUSTOMER_ID
-     * @expectedExceptionMessage No customer with customerId 4200 exists
-     */
     public function testResetPasswordTokenWrongUser()
     {
         $resetToken = 'lsdj579slkj5987slkj595lkj';
@@ -876,14 +816,20 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->resetPassword(4200, $password, $resetToken);
+        try {
+            $customerService->resetPassword(4200, $password, $resetToken);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (\Magento\Exception\NoSuchEntityException $nsee) {
+            $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $nsee->getParams(),
+                [
+                    'customerId' => 4200,
+                ]
+            );
+        }
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_RESET_TOKEN
-     * @expectedExceptionMessage Invalid password reset token
-     */
     public function testResetPasswordTokenInvalidUserId()
     {
         $resetToken = 'lsdj579slkj5987slkj595lkj';
@@ -911,10 +857,21 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
 
         $customerService = $this->_createService();
 
-        $customerService->resetPassword(0, $password, $resetToken);
+        try {
+            $customerService->resetPassword(0, $password, $resetToken);
+            $this->fail('Expected exception not thrown.');
+        } catch ( InputException $e) {
+            $expectedParams = [
+                [
+                    'code' => InputException::INVALID_FIELD_VALUE,
+                    'fieldName' => 'customerId',
+                    'value' => 0,
+                ]
+            ];
+            $this->assertEquals($expectedParams, $e->getParams());
+        }
     }
 
-
     public function testSendConfirmation()
     {
         $this->_customerFactoryMock->expects($this->any())
@@ -937,10 +894,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $customerService->sendConfirmation('email');
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_EMAIL_NOT_FOUND
-     */
     public function testSendConfirmationNoEmail()
     {
         $this->_customerFactoryMock->expects($this->any())
@@ -954,12 +907,21 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($this->_customerModelMock));
 
         $customerService = $this->_createService();
-        $customerService->sendConfirmation('email');
+        try {
+            $customerService->sendConfirmation('email@no.customer');
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (NoSuchEntityException $nsee) {
+            $expectedParams = [
+                'email' => 'email@no.customer',
+                'websiteId' => null
+            ];
+            $this->assertEquals($expectedParams, $nsee->getParams());
+        }
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_CONFIRMATION_NOT_NEEDED
+     * @expectedException \Magento\Exception\StateException
+     * @expectedExceptionCode \Magento\Exception\StateException::INVALID_STATE
      */
     public function testSendConfirmationNotNeeded()
     {
@@ -969,15 +931,18 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
         $this->_customerModelMock->expects($this->once())
             ->method('getId')
             ->will($this->returnValue(55));
+        $this->_storeMock->expects($this->once())
+            ->method('getWebsiteId')
+            ->will($this->returnValue(2));
         $this->_customerModelMock->expects($this->once())
             ->method('setWebsiteId')
+            ->with(2)
             ->will($this->returnValue($this->_customerModelMock));
 
         $customerService = $this->_createService();
-        $customerService->sendConfirmation('email');
+        $customerService->sendConfirmation('email@test.com');
     }
 
-
     private function _setupStoreMock()
     {
         $this->_storeManagerMock =
@@ -995,7 +960,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($this->_storeMock));
     }
 
-
     /**
      * @param \PHPUnit_Framework_MockObject_MockObject $mock
      * @param array $valueMap
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
index 84c8387aa610700e142506e0e744d7cb519f3864..1eae647d0a298ba4b27e5b077f4680a233932d86 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
@@ -24,6 +24,9 @@
 
 namespace Magento\Customer\Service\V1;
 
+use Magento\Exception\InputException;
+use Magento\Exception\NoSuchEntityException;
+
 /**
  * \Magento\Customer\Service\V1\CustomerAddressService
  *
@@ -34,7 +37,7 @@ namespace Magento\Customer\Service\V1;
  */
 class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
 {
-
+    /** Sample values for testing */
     const STREET = 'Parmer';
     const CITY = 'Albuquerque';
     const POSTCODE = '90014';
@@ -42,8 +45,6 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     const REGION = 'Alabama';
     const REGION_ID = 1;
     const COUNTRY_ID = 'US';
-
-    /** Sample values for testing */
     const ID = 1;
     const FIRSTNAME = 'Jane';
     const LASTNAME = 'Doe';
@@ -70,31 +71,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
      */
     private $_customerModelMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Attribute
-     */
-    private $_attributeModelMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
-     */
-    private $_eavMetadataServiceMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Event\ManagerInterface
-     */
-    private $_eventManagerMock;
-
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\StoreManagerInterface
      */
     private $_storeManagerMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Math\Random
-     */
-    private $_mathRandomMock;
-
     /**
      * @var \Magento\Customer\Model\Converter
      */
@@ -106,15 +87,18 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
     private $_storeMock;
 
     /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\AddressBuilder
+     * @var \Magento\Customer\Service\V1\Dto\AddressBuilder
      */
     private $_addressBuilder;
 
     /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\CustomerBuilder
+     * @var \Magento\Directory\Helper\Data
      */
-    private $_customerBuilder;
+    private $_directoryData;
 
+    /**
+     * @var \Magento\Customer\Model\Metadata\Validator
+     */
     private $_validator;
 
     public function setUp()
@@ -178,25 +162,15 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->setMethods(array('create'))
             ->getMock();
 
-        $this->_eavMetadataServiceMock =
-            $this->getMockBuilder('Magento\Customer\Service\Eav\AttributeMetadataServiceV1Interface')
-                ->disableOriginalConstructor()
-                ->getMock();
-
-        $this->_eventManagerMock =
-            $this->getMockBuilder('\Magento\Event\ManagerInterface')
-                ->disableOriginalConstructor()
-                ->getMock();
-
-        $this->_attributeModelMock =
-            $this->getMockBuilder('\Magento\Customer\Model\Attribute')
-                ->disableOriginalConstructor()
-                ->getMock();
+        $this->_directoryData = $this->getMockBuilder('\Magento\Directory\Helper\Data')
+            ->disableOriginalConstructor()
+            ->setMethods(array('getCountriesWithOptionalZip'))
+            ->getMock();
 
-        $this->_attributeModelMock
+        $this->_directoryData
             ->expects($this->any())
-            ->method('getAttributeCode')
-            ->will($this->returnValue(self::ATTRIBUTE_CODE));
+            ->method('getCountriesWithOptionalZip')
+            ->will($this->returnValue([]));
 
         $this->_customerModelMock
             ->expects($this->any())
@@ -211,18 +185,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
 
         $this->_setupStoreMock();
 
-        $this->_mathRandomMock = $this->getMockBuilder('\Magento\Math\Random')
-            ->disableOriginalConstructor()
-            ->getMock();
-
         $this->_validator = $this->getMockBuilder('\Magento\Customer\Model\Metadata\Validator')
             ->disableOriginalConstructor()
             ->getMock();
 
-        $this->_addressBuilder = new Dto\AddressBuilder(
-            new Dto\RegionBuilder());
-
-        $this->_customerBuilder = new Dto\CustomerBuilder();
+        $this->_addressBuilder = new Dto\AddressBuilder(new Dto\RegionBuilder());
 
         $customerBuilder = new Dto\CustomerBuilder();
 
@@ -321,18 +288,21 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($expected, $address->__toArray());
     }
 
-    public function testGetAddressesById()
+    public function testGetAddressById()
     {
         $addressMock = $this->_createAddress(1, 'John');
+        $addressMock->expects($this->any())
+            ->method('getCustomerId')
+            ->will($this->returnValue(self::ID));
+        $this->_addressFactoryMock->expects($this->once())
+            ->method('create')
+            ->will($this->returnValue($addressMock));
         $this->_customerModelMock->expects($this->any())
             ->method('load')
             ->will($this->returnValue($this->_customerModelMock));
         $this->_customerModelMock->expects($this->any())
             ->method('getId')
             ->will($this->returnValue(1));
-        $this->_customerModelMock->expects($this->any())
-            ->method('getAddressById')
-            ->will($this->returnValue($addressMock));
         $this->_customerModelMock->expects($this->any())
             ->method('getDefaultShipping')
             ->will($this->returnValue(1));
@@ -340,11 +310,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->method('create')
             ->will($this->returnValue($this->_customerModelMock));
 
+
         $customerService = $this->_createService();
 
-        $customerId = 1;
         $addressId = 1;
-        $address = $customerService->getAddressById($customerId, $addressId);
+        $address = $customerService->getAddressById($addressId);
 
         $expected = [
             'id' => 1,
@@ -590,10 +560,6 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals([1], $ids);
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionMessage No customer with customerId 4200 exists
-     */
     public function testSaveAddressesCustomerIdNotExist()
     {
         // Setup Customer mock
@@ -627,8 +593,20 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->setCountryId(self::COUNTRY_ID)
             ->setPostcode(self::POSTCODE);
 
-        $failures = $customerService->saveAddresses(4200, [$this->_addressBuilder->create()]);
-        $this->assertEmpty($failures);
+        try {
+            $customerService->saveAddresses(4200, [$this->_addressBuilder->create()]);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (\Magento\Exception\NoSuchEntityException $nsee) {
+            $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $nsee->getParams(),
+                [
+                    'customerId' => 4200,
+                ]
+            );
+        } catch (\Exception $unexpected) {
+            $this->fail('Unexpected exception type thrown. ' . $unexpected->getMessage());
+        }
     }
 
     public function testDeleteAddressFromCustomer()
@@ -647,33 +625,9 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->method('delete');
 
         $customerService = $this->_createService();
-        $customerService->deleteAddressFromCustomer(1, 1);
+        $customerService->deleteAddress(1);
     }
 
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_CUSTOMER_ID_MISMATCH
-     */
-    public function testDeleteAddressFromCustomerMismatch()
-    {
-        // Setup address mock
-        $mockAddress = $this->_createAddress(1, 'John', 55);
-        $this->_addressFactoryMock->expects($this->once())
-            ->method('create')
-            ->will($this->returnValue($mockAddress));
-
-        // verify delete is called on the mock address model
-        $mockAddress->expects($this->never())
-            ->method('delete');
-
-        $customerService = $this->_createService();
-        $customerService->deleteAddressFromCustomer(1, 1);
-    }
-
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_ADDRESS_NOT_FOUND
-     */
     public function testDeleteAddressFromCustomerBadAddrId()
     {
         // Setup address mock
@@ -690,20 +644,20 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->method('delete');
 
         $customerService = $this->_createService();
-        $customerService->deleteAddressFromCustomer(1, 2);
-    }
-
-    /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
-     * @expectedExceptionCode \Magento\Customer\Service\Entity\V1\Exception::CODE_INVALID_ADDRESS_ID
-     */
-    public function testDeleteAddressFromCustomerInvalidAddrId()
-    {
-        $customerService = $this->_createService();
-        $customerService->deleteAddressFromCustomer(1, 0);
+        try {
+            $customerService->deleteAddress(2);
+            $this->fail("Expected NoSuchEntityException not caught");
+        } catch (NoSuchEntityException $exception) {
+            $this->assertSame($exception->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY);
+            $this->assertSame(
+                $exception->getParams(),
+                [
+                    'addressId' => 2
+                ]
+            );
+        }
     }
 
-
     public function testSaveAddressesWithValidatorException()
     {
         // Setup Customer mock
@@ -720,13 +674,8 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->method('getAddresses')
             ->will($this->returnValue([]));
 
-        // Setup address mock
-        $mockAddress = $this->getMockBuilder('Magento\Customer\Model\Address')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $mockAddress->expects($this->any())
-            ->method('validate')
-            ->will($this->returnValue(['some error']));
+        // Setup address mock, no first name
+        $mockAddress = $this->_createAddress(1, '');
         $this->_addressFactoryMock->expects($this->once())
             ->method('create')
             ->will($this->returnValue($mockAddress));
@@ -746,14 +695,21 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             ->setPostcode(self::POSTCODE);
         try {
             $customerService->saveAddresses(1, [$this->_addressBuilder->create()]);
-        } catch (\Magento\Customer\Service\Entity\V1\AggregateException $ae) {
-            $addressException = $ae->getExceptions()[0];
-            $this->assertInstanceOf('\Magento\Customer\Service\Entity\V1\Exception', $addressException);
-            $this->assertInstanceOf('\Magento\Validator\ValidatorException', $addressException->getPrevious());
-            $this->assertSame('some error', $addressException->getPrevious()->getMessage());
-            return;
+            $this->fail("Expected InputException not caught");
+        } catch (InputException $exception) {
+            $this->assertSame($exception->getCode(), \Magento\Exception\InputException::INPUT_EXCEPTION);
+            $this->assertSame(
+                $exception->getParams(),
+                [
+                    [
+                        'index' => 0,
+                        'fieldName' => 'firstname',
+                        'code'      => \Magento\Exception\InputException::REQUIRED_FIELD,
+                        'value'     => null
+                    ]
+                ]
+            );
         }
-        $this->fail("Expected AggregateException not caught.");
     }
 
 
@@ -783,7 +739,8 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
             $this->_addressFactoryMock,
             $this->_converter,
             new Dto\RegionBuilder(),
-            $this->_addressBuilder
+            $this->_addressBuilder,
+            $this->_directoryData
         );
         return $customerService;
     }
@@ -819,7 +776,8 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
                     'addData', 'setData', 'setCustomerId', 'setPostIndex',
                     'setFirstname', 'load', 'save', '__sleep', '__wakeup',
                     'getDefaultAttributeCodes', 'getAttributes', 'getData',
-                    'getCustomerId', 'getParentId', 'delete', 'validate'
+                    'getCustomerId', 'getParentId', 'delete', 'validate',
+                    'getCountryModel', 'getRegionCollection', 'getSize'
                 ]
             )
             ->getMock();
@@ -835,9 +793,18 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase
         $addressMock->expects($this->any())
             ->method('getCustomerId')
             ->will($this->returnValue($customerId));
-        $addressMock->expects($this->any())
+        $addressMock->expects($this->never())
             ->method('validate')
             ->will($this->returnValue(true));
+        $addressMock->expects($this->any())
+            ->method('getCountryModel')
+            ->will($this->returnSelf());
+        $addressMock->expects($this->any())
+            ->method('getRegionCollection')
+            ->will($this->returnSelf());
+        $addressMock->expects($this->any())
+            ->method('getSize')
+            ->will($this->returnValue(0));
 
         $map = [
             ['firstname', null, $firstName],
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php
index 6a8d7cb856fa5dc103d959f78ec8817f82c6ef39..6c659d4ca5f319ba513eec33404d43cc6f6b9c9d 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php
@@ -23,6 +23,7 @@
  */
 
 namespace Magento\Customer\Service\V1;
+use Magento\Exception\InputException;
 
 /**
  * \Magento\Customer\Service\V1\CustomerService
@@ -34,36 +35,20 @@ namespace Magento\Customer\Service\V1;
  */
 class CustomerServiceTest extends \PHPUnit_Framework_TestCase
 {
-    const STREET = 'Parmer';
-    const CITY = 'Albuquerque';
-    const POSTCODE = '90014';
-    const TELEPHONE = '7143556767';
-    const REGION = 'Alabama';
-    const REGION_ID = 1;
-    const COUNTRY_ID = 'US';
-
     /** Sample values for testing */
     const ID = 1;
     const FIRSTNAME = 'Jane';
     const LASTNAME = 'Doe';
     const NAME = 'J';
     const EMAIL = 'janedoe@example.com';
-    const EMAIL_CONFIRMATION_KEY = 'blj487lkjs4confirmation_key';
-    const PASSWORD = 'password';
     const ATTRIBUTE_CODE = 'random_attr_code';
     const ATTRIBUTE_VALUE = 'random_attr_value';
-    const WEBSITE_ID = 1;
 
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\CustomerFactory
      */
     private $_customerFactoryMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\AddressFactory
-     */
-    private $_addressFactoryMock;
-
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Customer
      */
@@ -74,26 +59,11 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
      */
     private $_attributeModelMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface
-     */
-    private $_eavMetadataServiceMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Event\ManagerInterface
-     */
-    private $_eventManagerMock;
-
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\StoreManagerInterface
      */
     private $_storeManagerMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Math\Random
-     */
-    private $_mathRandomMock;
-
     /**
      * @var \Magento\Customer\Model\Converter
      */
@@ -104,17 +74,15 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
      */
     private $_storeMock;
 
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\AddressBuilder
-     */
-    private $_addressBuilder;
-
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\CustomerBuilder
      */
     private $_customerBuilder;
 
-    private $_validator;
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataService
+     */
+    private $_customerMetadataService;
 
     public function setUp()
     {
@@ -172,37 +140,11 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             )
             ->getMock();
 
-        $this->_addressFactoryMock = $this->getMockBuilder('Magento\Customer\Model\AddressFactory')
-            ->disableOriginalConstructor()
-            ->setMethods(array('create'))
-            ->getMock();
-
-        $this->_eavMetadataServiceMock =
-            $this->getMockBuilder('Magento\Customer\Service\Eav\AttributeMetadataServiceV1Interface')
-                ->disableOriginalConstructor()
-                ->getMock();
-
-        $this->_eventManagerMock =
-            $this->getMockBuilder('\Magento\Event\ManagerInterface')
-                ->disableOriginalConstructor()
-                ->getMock();
-
         $this->_attributeModelMock =
             $this->getMockBuilder('\Magento\Customer\Model\Attribute')
             ->disableOriginalConstructor()
             ->getMock();
 
-        $this->_attributeModelMock
-            ->expects($this->any())
-            ->method('getAttributeCode')
-            ->will($this->returnValue(self::ATTRIBUTE_CODE));
-
-        $this->_customerModelMock
-            ->expects($this->any())
-            ->method('getData')
-            ->with($this->equalTo(self::ATTRIBUTE_CODE))
-            ->will($this->returnValue(self::ATTRIBUTE_VALUE));
-
         $this->_customerModelMock
             ->expects($this->any())
             ->method('validate')
@@ -210,22 +152,13 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
 
         $this->_setupStoreMock();
 
-        $this->_mathRandomMock = $this->getMockBuilder('\Magento\Math\Random')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $this->_validator = $this->getMockBuilder('\Magento\Customer\Model\Metadata\Validator')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $this->_addressBuilder = new Dto\AddressBuilder(
-            new Dto\RegionBuilder());
-
         $this->_customerBuilder = new Dto\CustomerBuilder();
 
-        $customerBuilder = new Dto\CustomerBuilder();
+        $this->_converter = new \Magento\Customer\Model\Converter($this->_customerBuilder, $this->_customerFactoryMock);
 
-        $this->_converter = new \Magento\Customer\Model\Converter($customerBuilder, $this->_customerFactoryMock);
+        $this->_customerMetadataService = $this->getMockBuilder('Magento\Customer\Service\V1\CustomerMetadataService')
+            ->disableOriginalConstructor()
+            ->getMock();
     }
 
     public function testGetCustomer()
@@ -246,6 +179,17 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             )
         );
 
+        $this->_attributeModelMock
+            ->expects($this->any())
+            ->method('getAttributeCode')
+            ->will($this->returnValue(self::ATTRIBUTE_CODE));
+
+        $this->_customerModelMock
+            ->expects($this->any())
+            ->method('getData')
+            ->with($this->equalTo(self::ATTRIBUTE_CODE))
+            ->will($this->returnValue(self::ATTRIBUTE_VALUE));
+
         $this->_customerFactoryMock->expects($this->any())
             ->method('create')
             ->will($this->returnValue($this->_customerModelMock));
@@ -313,9 +257,19 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             array(
                 'getId' => self::ID,
                 'load' => $this->_customerModelMock,
+                'getEmail' => self::EMAIL,
+                'getFirstname' => self::FIRSTNAME,
+                'getLastname' => self::LASTNAME,
             )
         );
 
+        $mockAttribute = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_customerMetadataService->expects($this->any())
+            ->method('getCustomerAttributeMetadata')
+            ->will($this->returnValue($mockAttribute));
+
         // verify
         $this->_customerModelMock->expects($this->atLeastOnce())
             ->method('setData');
@@ -346,9 +300,19 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             $this->_customerModelMock,
             array(
                 'getId' => '2',
+                'getEmail' => self::EMAIL,
+                'getFirstname' => self::FIRSTNAME,
+                'getLastname' => self::LASTNAME,
             )
         );
 
+        $mockAttribute = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_customerMetadataService->expects($this->any())
+            ->method('getCustomerAttributeMetadata')
+            ->will($this->returnValue($mockAttribute));
+
         // verify
         $this->_customerModelMock->expects($this->atLeastOnce())
             ->method('setData');
@@ -378,9 +342,19 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             $this->_customerModelMock,
             array(
                 'getId' => self::ID,
+                'getEmail' => self::EMAIL,
+                'getFirstname' => self::FIRSTNAME,
+                'getLastname' => self::LASTNAME,
             )
         );
 
+        $mockAttribute = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_customerMetadataService->expects($this->any())
+            ->method('getCustomerAttributeMetadata')
+            ->will($this->returnValue($mockAttribute));
+
         // verify
         $this->_customerModelMock->expects($this->atLeastOnce())
             ->method('setData');
@@ -391,7 +365,7 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Customer\Service\Entity\V1\Exception
+     * @expectedException \Exception
      * @expectedExceptionMessage exception message
      */
     public function testSaveCustomerWithException()
@@ -414,9 +388,19 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             $this->_customerModelMock,
             array(
                 'getId' => self::ID,
+                'getEmail' => self::EMAIL,
+                'getFirstname' => self::FIRSTNAME,
+                'getLastname' => self::LASTNAME,
             )
         );
 
+        $mockAttribute = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_customerMetadataService->expects($this->any())
+            ->method('getCustomerAttributeMetadata')
+            ->will($this->returnValue($mockAttribute));
+
         $this->_customerModelMock->expects($this->once())
             ->method('save')
             ->will($this->throwException(new \Exception('exception message')));
@@ -427,6 +411,80 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
         $customerService->saveCustomer($customerEntity);
     }
 
+
+    public function testSaveCustomerWithInputException()
+    {
+        $customerData = [
+            'email' => self::EMAIL,
+            'firstname' => self::FIRSTNAME,
+            'lastname' => self::LASTNAME,
+            'create_in' => 'Admin',
+            'password' => 'password'
+        ];
+        $this->_customerBuilder->populateWithArray($customerData);
+        $customerEntity = $this->_customerBuilder->create();
+
+        $this->_customerFactoryMock->expects($this->any())
+            ->method('create')
+            ->will($this->returnValue($this->_customerModelMock));
+
+        $this->_mockReturnValue(
+            $this->_customerModelMock,
+            array(
+                'getId' => self::ID,
+                'getEmail' => 'missingAtSign',
+            )
+        );
+
+        $mockAttribute = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $mockAttribute->expects($this->atLeastOnce())
+            ->method('isRequired')
+            ->will($this->returnValue(true));
+        $this->_customerMetadataService->expects($this->any())
+            ->method('getCustomerAttributeMetadata')
+            ->will($this->returnValue($mockAttribute));
+
+        // verify
+        $customerService = $this->_createService();
+
+        try {
+            $customerService->saveCustomer($customerEntity);
+        } catch (InputException $inputException) {
+            $this->assertContains([
+                'fieldName' => 'firstname',
+                'code' => InputException::REQUIRED_FIELD,
+                'value' => null,
+            ], $inputException->getParams());
+            $this->assertContains([
+                'fieldName' => 'lastname',
+                'code' => InputException::REQUIRED_FIELD,
+                'value' => null,
+            ], $inputException->getParams());
+            $this->assertContains([
+                'fieldName' => 'email',
+                'code' => InputException::INVALID_FIELD_VALUE,
+                'value' => 'missingAtSign',
+            ], $inputException->getParams());
+            $this->assertContains([
+                'fieldName' => 'dob',
+                'code' => InputException::REQUIRED_FIELD,
+                'value' => null,
+            ], $inputException->getParams());
+            $this->assertContains([
+                'fieldName' => 'taxvat',
+                'code' => InputException::REQUIRED_FIELD,
+                'value' => null,
+            ], $inputException->getParams());
+            $this->assertContains([
+                'fieldName' => 'gender',
+                'code' => InputException::REQUIRED_FIELD,
+                'value' => null,
+            ], $inputException->getParams());
+        }
+    }
+
     /**
      * @param \PHPUnit_Framework_MockObject_MockObject $mock
      * @param array $valueMap
@@ -446,7 +504,8 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
     private function _createService()
     {
         $customerService = new CustomerService(
-            $this->_converter
+            $this->_converter,
+            $this->_customerMetadataService
         );
         return $customerService;
     }
@@ -467,5 +526,4 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase
             ->method('getStore')
             ->will($this->returnValue($this->_storeMock));
     }
-
 }
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php
index 1f58ade0380aa89fcdf35509af1787b7daec28ef..adf6fbd151fedf4155fda4bce4dbf5217eb008bb 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php
@@ -29,26 +29,7 @@ use Magento\Customer\Service\V1\Dto\AddressBuilder;
 
 class AddressTest extends \PHPUnit_Framework_TestCase
 {
-    /** Sample values for testing */
-    const ID = 14;
-    const IS_SHIPPING = true;
-    const IS_BILLING = false;
-    const COMPANY = 'Company Name';
-    const FAX = '(555) 555-5555';
-    const MIDDLENAME = 'Mid';
-    const PREFIX = 'Mr.';
-    const SUFFIX = 'Esq.';
-    const VAT_ID = 'S45';
-    const FIRSTNAME = 'Jane';
-    const LASTNAME = 'Doe';
-    const STREET_LINE_0 = '7700 W Parmer Ln';
-    const CITY = 'Austin';
-    const COUNTRY_CODE = 'US';
-    const POSTCODE = '78620';
-    const TELEPHONE = '5125125125';
-    const REGION = 'Texas';
-
-    protected $_expectedValues = [
+    private $_expectedValues = [
         'id' => 14,
         'default_shipping' => true,
         'default_billing' => false,
@@ -65,14 +46,16 @@ class AddressTest extends \PHPUnit_Framework_TestCase
         'country_id' => 'US',
         'postcode' => '78620',
         'telephone' => '5125125125',
-        'region_id' => 0,
-        'region' => 'Texas',
+        'region' => [
+            'region_id' => 0,
+            'region' => 'Texas',
+        ],
     ];
 
     /**
      * @var \Magento\Customer\Service\V1\Dto\AddressBuilder
      */
-    protected $_addressBuilder;
+    private $_addressBuilder;
 
     protected function setUp()
     {
@@ -172,7 +155,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase
         $addressBuilder->setCity($this->_expectedValues['city']);
         $addressBuilder->setCountryId($this->_expectedValues['country_id']);
         $addressBuilder->setRegion(
-            new \Magento\Customer\Service\V1\Dto\Region(['region' => $this->_expectedValues['region'],
+            new \Magento\Customer\Service\V1\Dto\Region(['region' => $this->_expectedValues['region']['region'],
                 'region_code' => ''])
         );
         $addressBuilder->setPostcode($this->_expectedValues['postcode']);
@@ -208,7 +191,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($this->_expectedValues['city'], $address->getCity());
         $this->assertEquals($this->_expectedValues['country_id'], $address->getCountryId());
         $this->assertEquals(
-            new \Magento\Customer\Service\V1\Dto\Region(['region' => $this->_expectedValues['region'],
+            new \Magento\Customer\Service\V1\Dto\Region(['region' => $this->_expectedValues['region']['region'],
                 'region_code' => '']),
             $address->getRegion()
         );
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/CustomerTest.php
index 138774bf6fcab0c245ef156a348029a524741d60..26a497f2c99b35180695fff9ba8281c969d8ba6e 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/CustomerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/CustomerTest.php
@@ -27,7 +27,7 @@ namespace Magento\Customer\Service\V1\Dto;
 /**
  * Customer
  *
- * @package Magento\Customer\Service\Entity\V1
+ * @package Magento\Customer\Service\V1\Dto
  */
 class CustomerTest extends \PHPUnit_Framework_TestCase
 {
@@ -56,7 +56,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase
     public function testSetters()
     {
         $customerData = $this->_createCustomerData();
-        $customerBuilder = new \Magento\Customer\Service\V1\Dto\CustomerBuilder();
+        $customerBuilder = new CustomerBuilder();
         $customerBuilder->populateWithArray($customerData);
 
         /** @var Customer $customer */
@@ -85,7 +85,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase
     public function testGetAttributeNotExist()
     {
         $customerData = $this->_createCustomerData();
-        $customerBuilder = new \Magento\Customer\Service\V1\Dto\CustomerBuilder();
+        $customerBuilder = new CustomerBuilder();
         $customerBuilder->populateWithArray($customerData);
         /** @var Customer $customer */
         $customer = $customerBuilder->create();
@@ -96,8 +96,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase
     public function testGetAttributes()
     {
         $customerData = $this->_createCustomerData();
-        /** @var CustomerBuilder $customerBuilder */
-        $customerBuilder = new \Magento\Customer\Service\V1\Dto\CustomerBuilder();
+        $customerBuilder = new CustomerBuilder();
         $customerBuilder->populateWithArray($customerData);
         /** @var Customer $customer */
         $customer = $customerBuilder->create();
@@ -126,10 +125,47 @@ class CustomerTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    public function testPopulateFromPrototypeVsArray()
+    {
+        $builder = new CustomerBuilder();
+        $builder->populateWithArray([
+            Customer::FIRSTNAME => self::FIRSTNAME,
+            Customer::LASTNAME  => self::LASTNAME,
+            Customer::EMAIL     => self::EMAIL,
+            Customer::ID        => self::ID,
+            'entity_id'         => self::ID,
+        ]);
+        $customerFromArray = $builder->create();
+        $builder = new CustomerBuilder();
+        $customerFromPrototype = $builder->populate($customerFromArray)->create();
+
+        $this->assertEquals($customerFromArray->__toArray(), $customerFromPrototype->__toArray());
+    }
+
+    public function testPopulateFromCustomerIdInArray()
+    {
+        $builder = new CustomerBuilder();
+        $builder->populateWithArray([
+            Customer::FIRSTNAME => self::FIRSTNAME,
+            Customer::LASTNAME  => self::LASTNAME,
+            Customer::EMAIL     => self::EMAIL,
+            'customer_id'        => self::ID,
+            'entity_id'         => self::ID,
+        ]);
+        /** @var Customer $customer */
+        $customer = $builder->create();
+
+        $this->assertEquals(self::FIRSTNAME, $customer->getFirstname());
+        $this->assertEquals(self::LASTNAME, $customer->getLastname());
+        $this->assertEquals(self::EMAIL, $customer->getEmail());
+        $this->assertEquals(self::ID, $customer->getCustomerId());
+        $this->assertEquals(self::ID, $customer->getAttribute('entity_id'));
+    }
+
     /**
      * Create customer using setters.
      *
-     * @return CustomerBuilder
+     * @return array
      */
     private function _createCustomerData()
     {
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/RegionTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/RegionTest.php
index bb323654fdd3c059e4adc0395db656a55fec42dd..f9037d4ba2c29d63b5a0d6f0529c7cd56d26cd38 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/RegionTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/RegionTest.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Test \Magento\Customer\Service\Entity\V1\Region
+ * Test \Magento\Customer\Service\V1\Dto\Region
  *
  * Magento
  *
diff --git a/dev/tests/unit/testsuite/Magento/Exception/AuthorizationExceptionTest.php b/dev/tests/unit/testsuite/Magento/Exception/AuthorizationExceptionTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..1153951eda454300fcb69adb45ec269fd6bc75d1
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Exception/AuthorizationExceptionTest.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+class AuthorizationExceptionTest extends \PHPUnit_Framework_TestCase
+{
+
+    public function testConstructor()
+    {
+        $authorizationException
+            = new AuthorizationException('No access to delete this record.', AuthorizationException::NO_RECORD_ACCESS);
+
+        $this->assertSame(AuthorizationException::NO_RECORD_ACCESS, $authorizationException->getCode());
+        $this->assertStringStartsWith('No access', $authorizationException->getMessage());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Exception/InputExceptionTest.php b/dev/tests/unit/testsuite/Magento/Exception/InputExceptionTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..fb5b4bf55e3a28f772041e393858dc089d14c46e
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Exception/InputExceptionTest.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+/**
+ * Class InputExceptionTest
+ *
+ * @package Magento\Exception
+ */
+class InputExceptionTest extends \PHPUnit_Framework_TestCase
+{
+
+    public function testConstructor()
+    {
+        $inputException = InputException::create(
+            InputException::INVALID_FIELD_RANGE,
+            'quantity',
+            -100,
+            ['minValue' => 0]
+        );
+
+        $this->assertEquals(InputException::INPUT_EXCEPTION, $inputException->getCode());
+        $this->assertStringStartsWith('One or more', $inputException->getMessage());
+        $this->assertEquals(
+            [
+                [
+                    'minValue'  => 0,
+                    'value'     => -100,
+                    'fieldName' => 'quantity',
+                    'code'      => InputException::INVALID_FIELD_RANGE,
+                ]
+            ],
+            $inputException->getParams()
+        );
+    }
+
+    public function testAddError()
+    {
+        $inputException = InputException::create(
+            InputException::INVALID_FIELD_RANGE,
+            'weight',
+            -100,
+            ['minValue' => 1]
+        );
+
+        $inputException->addError(
+            InputException::REQUIRED_FIELD,
+            'name',
+            ''
+        );
+
+        $this->assertEquals(InputException::INPUT_EXCEPTION, $inputException->getCode());
+        $this->assertStringStartsWith('One or more', $inputException->getMessage());
+        $this->assertEquals(
+            [
+                [
+                    'minValue'  => 1,
+                    'value'     => -100,
+                    'fieldName' => 'weight',
+                    'code'      => InputException::INVALID_FIELD_RANGE,
+                ],
+                [
+                    'fieldName' => 'name',
+                    'code'      => InputException::REQUIRED_FIELD,
+                    'value'     => '',
+                ]
+            ],
+            $inputException->getParams()
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Helper/FormTest.php b/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Helper/FormTest.php
index f0963f3939025f6636182e8f278e508184d02c6a..6e508551617c2b273631c56332c1355297cce5bc 100644
--- a/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Helper/FormTest.php
+++ b/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Helper/FormTest.php
@@ -80,7 +80,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
 
     public function testAddFieldsWithoutExperimentCode()
     {
-        $experimentCode = array();
+        $experimentCode = '';
         $experimentCodeId = '';
         $this->_prepareFormMock($experimentCode, $experimentCodeId);
 
diff --git a/dev/tests/unit/testsuite/Magento/Index/Model/Indexer/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Index/Model/Indexer/FactoryTest.php
deleted file mode 100644
index 1a166f51ff659d02ad347ce939d9ac4606c4efa4..0000000000000000000000000000000000000000
--- a/dev/tests/unit/testsuite/Magento/Index/Model/Indexer/FactoryTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-namespace Magento\Index\Model\Indexer;
-
-class FactoryTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Index\Model\Indexer\Factory
-     */
-    protected $_model;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_objectManagerMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_indexerMock;
-
-    protected function setUp()
-    {
-        $this->_objectManagerMock = $this->getMock('Magento\ObjectManager');
-        $this->_indexerMock = $this->getMock(
-            'Magento\Catalog\Model\Category\Indexer\Flat', array(), array(), '', false
-        );
-        $this->_model = new \Magento\Index\Model\Indexer\Factory($this->_objectManagerMock);
-    }
-
-    /**
-     * @covers \Magento\Index\Model\Indexer\Factory::create
-     */
-    public function testCreate()
-    {
-        $this->_objectManagerMock->expects($this->once())
-            ->method('create')
-            ->with('Magento_Indexer')
-            ->will($this->returnValue($this->_indexerMock));
-
-        $this->assertInstanceOf('Magento\Index\Model\Indexer\AbstractIndexer',
-            $this->_model->create('Magento_Indexer')
-        );
-    }
-
-    /**
-     * @covers \Magento\Index\Model\Indexer\Factory::create
-     */
-    public function testCreateWithNoInstance()
-    {
-        $this->assertEquals(null, $this->_model->create('Magento_Indexer'));
-    }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/DataTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/DataTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..b3fcb38acc49b9b83bca81e3a2a075c7a47149b1
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/DataTest.php
@@ -0,0 +1,145 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Indexer\Model\Config;
+
+class DataTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Indexer\Model\Config\Data
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Indexer\Model\Config\Reader|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $reader;
+
+    /**
+     * @var \Magento\Config\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $cache;
+
+    /**
+     * @var \Magento\Indexer\Model\Resource\Indexer\State\Collection|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $stateCollection;
+
+    /**
+     * @var string
+     */
+    protected $cacheId = 'indexer_config';
+
+    /**
+     * @var string
+     */
+    protected $indexers = array(
+        'indexer1' => array(),
+        'indexer3' => array(),
+    );
+
+    protected function setUp()
+    {
+        $this->reader = $this->getMock(
+            'Magento\Indexer\Model\Config\Reader', array('read'), array(), '', false
+        );
+        $this->cache = $this->getMockForAbstractClass(
+            'Magento\Config\CacheInterface', array(), '', false, false, true, array('test', 'load', 'save')
+        );
+        $this->stateCollection = $this->getMock(
+            'Magento\Indexer\Model\Resource\Indexer\State\Collection', array('getItems'), array(), '', false
+        );
+    }
+
+    public function testConstructorWithCache()
+    {
+        $this->cache->expects($this->once())
+            ->method('test')
+            ->with($this->cacheId)
+            ->will($this->returnValue(true));
+        $this->cache->expects($this->once())
+            ->method('load')
+            ->with($this->cacheId)
+            ->will($this->returnValue(serialize($this->indexers)));
+
+        $this->stateCollection->expects($this->never())
+            ->method('getItems');
+
+        $this->model = new \Magento\Indexer\Model\Config\Data(
+            $this->reader,
+            $this->cache,
+            $this->stateCollection,
+            $this->cacheId
+        );
+    }
+
+    public function testConstructorWithoutCache()
+    {
+        $this->cache->expects($this->once())
+            ->method('test')
+            ->with($this->cacheId)
+            ->will($this->returnValue(false));
+        $this->cache->expects($this->once())
+            ->method('load')
+            ->with($this->cacheId)
+            ->will($this->returnValue(false));
+
+        $this->reader->expects($this->once())
+            ->method('read')
+            ->will($this->returnValue($this->indexers));
+
+        $stateExistent = $this->getMock(
+            'Magento\Indexer\Model\Indexer\State', array('getIndexerId', '__wakeup', 'delete'), array(), '', false
+        );
+        $stateExistent->expects($this->once())
+            ->method('getIndexerId')
+            ->will($this->returnValue('indexer1'));
+        $stateExistent->expects($this->never())
+            ->method('delete');
+
+        $stateNonexistent = $this->getMock(
+            'Magento\Indexer\Model\Indexer\State', array('getIndexerId', '__wakeup', 'delete'), array(), '', false
+        );
+        $stateNonexistent->expects($this->once())
+            ->method('getIndexerId')
+            ->will($this->returnValue('indexer2'));
+        $stateNonexistent->expects($this->once())
+            ->method('delete');
+
+        $states = array(
+            $stateExistent,
+            $stateNonexistent,
+        );
+
+        $this->stateCollection->expects($this->once())
+            ->method('getItems')
+            ->will($this->returnValue($states));
+
+        $this->model = new \Magento\Indexer\Model\Config\Data(
+            $this->reader,
+            $this->cache,
+            $this->stateCollection,
+            $this->cacheId
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php
index 7652c3259ea0092acd2238366109ba981d96b840..56fe064b2a33409f265223afce305d181f3b7080 100644
--- a/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php
@@ -71,7 +71,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
 
         $entityFactory->expects($this->any())
             ->method('create')
-            ->with('Magento\Indexer\Model\Indexer')
+            ->with('Magento\Indexer\Model\IndexerInterface')
             ->will($this->returnValue($indexer));
 
         $statesFactory->expects($this->once())
@@ -79,8 +79,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($states));
 
         $config->expects($this->once())
-            ->method('getIndexerIds')
-            ->will($this->returnValue(array($indexerIdOne, $indexerIdSecond)));
+            ->method('getIndexers')
+            ->will($this->returnValue(array($indexerIdOne => 1, $indexerIdSecond => 2)));
 
         $states->expects($this->any())
             ->method('getItems')
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php
index 1c7927e5eb7b2f695c8c20e460316844f5411e3b..b6730672bef33d72b54726d8cb1444d1414d7d35 100644
--- a/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php
@@ -31,7 +31,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
     protected $model;
 
     /**
-     * @var \Magento\Indexer\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Indexer\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $configMock;
 
@@ -41,7 +41,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
     protected $actionFactoryMock;
 
     /**
-     * @var \Magento\Mview\View|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Mview\ViewInterface|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $viewMock;
 
@@ -57,16 +57,16 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->configMock = $this->getMock('Magento\Indexer\Model\Config', array('get'), array(), '', false);
+        $this->configMock = $this->getMockForAbstractClass(
+            'Magento\Indexer\Model\ConfigInterface', array(), '', false, false, true, array('getIndexer')
+        );
         $this->actionFactoryMock = $this->getMock(
             'Magento\Indexer\Model\ActionFactory', array('get'), array(), '', false
         );
-        $this->viewMock = $this->getMock(
-            'Magento\Mview\View',
-            array('load', 'getMode', 'getUpdated', 'getStatus', '__wakeup', 'getId'),
-            array(),
-            '',
-            false
+        $this->viewMock = $this->getMockForAbstractClass(
+            'Magento\Mview\ViewInterface',
+            array(), '', false, false, true,
+            array('load', 'isEnabled', 'getUpdated', 'getStatus', '__wakeup', 'getId', 'suspend', 'resume')
         );
         $this->stateFactoryMock = $this->getMock(
             'Magento\Indexer\Model\Indexer\StateFactory', array('create'), array(), '', false
@@ -91,7 +91,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
     {
         $indexId = 'indexer_id';
         $this->configMock->expects($this->once())
-            ->method('get')
+            ->method('getIndexer')
             ->with($indexId)
             ->will($this->returnValue($this->getIndexerData()));
         $this->model->load($indexId);
@@ -137,71 +137,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
         $this->assertInstanceOf('\Magento\Indexer\Model\Indexer\State', $this->model->getState());
     }
 
-    /**
-     * @param string $mode
-     * @param string $status
-     * @param bool $statusCall
-     * @param bool $stateCall
-     * @param string $result
-     * @dataProvider indexerStatusProvider
-     */
-    public function testGetStatus($mode, $status, $statusCall, $stateCall, $result)
-    {
-        $indexId = 'indexer_internal_name';
-        $this->viewMock->expects($statusCall ? $this->exactly(2) : $this->once())
-            ->method('getId')
-            ->will($this->returnValue(1));
-        $this->viewMock->expects($this->once())
-            ->method('getMode')
-            ->will($this->returnValue($mode));
-        $this->viewMock->expects($statusCall ? $this->once() : $this->never())
-            ->method('getStatus')
-            ->will($this->returnValue($status));
-
-        if ($stateCall) {
-            $stateMock = $this->getMock(
-                '\Magento\Indexer\Model\Indexer\State',
-                array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus'),
-                array(),
-                '',
-                false
-            );
-            $stateMock->expects($this->once())
-                ->method('load')
-                ->with($indexId, 'indexer_id')
-                ->will($this->returnSelf());
-            $stateMock->expects($this->never())
-                ->method('setIndexerId');
-            $stateMock->expects($this->once())
-                ->method('getId')
-                ->will($this->returnValue(1));
-            $stateMock->expects($this->once())
-                ->method('getStatus')
-                ->will($this->returnValue($status));
-            $this->stateFactoryMock->expects($this->once())
-                ->method('create')
-                ->will($this->returnValue($stateMock));
-        }
-
-        $this->loadIndexer($indexId);
-
-        $this->assertEquals($result, $this->model->getStatus());
-    }
-
-    /**
-     * @return array
-     */
-    public function indexerStatusProvider()
-    {
-        return array(
-            'enabled_working' => array('enabled', 'working', true, false, 'working'),
-            'enabled_idle'  => array('enabled', 'idle', true, true, 'idle'),
-            'disabled_working' => array('disabled', 'working', false, true, 'working'),
-            'disabled_idle' => array('disabled', 'idle', false, true, 'idle'),
-        );
-    }
-
-    public function testGetUpdated()
+    public function testGetLatestUpdated()
     {
         $checkValue = 1;
         $indexId = 'indexer_internal_name';
@@ -211,8 +147,8 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
             ->method('getId')
             ->will($this->returnValue(1));
         $this->viewMock->expects($this->once())
-            ->method('getMode')
-            ->will($this->returnValue('enabled'));
+            ->method('isEnabled')
+            ->will($this->returnValue(true));
         $this->viewMock->expects($this->any())
             ->method('getUpdated')
             ->will($this->returnValue($checkValue));
@@ -231,7 +167,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
             ->method('create')
             ->will($this->returnValue($stateMock));
 
-        $this->assertEquals($checkValue, $this->model->getUpdated());
+        $this->assertEquals($checkValue, $this->model->getLatestUpdated());
     }
 
     public function testReindexAll()
@@ -268,6 +204,14 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
             ->method('create')
             ->will($this->returnValue($stateMock));
 
+        $this->viewMock->expects($this->once())
+            ->method('isEnabled')
+            ->will($this->returnValue(true));
+        $this->viewMock->expects($this->once())
+            ->method('suspend');
+        $this->viewMock->expects($this->once())
+            ->method('resume');
+
         $actionMock = $this->getMock(
             'Magento\Indexer\Model\ActionInterface',
             array('executeFull', 'executeList', 'executeRow'),
@@ -321,6 +265,14 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
             ->method('create')
             ->will($this->returnValue($stateMock));
 
+        $this->viewMock->expects($this->once())
+            ->method('isEnabled')
+            ->will($this->returnValue(false));
+        $this->viewMock->expects($this->never())
+            ->method('suspend');
+        $this->viewMock->expects($this->once())
+            ->method('resume');
+
         $actionMock = $this->getMock(
             'Magento\Indexer\Model\ActionInterface',
             array('executeFull', 'executeList', 'executeRow'),
@@ -358,7 +310,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase
     protected function loadIndexer($indexId)
     {
         $this->configMock->expects($this->once())
-            ->method('get')
+            ->method('getIndexer')
             ->with($indexId)
             ->will($this->returnValue($this->getIndexerData()));
         $this->model->load($indexId);
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php
index 5a2025245e45d66ecdf69e415e8ecba59b729d04..20e16b719a220a01d9a8a90bddd12089e236f1f1 100644
--- a/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php
@@ -31,7 +31,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase
     protected $model;
 
     /**
-     * @var \Magento\Indexer\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Indexer\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $configMock;
 
@@ -52,7 +52,9 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->configMock = $this->getMock('Magento\Indexer\Model\Config', array('getIndexerIds'), array(), '', false);
+        $this->configMock = $this->getMockForAbstractClass(
+            'Magento\Indexer\Model\ConfigInterface', array(), '', false, false, true, array('getIndexers')
+        );
         $this->indexerFactoryMock = $this->getMock(
             'Magento\Indexer\Model\IndexerFactory', array('create'), array(), '', false
         );
@@ -78,7 +80,7 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase
         );
 
         $this->configMock->expects($this->once())
-            ->method('getIndexerIds')
+            ->method('getIndexers')
             ->will($this->returnValue($indexers));
 
         $state1Mock = $this->getMock('Magento\Indexer\Model\Indexer\State',
diff --git a/dev/tests/unit/testsuite/Magento/Mview/Config/DataTest.php b/dev/tests/unit/testsuite/Magento/Mview/Config/DataTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..0872d7ab15bedaf333a4b7f4b8112049505f0106
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/Config/DataTest.php
@@ -0,0 +1,146 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Mview\Config;
+
+class DataTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Mview\Config\Data
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Mview\Config\Reader|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $reader;
+
+    /**
+     * @var \Magento\Config\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $cache;
+
+    /**
+     * @var \Magento\Mview\View\State\CollectionInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $stateCollection;
+
+    /**
+     * @var string
+     */
+    protected $cacheId = 'mview_config';
+
+    /**
+     * @var string
+     */
+    protected $views = array(
+        'view1' => array(),
+        'view3' => array(),
+    );
+
+    protected function setUp()
+    {
+        $this->reader = $this->getMock(
+            'Magento\Mview\Config\Reader', array('read'), array(), '', false
+        );
+        $this->cache = $this->getMockForAbstractClass(
+            'Magento\Config\CacheInterface', array(), '', false, false, true, array('test', 'load', 'save')
+        );
+        $this->stateCollection = $this->getMockForAbstractClass(
+            'Magento\Mview\View\State\CollectionInterface',
+            array(), '', false, false, true, array('getItems')
+        );
+    }
+
+    public function testConstructorWithCache()
+    {
+        $this->cache->expects($this->once())
+            ->method('test')
+            ->with($this->cacheId)
+            ->will($this->returnValue(true));
+        $this->cache->expects($this->once())
+            ->method('load')
+            ->with($this->cacheId)
+            ->will($this->returnValue(serialize($this->views)));
+
+        $this->stateCollection->expects($this->never())
+            ->method('getItems');
+
+        $this->model = new \Magento\Mview\Config\Data(
+            $this->reader,
+            $this->cache,
+            $this->stateCollection,
+            $this->cacheId
+        );
+    }
+
+    public function testConstructorWithoutCache()
+    {
+        $this->cache->expects($this->once())
+            ->method('test')
+            ->with($this->cacheId)
+            ->will($this->returnValue(false));
+        $this->cache->expects($this->once())
+            ->method('load')
+            ->with($this->cacheId)
+            ->will($this->returnValue(false));
+
+        $this->reader->expects($this->once())
+            ->method('read')
+            ->will($this->returnValue($this->views));
+
+        $stateExistent = $this->getMock(
+            'Magento\Mview\Indexer\State', array('getViewId', '__wakeup', 'delete'), array(), '', false
+        );
+        $stateExistent->expects($this->once())
+            ->method('getViewId')
+            ->will($this->returnValue('view1'));
+        $stateExistent->expects($this->never())
+            ->method('delete');
+
+        $stateNonexistent = $this->getMock(
+            'Magento\Mview\Indexer\State', array('getViewId', '__wakeup', 'delete'), array(), '', false
+        );
+        $stateNonexistent->expects($this->once())
+            ->method('getViewId')
+            ->will($this->returnValue('view2'));
+        $stateNonexistent->expects($this->once())
+            ->method('delete');
+
+        $states = array(
+            $stateExistent,
+            $stateNonexistent,
+        );
+
+        $this->stateCollection->expects($this->once())
+            ->method('getItems')
+            ->will($this->returnValue($states));
+
+        $this->model = new \Magento\Mview\Config\Data(
+            $this->reader,
+            $this->cache,
+            $this->stateCollection,
+            $this->cacheId
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php
index d92dffc8c669c30af0b7cedf49807db127ea650c..621182ed32d9bcbcb2587cfffa79b5cf411ca3ae 100644
--- a/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php
+++ b/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php
@@ -47,11 +47,11 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase
      * Return array of mocked views
      *
      * @param string $method
-     * @return \Magento\Mview\View[]|\PHPUnit_Framework_MockObject_MockObject[]
+     * @return \Magento\Mview\ViewInterface[]|\PHPUnit_Framework_MockObject_MockObject[]
      */
     protected function getViews($method)
     {
-        $viewMock = $this->getMock('Magento\Mview\View', array(), array(), '', false);
+        $viewMock = $this->getMock('Magento\Mview\ViewInterface', array(), array(), '', false);
         $viewMock->expects($this->exactly(2))
             ->method($method);
         return array(
diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php
index 2d5870c89c4989c2127eaeaaa7b961f2d0503fa9..8d03b2522cdffc8f3e4c83f8bbbbb770d8ccb752 100644
--- a/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php
+++ b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php
@@ -33,12 +33,12 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
     /**
      * Mysql PDO DB adapter mock
      *
-     * @var \Magento\DB\Adapter\Pdo\Mysql
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\DB\Adapter\Pdo\Mysql
      */
     protected $connectionMock;
 
     /**
-     * @var \Magento\App\Resource
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\App\Resource
      */
     protected $resourceMock;
 
@@ -46,18 +46,22 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
     {
         $this->connectionMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array(), array(), '', false);
 
-        $this->resourceMock = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
-        $this->resourceMock->expects($this->once())
-            ->method('getConnection')
-            ->will($this->returnValue($this->connectionMock));
+        $this->resourceMock = $this->getMock(
+            'Magento\App\Resource', array('getConnection', 'getTableName'), array(), '', false, false
+        );
+        $this->mockGetConnection($this->connectionMock);
 
         $this->model = new \Magento\Mview\View\Changelog($this->resourceMock);
-        $this->model->setViewId('ViewIdTest');
     }
 
     public function testInstanceOf()
     {
-        $this->assertInstanceOf('\Magento\Mview\View\ChangelogInterface', $this->model);
+        $resourceMock = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+        $resourceMock->expects($this->once())
+            ->method('getConnection')
+            ->will($this->returnValue(true));
+        $model = new \Magento\Mview\View\Changelog($resourceMock);
+        $this->assertInstanceOf('\Magento\Mview\View\ChangelogInterface', $model);
     }
 
     /**
@@ -77,6 +81,7 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
 
     public function testGetName()
     {
+        $this->model->setViewId('ViewIdTest');
         $this->assertEquals('ViewIdTest' . '_' . \Magento\Mview\View\Changelog::NAME_SUFFIX, $this->model->getName());
     }
 
@@ -88,90 +93,79 @@ class ChangelogTest extends \PHPUnit_Framework_TestCase
     public function testGetVersionWithException()
     {
         $changelogTableName = 'viewIdtest_cl';
-        $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
-        $connection->expects($this->once())->method('isTableExists')
-            ->with($this->equalTo($changelogTableName))
-            ->will($this->returnValue(false));
+        $this->mockIsTableExists($changelogTableName, false);
+        $this->mockGetTableName();
 
-        $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
-        $resource->expects($this->once())
-            ->method('getConnection')
-            ->will($this->returnValue($connection));
-        $model = new \Magento\Mview\View\Changelog($resource);
-        $model->setViewId('viewIdtest');
         $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
-        $model->getVersion();
+        $this->model->setViewId('viewIdtest');
+        $this->model->getVersion();
     }
 
     public function testDropWithException()
     {
         $changelogTableName = 'viewIdtest_cl';
-        $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
-        $connection->expects($this->once())->method('isTableExists')
-            ->with($this->equalTo($changelogTableName))
-            ->will($this->returnValue(false));
+        $this->mockIsTableExists($changelogTableName, false);
+        $this->mockGetTableName();
 
-        $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
-        $resource->expects($this->once())
-            ->method('getConnection')
-            ->will($this->returnValue($connection));
-        $model = new \Magento\Mview\View\Changelog($resource);
-        $model->setViewId('viewIdtest');
         $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
-        $model->drop();
+        $this->model->setViewId('viewIdtest');
+        $this->model->drop();
     }
 
     public function testCreateWithException()
     {
         $changelogTableName = 'viewIdtest_cl';
-        $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
-        $connection->expects($this->once())->method('isTableExists')
-            ->with($this->equalTo($changelogTableName))
-            ->will($this->returnValue(true));
+        $this->mockIsTableExists($changelogTableName, true);
+        $this->mockGetTableName();
 
-        $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
-        $resource->expects($this->once())
-            ->method('getConnection')
-            ->will($this->returnValue($connection));
-        $model = new \Magento\Mview\View\Changelog($resource);
-        $model->setViewId('viewIdtest');
         $this->setExpectedException('Exception', "Table {$changelogTableName} already exist");
-        $model->create();
+        $this->model->setViewId('viewIdtest');
+        $this->model->create();
     }
 
     public function testGetListWithException()
     {
         $changelogTableName = 'viewIdtest_cl';
-        $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
-        $connection->expects($this->once())->method('isTableExists')
-            ->with($this->equalTo($changelogTableName))
-            ->will($this->returnValue(false));
+        $this->mockIsTableExists($changelogTableName, false);
+        $this->mockGetTableName();
 
-        $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
-        $resource->expects($this->once())
-            ->method('getConnection')
-            ->will($this->returnValue($connection));
-        $model = new \Magento\Mview\View\Changelog($resource);
-        $model->setViewId('viewIdtest');
         $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
-        $model->getList(mt_rand(1, 200), mt_rand(201, 400));
+        $this->model->setViewId('viewIdtest');
+        $this->model->getList(mt_rand(1, 200), mt_rand(201, 400));
     }
 
     public function testClearWithException()
     {
         $changelogTableName = 'viewIdtest_cl';
-        $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
-        $connection->expects($this->once())->method('isTableExists')
-            ->with($this->equalTo($changelogTableName))
-            ->will($this->returnValue(false));
+        $this->mockIsTableExists($changelogTableName, false);
+        $this->mockGetTableName();
+
+        $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
+        $this->model->setViewId('viewIdtest');
+        $this->model->clear(mt_rand(1, 200));
+    }
 
-        $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
-        $resource->expects($this->once())
+    /**
+     * @param $connection
+     */
+    protected function mockGetConnection($connection)
+    {
+        $this->resourceMock->expects($this->once())
             ->method('getConnection')
             ->will($this->returnValue($connection));
-        $model = new \Magento\Mview\View\Changelog($resource);
-        $model->setViewId('viewIdtest');
-        $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
-        $model->clear(mt_rand(1, 200));
+    }
+
+    protected function mockGetTableName()
+    {
+        $this->resourceMock->expects($this->once())
+            ->method('getTableName')
+            ->will($this->returnArgument(0));
+    }
+
+    protected function mockIsTableExists($changelogTableName, $result)
+    {
+        $this->connectionMock->expects($this->once())->method('isTableExists')
+            ->with($this->equalTo($changelogTableName))
+            ->will($this->returnValue($result));
     }
 }
diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php
index 517d618a4a25fe308a2165768155da2c17c3de99..f9bafce3668c0016b1e85ea6d5be33b8200ae3eb 100644
--- a/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php
+++ b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php
@@ -79,7 +79,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($states));
 
         $config->expects($this->once())
-            ->method('getAll')
+            ->method('getViews')
             ->will($this->returnValue(array($indexerIdOne => 1, $indexerIdSecond => 2)));
 
         $states->expects($this->any())
diff --git a/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php
index 811394055823d4d8429aafe607a93707fb024e9e..95afcaace75b1a7506f5d7caa42bd79c0fedba34 100644
--- a/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php
+++ b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php
@@ -31,7 +31,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
     protected $model;
 
     /**
-     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\Config
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\ConfigInterface
      */
     protected $configMock;
 
@@ -55,16 +55,21 @@ class ViewTest extends \PHPUnit_Framework_TestCase
      */
     protected $subscriptionFactoryMock;
 
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\App\Resource
+     */
+    protected $resourceMock;
+
     protected function setUp()
     {
-        $this->configMock = $this->getMock(
-            '\Magento\Mview\Config', array('get'), array(), '', false
+        $this->configMock = $this->getMockForAbstractClass(
+            'Magento\Mview\ConfigInterface', array(), '', false, false, true, array('getView')
         );
         $this->actionFactoryMock = $this->getMock(
-            '\Magento\Mview\ActionFactory', array('get'), array(), '', false
+            'Magento\Mview\ActionFactory', array('get'), array(), '', false
         );
         $this->stateMock = $this->getMock(
-            '\Magento\Core\Model\Mview\View\State',
+            'Magento\Core\Model\Mview\View\State',
             array('getViewId', 'loadByView', 'getVersionId', 'setVersionId',
                 'getStatus', 'setStatus', 'getMode', 'setMode', 'save', '__wakeup'),
             array(),
@@ -72,21 +77,23 @@ class ViewTest extends \PHPUnit_Framework_TestCase
             false
         );
         $this->changelogMock = $this->getMock(
-            '\Magento\Mview\View\Changelog',
+            'Magento\Mview\View\Changelog',
             array('getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList'),
             array(),
             '',
             false
         );
         $this->subscriptionFactoryMock = $this->getMock(
-            '\Magento\Mview\View\SubscriptionFactory', array('create'), array(), '', false
+            'Magento\Mview\View\SubscriptionFactory', array('create'), array(), '', false
         );
+        $this->resourceMock = $this->getMock('Magento\App\Resource', array('getTableName'), array(), '', false);
         $this->model = new View(
             $this->configMock,
             $this->actionFactoryMock,
             $this->stateMock,
             $this->changelogMock,
-            $this->subscriptionFactoryMock
+            $this->subscriptionFactoryMock,
+            $this->resourceMock
         );
     }
 
@@ -94,7 +101,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
     {
         $viewId = 'view_test';
         $this->configMock->expects($this->once())
-            ->method('get')
+            ->method('getView')
             ->with($viewId)
             ->will($this->returnValue($this->getViewData()));
         $this->assertInstanceOf('Magento\Mview\View', $this->model->load($viewId));
@@ -108,7 +115,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
     {
         $viewId = 'view_id';
         $this->configMock->expects($this->once())
-            ->method('get')
+            ->method('getView')
             ->with($viewId)
             ->will($this->returnValue($this->getViewData()));
         $this->model->load($viewId);
@@ -116,6 +123,10 @@ class ViewTest extends \PHPUnit_Framework_TestCase
 
     public function testSubscribe()
     {
+        $this->resourceMock->expects($this->once())
+            ->method('getTableName')
+            ->with('some_entity')
+            ->will($this->returnArgument(0));
         $this->stateMock->expects($this->once())
             ->method('getMode')
             ->will($this->returnValue('disabled'));
@@ -137,9 +148,17 @@ class ViewTest extends \PHPUnit_Framework_TestCase
 
     public function testUnsubscribe()
     {
+        $this->resourceMock->expects($this->once())
+            ->method('getTableName')
+            ->with('some_entity')
+            ->will($this->returnArgument(0));
         $this->stateMock->expects($this->once())
             ->method('getMode')
             ->will($this->returnValue('enabled'));
+        $this->stateMock->expects($this->once())
+            ->method('setVersionId')
+            ->with(null)
+            ->will($this->returnSelf());
         $this->stateMock->expects($this->once())
             ->method('setMode')
             ->with('disabled')
@@ -173,7 +192,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
         $this->stateMock->expects($this->once())
             ->method('getMode')
             ->will($this->returnValue('enabled'));
-        $this->stateMock->expects($this->once())
+        $this->stateMock->expects($this->exactly(2))
             ->method('getStatus')
             ->will($this->returnValue('idle'));
         $this->stateMock->expects($this->exactly(2))
@@ -225,7 +244,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
         $this->stateMock->expects($this->once())
             ->method('getMode')
             ->will($this->returnValue('enabled'));
-        $this->stateMock->expects($this->once())
+        $this->stateMock->expects($this->exactly(2))
             ->method('getStatus')
             ->will($this->returnValue('idle'));
         $this->stateMock->expects($this->exactly(2))
@@ -263,7 +282,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase
     {
         $viewId = 'view_test';
         $this->configMock->expects($this->once())
-            ->method('get')
+            ->method('getView')
             ->with($viewId)
             ->will($this->returnValue($this->getViewData()));
         $this->model->load($viewId);
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Block/System/Config/Form/Field/ExportTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Block/System/Config/Form/Field/ExportTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..fb42f6faa04a033f065390a0c672b8aba67b007f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Block/System/Config/Form/Field/ExportTest.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ * Page cache data helper
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @subpackage  unit_tests
+ * @author      Magento Core Team <core@magentocommerce.com>
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\PageCache\Block\System\Config\Form\Field;
+
+class ExportTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\PageCache\Block\System\Config\Form\Field\Export
+     */
+    protected $_model;
+
+    protected function setUp()
+    {
+        $this->_model = new StubExport();
+    }
+
+    /**
+     * Test Case for Retrieving 'Export VCL' button HTML markup
+     */
+    public function testGetElementHtml()
+    {
+        $expected = 'some test data';
+        $elementMock = $this->getMock('\Magento\Data\Form\Element\AbstractElement', array(), array(), '', false, false);
+
+        $form = $this->getMock('Magento\Data\Form', array('getLayout'), array(), '', false, false);
+        $layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false, false);
+
+        $buttonMock = $this->getMock('Magento\Backend\Block\Widget\Button', array(), array(), '', false, false);
+        $urlBuilderMock = $this->getMock('Magento\Backend\Model\Url', array('getUrl'), array(), '', false, false);
+        $urlBuilderMock->expects($this->once())
+            ->method('getUrl')
+            ->with('*/PageCache/exportVarnishConfig', array('website' => 1))
+            ->will($this->returnValue('/PageCache/exportVarnishConfig/'));
+        $this->_model->setUrlBuilder($urlBuilderMock);
+
+        $requestMock = $this->getMock('Magento\App\RequestInterface', array(), array(), '', false, false);
+        $requestMock->expects($this->once())->method('getParam')->with('website')->will($this->returnValue(1));
+
+        $mockData = $this->getMock('Magento\Object', array('toHtml'));
+        $mockData->expects($this->once())->method('toHtml')->will($this->returnValue($expected));
+
+        $buttonMock->expects($this->once())->method('getRequest')->will($this->returnValue($requestMock));
+        $buttonMock->expects($this->any())->method('setData')->will($this->returnValue($mockData));
+
+        $layoutMock->expects($this->once())->method('createBlock')->will($this->returnValue($buttonMock));
+        $form->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
+
+        $this->_model->setForm($form);
+        $this->assertEquals($expected, $this->_model->getElementHtml($elementMock));
+    }
+}
diff --git a/app/code/Magento/Customer/Service/Entity/V1/AggregateException.php b/dev/tests/unit/testsuite/Magento/PageCache/Block/System/Config/Form/Field/StubExport.php
similarity index 57%
rename from app/code/Magento/Customer/Service/Entity/V1/AggregateException.php
rename to dev/tests/unit/testsuite/Magento/PageCache/Block/System/Config/Form/Field/StubExport.php
index aff94b4f4f51576e2df6f3bb904247f8d15e4078..98662beb0c13a854eb7e86b249942bc09db820ab 100644
--- a/app/code/Magento/Customer/Service/Entity/V1/AggregateException.php
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Block/System/Config/Form/Field/StubExport.php
@@ -1,7 +1,5 @@
 <?php
 /**
- * Aggregate of multiple service exceptions
- *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -19,40 +17,39 @@
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
+ * Page cache data helper
  *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @subpackage  unit_tests
+ * @author      Magento Core Team <core@magentocommerce.com>
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Customer\Service\Entity\V1;
 
-class AggregateException extends Exception
-{
-    protected $_listOfExceptions = [];
+namespace Magento\PageCache\Block\System\Config\Form\Field;
 
+class StubExport extends \Magento\PageCache\Block\System\Config\Form\Field\Export
+{
     /**
-     * Returns the list of exceptions.
-     * @return array of exceptions that are stored
+     * Disable parent constructor
      */
-    public function getExceptions()
+    public function __construct()
     {
-        return $this->_listOfExceptions;
     }
 
-    /**
-     * Add an exception to the aggregate list.
-     * @param Exception $exception
-     */
-    public function pushException(Exception $exception)
+    public function setUrlBuilder(\Magento\UrlInterface $urlBuilder)
     {
-        $this->_listOfExceptions[] = $exception;
+        $this->_urlBuilder = $urlBuilder;
     }
-
     /**
-     * Returns true if the aggregate list contains exceptions.
-     * @return bool
+     * Retrieve element HTML markup
+     *
+     * @param \Magento\Data\Form\Element\AbstractElement $element
+     * @return string
      */
-    public function hasExceptions()
+    public function getElementHtml($element)
     {
-        return !empty($this->_listOfExceptions);
+        return $this->_getElementHtml($element);
     }
-}
\ No newline at end of file
+}
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Controller/Adminhtml/PageCacheTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Controller/Adminhtml/PageCacheTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ebec1e38b989e3fe4e993c7ee13a6e1acf467a21
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Controller/Adminhtml/PageCacheTest.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @subpackage  unit_tests
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+/**
+ * Test class for \Magento\PageCache\Controller\Adminhtml/PageCache
+ */
+namespace Magento\PageCache\Controller\Adminhtml;
+
+/**
+ * Class PageCacheTest
+ *
+ * @package Magento\PageCache\Controller\Adminhtml
+ */
+class PageCacheTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $requestMock;
+
+    /**
+     * @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $responseMock;
+
+    /**
+     * @var \Magento\App\View|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $viewMock;
+
+    /**
+     * @var \Magento\PageCache\Controller\Adminhtml\PageCache
+     */
+    protected $controller;
+
+    /**
+     * @var \Magento\App\Response\Http\FileFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $fileFactoryMock;
+
+    /**
+     * @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $configMock;
+
+    /**
+     * Set up before test
+     */
+    protected function setUp()
+    {
+        $this->fileFactoryMock = $this->getMockBuilder('Magento\App\Response\Http\FileFactory')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->configMock = $this->getMockBuilder('Magento\PageCache\Model\Config')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $contextMock = $this->getMockBuilder('Magento\Backend\App\Action\Context')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->requestMock = $this->getMockBuilder('Magento\App\Request\Http')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->responseMock = $this->getMockBuilder('Magento\App\Response\Http')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->viewMock = $this->getMockBuilder('Magento\App\View')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
+        $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
+        $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
+
+        $this->controller = new \Magento\PageCache\Controller\Adminhtml\PageCache(
+            $contextMock,
+            $this->fileFactoryMock,
+            $this->configMock
+
+        );
+    }
+
+    public function testExportVarnishConfigAction()
+    {
+        $fileContent = 'some conetnt';
+        $filename = 'varnish.vcl';
+        $responseMock = $this->getMockBuilder('Magento\App\ResponseInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->configMock->expects($this->once())
+            ->method('getVclFile')
+            ->will($this->returnValue($fileContent));
+        $this->fileFactoryMock->expects($this->once())
+            ->method('create')
+            ->with(
+                $this->equalTo($filename),
+                $this->equalTo($fileContent),
+                $this->equalTo(\Magento\App\Filesystem::VAR_DIR)
+            )
+            ->will($this->returnValue($responseMock));
+
+        $result = $this->controller->exportVarnishConfigAction();
+        $this->assertInstanceOf('Magento\App\ResponseInterface', $result);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php
index ca95859ee108e9444a96304effb97d2ad3679f84..4269686328030c4395207af85943a962dd62e055 100644
--- a/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php
@@ -37,43 +37,6 @@ namespace Magento\PageCache\Helper;
  */
 class DataTest extends \PHPUnit_Framework_TestCase
 {
-    /**
-     * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $configMock;
-
-    /**
-     * @var \Magento\PageCache\Helper\Data
-     */
-    protected $helper;
-
-    /**
-     * Set up before test
-     */
-    protected function setUp()
-    {
-        $context = $this->getMockBuilder('\Magento\App\Helper\Context')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $this->configMock = $this->getMockBuilder('\Magento\App\Config')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $this->helper = new \Magento\PageCache\Helper\Data($context, $this->configMock);
-    }
-
-    public function testGetPublicMaxAgeCache()
-    {
-        $age = 0;
-        $this->configMock->expects($this->once())
-            ->method('getValue')
-            ->with($this->equalTo(\Magento\PageCache\Helper\Data::PUBLIC_MAX_AGE_PATH))
-            ->will($this->returnValue($age));
-        $data = $this->helper->getPublicMaxAgeCache();
-        $this->assertEquals($age, $data);
-    }
-
     public function testMaxAgeCache()
     {
         // one year
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php
index 88efd47fe8a153a7e1a318225133fe60f763a210..9eef313212a24234080657d26f007532b9eb5bc1 100644
--- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php
@@ -69,11 +69,10 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
         $this->layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false);
         $this->configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
         $this->responseMock = $this->getMock('Magento\App\Response\Http', array(), array(), '', false);
-        $this->helperMock = $this->getMock('Magento\PageCache\Helper\Data', array(), array(), '', false);
         $this->versionMock = $this->getMockBuilder('Magento\PageCache\Model\Version')
             ->disableOriginalConstructor()
             ->getMock();
-        $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock, $this->helperMock, $this->versionMock);
+        $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock, $this->versionMock);
     }
 
     /**
@@ -104,7 +103,8 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
 
         $this->versionMock->expects($this->once())->method('process');
 
-        $this->plugin->afterDispatch($this->responseMock);
+        $result = $this->plugin->afterDispatch($this->responseMock);
+        $this->assertInstanceOf('Magento\App\ResponseInterface', $result);
     }
 
     /**
@@ -133,7 +133,8 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
         $this->layoutMock->expects($this->never())->method('isCacheable');
         $this->versionMock->expects($this->never())->method('process');
 
-        $this->plugin->afterDispatch($this->responseMock);
+        $result = $this->plugin->afterDispatch($this->responseMock);
+        $this->assertInstanceOf('Magento\App\ResponseInterface', $result);
     }
 
     /**
@@ -141,9 +142,14 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
      */
     public function testAfterDispatchPublicCache()
     {
-        $maxAge = 0;
+        $maxAge = 120;
         $pragma = 'cache';
-        $cacheControl = 'public, max-age=' . $maxAge;
+        $cacheControl = 'public, max-age=' . $maxAge . ', s-maxage=' . $maxAge;
+
+        $this->configMock->expects($this->once())
+            ->method('getValue')
+            ->with($this->equalTo(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL))
+            ->will($this->returnValue($maxAge));
 
         $this->layoutMock->expects($this->once())
             ->method('isPrivate')
@@ -153,8 +159,6 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
             ->method('isCacheable')
             ->will($this->returnValue(true));
 
-        $this->helperMock->expects($this->once())->method('getPublicMaxAgeCache')->will($this->returnValue(0));
-
         $this->responseMock->expects($this->at(0))
             ->method('setHeader')
             ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true));
@@ -167,6 +171,7 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
 
         $this->versionMock->expects($this->once())->method('process');
 
-        $this->plugin->afterDispatch($this->responseMock);
+        $result = $this->plugin->afterDispatch($this->responseMock);
+        $this->assertInstanceOf('Magento\App\ResponseInterface', $result);
     }
 }
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/ConfigTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..1880e32a1cfbc24be0b8d4080c44cfabe348d853
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/ConfigTest.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_PageCache
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\PageCache\Model;
+
+class ConfigTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\PageCache\Model\Config  */
+    protected $_model;
+
+    /**
+     * setUp all mocks and data function
+     */
+    public function setUp()
+    {
+        $filesystemMock = $this->getMock('Magento\App\Filesystem', ['getDirectoryRead'], [], '', false);
+        $coreStoreConfigMock = $this->getMock('Magento\Core\Model\Store\Config', ['getConfig'], [], '', false);
+        $appConfigMock = $this->getMockForAbstractClass(
+            'Magento\App\ConfigInterface',
+            [],
+            '',
+            true,
+            true,
+            true,
+            ['getValue']
+        );
+
+        $modulesDirectoryMock = $this->getMock('Magento\Filesystem\Directory\Write', [], [], '', false);
+        $filesystemMock->expects($this->once())
+            ->method('getDirectoryRead')
+            ->with(\Magento\App\Filesystem::MODULES_DIR)
+            ->will($this->returnValue($modulesDirectoryMock));
+        $modulesDirectoryMock->expects($this->once())
+            ->method('readFile')
+            ->will($this->returnValue(file_get_contents(__DIR__ . '/_files/test.vcl')));
+        $coreStoreConfigMock->expects($this->any())
+            ->method('getConfig')
+            ->will($this->returnValueMap([
+                [\Magento\PageCache\Model\Config::XML_VARNISH_PAGECACHE_BACKEND_HOST, null, 'example.com'],
+                [\Magento\PageCache\Model\Config::XML_VARNISH_PAGECACHE_BACKEND_PORT, null, '8080'],
+                [\Magento\PageCache\Model\Config::XML_VARNISH_PAGECACHE_ACCESS_LIST, null, '127.0.0.1, 192.168.0.1'],
+                [
+                    \Magento\PageCache\Model\Config::XML_VARNISH_PAGECACHE_DESIGN_THEME_REGEX,
+                    null,
+                    serialize([
+                        [
+                            'regexp' => '(?i)pattern',
+                            'value'  => 'value_for_pattern'
+                        ]
+                    ])
+                ]
+            ]));
+
+        $this->_model = new \Magento\PageCache\Model\Config($filesystemMock, $coreStoreConfigMock, $appConfigMock);
+    }
+
+    /**
+     * test for getVcl method
+     */
+    public function testGetVcl()
+    {
+        $test = $this->_model->getVclFile();
+        $this->assertEquals(file_get_contents(__DIR__ . '/_files/result.vcl'), $test);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/_files/result.vcl b/dev/tests/unit/testsuite/Magento/PageCache/Model/_files/result.vcl
new file mode 100644
index 0000000000000000000000000000000000000000..51e66c5de67ecde7c89fd21e4636ab5557044231
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/_files/result.vcl
@@ -0,0 +1,9 @@
+    example.com:8080
+
+    by ips:
+    "127.0.0.1";
+    "192.168.0.1";
+
+    if (req.http.user-agent ~ "(?pattern)?i") {
+        hash_data("value_for_pattern");
+    }
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/_files/test.vcl b/dev/tests/unit/testsuite/Magento/PageCache/Model/_files/test.vcl
new file mode 100644
index 0000000000000000000000000000000000000000..28a968fc9f1e76aecd41eac48c9730c86d5efae9
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/_files/test.vcl
@@ -0,0 +1,6 @@
+    {{ host }}:{{ port }}
+
+    by ips:
+{{ ips }}
+
+    {{ design_exceptions_code }}
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..f0ec49b266bce422c3ef326b491b5623cc4935de
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Block\Express;
+
+class FormTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Paypal\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_paypalData;
+
+    /**
+     * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_customerSession;
+
+    /**
+     * @var \Magento\Paypal\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_paypalConfig;
+
+    /**
+     * @var Form
+     */
+    protected $_model;
+
+    protected function setUp()
+    {
+        $this->_paypalData = $this->getMock('Magento\Paypal\Helper\Data', [], [], '', false);
+        $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false);
+        $this->_paypalConfig = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false);
+        $this->_paypalConfig->expects($this->once())
+            ->method('setMethod')
+            ->will($this->returnSelf());
+        $paypalConfigFactory = $this->getMock('Magento\Paypal\Model\ConfigFactory', ['create'], [], '', false);
+        $paypalConfigFactory->expects($this->once())->method('create')->will($this->returnValue($this->_paypalConfig));
+        $mark = $this->getMock('Magento\View\Element\Template', [], [], '', false);
+        $mark->expects($this->once())->method('setTemplate')->will($this->returnSelf());
+        $mark->expects($this->any())->method('__call')->will($this->returnSelf());
+        $layout = $this->getMockForAbstractClass('Magento\View\LayoutInterface');
+        $layout->expects($this->once())
+            ->method('createBlock')
+            ->with('Magento\View\Element\Template')
+            ->will($this->returnValue($mark));
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_model = $helper->getObject(
+            'Magento\Paypal\Block\Express\Form',
+            [
+                'paypalData' => $this->_paypalData,
+                'customerSession' => $this->_customerSession,
+                'paypalConfigFactory' => $paypalConfigFactory,
+                'layout' => $layout,
+            ]
+        );
+    }
+
+    /**
+     * @param bool $ask
+     * @param string|null $expected
+     * @dataProvider getBillingAgreementCodeDataProvider
+     */
+    public function testGetBillingAgreementCode($ask, $expected)
+    {
+        $this->_customerSession->expects($this->once())
+            ->method('getCustomerId')
+            ->will($this->returnValue('customer id'));
+        $this->_paypalData->expects($this->once())
+            ->method('shouldAskToCreateBillingAgreement')
+            ->with($this->identicalTo($this->_paypalConfig), 'customer id')
+            ->will($this->returnValue($ask));
+        $this->assertEquals($expected, $this->_model->getBillingAgreementCode());
+    }
+
+    public function getBillingAgreementCodeDataProvider()
+    {
+        return [
+            [true, \Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT],
+            [false, null]
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/ShortcutTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/ShortcutTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..66c8d606191735a4945b613b7e79dad3d94e8cd6
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/ShortcutTest.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Block\Express;
+
+class ShortcutTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Paypal\Block\Express\Shortcut|PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $model;
+
+    protected function setUp()
+    {
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->model = $helper->getObject('Magento\Paypal\Block\Express\Shortcut');
+    }
+
+    public function testGetAlias()
+    {
+        $this->assertEquals('product.info.addtocart.paypal', $this->model->getAlias());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..03f7466c6fa37dfced82b5d94a9df8a1748e4c66
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Block\PayflowExpress;
+
+class FormTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Paypal\Model\Config|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_paypalConfig;
+
+    /**
+     * @var Form
+     */
+    protected $_model;
+
+    protected function setUp()
+    {
+        $this->_paypalConfig = $this->getMock('Magento\Paypal\Model\Config', [], [], '', false);
+        $this->_paypalConfig->expects($this->once())
+            ->method('setMethod')
+            ->will($this->returnSelf());
+        $paypalConfigFactory = $this->getMock('Magento\Paypal\Model\ConfigFactory', ['create'], [], '', false);
+        $paypalConfigFactory->expects($this->once())->method('create')->will($this->returnValue($this->_paypalConfig));
+        $mark = $this->getMock('Magento\View\Element\Template', [], [], '', false);
+        $mark->expects($this->once())->method('setTemplate')->will($this->returnSelf());
+        $mark->expects($this->any())->method('__call')->will($this->returnSelf());
+        $layout = $this->getMockForAbstractClass('Magento\View\LayoutInterface');
+        $layout->expects($this->once())
+            ->method('createBlock')
+            ->with('Magento\View\Element\Template')
+            ->will($this->returnValue($mark));
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_model = $helper->getObject(
+            'Magento\Paypal\Block\PayflowExpress\Form',
+            [
+                'paypalConfigFactory' => $paypalConfigFactory,
+                'layout' => $layout,
+            ]
+        );
+    }
+
+    public function testGetBillingAgreementCode()
+    {
+        $this->assertFalse($this->_model->getBillingAgreementCode());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/ShortcutTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/ShortcutTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..363133de681320d773ce753ce885f8eb3bb00f42
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/ShortcutTest.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Block\PayflowExpress;
+
+class ShortcutTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Paypal\Block\PayflowExpress\Shortcut|PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $model;
+
+    protected function setUp()
+    {
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->model = $helper->getObject('Magento\Paypal\Block\PayflowExpress\Shortcut');
+    }
+
+    public function testGetAlias()
+    {
+        $this->assertEquals('product.info.addtocart.payflow', $this->model->getAlias());
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Controller/Billing/AgreementTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Controller/Billing/AgreementTest.php
similarity index 93%
rename from dev/tests/unit/testsuite/Magento/Sales/Controller/Billing/AgreementTest.php
rename to dev/tests/unit/testsuite/Magento/Paypal/Controller/Billing/AgreementTest.php
index 02002f50dded31f7ddc97fb084549a3714fb8a12..2ab47a4a2c81baf7df63091357aa2b78461dce5d 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Controller/Billing/AgreementTest.php
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Controller/Billing/AgreementTest.php
@@ -22,12 +22,12 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Sales\Controller\Billing;
+namespace Magento\Paypal\Controller\Billing;
 
 class AgreementTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Controller\Billing\Agreement
+     * @var \Magento\Paypal\Controller\Billing\Agreement
      */
     protected $_controller;
 
@@ -57,7 +57,7 @@ class AgreementTest extends \PHPUnit_Framework_TestCase
     protected $_messageManager;
 
     /**
-     * @var \Magento\Sales\Model\Billing\Agreement|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Paypal\Model\Billing\Agreement|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $_agreement;
 
@@ -66,7 +66,7 @@ class AgreementTest extends \PHPUnit_Framework_TestCase
         $this->_session = $this->getMock('Magento\Customer\Model\Session', array(), array(), '', false);
 
         $this->_agreement = $this->getMock(
-            'Magento\Sales\Model\Billing\Agreement',
+            'Magento\Paypal\Model\Billing\Agreement',
             array('load', 'getId', 'getCustomerId', 'getReferenceId', 'canCancel', 'cancel', '__wakeup'),
             array(), '', false
         );
@@ -81,7 +81,7 @@ class AgreementTest extends \PHPUnit_Framework_TestCase
         $this->_objectManager
             ->expects($this->once())
             ->method('create')
-            ->with('Magento\Sales\Model\Billing\Agreement')
+            ->with('Magento\Paypal\Model\Billing\Agreement')
             ->will($this->returnValue($this->_agreement))
         ;
 
@@ -105,7 +105,7 @@ class AgreementTest extends \PHPUnit_Framework_TestCase
 
         $title = $this->getMock('Magento\App\Action\Title', array(), array(), '', false);
 
-        $this->_controller = new \Magento\Sales\Controller\Billing\Agreement($context, $this->_registry, $title);
+        $this->_controller = new Agreement($context, $this->_registry, $title);
     }
 
     public function testCancelActionSuccess()
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..28a1cc105189650e5f475bf4dd62c961c906298c
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php
@@ -0,0 +1,148 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Helper;
+
+
+class DataTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_paymentDataMock;
+
+    /**
+     * @var \Magento\Paypal\Helper\Data
+     */
+    protected $_helper;
+
+    public function setUp()
+    {
+        $this->_paymentDataMock = $this->getMockBuilder('Magento\Payment\Helper\Data')
+            ->disableOriginalConstructor()
+            ->setMethods(array('getStoreMethods', 'getPaymentMethods'))
+            ->getMock();
+
+        $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_helper = $objectManager->getObject(
+            'Magento\Paypal\Helper\Data',
+            array(
+                'paymentData' => $this->_paymentDataMock
+            )
+        );
+    }
+
+    /**
+     * @dataProvider getBillingAgreementMethodsDataProvider
+     * @param $store
+     * @param $quote
+     * @param $paymentMethods
+     * @param $expectedResult
+     */
+    public function testGetBillingAgreementMethods($store, $quote, $paymentMethods, $expectedResult)
+    {
+        $this->_paymentDataMock->expects($this->any())
+            ->method('getStoreMethods')
+            ->with($store, $quote)
+            ->will($this->returnValue($paymentMethods));
+        $this->assertEquals($expectedResult, $this->_helper->getBillingAgreementMethods($store, $quote));
+    }
+
+    /**
+     * @dataProvider getAllBillingAgreementMethodsDataProvider
+     * @param $paymentMethods
+     * @param $expectedResult
+     */
+    public function testGetAllBillingAgreementMethods($paymentMethods, $expectedResult)
+    {
+        $this->_paymentDataMock->expects($this->any())
+            ->method('getPaymentMethods')
+            ->will($this->returnValue($paymentMethods));
+        $this->assertEquals($expectedResult, $this->_helper->getAllBillingAgreementMethods());
+    }
+
+    /**
+     * @dataProvider canManageBillingAgreementsDataProvider
+     * @param $expectedResult
+     * @param $methodInstance
+     */
+    public function testCanManageBillingAgreements($expectedResult, $methodInstance)
+    {
+        $this->assertEquals($expectedResult, $this->_helper->canManageBillingAgreements($methodInstance));
+    }
+
+    /**
+     * @return array
+     */
+    public function getBillingAgreementMethodsDataProvider()
+    {
+        $quoteMock = $this->getMockBuilder('Magento\Sales\Model\Quote')
+            ->disableOriginalConstructor()
+            ->setMethods(null);
+        $methodInterfaceMock = $this->getMockBuilder('Magento\Paypal\Model\Billing\Agreement\MethodInterface')
+            ->getMock();
+
+        return array(
+            array('1', $quoteMock, array($methodInterfaceMock), array($methodInterfaceMock)),
+            array('1', $quoteMock, array(new \StdClass()), array())
+        );
+    }
+
+    /**
+     * @return array
+     */
+    public function getAllBillingAgreementMethodsDataProvider()
+    {
+        $methodInterfaceMock = $this->getMockBuilder('Magento\Paypal\Model\Billing\Agreement\MethodInterface')
+            ->getMock();
+        return array(
+            array(
+                array(
+                    'code1' => array('model' => $methodInterfaceMock, 'title' => 'title1'),
+                    'code2' => array('title' => 'title2'),
+                    'code3' => array('model' => new \StdClass(), 'title' => 'title3'),
+                ),
+                array('code1' => 'title1')
+            ),
+            array(
+                array('code' => array('title' => 'title')),
+                array()
+            )
+        );
+    }
+
+    /**
+     * @return array
+     */
+    public function canManageBillingAgreementsDataProvider()
+    {
+        $methodInterfaceMock = $this->getMockBuilder('Magento\Paypal\Model\Billing\Agreement\MethodInterface')
+            ->getMock();
+        return array(
+            array(true, $methodInterfaceMock),
+            array(false, new \StdClass())
+        );
+    }
+}
+ 
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/Billing/Agreement/OrdersUpdaterTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/Billing/Agreement/OrdersUpdaterTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..fe6ba0fde2424895ad74f7cfc8c5074699819981
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/Billing/Agreement/OrdersUpdaterTest.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_Sales
+ * @subpackage  unit_tests
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Model\Billing\Agreement;
+
+class OrdersUpdaterTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var OrdersUpdater
+     */
+    protected $_model;
+
+    /**
+     * @var \Magento\Core\Model\Registry|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_registry;
+
+    /**
+     * @var \Magento\Paypal\Model\Resource\Billing\Agreement|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_agreementResource;
+
+    protected function setUp()
+    {
+        $this->_registry = $this->getMock('Magento\Core\Model\Registry', [], [], '', false);
+        $this->_agreementResource = $this->getMock(
+            '\Magento\Paypal\Model\Resource\Billing\Agreement',
+            [],
+            [],
+            '',
+            false
+        );
+
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_model = $helper->getObject(
+            'Magento\Paypal\Model\Billing\Agreement\OrdersUpdater',
+            ['coreRegistry' => $this->_registry, 'agreementResource' => $this->_agreementResource]
+        );
+    }
+
+    public function testUpdate()
+    {
+        $agreement = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false);
+        $argument = $this->getMock('Magento\Sales\Model\Resource\Order\Collection', [], [], '', false);
+
+        $this->_registry->expects($this->once())
+            ->method('registry')
+            ->with('current_billing_agreement')
+            ->will($this->returnValue($agreement));
+
+        $agreement->expects($this->once())->method('getId')->will($this->returnValue('agreement id'));
+        $this->_agreementResource
+            ->expects($this->once())
+            ->method('addOrdersFilter')
+            ->with($this->identicalTo($argument), 'agreement id');
+
+        $this->assertSame($argument, $this->_model->update($argument));
+    }
+
+    /**
+     * @expectedException \DomainException
+     */
+    public function testUpdateWhenBillingAgreementIsNotSet()
+    {
+        $this->_registry->expects($this->once())
+            ->method('registry')
+            ->with('current_billing_agreement')
+            ->will($this->returnValue(null));
+
+        $this->_model->update('any argument');
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/Method/AgreementTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/Method/AgreementTest.php
index ef9df2e4fcd915773cd535fcd3ac7d0b180b3e59..afc3d30a76db5cec849027f0101791627cf7b352 100644
--- a/dev/tests/unit/testsuite/Magento/Paypal/Model/Method/AgreementTest.php
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/Method/AgreementTest.php
@@ -67,7 +67,7 @@ class AgreementTest extends \PHPUnit_Framework_TestCase
             ->method('getConfig')
             ->will($this->returnValue($paypalConfigMock));
 
-        $billingAgreementMock = $this->getMockBuilder('\Magento\Sales\Model\Billing\Agreement')
+        $billingAgreementMock = $this->getMockBuilder('\Magento\Paypal\Model\Billing\Agreement')
             ->disableOriginalConstructor()
             ->setMethods(array('load', '__wakeup'))
             ->getMock();
@@ -75,7 +75,7 @@ class AgreementTest extends \PHPUnit_Framework_TestCase
             ->method('load')
             ->will($this->returnValue($billingAgreementMock));
 
-        $agreementFactoryMock = $this->getMockBuilder('\Magento\Sales\Model\Billing\AgreementFactory')
+        $agreementFactoryMock = $this->getMockBuilder('\Magento\Paypal\Model\Billing\AgreementFactory')
             ->disableOriginalConstructor()
             ->setMethods(array('create'))
             ->getMock();
diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..2ae638b57f0e702b0b59f5ec54ae5c4fb87dd899
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/ObserverTest.php
@@ -0,0 +1,262 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Paypal\Model;
+use Magento\TestFramework\Matcher\MethodInvokedAtIndex as MethodInvokedAtIndex;
+
+class ObserverTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var Observer
+     */
+    protected $_model;
+
+    /**
+     * @var \Magento\Event\Observer
+     */
+    protected $_observer;
+
+    /**
+     * @var \Magento\Object
+     */
+    protected $_event;
+
+    /**
+     * @var \Magento\AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_authorization;
+
+    /**
+     * @var \Magento\Paypal\Model\Billing\Agreement Factory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_agreementFactory;
+
+    /**
+     * @var \Magento\Checkout\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $_checkoutSession;
+
+    protected function setUp()
+    {
+        $this->_event = new \Magento\Object();
+
+        $this->_observer = new \Magento\Event\Observer();
+        $this->_observer->setEvent($this->_event);
+
+        $this->_authorization = $this->getMockForAbstractClass('Magento\AuthorizationInterface');
+        $this->_agreementFactory = $this->getMock(
+            'Magento\Paypal\Model\Billing\AgreementFactory',
+            ['create'],
+            [],
+            '',
+            false
+        );
+        $this->_checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false);
+
+        $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_model = $objectManagerHelper->getObject(
+            'Magento\Paypal\Model\Observer',
+            [
+                'authorization' => $this->_authorization,
+                'agreementFactory' => $this->_agreementFactory,
+                'checkoutSession' => $this->_checkoutSession
+            ]
+        );
+    }
+
+    public function testAddPaypalShortcuts()
+    {
+        $layoutMock = $this->getMockBuilder('Magento\Core\Model\Layout')
+            ->setMethods(array('createBlock'))
+            ->disableOriginalConstructor()
+            ->getMock();
+        $blocks = array(
+            'Magento\Paypal\Block\Express\Shortcut',
+            'Magento\Paypal\Block\PayflowExpress\Shortcut'
+        );
+
+        $blockInstances = array();
+        foreach ($blocks as $atPosition => $blockName) {
+            $block = $this->getMockBuilder($blockName)
+                ->setMethods(null)
+                ->disableOriginalConstructor()
+                ->getMock();
+
+            $blockInstances[$blockName] = $block;
+
+            $layoutMock->expects(new MethodInvokedAtIndex($atPosition))
+                ->method('createBlock')
+                ->with($blockName)
+                ->will($this->returnValue($block));
+        }
+
+        $shortcutButtonsMock = $this->getMockBuilder('Magento\Catalog\Block\ShortcutButtons')
+            ->setMethods(array('getLayout', 'addShortcut'))
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $shortcutButtonsMock->expects($this->any())
+            ->method('getLayout')
+            ->will($this->returnValue($layoutMock));
+
+        foreach ($blocks as $atPosition => $blockName) {
+            $shortcutButtonsMock->expects(new MethodInvokedAtIndex($atPosition))
+                ->method('addShortcut')
+                ->with($this->identicalTo($blockInstances[$blockName]));
+        }
+
+        $this->_event->setContainer($shortcutButtonsMock);
+        $this->_model->addPaypalShortcuts($this->_observer);
+    }
+
+    /**
+     * @param object $methodInstance
+     * @param bool $isAllowed
+     * @param bool $isAvailable
+     * @dataProvider restrictAdminBillingAgreementUsageDataProvider
+     */
+    public function testRestrictAdminBillingAgreementUsage($methodInstance, $isAllowed, $isAvailable)
+    {
+        $this->_event->setMethodInstance($methodInstance);
+        $this->_authorization->expects($this->any())
+            ->method('isAllowed')
+            ->with('Magento_Paypal::use')
+            ->will($this->returnValue($isAllowed));
+        $result = new \stdClass();
+        $result->isAvailable = true;
+        $this->_event->setResult($result);
+        $this->_model->restrictAdminBillingAgreementUsage($this->_observer);
+        $this->assertEquals($isAvailable, $result->isAvailable);
+    }
+
+    public function restrictAdminBillingAgreementUsageDataProvider()
+    {
+        return [
+            [new \stdClass(), false, true],
+            [
+                $this->getMockForAbstractClass(
+                    'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement',
+                    [],
+                    '',
+                    false
+                ),
+                true,
+                true
+            ],
+            [
+                $this->getMockForAbstractClass(
+                    'Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement',
+                    [],
+                    '',
+                    false
+                ),
+                false,
+                false
+            ],
+        ];
+    }
+
+    public function testAddBillingAgreementToSessionNoData()
+    {
+        $payment = $this->getMock('Magento\Sales\Model\Order\Payment', [], [], '', false);
+        $payment->expects($this->once())
+            ->method('__call')
+            ->with('getBillingAgreementData')
+            ->will($this->returnValue(null));
+        $this->_event->setPayment($payment);
+        $this->_agreementFactory->expects($this->never())->method('create');
+        $this->_checkoutSession->expects($this->once())
+            ->method('__call')
+            ->with('unsLastBillingAgreementReferenceId');
+        $this->_model->addBillingAgreementToSession($this->_observer);
+    }
+
+    /**
+     * @param bool $isValid
+     * @dataProvider addBillingAgreementToSessionDataProvider
+     */
+    public function testAddBillingAgreementToSession($isValid)
+    {
+        $agreement = $this->getMock('Magento\Paypal\Model\Billing\Agreement', [], [], '', false);
+        $agreement->expects($this->once())->method('isValid')->will($this->returnValue($isValid));
+        $comment = $this->getMockForAbstractClass(
+            'Magento\Core\Model\AbstractModel',
+            [],
+            '',
+            false,
+            true,
+            true,
+            ['__wakeup']
+        );
+        $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
+        $order->expects($this->once())
+            ->method('addStatusHistoryComment')
+            ->with(
+                $isValid
+                    ? __('Created billing agreement #%1.', 'agreement reference id')
+                    : __('We couldn\'t create a billing agreement for this order.')
+            )
+            ->will($this->returnValue($comment));
+        if ($isValid) {
+            $agreement->expects($this->any())
+                ->method('__call')
+                ->with('getReferenceId')
+                ->will($this->returnValue('agreement reference id'));
+            $order->expects(new MethodInvokedAtIndex(0))
+                ->method('addRelatedObject')
+                ->with($agreement);
+            $this->_checkoutSession->expects($this->once())
+                ->method('__call')
+                ->with('setLastBillingAgreementReferenceId', ['agreement reference id']);
+        } else {
+            $this->_checkoutSession->expects($this->once())
+                ->method('__call')
+                ->with('unsLastBillingAgreementReferenceId');
+            $agreement->expects($this->never())
+                ->method('__call');
+        }
+        $order->expects(new MethodInvokedAtIndex($isValid ? 1 : 0))
+            ->method('addRelatedObject')
+            ->with($comment);
+
+        $payment = $this->getMock('Magento\Sales\Model\Order\Payment', [], [], '', false);
+        $payment->expects($this->once())
+            ->method('__call')
+            ->with('getBillingAgreementData')
+            ->will($this->returnValue('not empty'));
+        $payment->expects($this->once())->method('getOrder')->will($this->returnValue($order));
+        $agreement->expects($this->once())
+            ->method('importOrderPayment')
+            ->with($payment)
+            ->will($this->returnValue($agreement));
+        $this->_event->setPayment($payment);
+        $this->_agreementFactory->expects($this->once())->method('create')->will($this->returnValue($agreement));
+        $this->_model->addBillingAgreementToSession($this->_observer);
+    }
+
+    public function addBillingAgreementToSessionDataProvider()
+    {
+        return [[true], [false]];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php
index 85ca47c0f2c91158192f3eef2fc2d057fe125d54..ea7198a2e84956aab3736242824a098c61afda3c 100644
--- a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php
+++ b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/PlaceholderTest.php
@@ -25,20 +25,73 @@ namespace Magento\Phrase\Renderer;
 
 class PlaceholderTest extends \PHPUnit_Framework_TestCase
 {
-    /**
-     * @var \Magento\Phrase\Renderer\Placeholder
-     */
+    /** @var Placeholder */
     protected $_renderer;
 
     protected function setUp()
     {
-        $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
-        $this->_renderer = $objectManagerHelper->getObject('Magento\Phrase\Renderer\Placeholder');
+        $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $this->_renderer = $objectManager->getObject('Magento\Phrase\Renderer\Placeholder');
     }
 
-    public function testRenderPlaceholder()
+    /**
+     * @param string $text The text with placeholders
+     * @param array $arguments The arguments supplying values for the placeholders
+     * @param string $result The result of Phrase rendering
+     *
+     * @dataProvider renderPlaceholderDataProvider
+     */
+    public function testRenderPlaceholder($text, array $arguments, $result)
+    {
+        $this->assertEquals($result, $this->_renderer->render($text, $arguments));
+    }
+
+    /**
+     * @return array
+     */
+    public function renderPlaceholderDataProvider()
     {
-        $result = 'text param1 param2';
-        $this->assertEquals($result, $this->_renderer->render('text %1 %2', array('param1', 'param2')));
+        return [
+            [
+                'text %1 %2',
+                ['one', 'two'],
+                'text one two'
+            ],
+            [
+                'text %one %two',
+                ['one' => 'one', 'two' => 'two'],
+                'text one two'
+            ],
+            [
+                '%one text %two %1',
+                ['one' => 'one', 'two' => 'two', 'three'],
+                'one text two three'
+            ],
+            [
+                'text %1 %two %2 %3 %five %4 %5',
+                ['one', 'two' => 'two', 'three', 'four', 'five' => 'five', 'six', 'seven'],
+                'text one two three four five six seven'
+            ],
+            [
+                '%one text %two text %three %1 %2',
+                ['two' => 'two', 'one' => 'one', 'three' => 'three', 'four', 'five'],
+                'one text two text three four five'
+            ],
+            [
+                '%three text %two text %1',
+                ['two' => 'two', 'three' => 'three', 'one'],
+                'three text two text one'
+            ],
+            [
+                'text %1 text %2 text',
+                [],
+                'text %1 text %2 text'
+            ],
+            [
+                '%1 text %2',
+                ['one'],
+                'one text %2'
+            ]
+        ];
     }
 }
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/GridTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php
similarity index 84%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/GridTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php
index e0ea3766974a3d412df6608ba76e9f89cec00f24..b9f13e125e527c5f5ff587c68935fb7a0e913d26 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php
@@ -18,16 +18,13 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile;
+namespace Magento\RecurringProfile\Block\Profile;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\Grid
+ * Test class for \Magento\RecurringProfile\Block\Profile\Grid
  */
 class GridTest extends \PHPUnit_Framework_TestCase
 {
@@ -59,9 +56,9 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $store = $this->getMockBuilder('Magento\Core\Model\Store')
             ->disableOriginalConstructor()
             ->getMock();
-        $collectionElement = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $collectionElement = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'renderData', 'getReferenceId', '__wakeup'))
+            ->setMethods(array('setStore', 'renderData', 'getReferenceId', '__wakeup'))
             ->getMock();
         $collectionElement->expects($this->once())->method('setStore')
             ->with($store)
@@ -70,7 +67,7 @@ class GridTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue(1));
         $collectionElement->expects($this->atLeastOnce())->method('renderData')
             ->will($this->returnValue(2));
-        $collection = $this->getMockBuilder('Magento\Sales\Model\Resource\Recurring\Profile\Collection')
+        $collection = $this->getMockBuilder('Magento\RecurringProfile\Model\Resource\Profile\Collection')
             ->disableOriginalConstructor()
             ->setMethods(array('addFieldToFilter', 'addFieldToSelect', 'setOrder'))
             ->getMock();
@@ -82,7 +79,7 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $collection->expects($this->once())->method('setOrder')
             ->will($this->returnValue(array($collectionElement)));
 
-        $profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
             ->setMethods(array('getCollection', 'getFieldLabel', '__wakeup'))
             ->getMock();
@@ -103,9 +100,9 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $locale->expects($this->once())->method('formatDate')
             ->will($this->returnValue('11-11-1999'));
         $block = $this->_objectManagerHelper->getObject(
-            'Magento\Sales\Block\Recurring\Profile\Grid',
+            'Magento\RecurringProfile\Block\Profile\Grid',
             array(
-                'profile' => $profile,
+                'recurringProfile' => $profile,
                 'registry' => $registry,
                 'storeManager' => $storeManager,
                 'locale' => $locale
@@ -126,14 +123,16 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $block->setLayout($layout);
 
         $this->assertNotEmpty($block->getGridColumns());
-        $expectedResult = array(new \Magento\Object(array(
-            'reference_id' => 1,
-            'reference_id_link_url' => null,
-            'state'       => 2,
-            'created_at'  => '11-11-1999',
-            'updated_at'  => '',
-            'method_code' => 2,
-        )));
+        $expectedResult = array(
+            new \Magento\Object(array(
+                'reference_id' => 1,
+                'reference_id_link_url' => null,
+                'state' => 2,
+                'created_at' => '11-11-1999',
+                'updated_at' => '',
+                'method_code' => 2,
+            ))
+        );
         $this->assertEquals($expectedResult, $block->getGridElements());
     }
 
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/Related/Orders/GridTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php
similarity index 80%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/Related/Orders/GridTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php
index 694961ca3b28b98513481e9fbd1fdfa0f05cec57..3069041d1b643a40c810f5ca7377f1b797496df4 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/Related/Orders/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php
@@ -18,16 +18,13 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\Related\Orders;
+namespace Magento\RecurringProfile\Block\Profile\Related\Orders;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\Related\Orders\Grid
+ * Test class for \Magento\RecurringProfile\Block\Profile\Related\Orders\Grid
  */
 class GridTest extends \PHPUnit_Framework_TestCase
 {
@@ -47,10 +44,15 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $customer->expects($this->once())->method('getId')->will($this->returnValue(1));
         $store = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
         $args = array(
-            'getIncrementId', 'getCreatedAt', 'getCustomerName', 'getBaseGrandTotal', 'getStatusLabel', 'getId',
+            'getIncrementId',
+            'getCreatedAt',
+            'getCustomerName',
+            'getBaseGrandTotal',
+            'getStatusLabel',
+            'getId',
             '__wakeup'
         );
-        $collectionElement = $this->getMock('Magento\Sales\Model\Recurring\Profile', $args, array(), '', false);
+        $collectionElement = $this->getMock('Magento\RecurringProfile\Model\Profile', $args, array(), '', false);
         $collectionElement->expects($this->once())->method('getIncrementId')
             ->will($this->returnValue(1));
         $collection = $this->getMock('Magento\Sales\Model\Resource\Order\Collection', array(), array(), '', false);
@@ -64,7 +66,7 @@ class GridTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($collection));
         $collection->expects($this->once())->method('getIterator')
             ->will($this->returnValue(new \ArrayIterator(array($collectionElement))));
-        $profile = $this->getMock('Magento\Sales\Model\Recurring\Profile', array(), array(), '', false);
+        $profile = $this->getMock('Magento\RecurringProfile\Model\Profile', array(), array(), '', false);
         $registry = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false);
         $registry->expects($this->at(0))
             ->method('registry')
@@ -75,7 +77,6 @@ class GridTest extends \PHPUnit_Framework_TestCase
             ->with('current_customer')
             ->will($this->returnValue($customer));
         $profile->expects($this->once())->method('setStore')->with($store)->will($this->returnValue($profile));
-        $profile->expects($this->once())->method('setLocale')->will($this->returnValue($profile));
         $storeManager = $this->getMock('Magento\Core\Model\StoreManagerInterface');
         $storeManager->expects($this->once())->method('getStore')
             ->will($this->returnValue($store));
@@ -86,7 +87,7 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $helper->expects($this->once())->method('formatCurrency')
             ->will($this->returnValue('10 USD'));
         $block = $this->_objectManagerHelper->getObject(
-            'Magento\Sales\Block\Recurring\Profile\Related\Orders\Grid',
+            'Magento\RecurringProfile\Block\Profile\Related\Orders\\Grid',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
@@ -108,17 +109,19 @@ class GridTest extends \PHPUnit_Framework_TestCase
         $block->setLayout($layout);
 
         /**
-         * @var \Magento\Sales\Block\Recurring\Profile\Related\Orders\Grid
+         * @var \Magento\RecurringProfile\Block\Profile\Related\Orders\\Grid
          */
         $this->assertNotEmpty($block->getGridColumns());
-        $expectedResult = array(new \Magento\Object(array(
-            'increment_id' => 1,
-            'increment_id_link_url' => null,
-            'created_at'  => '11-11-1999',
-            'customer_name' => null,
-            'status' => null,
-            'base_grand_total' => '10 USD'
-        )));
+        $expectedResult = array(
+            new \Magento\Object(array(
+                'increment_id' => 1,
+                'increment_id_link_url' => null,
+                'created_at' => '11-11-1999',
+                'customer_name' => null,
+                'status' => null,
+                'base_grand_total' => '10 USD'
+            ))
+        );
         $this->assertEquals($expectedResult, $block->getGridElements());
     }
 }
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/AddressTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/AddressTest.php
similarity index 86%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/AddressTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/AddressTest.php
index 4d7acff65973a108264e612b29a19265beb532f7..f9703297ac4e7308aa95de193f9a49323550edc4 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/AddressTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/AddressTest.php
@@ -18,26 +18,23 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\View\Address
+ * Test class for \Magento\RecurringProfile\Block\Profile\View\Address
  */
 class AddressTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View\Address
+     * @var \Magento\RecurringProfile\Block\Profile\View\Address
      */
     protected $_block;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
@@ -50,12 +47,11 @@ class AddressTest extends \PHPUnit_Framework_TestCase
     {
         $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
 
-        $this->_profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $this->_profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'getData', 'getInfoValue', '__wakeup'))
+            ->setMethods(array('setStore', 'getData', 'getInfoValue', '__wakeup'))
             ->getMock();
         $this->_profile->expects($this->once())->method('setStore')->will($this->returnValue($this->_profile));
-        $this->_profile->expects($this->once())->method('setLocale')->will($this->returnValue($this->_profile));
 
         $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
             ->disableOriginalConstructor()
@@ -83,7 +79,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase
             ->getMock();
 
         $this->_block = $objectManager->getObject(
-            'Magento\Sales\Block\Recurring\Profile\View\Address',
+            'Magento\RecurringProfile\Block\Profile\View\Address',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/DataTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/DataTest.php
similarity index 80%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/DataTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/DataTest.php
index 83809bc883b11135c9b97ceaebdad69286e950cf..cc325cf3e35d8a6f482df5cd232d33580c35618d 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/DataTest.php
@@ -18,26 +18,23 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\View\Data
+ * Test class for \Magento\RecurringProfile\Block\Profile\View\Data
  */
 class DataTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View\Data
+     * @var \Magento\RecurringProfile\Block\Profile\View\Data
      */
     protected $_block;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
@@ -45,12 +42,11 @@ class DataTest extends \PHPUnit_Framework_TestCase
     {
         $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
 
-        $this->_profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $this->_profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'canFetchUpdate', '__wakeup'))
+            ->setMethods(array('setStore', 'canFetchUpdate', '__wakeup'))
             ->getMock();
         $this->_profile->expects($this->once())->method('setStore')->will($this->returnValue($this->_profile));
-        $this->_profile->expects($this->once())->method('setLocale')->will($this->returnValue($this->_profile));
 
         $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
             ->disableOriginalConstructor()
@@ -73,7 +69,7 @@ class DataTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($store));
 
         $this->_block = $objectManager->getObject(
-            'Magento\Sales\Block\Recurring\Profile\View\Data',
+            'Magento\RecurringProfile\Block\Profile\View\Data',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/FeesTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/FeesTest.php
similarity index 80%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/FeesTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/FeesTest.php
index 15881b9b193fd9661f8950f6835f2376dab9bea9..d999c275efbe2a1e77f51f0c02d3b2d0e281fc4b 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/FeesTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/FeesTest.php
@@ -18,26 +18,23 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\View\Fees
+ * Test class for \Magento\RecurringProfile\Block\Profile\View\Fees
  */
 class FeesTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View\Fees
+     * @var \Magento\RecurringProfile\Block\Profile\View\Fees
      */
     protected $_block;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
@@ -45,12 +42,11 @@ class FeesTest extends \PHPUnit_Framework_TestCase
     {
         $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
 
-        $this->_profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $this->_profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'getFieldLabel', '__wakeup'))
+            ->setMethods(array('setStore', 'getFieldLabel', '__wakeup'))
             ->getMock();
         $this->_profile->expects($this->once())->method('setStore')->will($this->returnValue($this->_profile));
-        $this->_profile->expects($this->once())->method('setLocale')->will($this->returnValue($this->_profile));
 
         $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
             ->disableOriginalConstructor()
@@ -73,7 +69,7 @@ class FeesTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($store));
 
         $this->_block = $objectManager->getObject(
-            'Magento\Sales\Block\Recurring\Profile\View\Fees',
+            'Magento\RecurringProfile\Block\Profile\View\Fees',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ItemTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ItemTest.php
similarity index 79%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ItemTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ItemTest.php
index 3ad5bab78a4389d874705e9c05c91ad21bf5c0fc..f0ef714e47e962a470d1d5a7e6a9b6a6b3ad3800 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ItemTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ItemTest.php
@@ -18,26 +18,23 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\View\Item
+ * Test class for \Magento\RecurringProfile\Block\Profile\View\Item
  */
 class ItemTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View\Item
+     * @var \Magento\RecurringProfile\Block\Profile\View\Item
      */
     protected $_block;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
@@ -45,12 +42,11 @@ class ItemTest extends \PHPUnit_Framework_TestCase
     {
         $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
 
-        $this->_profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $this->_profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'getFieldLabel', '__wakeup'))
+            ->setMethods(array('setStore', 'getFieldLabel', '__wakeup'))
             ->getMock();
         $this->_profile->expects($this->once())->method('setStore')->will($this->returnValue($this->_profile));
-        $this->_profile->expects($this->once())->method('setLocale')->will($this->returnValue($this->_profile));
 
         $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
             ->disableOriginalConstructor()
@@ -73,7 +69,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($store));
 
         $this->_block = $objectManager->getObject(
-            'Magento\Sales\Block\Recurring\Profile\View\Item',
+            'Magento\RecurringProfile\Block\Profile\View\Item',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ReferenceTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ReferenceTest.php
similarity index 79%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ReferenceTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ReferenceTest.php
index c229a3767860a440aff08aa3eef801a306ff2d6a..f7d4daeff0220daf8db7a0e5d516940253aa7f6d 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ReferenceTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ReferenceTest.php
@@ -18,26 +18,23 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\View\Reference
+ * Test class for \Magento\RecurringProfile\Block\Profile\View\Reference
  */
 class ReferenceTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View\Reference
+     * @var \Magento\RecurringProfile\Block\Profile\View\Reference
      */
     protected $_block;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
@@ -45,12 +42,11 @@ class ReferenceTest extends \PHPUnit_Framework_TestCase
     {
         $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
 
-        $this->_profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $this->_profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'getFieldLabel', 'renderData', '__wakeup'))
+            ->setMethods(array('setStore', 'getFieldLabel', 'renderData', '__wakeup'))
             ->getMock();
         $this->_profile->expects($this->once())->method('setStore')->will($this->returnValue($this->_profile));
-        $this->_profile->expects($this->once())->method('setLocale')->will($this->returnValue($this->_profile));
 
         $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
             ->disableOriginalConstructor()
@@ -73,7 +69,7 @@ class ReferenceTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($store));
 
         $this->_block = $objectManager->getObject(
-            'Magento\Sales\Block\Recurring\Profile\View\Reference',
+            'Magento\RecurringProfile\Block\Profile\View\Reference',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ScheduleTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ScheduleTest.php
similarity index 79%
rename from dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ScheduleTest.php
rename to dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ScheduleTest.php
index 168457e26f5a8139fdf5b4dbc167f47f3204706b..8b836e1f6c814efe1c69d0c781b9cc8a74a6be4b 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Recurring/Profile/View/ScheduleTest.php
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/View/ScheduleTest.php
@@ -18,26 +18,23 @@
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
  *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-namespace Magento\Sales\Block\Recurring\Profile\View;
+namespace Magento\RecurringProfile\Block\Profile\View;
 
 /**
- * Test class for \Magento\Sales\Block\Recurring\Profile\View\Schedule
+ * Test class for \Magento\RecurringProfile\Block\Profile\View\Schedule
  */
 class ScheduleTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Sales\Block\Recurring\Profile\View\Schedule
+     * @var \Magento\RecurringProfile\Block\Profile\View\Schedule
      */
     protected $_block;
 
     /**
-     * @var \Magento\Sales\Model\Recurring\Profile
+     * @var \Magento\RecurringProfile\Model\Profile
      */
     protected $_profile;
 
@@ -45,12 +42,11 @@ class ScheduleTest extends \PHPUnit_Framework_TestCase
     {
         $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
 
-        $this->_profile = $this->getMockBuilder('Magento\Sales\Model\Recurring\Profile')
+        $this->_profile = $this->getMockBuilder('Magento\RecurringProfile\Model\Profile')
             ->disableOriginalConstructor()
-            ->setMethods(array('setStore', 'setLocale', 'getFieldLabel', 'renderData', '__wakeup'))
+            ->setMethods(array('setStore', 'getFieldLabel', 'renderData', '__wakeup'))
             ->getMock();
         $this->_profile->expects($this->once())->method('setStore')->will($this->returnValue($this->_profile));
-        $this->_profile->expects($this->once())->method('setLocale')->will($this->returnValue($this->_profile));
 
         $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
             ->disableOriginalConstructor()
@@ -73,7 +69,7 @@ class ScheduleTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($store));
 
         $this->_block = $objectManager->getObject(
-            'Magento\Sales\Block\Recurring\Profile\View\Schedule',
+            'Magento\RecurringProfile\Block\Profile\View\Schedule',
             array(
                 'registry' => $registry,
                 'storeManager' => $storeManager,
diff --git a/dev/tests/unit/testsuite/Magento/RecurringProfile/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Model/ObserverTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..4ca2571757ad6fdb18ccddb3c969dfc666f44237
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Model/ObserverTest.php
@@ -0,0 +1,159 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\RecurringProfile\Model;
+
+class ObserverTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\View\Element\BlockFactory
+     */
+    protected $_blockFactory;
+
+    /**
+     * @var \Magento\Event\Observer
+     */
+    protected $_observer;
+
+    /**
+     * @var \Magento\RecurringProfile\Model\Observer
+     */
+    protected $_testModel;
+
+    /**
+     * @var \Magento\RecurringProfile\Block\Fields
+     */
+    protected $_fieldsBlock;
+
+    /**
+     * @var \Magento\RecurringProfile\Model\RecurringProfileFactory
+     */
+    protected $_profileFactory;
+
+    /**
+     * @var \Magento\Event
+     */
+    protected $_event;
+
+    protected function setUp()
+    {
+        $this->_blockFactory = $this->getMock(
+            'Magento\View\Element\BlockFactory', ['createBlock'], [], '', false
+        );
+        $this->_observer = $this->getMock('Magento\Event\Observer', [], [], '', false);
+        $this->_fieldsBlock = $this->getMock(
+            '\Magento\RecurringProfile\Block\Fields', ['getFieldLabel'], [], '', false
+        );
+        $this->_profileFactory = $this->getMock(
+            '\Magento\RecurringProfile\Model\RecurringProfileFactory', ['create'], [], '', false
+        );
+
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+
+        $this->_testModel = $helper->getObject('Magento\RecurringProfile\Model\Observer', [
+            'blockFactory' => $this->_blockFactory,
+            'profileFactory' => $this->_profileFactory,
+            'fields' => $this->_fieldsBlock
+        ]);
+
+        $this->_event = $this->getMock(
+            'Magento\Event', ['getProductElement', 'getProduct', 'getResult', 'getBuyRequest'], [], '', false
+        );
+
+        $this->_observer->expects($this->any())->method('getEvent')->will($this->returnValue($this->_event));
+    }
+
+    public function testPrepareProductRecurringProfileOptions()
+    {
+        $profile = $this->getMock(
+            'Magento\Object',
+            [
+                'setStory',
+                'importBuyRequest',
+                'importProduct',
+                'exportStartDatetime',
+                'exportScheduleInfo',
+                'getFieldLabel'
+            ],
+            [],
+            '',
+            false
+        );
+        $profile->expects($this->once())->method('exportStartDatetime')->will($this->returnValue('date'));
+        $profile->expects($this->any())->method('setStore')->will($this->returnValue($profile));
+        $profile->expects($this->once())->method('importBuyRequest')->will($this->returnValue($profile));
+        $profile->expects($this->once())->method('exportScheduleInfo')
+            ->will($this->returnValue([new \Magento\Object(['title' => 'Title', 'schedule' => 'schedule'])]));
+
+        $this->_fieldsBlock->expects($this->once())->method('getFieldLabel')->will($this->returnValue('Field Label'));
+
+        $this->_profileFactory->expects($this->once())->method('create')->will($this->returnValue($profile));
+
+        $product = $this->getMock('Magento\Object', ['isRecurring', 'addCustomOption'], [], '', false);
+        $product->expects($this->once())->method('isRecurring')->will($this->returnValue(true));
+
+        $infoOptions = [
+            ['label' => 'Field Label', 'value' => 'date'],
+            ['label' => 'Title', 'value' => 'schedule']
+        ];
+
+        $product->expects($this->at(2))->method('addCustomOption')->with(
+            'additional_options',
+            serialize($infoOptions)
+        );
+
+        $this->_event->expects($this->any())->method('getProduct')->will($this->returnValue($product));
+
+        $this->_testModel->prepareProductRecurringProfileOptions($this->_observer);
+    }
+
+    public function testRenderRecurringProfileForm()
+    {
+        $blockMock = $this->getMock(
+            'Magento\View\Element\BlockInterface',
+            [
+                'setNameInLayout', 'setParentElement', 'setProductEntity', 'toHtml', 'addFieldMap',
+                'addFieldDependence', 'addConfigOptions'
+            ]
+        );
+        $map = [
+            ['Magento\RecurringProfile\Block\Adminhtml\Profile\Edit\Form', [], $blockMock],
+            ['Magento\Backend\Block\Widget\Form\Element\Dependence', [], $blockMock]
+        ];
+        $profileElement = $this->getMock('Magento\Data\Form\Element\AbstractElement', [], [], '', false);
+        $this->_event->expects($this->once())->method('getProductElement')->will($this->returnValue($profileElement));
+        $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false);
+        $this->_event->expects($this->once())->method('getProduct')->will($this->returnValue($product));
+        $this->_blockFactory->expects($this->any())->method('createBlock')->will($this->returnValueMap($map));
+        $blockMock->expects($this->any())->method('setNameInLayout');
+        $blockMock->expects($this->once())->method('setParentElement')->with($profileElement);
+        $blockMock->expects($this->once())->method('setProductEntity')->with($product);
+        $blockMock->expects($this->exactly(2))->method('toHtml')->will($this->returnValue('html'));
+        $blockMock->expects($this->once())->method('addConfigOptions')->with(['levels_up' => 2]);
+        $result = new \StdClass();
+        $this->_event->expects($this->once())->method('getResult')->will($this->returnValue($result));
+        $this->_testModel->addFieldsToProductEditForm($this->_observer);
+        $this->assertEquals('htmlhtml', $result->output);
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/RecurringProfile/Model/PeriodUnitsTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Model/PeriodUnitsTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..014dd010a11ac0d818f330a2ec14f69a0dbb5272
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Model/PeriodUnitsTest.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\RecurringProfile\Model;
+
+use Magento\TestFramework\Helper\ObjectManager;
+
+class PeriodUnitsTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var \Magento\RecurringProfile\Model\PeriodUnits */
+    protected $object;
+
+    protected function setUp()
+    {
+        $objectManager = new ObjectManager($this);
+        $this->object = $objectManager->getObject('Magento\RecurringProfile\Model\PeriodUnits');
+    }
+
+    public function testToOptionArray()
+    {
+        $this->assertEquals(
+            [
+                'day' => 'Day',
+                'week' => 'Week',
+                'semi_month' => 'Two Weeks',
+                'month' => 'Month',
+                'year' => 'Year',
+            ],
+            $this->object->toOptionArray()
+        );
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Billing/Agreement/OrdersUpdaterTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Billing/Agreement/OrdersUpdaterTest.php
deleted file mode 100644
index 54a1829c903b2d1b3cd4863c6e86a7a45aa24f2e..0000000000000000000000000000000000000000
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Billing/Agreement/OrdersUpdaterTest.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    Magento
- * @package     Magento_Sales
- * @subpackage  unit_tests
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-namespace Magento\Sales\Model\Billing\Agreement;
-
-class OrdersUpdaterTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Sales\Model\Billing\Agreement\OrdersUpdater
-     */
-    protected $_object;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_registryMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_argumentMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_agreementMock;
-
-    protected function setUp()
-    {
-        $this->_argumentMock = $this->getMock(
-            'Magento\Sales\Model\Resource\Order\Grid\Collection',
-            array(),
-            array(),
-            '',
-            false
-        );
-
-        $this->_agreementMock = $this->getMock(
-            'Magento\Sales\Model\Billing\Agreement',
-            array('getId', '__wakeup'),
-            array(),
-            '',
-            false
-        );
-
-        $this->_registryMock = $this->getMock(
-            'Magento\Core\Model\Registry',
-            array(),
-            array(),
-            '',
-            false
-        );
-
-        $this->_object = new \Magento\Sales\Model\Billing\Agreement\OrdersUpdater($this->_registryMock);
-    }
-
-    /**
-     * @covers \Magento\Sales\Model\Billing\Agreement\OrdersUpdater::update
-     */
-    public function testUpdate()
-    {
-        $this->_argumentMock->expects($this->once())
-            ->method('addBillingAgreementsFilter')
-            ->with(1);
-
-        $this->_registryMock->expects($this->once())
-            ->method('registry')
-            ->with('current_billing_agreement')
-            ->will($this->returnValue($this->_agreementMock));
-
-        $this->_agreementMock->expects($this->once())->method('getId')->will($this->returnValue(1));
-
-        $this->_object->update($this->_argumentMock);
-    }
-
-    /**
-     * @covers \Magento\Sales\Model\Billing\Agreement\OrdersUpdater::update
-     * @expectedException \DomainException
-     */
-    public function testUpdateWhenBillingAgreementIsNotSet()
-    {
-        $this->_argumentMock->expects($this->never())
-            ->method('addBillingAgreementsFilter');
-
-        $this->_agreementMock->expects($this->never())->method('getId');
-
-        $this->_registryMock->expects($this->once())
-            ->method('registry')
-            ->with('current_billing_agreement')
-            ->will($this->returnValue(null));
-
-        $this->_object->update($this->_argumentMock);
-    }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/BillingAgreementTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/BillingAgreementTest.php
deleted file mode 100644
index 98cd3bbd70f9ab520c194487b607da7b1a9abaef..0000000000000000000000000000000000000000
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/BillingAgreementTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-namespace Magento\Sales\Model\Observer\Backend;
-
-class BillingAgreementTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Sales\Model\Observer\Backend\BillingAgreement
-     */
-    protected $_model;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_authorizationMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_observerMock;
-
-    protected function setUp()
-    {
-        $this->_authorizationMock = $this->getMock('Magento\AuthorizationInterface');
-        $this->_observerMock = $this->getMock('Magento\Event\Observer', array(), array(), '', false);
-        $this->_model = new \Magento\Sales\Model\Observer\Backend\BillingAgreement(
-            $this->_authorizationMock
-        );
-    }
-
-    public function testDispatchIfMethodInterfaceNotAgreement()
-    {
-        $event = $this->getMock('Magento\Event', array('getMethodInstance'), array(), '', false);
-        $this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($event));
-        $event->expects($this->once())->method('getMethodInstance')->will($this->returnValue('some incorrect value'));
-        $event->expects($this->never())->method('isAvailable');
-        $this->_model->dispatch($this->_observerMock);
-    }
-
-    public function testDispatchIfMethodInterfaceAgreement()
-    {
-        $event = $this->getMock('Magento\Event', array('getMethodInstance', 'getResult'), array(), '', false);
-        $this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($event));
-        $methodInstance = $this->getMock('Magento\Paypal\Model\Method\Agreement', array(), array(), '', false);
-        $event->expects($this->once())->method('getMethodInstance')->will($this->returnValue($methodInstance));
-        $this->_authorizationMock->expects(
-            $this->once())->method('isAllowed')->with('Magento_Sales::use')->will($this->returnValue(false)
-        );
-        $result = new \StdClass();
-        $event->expects($this->once())->method('getResult')->will($this->returnValue($result));
-        $this->_model->dispatch($this->_observerMock);
-        $this->assertFalse($result->isAvailable);
-    }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/RecurringProfile/FormRendererTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/RecurringProfile/FormRendererTest.php
deleted file mode 100644
index 43ddabb2f863381dbcea89473840c3c4b31ba2f2..0000000000000000000000000000000000000000
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Observer/Backend/RecurringProfile/FormRendererTest.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
- */
-
-namespace Magento\Sales\Model\Observer\Backend\RecurringProfile;
-
-class FormRendererTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * @var \Magento\Sales\Model\Observer\Backend\RecurringProfile\FormRenderer
-     */
-    protected $_model;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_blockFactoryMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $_observerMock;
-
-    protected function setUp()
-    {
-        $this->_blockFactoryMock = $this->getMock(
-            'Magento\View\Element\BlockFactory', array('createBlock'), array(), '', false
-        );
-        $this->_observerMock = $this->getMock('Magento\Event\Observer', array(), array(), '', false);
-        $this->_model = new \Magento\Sales\Model\Observer\Backend\RecurringProfile\FormRenderer(
-            $this->_blockFactoryMock
-        );
-    }
-
-    public function testRender()
-    {
-        $blockMock = $this->getMock(
-            'Magento\View\Element\BlockInterface',
-            array(
-                'setNameInLayout', 'setParentElement', 'setProductEntity', 'toHtml', 'addFieldMap',
-                'addFieldDependence', 'addConfigOptions'
-            )
-        );
-        $map = array(
-            array('Magento\Sales\Block\Adminhtml\Recurring\Profile\Edit\Form', array(), $blockMock),
-            array('Magento\Backend\Block\Widget\Form\Element\Dependence', array(), $blockMock)
-
-        );
-        $event = $this->getMock(
-            'Magento\Event', array('getProductElement', 'getProduct', 'getResult'), array(), '', false
-        );
-        $this->_observerMock->expects($this->any())->method('getEvent')->will($this->returnValue($event));
-        $profileElement = $this->getMock('Magento\Data\Form\Element\AbstractElement', array(), array(), '', false);
-        $event->expects($this->once())->method('getProductElement')->will($this->returnValue($profileElement));
-        $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false);
-        $event->expects($this->once())->method('getProduct')->will($this->returnValue($product));
-        $this->_blockFactoryMock->expects($this->any())->method('createBlock')->will($this->returnValueMap($map));
-        $blockMock->expects($this->any())->method('setNameInLayout');
-        $blockMock->expects($this->once())->method('setParentElement')->with($profileElement);
-        $blockMock->expects($this->once())->method('setProductEntity')->with($product);
-        $blockMock->expects($this->exactly(2))->method('toHtml')->will($this->returnValue('html'));
-        $blockMock->expects($this->once())->method('addConfigOptions')->with(array('levels_up' => 2));
-        $result = new \StdClass();
-        $event->expects($this->once())->method('getResult')->will($this->returnValue($result));
-        $this->_model->render($this->_observerMock);
-        $this->assertEquals('htmlhtml', $result->output);
-    }
-}
diff --git a/dev/tests/unit/testsuite/Magento/ShellTest.php b/dev/tests/unit/testsuite/Magento/ShellTest.php
index e2b1fafdcbec60f22f2eb646d47e1c5ca2a4532c..464fa84d7d08901af6fd178e2ac73461f9440065 100644
--- a/dev/tests/unit/testsuite/Magento/ShellTest.php
+++ b/dev/tests/unit/testsuite/Magento/ShellTest.php
@@ -29,6 +29,16 @@ namespace Magento;
 
 class ShellTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @var \Magento\OSInfo|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $osInfo;
+
+    public function setUp()
+    {
+        $this->osInfo = $this->getMockBuilder('Magento\OSInfo')->disableOriginalConstructor()->getMock();
+    }
+
     /**
      * Test that a command with input arguments returns an expected result
      *
@@ -52,7 +62,7 @@ class ShellTest extends \PHPUnit_Framework_TestCase
      */
     public function testExecute($command, $commandArgs, $expectedResult)
     {
-        $this->_testExecuteCommand(new \Magento\Shell(), $command, $commandArgs, $expectedResult);
+        $this->_testExecuteCommand(new \Magento\Shell($this->osInfo), $command, $commandArgs, $expectedResult);
     }
 
     /**
@@ -74,7 +84,7 @@ class ShellTest extends \PHPUnit_Framework_TestCase
                 ->with($expectedLogMessage, \Zend_Log::INFO)
             ;
         }
-        $this->_testExecuteCommand(new \Magento\Shell($logger), $command, $commandArgs, $expectedResult);
+        $this->_testExecuteCommand(new \Magento\Shell($this->osInfo, $logger), $command, $commandArgs, $expectedResult);
     }
 
     public function executeDataProvider()
@@ -108,7 +118,7 @@ class ShellTest extends \PHPUnit_Framework_TestCase
      */
     public function testExecuteFailure()
     {
-        $shell = new \Magento\Shell();
+        $shell = new \Magento\Shell($this->osInfo);
         $shell->execute('non_existing_command');
     }
 
diff --git a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php
index b6267278d1d003658753bab2334bd33e2249e5f3..02c628ff446942163247efc7b3044f6da51ba863 100644
--- a/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php
+++ b/dev/tests/unit/testsuite/Magento/User/Model/UserTest.php
@@ -84,7 +84,7 @@ class UserTest extends \PHPUnit_Framework_TestCase
         $coreRegistry = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false);
 
         $eventManagerMock = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false);
-        $objectFactoryMock = $this->getMock('Magento\Validator\Composite\VarienObjectFactory', array('create'),
+        $objectFactoryMock = $this->getMock('Magento\Validator\ObjectFactory', array('create'),
             array(), '', false);
         $roleFactoryMock = $this->getMock('Magento\User\Model\RoleFactory', array('create'),
             array(), '', false);
@@ -103,7 +103,7 @@ class UserTest extends \PHPUnit_Framework_TestCase
             'registry' => $coreRegistry,
             'resource' => $this->_resourceMock,
             'resourceCollection' => $this->_collectionMock,
-            'validatorCompositeFactory' => $objectFactoryMock,
+            'validatorObjectFactory' => $objectFactoryMock,
             'roleFactory' => $roleFactoryMock,
             'emailInfoFactory' => $emailFactoryMock,
             'mailerFactory' => $mailerFactoryMock,
diff --git a/dev/tests/unit/testsuite/Magento/Validator/Composite/VarienObjectTest.php b/dev/tests/unit/testsuite/Magento/Validator/ObjectTest.php
similarity index 95%
rename from dev/tests/unit/testsuite/Magento/Validator/Composite/VarienObjectTest.php
rename to dev/tests/unit/testsuite/Magento/Validator/ObjectTest.php
index 3c4e20713236ec9befa1885ffacc5a0407a3aa4e..b10bbe8a171797614d4439f3f767f39f1d57cf6b 100644
--- a/dev/tests/unit/testsuite/Magento/Validator/Composite/VarienObjectTest.php
+++ b/dev/tests/unit/testsuite/Magento/Validator/ObjectTest.php
@@ -22,18 +22,18 @@
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
-namespace Magento\Validator\Composite;
+namespace Magento\Validator;
 
-class VarienObjectTest extends \PHPUnit_Framework_TestCase
+class ObjectTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Validator\Composite\VarienObject
+     * @var \Magento\Validator\Object
      */
     protected $_model;
 
     protected function setUp()
     {
-        $this->_model = new \Magento\Validator\Composite\VarienObject();
+        $this->_model = new \Magento\Validator\Object();
 
         $fieldOneExactValue = new \Zend_Validate_Identical('field_one_value');
         $fieldOneExactValue->setMessage("'field_one' does not match expected value");
diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/PreProcessor/CompositeTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/PreProcessor/CompositeTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..cf9f2360cbe8fc090e678baca90778bb8df6055f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/View/Asset/PreProcessor/CompositeTest.php
@@ -0,0 +1,187 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\View\Asset\PreProcessor;
+
+use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
+
+class CompositeTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\View\Asset\PreProcessor\Composite
+     */
+    protected $composite;
+
+    /** @var ObjectManagerHelper */
+    protected $objectManagerHelper;
+
+    /** @var \Magento\View\Asset\PreProcessorFactory|\PHPUnit_Framework_MockObject_MockObject */
+    protected $preProcessorFactoryMock;
+
+    /**
+     * @var array
+     */
+    protected $callMap = [];
+
+    protected function setUp()
+    {
+        $this->preProcessorFactoryMock = $this->getMock('Magento\View\Asset\PreProcessorFactory', [], [], '', false);
+        $this->objectManagerHelper = new ObjectManagerHelper($this);
+    }
+
+    /**
+     * @param array $params
+     * @param array $preProcessorsConfig
+     * @param array $createMap
+     * @param string $expectedResult
+     * @dataProvider processDataProvider
+     */
+    public function testProcess($params, $preProcessorsConfig, $createMap, $expectedResult)
+    {
+        $this->composite = $this->objectManagerHelper->getObject(
+            'Magento\View\Asset\PreProcessor\Composite',
+            [
+                'preProcessorFactory' => $this->preProcessorFactoryMock,
+                'preProcessorsConfig' => $preProcessorsConfig
+            ]
+        );
+
+        $targetDir = $this->getMock($params['targetDirectory'], array(), array(), '', false);
+
+        foreach ($createMap as $className) {
+            $this->callMap[$className] = $this->getMock($className, array('process'), array(), '', false);
+            $this->callMap[$className]->expects($this->once())
+                ->method('process')
+                ->with(
+                    $this->equalTo($params['filePath']),
+                    $this->equalTo($params['params']),
+                    $this->equalTo($targetDir),
+                    $this->equalTo($params['sourcePath'])
+                )
+                ->will($this->returnValue($expectedResult));
+        }
+
+        $this->preProcessorFactoryMock->expects($this->any())
+            ->method('create')
+            ->will($this->returnCallback(array($this, 'createProcessor')));
+
+        $result = $this->composite->process(
+            $params['filePath'],
+            $params['params'],
+            $targetDir,
+            $params['sourcePath']
+        );
+        $this->assertEquals($expectedResult, $result);
+    }
+
+    /**
+     * Create pre-processor callback
+     *
+     * @param string $className
+     * @return \Magento\View\Asset\PreProcessor\PreProcessorInterface[]
+     */
+    public function createProcessor($className)
+    {
+        return $this->callMap[$className];
+    }
+
+    /**
+     * @return array
+     */
+    public function processDataProvider()
+    {
+        return [
+            'list of processors for css' => [
+                'params' => [
+                    'filePath' => '/some/file/path.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => 'result_source_path'
+                ],
+                'preProcessorsConfig' => [
+                    'css_preprocessor' => [
+                        'class' => 'Magento\Css\PreProcessor\Composite',
+                        'asset_type' => 'css'
+                    ],
+                    'css_preprocessor2' => [
+                        'class' => 'Magento\Css\PreProcessor\Composite2',
+                        'asset_type' => 'css'
+                    ],
+                ],
+                'createMap' => [
+                    'Magento\Css\PreProcessor\Composite',
+                    'Magento\Css\PreProcessor\Composite2'
+                ],
+                'expectedResult' => 'result_source_path'
+            ],
+            'one processor for css' => [
+                'params' => [
+                    'filePath' => '/some/file/path_one.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => 'result_source_path_one'
+                ],
+                'preProcessorsConfig' => [
+                    'css_preprocessor' => [
+                        'class' => 'Magento\Css\PreProcessor\Composite',
+                        'asset_type' => 'css'
+                    ],
+                ],
+                'createMap' => [
+                    'Magento\Css\PreProcessor\Composite',
+                ],
+                'expectedResult' => 'result_source_path_one'
+            ],
+            'one processor for css with no result' => [
+                'params' => [
+                    'filePath' => '/some/file/path_one.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => null
+                ],
+                'preProcessorsConfig' => [
+                    'css_preprocessor' => [
+                        'class' => 'Magento\Css\PreProcessor\Composite',
+                        'asset_type' => 'css'
+                    ],
+                ],
+                'createMap' => [
+                    'Magento\Css\PreProcessor\Composite',
+                ],
+                'expectedResult' => null
+            ],
+            'no processors' => [
+                'params' => [
+                    'filePath' => '/some/file/path.css',
+                    'params' => ['theme' => 'some_theme', 'area' => 'frontend'],
+                    'targetDirectory' => 'Magento\Filesystem\Directory\WriteInterface',
+                    'sourcePath' => null
+                ],
+                'preProcessorsConfig' => [],
+                'createMap' => [],
+                'expectedResult' => null
+            ],
+        ];
+    }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php
index 7f69c2728663b0d425dc79a04844b2d1bcee10c1..ad2d62a1ff9b7b78f2aba26eb8a2ca18c20568f8 100644
--- a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php
+++ b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php
@@ -33,7 +33,121 @@ class IndexTest extends \PHPUnit_Framework_TestCase
     {
         $this->assertInstanceOf(
             'Magento\Catalog\Controller\Product\View\ViewInterface',
-            $this->getMock('Magento\Wishlist\Controller\Index', array(), array(), '', false)
+            $this->getMock('Magento\Wishlist\Controller\Index', [], [], '', false)
         );
     }
+
+    public function testCartAction()
+    {
+        $request = $this->getMock('Magento\App\Request\Http', [], [], '', false);
+        $response = $this->getMock('Magento\App\Response\Http', [], [], '', false);
+
+        $wishlistItem = $this->getMock('Magento\Object',
+            ['load', 'getId', 'mergeBuyRequest', 'addToCart', 'getProduct'],
+            [],
+            '',
+            false
+        );
+        $wishlistItem->expects($this->once())->method('load')->will($this->returnValue($wishlistItem));
+        $wishlistItem->expects($this->once())->method('getId')->will($this->returnValue(1));
+        $wishlistItem->expects($this->once())->method('getProduct')->will($this->returnValue($wishlistItem));
+
+        $objectManager = $this->getMock('Magento\ObjectManager');
+
+        $locale = $this->getMock('Magento\Core\Model\Locale', [], [], '', false);
+
+        $optionCollection  = $this->getMock(
+            'Magento\Wishlist\Model\Resource\Item\Option\Collection',
+            ['addItemFilter', 'getOptionsByItem'],
+            [],
+            '',
+            false
+        );
+        $optionCollection->expects($this->once())->method('addItemFilter')->will($this->returnValue($optionCollection));
+
+        $cart = $this->getMock('Magento\Checkout\Model\Cart', ['save', 'getQuote', 'collectTotals'], [], '', false);
+        $cart->expects($this->once())->method('save')->will($this->returnValue($cart));
+        $cart->expects($this->any())->method('getQuote')->will($this->returnValue($cart));
+
+        $option = $this->getMock('Magento\Object', ['getCollection'], [], '', false);
+        $option->expects($this->once())->method('getCollection')->will($this->returnValue($optionCollection));
+
+        $product = $this->getMock('Magento\Catalog\Helper\Product', [], [], '', false);
+
+        $escaper = $this->getMock('Magento\Excaper', ['escapeHtml'], [], '', false);
+
+        $wishlistHelper = $this->getMock('Magento\Wishlist\Helper\Data',
+            ['getShouldRedirectToCart', 'calculate', 'getCustomer'],
+            [],
+            '',
+            false
+        );
+
+        $mapGet = [
+            ['Magento\Core\Model\LocaleInterface', $locale],
+            ['Magento\Checkout\Model\Cart', $cart],
+            ['Magento\Catalog\Helper\Product', $product],
+            ['Magento\Escaper', $escaper],
+            ['Magento\Wishlist\Helper\Data', $wishlistHelper],
+            ['Magento\Checkout\Helper\Cart', $wishlistHelper]
+        ];
+
+        $mapCreate = [
+            ['Magento\Wishlist\Model\Item', [], $wishlistItem],
+            ['Magento\Wishlist\Model\Item\Option', [], $option]
+        ];
+
+        $objectManager->expects($this->any())->method('get')->will($this->returnValueMap($mapGet));
+        $objectManager->expects($this->any())->method('create')->will($this->returnValueMap($mapCreate));
+
+        $controller = $this->_factory($request, $response, $objectManager);
+
+        $controller->cartAction();
+    }
+
+    /**
+     * Create the tested object
+     *
+     * @param \Magento\App\Request\Http $request
+     * @param \Magento\App\Response\Http|null $response
+     * @param \Magento\ObjectManager|null $objectManager
+     * @return \Magento\Wishlist\Controller\Index
+     */
+    protected function _factory($request, $response = null, $objectManager = null)
+    {
+        if (!$response) {
+            /** @var $response \Magento\App\ResponseInterface */
+            $response = $this->getMock('Magento\App\Response\Http', [], [], '', false);
+            $response->headersSentThrowsException = false;
+        }
+        if (!$objectManager) {
+            $objectManager = new \Magento\ObjectManager\ObjectManager();
+        }
+        $rewriteFactory = $this->getMock('Magento\Core\Model\Url\RewriteFactory', ['create'], [], '', false);
+        $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
+        $varienFront = $helper->getObject('Magento\App\FrontController',
+            ['rewriteFactory' => $rewriteFactory]
+        );
+
+        $arguments = [
+            'request' => $request,
+            'response' => $response,
+            'objectManager' => $objectManager,
+            'frontController' => $varienFront,
+        ];
+        $context = $helper->getObject('Magento\Backend\App\Action\Context', $arguments);
+
+        $wishlistModel = $this->getMock('\Magento\Wishlist\Model\Wishlist', [], [], '', false);
+
+        $coreRegistry = $this->getMock('\Magento\Core\Model\Registry', ['registry'], [], '', false);
+        $coreRegistry->expects($this->once())->method('registry')->will($this->returnValue($wishlistModel));
+
+        $messageManager = $this->getMock('\Magento\Message\Manager', [], [], '', false);
+
+        return $helper->getObject('Magento\Wishlist\Controller\Index', [
+            'context' => $context,
+            'coreRegistry' => $coreRegistry,
+            'messageManager' => $messageManager
+        ]);
+    }
 }
diff --git a/dev/tools/Magento/Tools/Migration/Acl/log/MenuIdToAclId.log b/dev/tools/Magento/Tools/Migration/Acl/log/MenuIdToAclId.log
index fa5d0b606e17477755d71867c0a21199b841f4b3..4e4e09bcc85720547615eb6c3b73675736fe76a4 100644
--- a/dev/tools/Magento/Tools/Migration/Acl/log/MenuIdToAclId.log
+++ b/dev/tools/Magento/Tools/Migration/Acl/log/MenuIdToAclId.log
@@ -1 +1 @@
-{"Magento_Banner::cms_magento_banner":"Magento_Banner::magento_banner","Magento_CatalogEvent::catalog_magento_catalogevent":"Magento_Catalog::categories","Magento_CatalogEvent::catalog_magento_catalogevent_events":"Magento_CatalogEvent::events","Magento_VersionsCms::cms_enterprise_page":"Magento_Cms::page","Magento_VersionsCms::cms_enterprise_page_page":"Magento_Cms::page","Magento_VersionsCms::cms_enterprise_page_hierarchy":"Magento_VersionsCms::hierarchy","Magento_CustomerSegment::customer_customersegment":"Magento_CustomerSegment::customersegment","Magento_CustomerSegment::report_customers_segment":"Magento_CustomerSegment::segment","Magento_CustomerCustomAttributes::customer_attributes":"Magento_CustomerCustomAttributes::attributes","Magento_CustomerCustomAttributes::customer_attributes_customer_attributes":"Magento_CustomerCustomAttributes::customer_attributes","Magento_CustomerCustomAttributes::customer_attributes_customer_address_attributes":"Magento_CustomerCustomAttributes::customer_address_attributes","Magento_GiftCardAccount::customer_giftcardaccount":"Magento_GiftCardAccount::customer_giftcardaccount","Magento_GiftRegistry::customer_magento_giftregistry":"Magento_GiftRegistry::customer_magento_giftregistry","Magento_GiftWrapping::sales_magento_giftwrapping":"Magento_GiftWrapping::magento_giftwrapping","Magento_ScheduledImportExport::system_convert_enterprise_scheduled_operation":"Magento_ScheduledImportExport::enterprise_scheduled_operation","Magento_Invitation::customer_magento_invitation":"Magento_Invitation::magento_invitation","Magento_Invitation::report_magento_invitation":"Magento_Invitation::report_magento_invitation","Magento_Invitation::report_magento_invitation_general":"Magento_Invitation::report_magento_invitation","Magento_Invitation::report_magento_invitation_customer":"Magento_Invitation::report_magento_invitation","Magento_Invitation::report_magento_invitation_order":"Magento_Invitation::report_magento_invitation","Magento_Logging::system_magento_logging":"Magento_Logging::magento_logging","Magento_Logging::system_magento_logging_events":"Magento_Logging::magento_logging_events","Magento_Logging::system_magento_logging_backups":"Magento_Logging::backups","Magento_Pci::system_crypt_key":"Magento_Pci::crypt_key","Magento_Pci::system_acl_locks":"Magento_Pci::locks","Magento_Reminder::promo_reminder":"Magento_Reminder::magento_reminder","Magento_Reward::customer_reward":"Magento_Reward::rates","Magento_Rma::sales_magento_rma":"Magento_Rma::magento_rma","Magento_Rma::sales_magento_rma_rma":"Magento_Rma::magento_rma","Magento_Rma::sales_magento_rma_rma_item_attribute":"Magento_Rma::magento_rma","Magento_SalesArchive::sales_archive":"Magento_SalesArchive::archive","Magento_SalesArchive::sales_archive_orders":"Magento_SalesArchive::orders","Magento_SalesArchive::sales_archive_invoices":"Magento_SalesArchive::invoices","Magento_SalesArchive::sales_archive_shipments":"Magento_SalesArchive::shipments","Magento_SalesArchive::sales_archive_creditmemos":"Magento_SalesArchive::creditmemos","Magento_TargetRule::catalog_targetrule":"Magento_TargetRule::targetrule","Magento_MultipleWishlist::report_customers_wishlist":"Magento_MultipleWishlist::wishlist","Magento_AdminNotification::system_adminnotification":"Magento_AdminNotification::adminnotification","Magento_Adminhtml::dashboard":"Magento_Adminhtml::dashboard","Magento_Adminhtml::system":"Magento_Adminhtml::system","Magento_Adminhtml::system_myaccount":"Magento_Adminhtml::myaccount","Magento_Adminhtml::system_tools":"Magento_Adminhtml::tools","Magento_Adminhtml::system_design":"Magento_Adminhtml::design","Magento_Adminhtml::system_design_schedule":"Magento_Adminhtml::schedule","Magento_Adminhtml::system_currency":"Magento_CurrencySymbol::system_currency","Magento_Adminhtml::system_email_template":"Magento_Email::template","Magento_Adminhtml::system_variable":"Magento_Adminhtml::variable","Magento_Adminhtml::system_cache":"Magento_Adminhtml::cache","Magento_Adminhtml::system_store":"Magento_Adminhtml::store","Magento_Adminhtml::system_config":"Magento_Adminhtml::config","Magento_Backup::system_tools_backup":"Magento_Backup::backup","Magento_CatalogRule::promo":"Magento_CatalogRule::promo","Magento_CatalogRule::promo_catalog":"Magento_CatalogRule::promo_catalog","Magento_CatalogSearch::catalog_search":"Magento_CatalogSearch::search","Magento_Catalog::catalog":"Magento_Catalog::catalog","Magento_Catalog::catalog_products":"Magento_Catalog::products","Magento_Catalog::catalog_categories":"Magento_Catalog::categories","Magento_Catalog::catalog_attributes":"Magento_Catalog::catalog_attributes","Magento_Catalog::catalog_attributes_attributes":"Magento_Catalog::attributes_attributes","Magento_Catalog::catalog_attributes_sets":"Magento_Catalog::sets","Magento_Catalog::catalog_urlrewrite":"Magento_Catalog::urlrewrite","Magento_Checkout::sales_checkoutagreement":"Magento_Checkout::checkoutagreement","Magento_Cms::cms":"Magento_Cms::cms","Magento_Cms::cms_page":"Magento_Cms::page","Magento_Cms::cms_block":"Magento_Cms::block","Magento_Connect::system_extensions":"Magento_Adminhtml::extensions","Magento_Connect::system_extensions_local":"Magento_Adminhtml::local","Magento_Connect::system_extensions_custom":"Magento_Adminhtml::custom","Magento_CurrencySymbol::system_currency_rates":"Magento_CurrencySymbol::currency_rates","Magento_CurrencySymbol::system_currency_symbols":"Magento_CurrencySymbol::symbols","Magento_Customer::customer":"Magento_Customer::customer","Magento_Customer::customer_manage":"Magento_Customer::manage","Magento_Customer::customer_group":"Magento_Customer::group","Magento_Customer::customer_online":"Magento_Customer::online","Magento_DesignEditor::system_design_editor":"Magento_DesignEditor::editor","Magento_Downloadable::report_products_downloads":"Magento_Reports::downloads","Magento_GoogleShopping::catalog_googleshopping":"Magento_GoogleShopping::googleshopping","Magento_GoogleShopping::catalog_googleshopping_types":"Magento_GoogleShopping::types","Magento_GoogleShopping::catalog_googleshopping_items":"Magento_GoogleShopping::items","Magento_ImportExport::system_convert_import":"Magento_ImportExport::import","Magento_ImportExport::system_convert_export":"Magento_ImportExport::export","Magento_Index::system_index":"Magento_Index::index","Magento_Newsletter::newsletter":"Magento_Newsletter::admin_newsletter","Magento_Newsletter::newsletter_template":"Magento_Newsletter::template","Magento_Newsletter::newsletter_queue":"Magento_Newsletter::queue","Magento_Newsletter::newsletter_subscriber":"Magento_Newsletter::subscriber","Magento_Newsletter::newsletter_problem":"Magento_Newsletter::problem","Magento_Paypal::report_salesroot_paypal_settlement_reports":"Magento_Paypal::paypal_settlement_reports","Magento_Poll::cms_poll":"Magento_Poll::poll","Magento_Reports::report":"Magento_Reports::report","Magento_Reports::report_salesroot":"Magento_Reports::salesroot","Magento_Reports::report_salesroot_sales":"Magento_Reports::salesroot_sales","Magento_Reports::report_salesroot_tax":"Magento_Reports::tax","Magento_Reports::report_salesroot_invoiced":"Magento_Reports::invoiced","Magento_Reports::report_salesroot_shipping":"Magento_Reports::shipping","Magento_Reports::report_salesroot_refunded":"Magento_Reports::refunded","Magento_Reports::report_salesroot_coupons":"Magento_Reports::coupons","Magento_Reports::report_shopcart":"Magento_Reports::shopcart","Magento_Reports::report_shopcart_product":"Magento_Reports::product","Magento_Reports::report_shopcart_abandoned":"Magento_Reports::abandoned","Magento_Reports::report_products":"Magento_Reports::report_products","Magento_Reports::report_products_bestsellers":"Magento_Reports::bestsellers","Magento_Reports::report_products_sold":"Magento_Reports::sold","Magento_Reports::report_products_viewed":"Magento_Reports::viewed","Magento_Reports::report_products_lowstock":"Magento_Reports::lowstock","Magento_Reports::report_customers":"Magento_Reports::customers","Magento_Reports::report_customers_accounts":"Magento_Reports::accounts","Magento_Reports::report_customers_totals":"Magento_Reports::totals","Magento_Reports::report_customers_orders":"Magento_Reports::customers_orders","Magento_Reports::report_search":"Magento_Reports::report_search","Magento_Reports::report_statistics":"Magento_Reports::statistics","Magento_Review::catalog_reviews_ratings":"Magento_Review::reviews_ratings","Magento_Review::catalog_reviews_ratings_reviews":"Magento_Review::reviews","Magento_Review::catalog_reviews_ratings_ratings":"Magento_Rating::ratings","Magento_Review::catalog_reviews_ratings_reviews_pending":"Magento_Review::pending","Magento_Review::catalog_reviews_ratings_reviews_all":"Magento_Review::reviews_all","Magento_Review::report_review":"Magento_Reports::review","Magento_Review::report_review_customer":"Magento_Reports::review_customer","Magento_Review::report_review_product":"Magento_Reports::review_product","Magento_SalesRule::promo_quote":"Magento_SalesRule::quote","Magento_Sales::sales":"Magento_Sales::sales","Magento_Sales::sales_order":"Magento_Sales::sales_order","Magento_Sales::sales_invoice":"Magento_Sales::sales_invoice","Magento_Sales::sales_shipment":"Magento_Sales::shipment","Magento_Sales::sales_creditmemo":"Magento_Sales::sales_creditmemo","Magento_Sales::sales_transactions":"Magento_Sales::transactions","Magento_Sales::sales_recurring_profile":"Magento_Sales::recurring_profile","Magento_Sales::sales_billing_agreement":"Magento_Sales::billing_agreement","Magento_Sales::system_order_statuses":"Magento_Sales::order_statuses","Magento_Sitemap::catalog_sitemap":"Magento_Sitemap::sitemap","Magento_Tax::sales_tax":"Magento_Tax::sales_tax","Magento_Tax::sales_tax_rules":"Magento_Tax::rules","Magento_Tax::sales_tax_rates":"Magento_Tax::tax_rates","Magento_Tax::sales_tax_import_export":"Magento_Tax::import_export","Magento_Tax::sales_tax_classes_customer":"Magento_Tax::classes_customer","Magento_Tax::sales_tax_classes_product":"Magento_Tax::classes_product","Magento_User::system_acl":"Magento_User::acl","Magento_User::system_acl_users":"Magento_User::acl_users","Magento_User::system_acl_roles":"Magento_User::acl_roles","Magento_Widget::cms_widget_instance":"Magento_Widget::widget_instance"}
+{"Magento_Banner::cms_magento_banner":"Magento_Banner::magento_banner","Magento_CatalogEvent::catalog_magento_catalogevent":"Magento_Catalog::categories","Magento_CatalogEvent::catalog_magento_catalogevent_events":"Magento_CatalogEvent::events","Magento_VersionsCms::cms_enterprise_page":"Magento_Cms::page","Magento_VersionsCms::cms_enterprise_page_page":"Magento_Cms::page","Magento_VersionsCms::cms_enterprise_page_hierarchy":"Magento_VersionsCms::hierarchy","Magento_CustomerSegment::customer_customersegment":"Magento_CustomerSegment::customersegment","Magento_CustomerSegment::report_customers_segment":"Magento_CustomerSegment::segment","Magento_CustomerCustomAttributes::customer_attributes":"Magento_CustomerCustomAttributes::attributes","Magento_CustomerCustomAttributes::customer_attributes_customer_attributes":"Magento_CustomerCustomAttributes::customer_attributes","Magento_CustomerCustomAttributes::customer_attributes_customer_address_attributes":"Magento_CustomerCustomAttributes::customer_address_attributes","Magento_GiftCardAccount::customer_giftcardaccount":"Magento_GiftCardAccount::customer_giftcardaccount","Magento_GiftRegistry::customer_magento_giftregistry":"Magento_GiftRegistry::customer_magento_giftregistry","Magento_GiftWrapping::sales_magento_giftwrapping":"Magento_GiftWrapping::magento_giftwrapping","Magento_ScheduledImportExport::system_convert_enterprise_scheduled_operation":"Magento_ScheduledImportExport::enterprise_scheduled_operation","Magento_Invitation::customer_magento_invitation":"Magento_Invitation::magento_invitation","Magento_Invitation::report_magento_invitation":"Magento_Invitation::report_magento_invitation","Magento_Invitation::report_magento_invitation_general":"Magento_Invitation::report_magento_invitation","Magento_Invitation::report_magento_invitation_customer":"Magento_Invitation::report_magento_invitation","Magento_Invitation::report_magento_invitation_order":"Magento_Invitation::report_magento_invitation","Magento_Logging::system_magento_logging":"Magento_Logging::magento_logging","Magento_Logging::system_magento_logging_events":"Magento_Logging::magento_logging_events","Magento_Logging::system_magento_logging_backups":"Magento_Logging::backups","Magento_Pci::system_crypt_key":"Magento_Pci::crypt_key","Magento_Pci::system_acl_locks":"Magento_Pci::locks","Magento_Reminder::promo_reminder":"Magento_Reminder::magento_reminder","Magento_Reward::customer_reward":"Magento_Reward::rates","Magento_Rma::sales_magento_rma":"Magento_Rma::magento_rma","Magento_Rma::sales_magento_rma_rma":"Magento_Rma::magento_rma","Magento_Rma::sales_magento_rma_rma_item_attribute":"Magento_Rma::magento_rma","Magento_SalesArchive::sales_archive":"Magento_SalesArchive::archive","Magento_SalesArchive::sales_archive_orders":"Magento_SalesArchive::orders","Magento_SalesArchive::sales_archive_invoices":"Magento_SalesArchive::invoices","Magento_SalesArchive::sales_archive_shipments":"Magento_SalesArchive::shipments","Magento_SalesArchive::sales_archive_creditmemos":"Magento_SalesArchive::creditmemos","Magento_TargetRule::catalog_targetrule":"Magento_TargetRule::targetrule","Magento_MultipleWishlist::report_customers_wishlist":"Magento_MultipleWishlist::wishlist","Magento_AdminNotification::system_adminnotification":"Magento_AdminNotification::adminnotification","Magento_Adminhtml::dashboard":"Magento_Adminhtml::dashboard","Magento_Adminhtml::system":"Magento_Adminhtml::system","Magento_Adminhtml::system_myaccount":"Magento_Adminhtml::myaccount","Magento_Adminhtml::system_tools":"Magento_Adminhtml::tools","Magento_Adminhtml::system_design":"Magento_Adminhtml::design","Magento_Adminhtml::system_design_schedule":"Magento_Adminhtml::schedule","Magento_Adminhtml::system_currency":"Magento_CurrencySymbol::system_currency","Magento_Adminhtml::system_email_template":"Magento_Email::template","Magento_Adminhtml::system_variable":"Magento_Adminhtml::variable","Magento_Adminhtml::system_cache":"Magento_Adminhtml::cache","Magento_Adminhtml::system_store":"Magento_Adminhtml::store","Magento_Adminhtml::system_config":"Magento_Adminhtml::config","Magento_Backup::system_tools_backup":"Magento_Backup::backup","Magento_CatalogRule::promo":"Magento_CatalogRule::promo","Magento_CatalogRule::promo_catalog":"Magento_CatalogRule::promo_catalog","Magento_CatalogSearch::catalog_search":"Magento_CatalogSearch::search","Magento_Catalog::catalog":"Magento_Catalog::catalog","Magento_Catalog::catalog_products":"Magento_Catalog::products","Magento_Catalog::catalog_categories":"Magento_Catalog::categories","Magento_Catalog::catalog_attributes":"Magento_Catalog::catalog_attributes","Magento_Catalog::catalog_attributes_attributes":"Magento_Catalog::attributes_attributes","Magento_Catalog::catalog_attributes_sets":"Magento_Catalog::sets","Magento_Catalog::catalog_urlrewrite":"Magento_Catalog::urlrewrite","Magento_Checkout::sales_checkoutagreement":"Magento_Checkout::checkoutagreement","Magento_Cms::cms":"Magento_Cms::cms","Magento_Cms::cms_page":"Magento_Cms::page","Magento_Cms::cms_block":"Magento_Cms::block","Magento_Connect::system_extensions":"Magento_Adminhtml::extensions","Magento_Connect::system_extensions_local":"Magento_Adminhtml::local","Magento_Connect::system_extensions_custom":"Magento_Adminhtml::custom","Magento_CurrencySymbol::system_currency_rates":"Magento_CurrencySymbol::currency_rates","Magento_CurrencySymbol::system_currency_symbols":"Magento_CurrencySymbol::symbols","Magento_Customer::customer":"Magento_Customer::customer","Magento_Customer::customer_manage":"Magento_Customer::manage","Magento_Customer::customer_group":"Magento_Customer::group","Magento_Customer::customer_online":"Magento_Customer::online","Magento_DesignEditor::system_design_editor":"Magento_DesignEditor::editor","Magento_Downloadable::report_products_downloads":"Magento_Reports::downloads","Magento_GoogleShopping::catalog_googleshopping":"Magento_GoogleShopping::googleshopping","Magento_GoogleShopping::catalog_googleshopping_types":"Magento_GoogleShopping::types","Magento_GoogleShopping::catalog_googleshopping_items":"Magento_GoogleShopping::items","Magento_ImportExport::system_convert_import":"Magento_ImportExport::import","Magento_ImportExport::system_convert_export":"Magento_ImportExport::export","Magento_Index::system_index":"Magento_Index::index","Magento_Newsletter::newsletter":"Magento_Newsletter::admin_newsletter","Magento_Newsletter::newsletter_template":"Magento_Newsletter::template","Magento_Newsletter::newsletter_queue":"Magento_Newsletter::queue","Magento_Newsletter::newsletter_subscriber":"Magento_Newsletter::subscriber","Magento_Newsletter::newsletter_problem":"Magento_Newsletter::problem","Magento_Paypal::report_salesroot_paypal_settlement_reports":"Magento_Paypal::paypal_settlement_reports","Magento_Poll::cms_poll":"Magento_Poll::poll","Magento_Reports::report":"Magento_Reports::report","Magento_Reports::report_salesroot":"Magento_Reports::salesroot","Magento_Reports::report_salesroot_sales":"Magento_Reports::salesroot_sales","Magento_Reports::report_salesroot_tax":"Magento_Reports::tax","Magento_Reports::report_salesroot_invoiced":"Magento_Reports::invoiced","Magento_Reports::report_salesroot_shipping":"Magento_Reports::shipping","Magento_Reports::report_salesroot_refunded":"Magento_Reports::refunded","Magento_Reports::report_salesroot_coupons":"Magento_Reports::coupons","Magento_Reports::report_shopcart":"Magento_Reports::shopcart","Magento_Reports::report_shopcart_product":"Magento_Reports::product","Magento_Reports::report_shopcart_abandoned":"Magento_Reports::abandoned","Magento_Reports::report_products":"Magento_Reports::report_products","Magento_Reports::report_products_bestsellers":"Magento_Reports::bestsellers","Magento_Reports::report_products_sold":"Magento_Reports::sold","Magento_Reports::report_products_viewed":"Magento_Reports::viewed","Magento_Reports::report_products_lowstock":"Magento_Reports::lowstock","Magento_Reports::report_customers":"Magento_Reports::customers","Magento_Reports::report_customers_accounts":"Magento_Reports::accounts","Magento_Reports::report_customers_totals":"Magento_Reports::totals","Magento_Reports::report_customers_orders":"Magento_Reports::customers_orders","Magento_Reports::report_search":"Magento_Reports::report_search","Magento_Reports::report_statistics":"Magento_Reports::statistics","Magento_Review::catalog_reviews_ratings":"Magento_Review::reviews_ratings","Magento_Review::catalog_reviews_ratings_reviews":"Magento_Review::reviews","Magento_Review::catalog_reviews_ratings_ratings":"Magento_Rating::ratings","Magento_Review::catalog_reviews_ratings_reviews_pending":"Magento_Review::pending","Magento_Review::catalog_reviews_ratings_reviews_all":"Magento_Review::reviews_all","Magento_Review::report_review":"Magento_Reports::review","Magento_Review::report_review_customer":"Magento_Reports::review_customer","Magento_Review::report_review_product":"Magento_Reports::review_product","Magento_SalesRule::promo_quote":"Magento_SalesRule::quote","Magento_Sales::sales":"Magento_Sales::sales","Magento_Sales::sales_order":"Magento_Sales::sales_order","Magento_Sales::sales_invoice":"Magento_Sales::sales_invoice","Magento_Sales::sales_shipment":"Magento_Sales::shipment","Magento_Sales::sales_creditmemo":"Magento_Sales::sales_creditmemo","Magento_Sales::sales_transactions":"Magento_Sales::transactions","Magento_Sales::sales_recurring_profile":"Magento_Sales::recurring_profile","Magento_Paypal::paypal_billing_agreement":"Magento_Paypal::billing_agreement","Magento_Sales::system_order_statuses":"Magento_Sales::order_statuses","Magento_Sitemap::catalog_sitemap":"Magento_Sitemap::sitemap","Magento_Tax::sales_tax":"Magento_Tax::sales_tax","Magento_Tax::sales_tax_rules":"Magento_Tax::rules","Magento_Tax::sales_tax_rates":"Magento_Tax::tax_rates","Magento_Tax::sales_tax_import_export":"Magento_Tax::import_export","Magento_Tax::sales_tax_classes_customer":"Magento_Tax::classes_customer","Magento_Tax::sales_tax_classes_product":"Magento_Tax::classes_product","Magento_User::system_acl":"Magento_User::acl","Magento_User::system_acl_users":"Magento_User::acl_users","Magento_User::system_acl_roles":"Magento_User::acl_roles","Magento_Widget::cms_widget_instance":"Magento_Widget::widget_instance"}
diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php
index 71c4e44e7395b5aca1ee987f2dcc6278a0cf759e..72200fd86dcecc492dc8e27526f3b57b7f03ff04 100644
--- a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php
+++ b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php
@@ -311,8 +311,8 @@ return array(
     'sales/bestsellers_aggregated_daily' => 'sales_bestsellers_aggregated_daily',
     'sales/bestsellers_aggregated_monthly' => 'sales_bestsellers_aggregated_monthly',
     'sales/bestsellers_aggregated_yearly' => 'sales_bestsellers_aggregated_yearly',
-    'sales/billing_agreement' => 'sales_billing_agreement',
-    'sales/billing_agreement_order' => 'sales_billing_agreement_order',
+    'sales/billing_agreement' => 'paypal_billing_agreement',
+    'sales/billing_agreement_order' => 'paypal_billing_agreement_order',
     'sales/creditmemo' => 'sales_flat_creditmemo',
     'sales/creditmemo_comment' => 'sales_flat_creditmemo_comment',
     'sales/creditmemo_grid' => 'sales_flat_creditmemo_grid',
@@ -345,8 +345,8 @@ return array(
     'sales/quote_item' => 'sales_flat_quote_item',
     'sales/quote_item_option' => 'sales_flat_quote_item_option',
     'sales/quote_payment' => 'sales_flat_quote_payment',
-    'sales/recurring_profile' => 'sales_recurring_profile',
-    'sales/recurring_profile_order' => 'sales_recurring_profile_order',
+    'sales/recurring_profile' => 'recurring_profile',
+    'sales/recurring_profile_order' => 'recurring_profile_order',
     'sales/refunded_aggregated' => 'sales_refunded_aggregated',
     'sales/refunded_aggregated_order' => 'sales_refunded_aggregated_order',
     'sales/shipment' => 'sales_flat_shipment',
diff --git a/lib/Magento/App/Config/Scope/Converter.php b/lib/Magento/App/Config/Scope/Converter.php
index 3568065709d17210854d1faa2526bb5da1b0fd56..534e5f6b09a0a3a3e221374eda8b5785dcf76990 100644
--- a/lib/Magento/App/Config/Scope/Converter.php
+++ b/lib/Magento/App/Config/Scope/Converter.php
@@ -46,9 +46,10 @@ class Converter implements \Magento\Config\ConverterInterface
     /**
      * Set array value by path
      *
-     * @param array $container
+     * @param array &$container
      * @param string $path
      * @param string $value
+     * @return void
      */
     protected function _setArrayValue(array &$container, $path, $value)
     {
diff --git a/lib/Magento/App/Config/Storage/WriterInterface.php b/lib/Magento/App/Config/Storage/WriterInterface.php
index 6f159b77e7039be668b79fed529d97f047956aa1..8eed7925f71e1eb54aa4860b55f874824ea9da1b 100644
--- a/lib/Magento/App/Config/Storage/WriterInterface.php
+++ b/lib/Magento/App/Config/Storage/WriterInterface.php
@@ -33,6 +33,7 @@ interface WriterInterface
      * @param   string $path
      * @param   string $scope
      * @param   int $scopeId
+     * @return void
      */
     public function delete($path, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeId = 0);
 
@@ -43,6 +44,7 @@ interface WriterInterface
      * @param string $value
      * @param string $scope
      * @param int $scopeId
+     * @return void
      */
     public function save($path, $value, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeId = 0);
 }
diff --git a/lib/Magento/App/Console/Request.php b/lib/Magento/App/Console/Request.php
new file mode 100644
index 0000000000000000000000000000000000000000..173abd2d50ce176a32682e0bae14809cbb3d820b
--- /dev/null
+++ b/lib/Magento/App/Console/Request.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Console request
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\App\Console;
+
+class Request implements \Magento\App\RequestInterface
+{
+    /**
+     * @var array
+     */
+    protected $params;
+
+    /**
+     * @param array $parameters
+     */
+    public function __construct($parameters = array())
+    {
+        $this->params = $this->setParam($parameters);
+    }
+
+    /**
+     * Initialize console parameters
+     *
+     * @param $parameters
+     */
+    public function setParam($parameters)
+    {
+        $this->params = getopt(null, $parameters);
+    }
+
+    /**
+     * Retrieve module name
+     *
+     * @return string
+     */
+    public function getModuleName()
+    {
+        return;
+    }
+
+    /**
+     * Set Module name
+     *
+     * @param string $name
+     */
+    public function setModuleName($name)
+    {
+    }
+
+    /**
+     * Retrieve action name
+     *
+     * @return string
+     */
+    public function getActionName()
+    {
+        return;
+    }
+
+    /**
+     * Set action name
+     *
+     * @param string $name
+     */
+    public function setActionName($name)
+    {
+    }
+
+    /**
+     * Retrieve param by key
+     *
+     * @param string $key
+     * @param mixed $defaultValue
+     * @return mixed
+     */
+    public function getParam($key, $defaultValue = null)
+    {
+        if (isset($this->params[$key])) {
+            return $this->params[$key];
+        }
+        return $defaultValue;
+    }
+}
diff --git a/lib/Magento/App/Cron.php b/lib/Magento/App/Cron.php
index d503265ec659e408f8353d647ab23dad7ed92444..f79fcfef3a4794d5e1f126b5294f99e1727bb4aa 100644
--- a/lib/Magento/App/Cron.php
+++ b/lib/Magento/App/Cron.php
@@ -25,7 +25,6 @@
  */
 namespace Magento\App;
 
-use Magento\App\Console\Response;
 use \Magento\App\ObjectManager\ConfigLoader,
     \Magento\Event\ManagerInterface;
 
@@ -41,6 +40,11 @@ class Cron implements \Magento\LauncherInterface
      */
     protected $_state;
 
+    /**
+     * @var Console\Request
+     */
+    protected $_request;
+
     /**
      * @var Console\Response
      */
@@ -49,15 +53,21 @@ class Cron implements \Magento\LauncherInterface
     /**
      * @param ManagerInterface $eventManager
      * @param State $state
-     * @param Response $response
+     * @param Console\Request $request
+     * @param Console\Response $response
+     * @param array $parameters
      */
     public function __construct(
         ManagerInterface $eventManager,
         State $state,
-        Response $response
+        Console\Request $request,
+        Console\Response $response,
+        array $parameters = array()
     ) {
         $this->_eventManager = $eventManager;
         $this->_state = $state;
+        $this->_request = $request;
+        $this->_request->setParam($parameters);
         $this->_response = $response;
     }
 
diff --git a/lib/Magento/App/Filesystem.php b/lib/Magento/App/Filesystem.php
index 2867c408dfbdfca8bdcd0624f86d2d86734c0d90..dd230103f30413c8479351609c9bbaf2c04d4deb 100644
--- a/lib/Magento/App/Filesystem.php
+++ b/lib/Magento/App/Filesystem.php
@@ -137,4 +137,17 @@ class Filesystem extends \Magento\Filesystem
      * System base temporary folder
      */
     const SYS_TMP_DIR = 'sys_tmp';
+
+    /**
+     * Retrieve absolute path for for given code
+     *
+     * @param string $code
+     * @return string
+     */
+    public function getPath($code = self::ROOT_DIR)
+    {
+        $config = $this->directoryList->getConfig($code);
+        $path = isset($config['path']) ? $config['path'] : '';
+        return str_replace('\\', '/', $path);
+    }
 }
diff --git a/lib/Magento/App/ReinitableConfig.php b/lib/Magento/App/ReinitableConfig.php
index addd7dceebf48f843d62f429e455c2932c29f276..343bb2584e3c32d4060033d3e4e84149885eb3f8 100644
--- a/lib/Magento/App/ReinitableConfig.php
+++ b/lib/Magento/App/ReinitableConfig.php
@@ -1,7 +1,5 @@
 <?php
 /**
- * Application configuration used to re-initialize config.
- *
  * Magento
  *
  * NOTICE OF LICENSE
@@ -23,13 +21,12 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\App;
 
 class ReinitableConfig extends \Magento\App\Config implements \Magento\App\ReinitableConfigInterface
 {
     /**
-     * (@inheritdoc)
+     * {@inheritdoc}
      */
     public function reinit()
     {
diff --git a/lib/Magento/App/Response/Http.php b/lib/Magento/App/Response/Http.php
index 6cd61837bdab2c7780fed17a70a4dd8c70ef851a..c898e46c57e66feec1bec6e25cef573bac155bb3 100644
--- a/lib/Magento/App/Response/Http.php
+++ b/lib/Magento/App/Response/Http.php
@@ -30,7 +30,7 @@ class Http extends \Zend_Controller_Response_Http implements \Magento\App\Respon
     /**
      * Cookie to store page vary string
      */
-    const COOKIE_VARY_STRING = 'X-VARY-STRING';
+    const COOKIE_VARY_STRING = 'X-Magento-Vary';
 
     /**
      * Response vary identifiers
diff --git a/lib/Magento/Archive/Helper/File.php b/lib/Magento/Archive/Helper/File.php
index 43de8bc9c62c5a18f8b33523edb8e4a1f2ad91ee..65aad0d8caa24ca2af8245be26e04754b78953e8 100644
--- a/lib/Magento/Archive/Helper/File.php
+++ b/lib/Magento/Archive/Helper/File.php
@@ -82,8 +82,6 @@ class File
 
     /**
      * Close file if it's not closed before object destruction
-     *
-     * @return void
      */
     public function __destruct()
     {
diff --git a/lib/Magento/Archive/Tar.php b/lib/Magento/Archive/Tar.php
index 456d901ec0a4f21f4558a878231088c38e1165a7..ec5d990e007d0c8c269f8734be9310a7e6aa5a47 100644
--- a/lib/Magento/Archive/Tar.php
+++ b/lib/Magento/Archive/Tar.php
@@ -260,10 +260,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
      * Walk through directory and add to tar file or directory.
      * Result is packed string on TAR format.
      *
-     * @deprecated after 1.7.0.0
-     * @param boolean $skipRoot
+     * @param bool $skipRoot
      * @return string
      * @throws \Magento\Exception
+     *
+     * @deprecated after 1.7.0.0
      */
     protected function _packToTar($skipRoot=false)
     {
@@ -295,8 +296,8 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
     /**
      * Recursively walk through file tree and create tarball
      *
-     * @param boolean $skipRoot
-     * @param boolean $finalize
+     * @param bool $skipRoot
+     * @param bool $finalize
      * @return void
      * @throws \Magento\Exception
      */
@@ -365,7 +366,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
      * method breaks header into two pieces. First contains
      * header and data with long name. Second contain only header.
      *
-     * @param boolean $long
+     * @param bool $long
      * @return string
      */
     protected function _composeHeader($long = false)
@@ -478,9 +479,10 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
     /**
      * Get header from TAR string and unpacked it by format.
      *
+     * @param resource &$pointer
+     * @return string|bool
+     *
      * @deprecated after 1.7.0.0
-     * @param resource $pointer
-     * @return string
      */
     protected function _parseHeader(&$pointer)
     {
@@ -534,7 +536,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
     /**
      * Read and decode file header information from tarball
      *
-     * @return array|boolean
+     * @return array|bool
      */
     protected function _extractFileHeader()
     {
@@ -620,7 +622,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
      *
      * @param string $source
      * @param string $destination
-     * @param boolean $skipRoot
+     * @param bool $skipRoot
      * @return string
      */
     public function pack($source, $destination, $skipRoot = false)
diff --git a/lib/Magento/Code/Minifier/StrategyInterface.php b/lib/Magento/Code/Minifier/StrategyInterface.php
index ac1919dc90528d526540a56e47a9b4fb7c40c893..69660e0b5e842017cdfcbb6b84d7f12a62663869 100644
--- a/lib/Magento/Code/Minifier/StrategyInterface.php
+++ b/lib/Magento/Code/Minifier/StrategyInterface.php
@@ -34,6 +34,8 @@ interface StrategyInterface
      *
      * @param string $originalFile path relative to pub/view_cache
      * @param string $targetFile path relative to pub/view_cache
+     *
+     * @return void
      */
     public function minifyFile($originalFile, $targetFile);
 }
diff --git a/lib/Magento/Connect/Channel/Generator.php b/lib/Magento/Connect/Channel/Generator.php
index 9664a349c37006e2b9df41af54b19909d29827d4..1ab997270ee0a90906dc48406dc519e3895237a1 100644
--- a/lib/Magento/Connect/Channel/Generator.php
+++ b/lib/Magento/Connect/Channel/Generator.php
@@ -23,14 +23,25 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Channel;
 
-class Generator extends \Magento\Xml\Generator
+use Magento\Xml\Generator as XmlGenerator;
+
+class Generator extends XmlGenerator
 {
-    protected $_file      = 'channel.xml';
+    /**
+     * @var string
+     */
+    protected $_file = 'channel.xml';
+
+    /**
+     * @var XmlGenerator
+     */
     protected $_generator = null;
 
+    /**
+     * @param string $file
+     */
     public function __construct($file='')
     {
         if ($file) {
@@ -39,21 +50,28 @@ class Generator extends \Magento\Xml\Generator
         return $this;
     }
 
+    /**
+     * @return string
+     */
     public function getFile()
     {
         return $this->_file;
     }
 
+    /**
+     * @return XmlGenerator
+     */
     public function getGenerator()
     {
         if (is_null($this->_generator)) {
-            $this->_generator = new \Magento\Xml\Generator();
+            $this->_generator = new XmlGenerator();
         }
         return $this->_generator;
     }
 
     /**
      * @param array $content
+     * @return this
      */
     public function save($content)
     {
diff --git a/lib/Magento/Connect/Channel/VO.php b/lib/Magento/Connect/Channel/VO.php
index a92f0bc8d00c8b191d61b28a4110d658be19eca7..4f950fffd6273e98e6ab618dc5139c96f4140736 100644
--- a/lib/Magento/Connect/Channel/VO.php
+++ b/lib/Magento/Connect/Channel/VO.php
@@ -27,37 +27,63 @@
 
 namespace Magento\Connect\Channel;
 
+use Magento\Connect\Validator;
+
 class VO implements \Iterator
 {
-    
+    /**
+     * @var Validator
+     */
     private $_validator = null;
-    
+
+    /**
+     * @var array
+     */
     protected $properties = array(
         'name' => '',
         'uri' => '',
         'summary' => '',
     );
 
+    /**
+     * @return void
+     */
     public function rewind() {
         reset($this->properties);
     }
 
+    /**
+     * @return bool
+     */
     public function valid() {
         return current($this->properties) !== false;
     }
 
+    /**
+     * @return mixed
+     */
     public function key() {
         return key($this->properties);
     }
 
+    /**
+     * @return mixed
+     */
     public function current() {
         return current($this->properties);
     }
 
+    /**
+     * @return void
+     */
     public function next() {
         next($this->properties);
     }
 
+    /**
+     * @param string $var
+     * @return null|string
+     */
     public function __get($var)
     {
         if (isset($this->properties[$var])) {
@@ -66,6 +92,11 @@ class VO implements \Iterator
         return null;
     }
 
+    /**
+     * @param string $var
+     * @param string|null $value
+     * @return void
+     */
     public function __set($var, $value)
     {
         if (is_string($value)) {
@@ -79,11 +110,18 @@ class VO implements \Iterator
         }
     }
 
+    /**
+     * @return array
+     */
     public function toArray()
     {
         return array('channel' => $this->properties);
     }
-     
+
+    /**
+     * @param array $arr
+     * @return void
+     */
     public function fromArray(array $arr)
     {
         foreach($arr as $k=>$v) {
@@ -91,17 +129,21 @@ class VO implements \Iterator
         }
     }
 
-    
+    /**
+     * @return Validator
+     */
     private function validator()
     { 
         if(is_null($this->_validator)) {
-            $this->_validator = new \Magento\Connect\Validator();
+            $this->_validator = new Validator();
         }
         return $this->_validator;
     }
     
     /**
-     Stub for validation result
+     * Stub for validation result
+     *
+     * @return bool
      */
     public function validate()
     {
diff --git a/lib/Magento/Connect/Command.php b/lib/Magento/Connect/Command.php
index 13afb059e330dcf23bba9939114c536a9733a613..5190daa944c02a0d8836a0cd6e57adddd2924575 100644
--- a/lib/Magento/Connect/Command.php
+++ b/lib/Magento/Connect/Command.php
@@ -46,21 +46,56 @@ class Command
      * @var \Magento\Connect\Frontend
      */
     protected static $_frontend = null;
+
+    /**
+     * @var Config
+     */
     protected static $_config = null;
+
+    /**
+     * @var mixed
+     */
     protected static $_registry = null;
+
+    /**
+     * @var Validator
+     */
     protected static $_validator = null;
+
+    /**
+     * @var Rest
+     */
     protected static $_rest = null;
+
+    /**
+     * @var Singleconfig
+     */
     protected static $_sconfig = null;
 
+    /**
+     * @var mixed
+     */
     protected $_data;
+
+    /**
+     * String name of this class
+     *
+     * @var string
+     */
     protected $_class;
+
+    /**
+     * @var \Magento\Connect\Packager
+     */
     protected static $_packager = null;
 
+    /**
+     * @var array
+     */
     protected static $_return = array();
 
     /**
      * Constructor
-     *
      */
     public function __construct()
     {
@@ -75,12 +110,12 @@ class Command
     /**
      * Get command info (static)
      * @param string $name command name
-     * @return array/bool
+     * @return array|bool
      */
     public static function commandInfo($name)
     {
         $name = strtolower($name);
-        if(!isset(self::$_commandsAll[$name])) {
+        if (!isset(self::$_commandsAll[$name])) {
             return false;
         }
         return self::$_commandsAll[$name];
@@ -89,12 +124,12 @@ class Command
     /**
      * Get command info for current command object
      * @param string $name
-     * @return array/bool
+     * @return array|bool
      */
 
     public function getCommandInfo($name)
     {
-        if(!isset(self::$_commandsByClass[$this->_class][$name])) {
+        if (!isset(self::$_commandsByClass[$this->_class][$name])) {
             return false;
         }
         return self::$_commandsByClass[$this->_class][$name];
@@ -105,7 +140,7 @@ class Command
      * @param string $command
      * @param string $options
      * @param string $params
-     * @throws \Exception if there's no needed method
+     * @throws \Exception If there's no needed method
      * @return mixed
      */
     public function run($command, $options, $params)
@@ -124,8 +159,8 @@ class Command
 
     /**
      * Static
-     * @param $commandName
-     * @return unknown_type
+     * @param string $commandName
+     * @return object
      */
     public static function getInstance($commandName)
     {
@@ -136,22 +171,25 @@ class Command
         return new $currentCommand['class']();
     }
 
-    
+    /**
+     * @param Singleconfig $obj
+     * @return void
+     */
     public static function setSconfig($obj)
     {
         self::$_sconfig = $obj;
     }
-    
+
     /**
-     * 
-     * @return \Magento\Connect\Singleconfig
+     *
+     * @return Singleconfig
      */
     public function getSconfig()
     {
         return self::$_sconfig;
     }
-    
-    
+
+
     /**
      * Sets frontend object for all commands
      *
@@ -166,7 +204,8 @@ class Command
 
     /**
      * Set config object for all commands
-     * @param \Magento\Connect\Config $obj
+     *
+     * @param Config $obj
      * @return void
      */
     public static function setConfigObject($obj)
@@ -174,10 +213,11 @@ class Command
         self::$_config = $obj;
     }
 
-  
+
     /**
      * Non-static getter for config
-     * @return \Magento\Connect\Config
+     *
+     * @return Config
      */
     public function config()
     {
@@ -196,24 +236,26 @@ class Command
 
     /**
      * Get validator object
-     * @return \Magento\Connect\Validator
+     *
+     * @return Validator
      */
     public function validator()
     {
         if(is_null(self::$_validator)) {
-            self::$_validator = new \Magento\Connect\Validator();
+            self::$_validator = new Validator();
         }
         return self::$_validator;
     }
 
     /**
      * Get rest object
-     * @return \Magento\Connect\Rest
+     *
+     * @return Rest
      */
     public function rest()
     {
         if(is_null(self::$_rest)) {
-            self::$_rest = new \Magento\Connect\Rest(self::config()->protocol);
+            self::$_rest = new Rest(self::config()->protocol);
         }
         return self::$_rest;
     }
@@ -236,8 +278,8 @@ class Command
     /**
      * Get Getopt args from command definitions
      * and parse them
-     * @param $command
-     * @return array
+     * @param string $command
+     * @return array|void
      */
     public static function getGetoptArgs($command)
     {
@@ -298,6 +340,11 @@ class Command
         }
     }
 
+    /**
+     * @param string $command
+     * @param string $message
+     * @return void
+     */
     public function doError($command, $message)
     {
         return $this->ui()->doError($command, $message);
@@ -317,15 +364,15 @@ class Command
 
     /**
      * Get command return
-     * @param $key
-     * @param $clear
-     * @return mixed
+     * @param string $key
+     * @param bool $clear
+     * @return array|null
      */
     public static function getReturn($key, $clear = true)
     {
-        if(isset(self::$_return[$key])) {
+        if (isset(self::$_return[$key])) {
             $out = self::$_return[$key];
-            if($clear) {
+            if ($clear) {
                 unset(self::$_return[$key]);
             }
             return $out;
@@ -336,18 +383,19 @@ class Command
     /**
      * Cleanup command params from empty strings
      *
-     * @param array $params by reference
+     * @param array &$params by reference
+     * @return void
      */
     public function cleanupParams(array & $params)
     {
         $newParams = array();
-        if(!count($params)) {
+        if (!count($params)) {
             return;
         }
-        foreach($params as $k=>$v) {
-            if(is_string($v)) {
+        foreach ($params as $k=>$v) {
+            if (is_string($v)) {
                 $v = trim($v);
-                if(!strlen($v)) {
+                if (!strlen($v)) {
                     continue;
                 }
             }
@@ -360,33 +408,32 @@ class Command
      * Splits first command argument: channel/package
      * to two arguments if found in top of array
      *
-     * @param array $params
+     * @param array &$params
+     * @return void
      */
     public function splitPackageArgs(array & $params)
     {
-        if(!count($params) || !isset($params[0])) {
+        if (!count($params) || !isset($params[0])) {
             return;
         }
-        if($this->validator()->validateUrl($params[0])) {
+        if ($this->validator()->validateUrl($params[0])) {
             return;
         }
-        if(preg_match("@([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)@ims", $params[0], $subs)) {
-           $params[0] = $subs[2];
-           array_unshift($params, $subs[1]);
+        if (preg_match("@([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)@ims", $params[0], $subs)) {
+            $params[0] = $subs[2];
+            array_unshift($params, $subs[1]);
         }
     }
 
-    
     /**
      * Get packager instance
      * @return \Magento\Connect\Packager
      */
-    public function getPackager() 
+    public function getPackager()
     {
-        if(!self::$_packager) {
+        if (!self::$_packager) {
             self::$_packager = new \Magento\Connect\Packager();
         }
-        return self::$_packager;    
+        return self::$_packager;
     }
-    
 }
diff --git a/lib/Magento/Connect/Command/Channels.php b/lib/Magento/Connect/Command/Channels.php
index fffe5d2463da7c964adc83f7b9885924a8bf9768..7bc0b782e93236c603ac4f7010d3c1e7f6e80c05 100644
--- a/lib/Magento/Connect/Command/Channels.php
+++ b/lib/Magento/Connect/Command/Channels.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Command;
 
 final class Channels
@@ -32,9 +31,11 @@ extends \Magento\Connect\Command
 
     /**
      * List available channels
-     * @param $command
-     * @param $params
-     * @param $options
+     *
+     * @param string $command
+     * @param array $options
+     * @param string[] $params
+     * @return void
      */
     public function doList($command, $options, $params)
     {
@@ -62,10 +63,12 @@ extends \Magento\Connect\Command
     }
 
     /**
-     * channel-delete callback method
+     * Channel-delete callback method
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
+     * @return void
      */
     public function doDelete($command, $options, $params)
     {
@@ -96,9 +99,11 @@ extends \Magento\Connect\Command
 
     /**
      * Channel-add callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
+     * @return void
      */
     public function doAdd($command, $options, $params)
     {
@@ -134,9 +139,11 @@ extends \Magento\Connect\Command
 
     /**
      * Get information about given channel callback
+     *
      * @param string $command
      * @param array $options
      * @param array $params
+     * @return void
      */
     public function doInfo($command, $options, $params)
     {
@@ -144,11 +151,12 @@ extends \Magento\Connect\Command
     }
 
     /**
-     * channel-alias
-     * @param $command
-     * @param $options
-     * @param $params
-     * @return unknown_type
+     * Channel-alias
+     *
+     * @param string $command
+     * @param array $options
+     * @param string[] $params
+     * @return void
      */
     public function doAlias($command, $options, $params)
     {
@@ -178,11 +186,23 @@ extends \Magento\Connect\Command
         }
     }
 
+    /**
+     * @param string $command
+     * @param array $options
+     * @param string[] $params
+     * @return void
+     */
     public function doLogin($command, $options, $params)
     {
 
     }
 
+    /**
+     * @param string $command
+     * @param array $options
+     * @param string[] $params
+     * @return void
+     */
     public function doLogout($command, $options, $params)
     {
 
diff --git a/lib/Magento/Connect/Command/Config.php b/lib/Magento/Connect/Command/Config.php
index b06457b3352e794e5e2772d3bc21bbd756a2e191..a46d3080a16a0fdfacd966856fbdab6089cd9a4d 100644
--- a/lib/Magento/Connect/Command/Config.php
+++ b/lib/Magento/Connect/Command/Config.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Connect\Command;
 
 class Config
@@ -37,9 +35,10 @@ extends \Magento\Connect\Command
 
     /**
      * Show config variable
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doConfigShow($command, $options, $params)
@@ -75,9 +74,10 @@ extends \Magento\Connect\Command
 
     /**
      * Set config variable
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doConfigSet($command, $options, $params)
@@ -123,9 +123,10 @@ extends \Magento\Connect\Command
 
     /**
      * Get config var
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doConfigGet($command, $options, $params)
@@ -161,9 +162,10 @@ extends \Magento\Connect\Command
 
     /**
      * Config help
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doConfigHelp($command, $options, $params)
diff --git a/lib/Magento/Connect/Command/Install.php b/lib/Magento/Connect/Command/Install.php
index eab7c5cd10b7f64c3abd168fc8829e810d01d96a..923a60fdae210834986d449eb11f31933864accf 100644
--- a/lib/Magento/Connect/Command/Install.php
+++ b/lib/Magento/Connect/Command/Install.php
@@ -23,8 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
 namespace Magento\Connect\Command;
 
 final class Install
@@ -33,10 +31,12 @@ extends \Magento\Connect\Command
 
     /**
      * Install action callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
-     * @return void
+     * @param string[] $params
+     * @param array $objects
+     * @return array
      */
     public function doInstall($command, $options, $params, $objects = array())
     {
@@ -336,10 +336,11 @@ extends \Magento\Connect\Command
 
     /**
      * Upgrade action callback
+     *
      * @param string $command
      * @param array $options
      * @param array $params
-     * @return void
+     * @return array
      */
     public function doUpgrade($command, $options, $params)
     {
@@ -349,10 +350,11 @@ extends \Magento\Connect\Command
 
     /**
      * Updgrade action callback
+     *
      * @param string $command
      * @param array $options
      * @param array $params
-     * @return void
+     * @return array
      */
     public function doUpgradeAll($command, $options, $params)
     {
@@ -362,10 +364,11 @@ extends \Magento\Connect\Command
 
     /**
      * Uninstall package callback
+     *
      * @param string $command
      * @param array $options
      * @param array $params
-     * @return unknown_type
+     * @return void
      */
     public function doUninstall($command, $options, $params)
     {
diff --git a/lib/Magento/Connect/Command/Package.php b/lib/Magento/Connect/Command/Package.php
index a6f5672648816043dcb3a00c657d8eab9c834f5f..9f84a5ef477612a630e5a2469e42300c198fa534 100644
--- a/lib/Magento/Connect/Command/Package.php
+++ b/lib/Magento/Connect/Command/Package.php
@@ -23,7 +23,6 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Command;
 
 final class Package
@@ -43,9 +42,10 @@ extends \Magento\Connect\Command
 
     /**
      * Package command callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doPackage($command, $options, $params)
@@ -80,10 +80,11 @@ extends \Magento\Connect\Command
 
     /**
      * Display/get dependencies
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
-     * @return void/array
+     * @param string[] $params
+     * @return void
      */
     public function doPackageDependencies($command, $options, $params)
     {
@@ -115,6 +116,12 @@ extends \Magento\Connect\Command
         }
     }
 
+    /**
+     * @param string $command
+     * @param array $options
+     * @param string[] $params
+     * @return void
+     */
     public function doConvert($command, $options, $params)
     {
         $this->cleanupParams($params);
diff --git a/lib/Magento/Connect/Command/Registry.php b/lib/Magento/Connect/Command/Registry.php
index 7e3b4563ecd09b0ef456841c5306ccb36c24dfef..3faf767fa208316e362cce2431e5d16f5dc74d89 100644
--- a/lib/Magento/Connect/Command/Registry.php
+++ b/lib/Magento/Connect/Command/Registry.php
@@ -32,9 +32,10 @@ extends \Magento\Connect\Command
 
     /**
      * List-installed callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doList($command, $options, $params)
@@ -69,9 +70,10 @@ extends \Magento\Connect\Command
 
     /**
      * list-files callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doFileList($command, $options, $params)
@@ -127,10 +129,11 @@ extends \Magento\Connect\Command
     /**
      * Installed package info
      * info command callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
-     * @return
+     * @param string[] $params
+     * @return void
      */
     public function doInfo($command, $options, $params)
     {
diff --git a/lib/Magento/Connect/Command/Remote.php b/lib/Magento/Connect/Command/Remote.php
index 2435f7220c4ca054a9b4d980624e58dfd1694629..e0e3a24c350adc64dcb20a7126116858eedc391c 100644
--- a/lib/Magento/Connect/Command/Remote.php
+++ b/lib/Magento/Connect/Command/Remote.php
@@ -32,9 +32,10 @@ extends \Magento\Connect\Command
 
     /**
      * List-upgrades callback
-     * @param srting $command
+     *
+     * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doListUpgrades($command, $options, $params)
@@ -73,10 +74,10 @@ extends \Magento\Connect\Command
 
     /**
      * List available
-     * @param $command
-     * @param $options
-     * @param $params
-     * @return unknown_type
+     * @param string $command
+     * @param array $options
+     * @param string[] $params
+     * @return void
      */
 
     public function doListAvailable($command, $options, $params)
@@ -144,7 +145,7 @@ extends \Magento\Connect\Command
      *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doDownload($command, $options, $params)
@@ -197,9 +198,10 @@ extends \Magento\Connect\Command
 
     /**
      * Clear cache command callback
+     *
      * @param string $command
      * @param array $options
-     * @param array $params
+     * @param string[] $params
      * @return void
      */
     public function doClearCache($command, $options, $params)
diff --git a/lib/Magento/Connect/Config.php b/lib/Magento/Connect/Config.php
index c8eb95f6d81ce24bb8f9ca35304608fd477fc1d9..0641cabe9d5bd9cc3fa0df37826c8d31855846d9 100644
--- a/lib/Magento/Connect/Config.php
+++ b/lib/Magento/Connect/Config.php
@@ -23,19 +23,29 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect;
 
-class Config
-implements \Iterator
+class Config implements \Iterator
 {
-    protected $_configFile;
     const HEADER = "::ConnectConfig::v::1.0::";
+
     const DEFAULT_DOWNLOADER_PATH = "downloader";
+
     const DEFAULT_CACHE_PATH = ".cache";
 
+    /**
+     * @var string
+     */
+    protected $_configFile;
+
+    /**
+     * @var array
+     */
     protected $properties = array();
 
+    /**
+     * @return void
+     */
     protected function initProperties()
     {
         $this->properties = array (
@@ -95,28 +105,40 @@ implements \Iterator
                 'doc' => "",
                 'possible' => '',
         ),
-        
+
         );
 
     }
-    
+
+    /**
+     * @return string
+     */
     public function getDownloaderPath()
     {
         return $this->magento_root . '/' . $this->downloader_path;
     }
-    
+
+    /**
+     * @return string
+     */
     public function getPackagesCacheDir()
     {
         return $this->getDownloaderPath() . '/' . self::DEFAULT_CACHE_PATH;
     }
-    
+
+    /**
+     * @param string $channel
+     * @return string
+     */
     public function getChannelCacheDir($channel)
     {
         $channel = trim( $channel, "\\/");
         return $this->getPackagesCacheDir() . '/' . $channel;
     }
-    
-    
+
+    /**
+     * @param string $configFile
+     */
     public function __construct($configFile = "connect.cfg")
     {
         $this->initProperties();
@@ -124,11 +146,17 @@ implements \Iterator
         $this->load();
     }
 
+    /**
+     * @return string
+     */
     public function getFilename()
     {
         return $this->_configFile;
     }
-    
+
+    /**
+     * @return void
+     */
     public function load()
     {
         /**
@@ -139,7 +167,7 @@ implements \Iterator
         $f = fopen($this->_configFile, "a+");
         fseek($f, 0, SEEK_SET);
         $size = filesize($this->_configFile);
-        if(!$size) {
+        if (!$size) {
             $this->store();
             return;
         }
@@ -147,7 +175,7 @@ implements \Iterator
         $headerLen = strlen(self::HEADER);
         $contents = fread($f, $headerLen);
 
-        if(self::HEADER != $contents) {
+        if (self::HEADER != $contents) {
             $this->store();
             return;
         }
@@ -156,16 +184,19 @@ implements \Iterator
         $contents = fread($f, $size);
 
         $data = @unserialize($contents);
-        if($data === unserialize(false)) {
+        if ($data === unserialize(false)) {
             $this->store();
             return;
         }
-        foreach($data as $k=>$v) {
+        foreach ($data as $k=>$v) {
             $this->$k = $v;
         }
         fclose($f);
     }
 
+    /**
+     * @return void
+     */
     public function store()
     {
         $data = serialize($this->toArray());
@@ -176,6 +207,11 @@ implements \Iterator
     }
 
 
+    /**
+     * @param string $key
+     * @param mixed $val
+     * @return bool
+     */
     public function validate($key, $val)
     {
         $rules = $this->extractField($key, 'rules');
@@ -187,46 +223,69 @@ implements \Iterator
         return false;
     }
 
+    /**
+     * @param string $key
+     * @return null|string
+     */
     public function possible($key)
     {
         $data = $this->getKey($key);
-        if(! $data) {
+        if (! $data) {
             return null;
         }
-        if('set' == $data['type']) {
+        if ('set' == $data['type']) {
             return implode("|", $data['rules']);
         }
-        if(!empty($data['possible'])) {
+        if (!empty($data['possible'])) {
             return $data['possible'];
         }
         return "<".$data['type'].">";
     }
 
+    /**
+     * @param string $key
+     * @return null|string
+     */
     public function type($key)
     {
         return $this->extractField($key, 'type');
     }
 
+    /**
+     * @param string $key
+     * @return null|string
+     */
     public function doc($key)
     {
         return $this->extractField($key, 'doc');
     }
 
-
+    /**
+     * @param string $key
+     * @param string $field
+     * @return null|string
+     */
     public function extractField($key, $field)
     {
-        if(!isset($this->properties[$key][$field])) {
+        if (!isset($this->properties[$key][$field])) {
             return null;
         }
         return $this->properties[$key][$field];
     }
 
-
+    /**
+     * @param string $fld
+     * @return bool
+     */
     public function hasKey($fld)
     {
         return isset($this->properties[$fld]);
     }
 
+    /**
+     * @param string $fld
+     * @return null|bool
+     */
     public function getKey($fld)
     {
         if($this->hasKey($fld)) {
@@ -235,26 +294,50 @@ implements \Iterator
         return null;
     }
 
-    public function rewind() {
+    /**
+     * @return void
+     */
+    public function rewind()
+    {
         reset($this->properties);
     }
 
-    public function valid() {
+    /**
+     * @return bool
+     */
+    public function valid()
+    {
         return current($this->properties) !== false;
     }
 
-    public function key() {
+    /**
+     * @return string
+     */
+    public function key()
+    {
         return key($this->properties);
     }
 
-    public function current() {
+    /**
+     * @return array
+     */
+    public function current()
+    {
         return current($this->properties);
     }
 
-    public function next() {
+    /**
+     * @return void
+     */
+    public function next()
+    {
         next($this->properties);
     }
 
+    /**
+     * @param string $var
+     * @return null|string
+     */
     public function __get($var)
     {
         if (isset($this->properties[$var]['value'])) {
@@ -263,6 +346,11 @@ implements \Iterator
         return null;
     }
 
+    /**
+     * @param string $var
+     * @param string $value
+     * @return void
+     */
     public function __set($var, $value)
     {
         if (is_string($value)) {
@@ -272,17 +360,21 @@ implements \Iterator
             if ($value === null) {
                 $value = '';
             }
-            if($this->properties[$var]['value'] !== $value) {
+            if ($this->properties[$var]['value'] !== $value) {
                 $this->properties[$var]['value'] = $value;
                 $this->store();
             }
         }
     }
 
+    /**
+     * @param bool $withRules
+     * @return array
+     */
     public function toArray($withRules = false)
     {
         $out = array();
-        foreach($this as $k=>$v) {
+        foreach ($this as $k=>$v) {
             $out[$k] = $withRules ? $v : $v['value'];
         }
         return $out;
diff --git a/lib/Magento/Connect/Converter.php b/lib/Magento/Connect/Converter.php
index 7938e6ca5113c57f870992c4ac6f385510e854a7..f3a86d9a37db0099b014b9f675207d35df5dc71c 100644
--- a/lib/Magento/Connect/Converter.php
+++ b/lib/Magento/Connect/Converter.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Magento
  *
@@ -24,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect;
+
+use Magento\Archive;
 
 /**
  * Class for convertiong old magento PEAR packages to new one
@@ -32,25 +34,28 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Connect;
-
 final class Converter
 {
+    /**
+     * @var Archive
+     */
     protected $_archiver;
 
     /**
      *
-     * @return \Magento\Archive
+     * @return Archive
      */
     public function arc()
     {
         if(!$this->_archiver) {
-            $this->_archiver = new \Magento\Archive();
+            $this->_archiver = new Archive();
         }
         return $this->_archiver;
     }
 
+    /**
+     * @return Package
+     */
     public function newPackage()
     {
         return new \Magento\Connect\Package();
@@ -65,13 +70,18 @@ final class Converter
         return new Pear_Package_Parser_v2();
     }
 
-
+    /**
+     * Constructor
+     */
     public function __construct()
     {
 
     }
 
-
+    /**
+     * @param string $channel
+     * @return string|string[]
+     */
     public function convertChannelName($channel)
     {
         return str_replace("connect.magentocommerce.com/", "", $channel);
@@ -79,37 +89,46 @@ final class Converter
 
     /**
      * Convert package dependencies - urls - by ref
-     * @param array $deps  ref to array
-     * @return void
+     *
+     * @param array $oldDeps  ref to array
+     * @return array
      */
     public function convertPackageDependencies($oldDeps)
     {
         $out = array();
-        if(empty($oldDeps['required']['package'])) {
+        if (empty($oldDeps['required']['package'])) {
             return $out;
         }
         $deps = $oldDeps['required']['package'];
-        if(!isset($deps[0])) {
+        if (!isset($deps[0])) {
             $deps = array($deps);
         }
-        for($i=0, $c=count($deps); $i<$c; $i++) {
+        for ($i=0, $c=count($deps); $i<$c; $i++) {
             $deps[$i]['min_version'] = isset($deps[$i]['min']) ? $deps[$i]['min'] : false;
             $deps[$i]['max_version'] = isset($deps[$i]['max']) ? $deps[$i]['max'] : false;
             $deps[$i]['channel'] = $this->convertChannelName($deps[$i]['channel']);
             $out[] = $deps[$i];
         }
-         
+
         return $out;
     }
 
+    /**
+     * @param array $oldLicense
+     * @return array|int|float|bool|string
+     */
     public function convertLicense($oldLicense)
     {
-        if(is_scalar($oldLicense)) {
+        if (is_scalar($oldLicense)) {
             return $oldLicense;
         }
         return array($oldLicense['_content'], $oldLicense['attribs']['uri']);
     }
 
+    /**
+     * @param array $maintainers
+     * @return array
+     */
     public function convertMaintainers($maintainers)
     {
         if(!is_array($maintainers) || !count($maintainers)) {
@@ -122,15 +141,19 @@ final class Converter
         return $out;
     }
 
+    /**
+     * @var array
+     */
     protected $fileMap = array();
 
-    
+
     /**
-     * Conver pear package object to magento object
+     * Convert pear package object to magento object
+     *
      * @param Pear_Package_V2 $pearObject
      * @return \Magento\Connect\Package
+     * @throws \Exception
      */
-
     public function convertPackageObject($pearObject)
     {
         $data = array();
@@ -142,22 +165,22 @@ final class Converter
             'name'         => null,
             'version'      => array('getterArgs' => array('release')
         ),
-            'package_deps' => array( 'getter'=>'getDependencies', 
-                                     'converter'=>'convertPackageDependencies', 
+            'package_deps' => array( 'getter'=>'getDependencies',
+                                     'converter'=>'convertPackageDependencies',
                                      'setter'=>'setDependencyPackages',
         ),
             'stability'    => array( 'getter'=>'getState',
-                                     'getterArgs' => array('release'), 
+                                     'getterArgs' => array('release'),
         ),
             'license'      => array( 'getterArgs' => array(true),
                                      'converter' => 'convertLicense',
-                                     'noArrayWrap' => true,                                    
+                                     'noArrayWrap' => true,
         ),
             'summary'      => null,
-            'description'  => null,                              
-            'notes'        => null,                              
-            'date'         => null,                              
-            'time'         => null,         
+            'description'  => null,
+            'notes'        => null,
+            'date'         => null,
+            'time'         => null,
             'authors'      => array( 'converter' => 'convertMaintainers',
                                      'getter' => 'getMaintainers',
         ),
@@ -234,9 +257,11 @@ final class Converter
 
     /**
      * Convert PEAR package to Magento package
+     *
      * @param string $sourceFile  path to PEAR .tgz
      * @param string|false $destFile    path to newly-created Magento .tgz, false to specify auto
-     * @return bool
+     * @return string|false
+     * @throws \Exception
      */
     public function convertPearToMage($sourceFile, $destFile = false)
     {
@@ -281,10 +306,10 @@ final class Converter
                     $destFile .= "." . $pathinfo['extension'];
                 }
             }
-            
+
             $target = new \Magento\Connect\Package\Target("target.xml");
-            $targets = $target->getTargets();                        
-            $mageObject->setTarget($target);            
+            $targets = $target->getTargets();
+            $mageObject->setTarget($target);
             $validRoles = array_keys($targets);
             $data = $pearObject->getFilelist();
             $pathSource = dirname($pearObject->getPackageFile())
@@ -309,14 +334,14 @@ final class Converter
                     }
                 }
                 $filesToDo[] = array ('name'=> $name, 'role'=>$role);
-            }                        
+            }
             $cwd = getcwd();
             @chdir($outDir);
             foreach($filesToDo as $fileToDo) {
                 $mageObject->addContent($fileToDo['name'], $fileToDo['role']);
             }
             $mageObject->save(getcwd());
-            @chdir($cwd);            
+            @chdir($cwd);
             $filename = $outDir . '/' . $mageObject->getReleaseFilename() . '.tgz';
             if(@file_exists($targetArchive)) {
                 @unlink($targetArchive);
diff --git a/lib/Magento/Connect/Frontend.php b/lib/Magento/Connect/Frontend.php
index 6d4b3f6f3bdac602b80dab27835ddc4ddb9adb1b..8faf9b4a0a66a0ce188284c8b736e7656961adcc 100644
--- a/lib/Magento/Connect/Frontend.php
+++ b/lib/Magento/Connect/Frontend.php
@@ -23,47 +23,51 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect;
 
 class Frontend
 {
-
     /**
      * Silent flag. If set no output is produced to view.
      * Should be used in derived classes.
+     *
      * @var bool
      */
     protected $_silent = false;
 
     /**
      * Capture mode. If set command output should be collected
-     * by derived class impplementation
+     * by derived class implementation
+     *
      * @var bool
      */
     protected $_capture = false;
 
 
     /**
-     * push/pop variable for capture
+     * Push/pop variable for capture
+     *
      * @var array
      */
     protected $_captureSaved = array();
 
     /**
-     * push/pop variable for silent
+     * Push/pop variable for silent
+     *
      * @var array
      */
     protected $_silentSaved = array();
 
     /**
      * Errors list
+     *
      * @var array
      */
     protected $_errors = array();
 
     /**
      * Add error to errors list
+     *
      * @param mixed $data
      * @return void
      */
@@ -74,6 +78,7 @@ class Frontend
 
     /**
      * Get errors, clear errors list with first param
+     *
      * @param bool $clear
      * @return array
      */
@@ -89,6 +94,7 @@ class Frontend
 
     /**
      * Clear errors array
+     *
      * @return void
      */
     public function clearErrors()
@@ -97,7 +103,8 @@ class Frontend
     }
 
     /**
-     * Are there any errros?
+     * Are there any errors?
+     *
      * @return bool
      */
     public function hasErrors()
@@ -107,8 +114,9 @@ class Frontend
 
     /**
      * Error processing
+     *
      * @param string $command
-     * @param stting $message
+     * @param string $message
      * @return void
      */
     public function doError($command, $message)
@@ -118,7 +126,8 @@ class Frontend
 
     /**
      * Save capture state
-     * @return \Magento\Connect\Frontend
+     *
+     * @return $this
      */
     public function pushCapture()
     {
@@ -128,7 +137,8 @@ class Frontend
 
     /**
      * Restore capture state
-     * @return \Magento\Connect\Frontend
+     *
+     * @return $this
      */
     public function popCapture()
     {
@@ -138,8 +148,9 @@ class Frontend
 
     /**
      * Set capture mode
+     *
      * @param bool $arg true by default
-     * @return \Magento\Connect\Frontend
+     * @return $this
      */
     public function setCapture($arg = true)
     {
@@ -149,6 +160,7 @@ class Frontend
 
     /**
      * Getter for capture mode
+     *
      * @return bool
      */
     public function isCapture()
@@ -158,8 +170,9 @@ class Frontend
 
     /**
      * Log stub
-     * @param $msg
-     * @return
+     *
+     * @param string $msg
+     * @return void
      */
     public function log($msg)
     {
@@ -168,6 +181,7 @@ class Frontend
 
     /**
      * Ouptut method
+     *
      * @param array $data
      * @return void
      */
@@ -179,7 +193,7 @@ class Frontend
     /**
      * Get instance of derived class
      *
-     * @param $class CLI for example will produce \Magento\Connect\Frontend\CLI
+     * @param string $class CLI for example will produce \Magento\Connect\Frontend\CLI
      * @return object
      */
     public static function getInstance($class)
@@ -191,6 +205,7 @@ class Frontend
     /**
      * Get output if capture mode set
      * Clear prevoius if needed
+     *
      * @param bool $clearPrevious
      * @return mixed
      */
@@ -202,7 +217,8 @@ class Frontend
 
     /**
      * Save silent mode
-     * @return \Magento\Connect\Frontend
+     *
+     * @return $this
      */
     public function pushSilent()
     {
@@ -212,7 +228,8 @@ class Frontend
 
     /**
      * Restore silent mode
-     * @return \Magento\Connect\Frontend
+     *
+     * @return $this
      */
     public function popSilent()
     {
@@ -222,8 +239,9 @@ class Frontend
 
     /**
      * Set silent mode
+     *
      * @param bool $value
-     * @return \Magento\Connect\Frontend
+     * @return $this
      */
     public function setSilent($value = true)
     {
@@ -233,6 +251,7 @@ class Frontend
 
     /**
      * Is silent mode?
+     *
      * @return bool
      */
     public function isSilent()
@@ -241,13 +260,14 @@ class Frontend
     }
 
     /**
-    * Method for ask client about rewrite all files.
-    *
-    * @param $string
-    */
+     * Method for ask client about rewrite all files.
+     *
+     * @param string $string
+     * @return void
+     */
     public function confirm($string)
     {
-        
+
     }
 }
 
diff --git a/lib/Magento/Connect/Frontend/CLI.php b/lib/Magento/Connect/Frontend/CLI.php
index ad37d837a25f44996ea82e712937a88a8adafa6f..41497c1305297244970aaaa3e7e9f38f0acefff8 100644
--- a/lib/Magento/Connect/Frontend/CLI.php
+++ b/lib/Magento/Connect/Frontend/CLI.php
@@ -31,7 +31,6 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
 namespace Magento\Connect\Frontend;
 
 class CLI
@@ -40,12 +39,14 @@ extends \Magento\Connect\Frontend
 
     /**
      * Collected output
+     *
      * @var array
      */
     protected $_output = array();
 
     /**
      * Output error
+     *
      * @param string $command
      * @param string $message
      * @return void
@@ -60,6 +61,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output config help
+     *
      * @param array $data
      * @return void
      */
@@ -77,6 +79,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output info
+     *
      * @param array $data
      * @return void
      */
@@ -90,7 +93,10 @@ extends \Magento\Connect\Frontend
         }
     }
 
-
+    /**
+     * @param string $type
+     * @return string
+     */
     public function detectMethodByType($type)
     {
         $defaultMethod = "output";
@@ -116,7 +122,10 @@ extends \Magento\Connect\Frontend
         return $defaultMethod;
     }
 
-
+    /**
+     * @param array $data
+     * @return void
+     */
     public function outputDeleted($data)
     {
         if(!count($data['data'])) {
@@ -127,7 +136,11 @@ extends \Magento\Connect\Frontend
             $this->writeln("$row[0]/$row[1]");
         }
     }
-    
+
+    /**
+     * @param array $data
+     * @return void
+     */
     public function outputListChannels($data)
     {
         $this->writeln($data['title']);
@@ -149,6 +162,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output install result
+     *
      * @param array $data
      * @return void
      */
@@ -166,6 +180,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Ouptut package contents
+     *
      * @param array $data
      * @return void
      */
@@ -179,7 +194,8 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output package dependencies
-     * @param $data
+     *
+     * @param array $data
      * @return void
      */
     public function outputPackageDeps($data)
@@ -193,8 +209,9 @@ extends \Magento\Connect\Frontend
 
     /**
      * Ouptut channel packages
-     * @param $data
-     * @return unknown_type
+     *
+     * @param array $data
+     * @return void
      */
     public function outputChannelsPackages($data)
     {
@@ -214,7 +231,6 @@ extends \Magento\Connect\Frontend
         }
     }
 
-
     /**
      * Make output
      *
@@ -247,6 +263,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Detailed package info
+     *
      * @param \Magento\Connect\Package $package
      * @return void
      */
@@ -280,6 +297,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Write channels list
+     *
      * @param array $data
      * @return void
      */
@@ -296,6 +314,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Write installed list
+     *
      * @param array $data
      * @return void
      */
@@ -321,6 +340,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output commands list
+     *
      * @param array $data
      * @return void
      */
@@ -348,6 +368,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output config variable
+     *
      * @param string $key
      * @param string $value
      * @return void
@@ -362,6 +383,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Write data and "\n" afterwards
+     *
      * @param string $data
      * @return void
      */
@@ -388,6 +410,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Write data to console
+     *
      * @param string $data
      * @return void
      */
@@ -401,6 +424,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output printf-stlye formatted string and args
+     *
      * @return void
      */
     public function printf()
@@ -411,6 +435,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Readline from console
+     *
      * @return string
      */
     public function readln()
@@ -426,6 +451,7 @@ extends \Magento\Connect\Frontend
 
     /**
      * Output upgrades
+     *
      * @param array $data
      * @return void
      */
diff --git a/lib/Magento/Connect/Loader.php b/lib/Magento/Connect/Loader.php
index 169911a7964f053f9044e4af1ead3d256407333d..f7a9b74cbb05c87cf979de1eff224ee4ddf9e2ad 100644
--- a/lib/Magento/Connect/Loader.php
+++ b/lib/Magento/Connect/Loader.php
@@ -39,7 +39,7 @@ class Loader
     /**
      * Factory for HTTP client
      * @param string/false $protocol  'curl'/'socket' or false for auto-detect
-     * @return \Magento\HTTP\Client/\Magento\Connect\Loader\Ftp
+     * @return \Magento\HTTP\Client|\Magento\Connect\Loader\Ftp
      */
     public static function getInstance($protocol='')
     {
diff --git a/lib/Magento/Connect/Loader/Ftp.php b/lib/Magento/Connect/Loader/Ftp.php
index 9bdb300333a8e4c46ebb64230f09a4b612875584..d46c3021bae5cddc389ce7a7c2ae869a7977db93 100644
--- a/lib/Magento/Connect/Loader/Ftp.php
+++ b/lib/Magento/Connect/Loader/Ftp.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect\Loader;
+
+use Magento\Connect\Ftp as ConnectFtp;
 
 /**
  * Class for ftp loader which using in the Rest
@@ -31,11 +34,8 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Connect\Loader;
-
 class Ftp
 {
-
     const TEMPORARY_DIR = 'var/package/tmp';
 
     const FTP_USER = 'magconnect';
@@ -43,10 +43,10 @@ class Ftp
     const FTP_PASS = '4SyTUxPts0o2';
 
     /**
-    * Object of Ftp
-    *
-    * @var \Magento\Connect\Ftp
-    */
+     * Object of Ftp
+     *
+     * @var ConnectFtp
+     */
     protected $_ftp = null;
 
     /**
@@ -62,24 +62,27 @@ class Ftp
     protected $_responseStatus = 0;
 
     /**
-    * Constructor
-    */
+     * Constructor
+     */
     public function __construct()
     {
-        $this->_ftp = new \Magento\Connect\Ftp();
+        $this->_ftp = new ConnectFtp();
     }
 
+    /**
+     * @return ConnectFtp
+     */
     public function getFtp()
     {
         return $this->_ftp;
     }
 
     /**
-    * Retrieve file from URI
-    *
-    * @param mixed $uri
-    * @return bool
-    */
+     * Retrieve file from URI
+     *
+     * @param string $uri
+     * @return bool
+     */
     public function get($uri)
     {
         $remoteFile = basename($uri);
@@ -111,10 +114,10 @@ class Ftp
     }
 
     /**
-    * put your comment there...
-    *
-    * @return string
-    */
+     * TODO: put your comment there...
+     *
+     * @return string
+     */
     public function getBody()
     {
         return $this->_responseBody;
diff --git a/lib/Magento/Connect/Package.php b/lib/Magento/Connect/Package.php
index 4da0d989ae0b09a5f2d96ef72907309f7431c872..da8ba44033c48f64b7da627e8e3cde77d1ac312d 100644
--- a/lib/Magento/Connect/Package.php
+++ b/lib/Magento/Connect/Package.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect;
+
+use Magento\Connect\Package\Target;
 
 /**
  * Class to work with Magento Connect packages
@@ -31,8 +34,6 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Connect;
-
 class Package
 {
     /*
@@ -125,7 +126,7 @@ class Package
     /**
     * Object with target
     *
-    * @var \Magento\Connect\Package\Target
+    * @var Target
     */
     protected $_target = null;
 
@@ -172,7 +173,7 @@ class Package
      * Initializes an empty package object
      *
      * @param null|string $definition optional package definition xml
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     protected function _init($definition=null)
     {
@@ -209,7 +210,7 @@ END;
      * Loads a package from specified file
      *
      * @param string $filename
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     protected function _loadFile($filename='')
     {
@@ -225,7 +226,7 @@ END;
      * Creates a package and saves it
      *
      * @param string $path
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function save($path)
     {
@@ -239,7 +240,7 @@ END;
      * Creates a package that is compatible with the previous version of Magento Connect Manager and saves it
      *
      * @param string $path
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function saveV1x($path)
     {
@@ -253,7 +254,7 @@ END;
      * Creates a package archive and saves it to specified path
      *
      * @param string $path
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     protected function _savePackage($path)
     {
@@ -273,7 +274,7 @@ END;
      * Package is compatible with the previous version of magento Connect Manager
      *
      * @param string $path
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     protected function _savePackageV1x($path)
     {
@@ -390,7 +391,7 @@ END;
      * @param \SimpleXMLElement $destination
      * @param \SimpleXMLElement $source
      * @param string $role
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     protected function _mergeContentsToV1x($destination, $source, $role)
     {
@@ -416,19 +417,23 @@ END;
     /**
     * Retrieve Target object
     *
-    * @return \Magento\Connect\Package\Target
+    * @return Target
     */
     protected function getTarget()
     {
-        if (!$this->_target instanceof \Magento\Connect\Package\Target) {
-            $this->_target = new \Magento\Connect\Package\Target();
+        if (!$this->_target instanceof Target) {
+            $this->_target = new Target();
         }
         return $this->_target;
     }
 
+    /**
+     * @param Target $arg
+     * @return void
+     */
     public function setTarget($arg)
     {
-        if ($arg instanceof \Magento\Connect\Package\Target) {
+        if ($arg instanceof Target) {
             $this->_target = $arg;
         }
     }
@@ -439,7 +444,7 @@ END;
      * Puts value to name
      *
      * @param string $name
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setName($name)
     {
@@ -451,7 +456,7 @@ END;
      * Puts value to <channel />
      *
      * @param string $channel
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setChannel($channel)
     {
@@ -463,7 +468,7 @@ END;
      * Puts value to <summary />
      *
      * @param string $summary
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setSummary($summary)
     {
@@ -475,7 +480,7 @@ END;
      * Puts value to <description />
      *
      * @param string $description
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setDescription($description)
     {
@@ -486,13 +491,14 @@ END;
     /**
      * Puts value to <authors />
      *
+     * The format of the authors array is
      * array(
      *     array('name'=>'Name1', 'user'=>'User1', 'email'=>'email1@email.com'),
      *     array('name'=>'Name2', 'user'=>'User2', 'email'=>'email2@email.com'),
      * );
      *
      * @param array $authors
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setAuthors($authors)
     {
@@ -504,13 +510,13 @@ END;
     }
 
     /**
-    * Add author to <authors/>
-    *
-    * @param string $name
-    * @param string $user
-    * @param string $email
-    * @return \Magento\Connect\Package
-    */
+     * Add author to <authors/>
+     *
+     * @param string $name
+     * @param string $user
+     * @param string $email
+     * @return $this
+     */
     public function addAuthor($name=null, $user=null, $email=null)
     {
         $this->_authors[] = array(
@@ -529,7 +535,7 @@ END;
      * Puts value to <date/>. Format should be Y-M-D.
      *
      * @param string $date
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setDate($date)
     {
@@ -541,7 +547,7 @@ END;
      * Puts value to <time />. Format should be H:i:s.
      *
      * @param string $time
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setTime($time)
     {
@@ -553,7 +559,7 @@ END;
      * Puts value to <version/>. Format should be X.Y.Z.
      *
      * @param string $version
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setVersion($version)
     {
@@ -565,7 +571,7 @@ END;
      * Puts value to <stability/>. It can be alpha, beta, devel and stable.
      *
      * @param string $stability
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setStability($stability)
     {
@@ -578,7 +584,7 @@ END;
      *
      * @param string $license
      * @param string $uri
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setLicense($license, $uri=null)
     {
@@ -593,7 +599,7 @@ END;
      * Puts value to <notes/>.
      *
      * @param string $notes
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setNotes($notes)
     {
@@ -602,15 +608,15 @@ END;
     }
 
     /**
-    * Retrieve \SimpleXMLElement node by xpath. If it absent, create new.
-    * For comparing nodes method uses attribute "name" in each nodes.
-    * If attribute "name" is same for both nodes, nodes are same.
-    *
-    * @param string $tag
-    * @param \SimpleXMLElement $parent
-    * @param string $name
-    * @return \SimpleXMLElement
-    */
+     * Retrieve \SimpleXMLElement node by xpath. If it absent, create new.
+     * For comparing nodes method uses attribute "name" in each nodes.
+     * If attribute "name" is same for both nodes, nodes are same.
+     *
+     * @param string $tag
+     * @param \SimpleXMLElement $parent
+     * @param string $name
+     * @return \SimpleXMLElement
+     */
     protected function _getNode($tag, $parent, $name='')
     {
         $found = false;
@@ -630,14 +636,13 @@ END;
         return $node;
     }
 
-    /**
-     * Add directory or file to <contents />.
-     *
-     * @param string $path Path to directory or file
-     * @param string $targetName Target name.
-     * @param string $hash MD5 hash of the file
-     * @return \Magento\Connect\Package
-     */
+     /**
+      * Add directory or file to <contents />.
+      *
+      * @param string $path Path to directory or file
+      * @param string $targetName Target name.
+      * @return $this
+      */
     public function addContent($path, $targetName)
     {
         $found = false;
@@ -663,11 +668,10 @@ END;
      * Exclude and Include can be add using Regular Expression.
      *
      * @param string $targetName Target name
-     * @param string $targetDir Path for target name
      * @param string $path Path to directory
      * @param string $exclude Exclude
      * @param string $include Include
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function addContentDir($targetName, $path, $exclude=null, $include=null)
     {
@@ -710,7 +714,7 @@ END;
      * @param string $channel
      * @param string $minVersion
      * @param string $maxVersion
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function addCompatible($packageName, $channel, $minVersion, $maxVersion)
     {
@@ -727,7 +731,7 @@ END;
      *
      * @param string $minVersion
      * @param string $maxVersion
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setDependencyPhpVersion($minVersion, $maxVersion)
     {
@@ -742,8 +746,7 @@ END;
 
     /**
      * Check PHP version restriction
-     * @param $phpVersion PHP_VERSION by default
-     * @return true | string
+     * @return true|string
      */
     public function checkPhpVersion()
     {
@@ -771,8 +774,8 @@ END;
 
     /**
      * Check PHP extensions availability
-     * @throws Exceptiom on failure
-     * @return true | array
+     * @throws \Exception On failure
+     * @return true|array
      */
     public function checkPhpDependencies()
     {
@@ -793,11 +796,11 @@ END;
     /**
      * Set dependency from php extensions.
      *
-     * $extension has next view:
+     * The $extension has next view:
      * array('curl', 'mysql')
      *
      * @param array|string $extensions
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function setDependencyPhpExtensions($extensions)
     {
@@ -812,18 +815,18 @@ END;
     }
 
     /**
-    * Set dependency from another packages.
-    *
-    * $packages should contain:
-    * array(
-    *     array('name'=>'test1', 'channel'=>'test1', 'min_version'=>'0.0.1', 'max_version'=>'0.1.0'),
-    *     array('name'=>'test2', 'channel'=>'test2', 'min_version'=>'0.0.1', 'max_version'=>'0.1.0'),
-    * )
-    *
-    * @param array $packages
-    * @param bool $clear
-    * @return \Magento\Connect\Package
-    */
+     * Set dependency from another packages.
+     *
+     * The $packages should contain:
+     * array(
+     *     array('name'=>'test1', 'channel'=>'test1', 'min_version'=>'0.0.1', 'max_version'=>'0.1.0'),
+     *     array('name'=>'test2', 'channel'=>'test2', 'min_version'=>'0.0.1', 'max_version'=>'0.1.0'),
+     * )
+     *
+     * @param array $packages
+     * @param bool $clear
+     * @return $this
+     */
     public function setDependencyPackages($packages, $clear = false)
     {
         if($clear) {
@@ -851,11 +854,12 @@ END;
     /**
      * Add package to dependency packages.
      *
-     * @param string $package
+     * @param string $name
      * @param string $channel
      * @param string $minVersion
      * @param string $maxVersion
-     * @return \Magento\Connect\Package
+     * @param array $files
+     * @return $this
      */
     public function addDependencyPackage($name, $channel, $minVersion, $maxVersion, $files = array())
     {
@@ -880,15 +884,13 @@ END;
         return $this;
     }
 
-
-
     /**
      * Add package to dependency extension.
      *
-     * @param string $package
+     * @param string $name
      * @param string $minVersion
      * @param string $maxVersion
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function addDependencyExtension($name, $minVersion, $maxVersion)
     {
@@ -1077,11 +1079,12 @@ END;
     }
 
     /**
-    * Helper for getContents(). Create recursively list.
-    *
-    * @param \SimpleXMLElement $parent
-    * @param string $path
-    */
+     * Helper for getContents(). Create recursively list.
+     *
+     * @param \SimpleXMLElement $parent
+     * @param string $path
+     * @return void
+     */
     protected function _getList($parent, $path)
     {
         if (count($parent) == 0) {
@@ -1113,11 +1116,13 @@ END;
     }
 
     /**
-    * Helper for getHashContents(). Create recursively list.
-    *
-    * @param \SimpleXMLElement $parent
-    * @param string $path
-    */
+     * Helper for getHashContents(). Create recursively list.
+     *
+     * @param \SimpleXMLElement $parent
+     * @param string $path
+     * @param string $hash
+     * @return void
+     */
     protected function _getHashList($parent, $path, $hash='')
     {
         if (count($parent) == 0) {
@@ -1230,9 +1235,6 @@ END;
         return $this->_dependencyPackages;
     }
 
-
-
-
     /**
      * Get string with XML content.
      *
@@ -1271,7 +1273,7 @@ END;
      * Setter for validation errors
      *
      * @param array $errors
-     * @return
+     * @return void
      */
     protected function setErrors(array $errors)
     {
@@ -1294,6 +1296,7 @@ END;
      * retrieved by calling getErrors();
      *
      * @return bool
+     * @throws \Magento\Exception
      */
     public function validate()
     {
@@ -1480,7 +1483,7 @@ END;
     /**
     * Clear dependencies
     *
-    * @return \Magento\Connect\Package
+    * @return $this
     */
     public function clearDependencies()
     {
@@ -1491,7 +1494,7 @@ END;
     /**
     * Clear contents
     *
-    * @return \Magento\Connect\Package
+    * @return $this
     */
     public function clearContents()
     {
diff --git a/lib/Magento/Connect/Package/Hotfix.php b/lib/Magento/Connect/Package/Hotfix.php
index 34af90c5998eb68402975ac8a211f8fa176e845e..4c90e08bf01b4ad699b674660df83e36cfd16fdb 100644
--- a/lib/Magento/Connect/Package/Hotfix.php
+++ b/lib/Magento/Connect/Package/Hotfix.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect\Package;
 
  /**
  * Class to work with Magento Connect Hotfix
@@ -31,17 +32,13 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Connect\Package;
-
 class Hotfix extends \Magento\Connect\Package
 {
-
     /**
      * Initializes an empty package object
      *
      * @param null|string $definition optional package definition xml
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     protected function _init($definition=null)
     {
@@ -75,10 +72,12 @@ END;
     }
 
     /**
-    * Add content to node <replace/>
-    *
-    * @return \Magento\Connect\Package\Hotfix
-    */
+     * Add content to node <replace/>
+     *
+     * @param string $path
+     * @param string $targetName
+     * @return $this
+     */
     public function addReplace($path, $targetName)
     {
         $found = false;
@@ -105,7 +104,7 @@ END;
      * @param string $path Path to directory
      * @param string $exclude Exclude
      * @param string $include Include
-     * @return \Magento\Connect\Package
+     * @return $this
      */
     public function addReplaceDir($targetName, $targetDir, $path, $exclude=null, $include=null)
     {
diff --git a/lib/Magento/Connect/Package/Reader.php b/lib/Magento/Connect/Package/Reader.php
index 4ba0635827c01f4240fcb22bc7fa0d003a2619fa..a70e7b37a7c5338a6e647b3aa09324adc7e7d10d 100644
--- a/lib/Magento/Connect/Package/Reader.php
+++ b/lib/Magento/Connect/Package/Reader.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect\Package;
 
 /**
  * Class to get package.xml from different places.
@@ -31,11 +32,8 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Connect\Package;
-
 class Reader
 {
-
     /**
     * Name of package file
     */
@@ -47,25 +45,25 @@ class Reader
     const PATH_TO_TEMPORARY_DIRECTORY = 'var/package/tmp/';
 
     /**
-    * Current path to file.
-    *
-    * @var string
-    */
+     * Current path to file.
+     *
+     * @var string
+     */
     protected $_file = '';
 
     /**
-    * Archivator is used for extract DEFAULT_NAME_PACKAGE.
-    *
-    * @var \Magento\Archive
-    */
+     * Archivator is used for extract DEFAULT_NAME_PACKAGE.
+     *
+     * @var \Magento\Archive
+     */
     protected $_archivator = null;
 
     /**
-    * Constructor initializes $_file.
-    *
-    * @param string $file
-    * @return \Magento\Connect\Package\Reader
-    */
+     * Constructor initializes $_file.
+     *
+     * @param string $file
+     * @return $this
+     */
     public function __construct($file='')
     {
         if ($file) {
@@ -77,10 +75,10 @@ class Reader
     }
 
     /**
-    * Retrieve archivator.
-    *
-    * @return \Magento\Archive
-    */
+     * Retrieve archivator.
+     *
+     * @return \Magento\Archive
+     */
     protected function _getArchivator()
     {
         if (is_null($this->_archivator)) {
@@ -90,10 +88,11 @@ class Reader
     }
 
     /**
-    * Open file directly or from archive and return his content.
-    *
-    * @return string Content of file $file
-    */
+     * Open file directly or from archive and return his content.
+     *
+     * @return string Content of file $file
+     * @throws \Exception
+     */
     public function load()
     {
         if (!is_file($this->_file) || !is_readable($this->_file)) {
@@ -112,10 +111,11 @@ class Reader
     }
 
     /**
-    * Read content file.
-    *
-    * @return string Content of file $file
-    */
+     * Read content file.
+     *
+     * @return string Content of file $file
+     * @throws \Magento\Exception
+     */
     protected function _readFile()
     {
         $handle = fopen($this->_file, 'r');
@@ -130,11 +130,12 @@ class Reader
     }
 
     /**
-    * Loads a package from specified resource
-    *
-    * @param resource $resource only file resources are supported at the moment
-    * @return \Magento\Connect\Package
-    */
+     * Loads a package from specified resource
+     *
+     * @param resource &$resource only file resources are supported at the moment
+     * @return \Magento\Connect\Package
+     * @throws \Magento\Exception
+     */
     protected function _loadResource(&$resource)
     {
         $data = '';
diff --git a/lib/Magento/Connect/Package/VO.php b/lib/Magento/Connect/Package/VO.php
index 8b04e675331aa24de951c885134ba5556342bbdc..e38240aa1f67a29437fe8ec1b7248d5fd8ff6490 100644
--- a/lib/Magento/Connect/Package/VO.php
+++ b/lib/Magento/Connect/Package/VO.php
@@ -23,75 +23,104 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Package;
 
 class VO implements \Iterator
 {
+    /**
+     * @var array
+     */
     protected $properties = array(
         'name' => '',
-	    'package_type_vesrion' => '',
+        'package_type_vesrion' => '',
         'cahnnel' => '',
         'extends' => '',
-		'summary' => '',
-		'description' => '',
-		'authors' => '',
-		'date' => '',
-	    'time' => '',
-		'version' => '',
-	    'stability' => 'dev',
-	    'license' => '',
-	    'license_uri' => '',
-	    'contents' => '',
-	    'compatible' => '',	  
-		'hotfix' => ''  
-		);
+        'summary' => '',
+        'description' => '',
+        'authors' => '',
+        'date' => '',
+        'time' => '',
+        'version' => '',
+        'stability' => 'dev',
+        'license' => '',
+        'license_uri' => '',
+        'contents' => '',
+        'compatible' => '',
+        'hotfix' => ''
+    );
 
-		public function rewind() {
-		    reset($this->properties);
-		}
+    /**
+     * @return void
+     */
+    public function rewind() {
+        reset($this->properties);
+    }
 
-		public function valid() {
-		    return current($this->properties) !== false;
-		}
+    /**
+     * @return bool
+     */
+    public function valid() {
+        return current($this->properties) !== false;
+    }
 
-		public function key() {
-		    return key($this->properties);
-		}
+    /**
+     * @return string
+     */
+    public function key() {
+        return key($this->properties);
+    }
 
-		public function current() {
-		    return current($this->properties);
-		}
+    /**
+     * @return string
+     */
+    public function current() {
+        return current($this->properties);
+    }
 
-		public function next() {
-		    next($this->properties);
-		}
+    /**
+     * @return void
+     */
+    public function next() {
+        next($this->properties);
+    }
 
-		public function __get($var)
-		{
-		    if (isset($this->properties[$var])) {
-		        return $this->properties[$var];
-		    }
-		    return null;
-		}
+    /**
+     * @param string $var
+     * @return null|string
+     */
+    public function __get($var)
+    {
+        if (isset($this->properties[$var])) {
+            return $this->properties[$var];
+        }
+        return null;
+    }
 
-		public function __set($var, $value)
-		{
-		    if (is_string($value)) {
-		        $value = trim($value);
-		    }
-		    if (isset($this->properties[$var])) {
-		        if ($value === null) {
-		            $value = '';
-		        }
-		        $this->properties[$var] = $value;
-		    }
-		}
+    /**
+     * @param string $var
+     * @param null|string $value
+     * @return void
+     */
+    public function __set($var, $value)
+    {
+        if (is_string($value)) {
+            $value = trim($value);
+        }
+        if (isset($this->properties[$var])) {
+            if ($value === null) {
+                $value = '';
+            }
+            $this->properties[$var] = $value;
+        }
+    }
 
-		public function toArray()
-		{
-		    return $this->properties;
-		}
+    /**
+     * @return array
+     */
+    public function toArray()
+    {
+        return $this->properties;
+    }
 
 }
 
diff --git a/lib/Magento/Connect/Package/Writer.php b/lib/Magento/Connect/Package/Writer.php
index 1969c23744682d6ea4164bce0eba20c661ae70da..d753e3773cf1123e55b1467f991cbc102c39d2be 100644
--- a/lib/Magento/Connect/Package/Writer.php
+++ b/lib/Magento/Connect/Package/Writer.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect\Package;
 
 /**
  * Class to create archive.
@@ -31,64 +32,61 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Connect\Package;
-
 class Writer
 {
-
     /**
-    * Name of package configuration file
-    */
+     * Name of package configuration file
+     */
     const DEFAULT_NAME_PACKAGE_CONFIG = 'package.xml';
 
     /**
-    * Temporary dir for extract DEFAULT_NAME_PACKAGE.
-    */
+     * Temporary dir for extract DEFAULT_NAME_PACKAGE.
+     */
     const PATH_TO_TEMPORARY_DIRECTORY = 'var/package/tmp/';
 
     /**
-    * Files are used in package.
-    *
-    * @var array
-    */
+     * Files are used in package.
+     *
+     * @var array
+     */
     protected $_files = array();
 
     /**
-    * Archivator is used for extract DEFAULT_NAME_PACKAGE.
-    *
-    * @var \Magento\Archive
-    */
+     * Archivator is used for extract DEFAULT_NAME_PACKAGE.
+     *
+     * @var \Magento\Archive
+     */
     protected $_archivator = null;
 
     /**
-    * Name of package with extension. Extension should be only one.
-    * "package.tar.gz" is not ability, only "package.tgz".
-    *
-    * @var string
-    */
+     * Name of package with extension. Extension should be only one.
+     * "package.tar.gz" is not ability, only "package.tgz".
+     *
+     * @var string
+     */
     protected $_namePackage = 'package';
 
     /**
-    * Temporary directory where package is situated.
-    *
-    * @var string
-    */
+     * Temporary directory where package is situated.
+     *
+     * @var string
+     */
     protected $_temporaryPackageDir = '';
 
     /**
-    * Path to archive with package.
-    *
-    * @var mixed
-    */
+     * Path to archive with package.
+     *
+     * @var string
+     */
     protected $_pathToArchive = '';
 
     /**
-    * Constructor initializes $_file.
-    *
-    * @param array $files
-    * @param string $namePackage
-    * @return \Magento\Connect\Package\Reader
-    */
+     * Constructor initializes $_file.
+     *
+     * @param array $files
+     * @param string $namePackage
+     * @return $this
+     */
     public function __construct($files, $namePackage='')
     {
         $this->_files = $files;
@@ -97,10 +95,10 @@ class Writer
     }
 
     /**
-    * Retrieve archivator.
-    *
-    * @return \Magento\Archive
-    */
+     * Retrieve archivator.
+     *
+     * @return \Magento\Archive
+     */
     protected function _getArchivator()
     {
         if (is_null($this->_archivator)) {
@@ -110,18 +108,18 @@ class Writer
     }
 
     /**
-    * Create dir in PATH_TO_TEMPORARY_DIRECTORY and move all files
-    * to this dir.
-    *
-    * @return \Magento\Connect\Package\Writer
-    */
+     * Create dir in PATH_TO_TEMPORARY_DIRECTORY and move all files
+     * to this dir.
+     *
+     * @return $this
+     */
     public function composePackage()
     {
-        @mkdir(self::PATH_TO_TEMPORARY_DIRECTORY, 0777, true);        
+        @mkdir(self::PATH_TO_TEMPORARY_DIRECTORY, 0777, true);
         $root = self::PATH_TO_TEMPORARY_DIRECTORY . basename($this->_namePackage);
         @mkdir($root, 0777, true);
         foreach ($this->_files as $file) {
-            
+
             if (is_dir($file) || is_file($file)) {
                 $fileName = basename($file);
                 $filePath = dirname($file);
@@ -138,13 +136,13 @@ class Writer
     }
 
     /**
-    * Create dir in PATH_TO_TEMPORARY_DIRECTORY and move all files
-    * to this dir.
-    * This dir has a structure compatible with previous version of Magento Connact Manager
-    *
-    * @param arra $destinationFiles
-    * @return \Magento\Connect\Package\Writer
-    */
+     * Create dir in PATH_TO_TEMPORARY_DIRECTORY and move all files
+     * to this dir.
+     * This dir has a structure compatible with previous version of Magento Connact Manager
+     *
+     * @param array $destinationFiles
+     * @return $this
+     */
     public function composePackageV1x(array $destinationFiles)
     {
         @mkdir(self::PATH_TO_TEMPORARY_DIRECTORY, 0777, true);
@@ -170,11 +168,11 @@ class Writer
     }
 
     /**
-    * Add package.xml to temporary package directory.
-    *
-    * @param $content
-    * @return \Magento\Connect\Package\Writer
-    */
+     * Add package.xml to temporary package directory.
+     *
+     * @param mixed $content
+     * @return $this
+     */
     public function addPackageXml($content)
     {
         file_put_contents($this->_temporaryPackageDir . '/' . self::DEFAULT_NAME_PACKAGE_CONFIG, $content);
@@ -182,10 +180,10 @@ class Writer
     }
 
     /**
-    * Archives package.
-    *
-    * @return \Magento\Connect\Package\Writer
-    */
+     * Archives package.
+     *
+     * @return $this
+     */
     public function archivePackage()
     {
         $this->_pathToArchive = $this->_getArchivator()->pack(
@@ -197,12 +195,12 @@ class Writer
         \Magento\System\Dirs::rm(array("-r", $this->_temporaryPackageDir));
         return $this;
     }
-    
+
     /**
-    * Getter for pathToArchive
-    *
-    * @return string
-    */
+     * Getter for pathToArchive
+     *
+     * @return string
+     */
     public function getPathToArchive()
     {
         return $this->_pathToArchive;
diff --git a/lib/Magento/Connect/Packager.php b/lib/Magento/Connect/Packager.php
index 380bc9019120adebb12c81533a70b158abcdf18c..96df959877bda981590fefafaf9805ec258f276e 100644
--- a/lib/Magento/Connect/Packager.php
+++ b/lib/Magento/Connect/Packager.php
@@ -23,6 +23,9 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect;
+
+use Magento\HTTP\IClient;
 
 /**
  * Class to manipulate with packages
@@ -31,9 +34,6 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Connect;
-
 class Packager
 {
     /**
@@ -48,9 +48,11 @@ class Packager
      * @var \Magento\Archive
      */
     protected $_archiver = null;
-    protected $_http = null;
-
 
+    /**
+     * @var IClient
+     */
+    protected $_http = null;
 
     /**
      *
@@ -64,18 +66,24 @@ class Packager
         return $this->_archiver;
     }
 
+    /**
+     * @return IClient
+     */
     public function getDownloader()
     {
-        if(is_null($this->_http)) {
+        if (is_null($this->_http)) {
             $this->_http = \Magento\HTTP\Client::getInstance();
         }
         return $this->_http;
     }
 
-
+    /**
+     * @param string $ftpString
+     * @return \Magento\Object[]
+     */
     public function getRemoteConf($ftpString)
     {
-        $ftpObj = new \Magento\Connect\Ftp();
+        $ftpObj = new Ftp();
         $ftpObj->connect($ftpString);
         $cfgFile = "connect.cfg";
         $cacheFile = "cache.cfg";
@@ -85,13 +93,13 @@ class Packager
 
         $remoteConfigExists = $ftpObj->fileExists($cfgFile);
         $tempConfigFile = uniqid($cfgFile."_temp");
-        if(!$remoteConfigExists) {
-            $remoteCfg = new \Magento\Connect\Config($tempConfigFile);
+        if (!$remoteConfigExists) {
+            $remoteCfg = new Config($tempConfigFile);
             $remoteCfg->store();
             $ftpObj->upload($cfgFile, $tempConfigFile);
         } else {
             $ftpObj->get($tempConfigFile, $cfgFile);
-            $remoteCfg = new \Magento\Connect\Config($tempConfigFile);
+            $remoteCfg = new Config($tempConfigFile);
         }
 
         $ftpObj->chdir($wd);
@@ -99,42 +107,48 @@ class Packager
         $remoteCacheExists = $ftpObj->fileExists($cacheFile);
         $tempCacheFile = uniqid($cacheFile."_temp");
 
-        if(!$remoteCacheExists) {
-            $remoteCache = new \Magento\Connect\Singleconfig($tempCacheFile);
+        if (!$remoteCacheExists) {
+            $remoteCache = new Singleconfig($tempCacheFile);
             $remoteCache->clear();
             $ftpObj->upload($cacheFile, $tempCacheFile);
         } else {
             $ftpObj->get($tempCacheFile, $cacheFile);
-            $remoteCache = new \Magento\Connect\Singleconfig($tempCacheFile);
+            $remoteCache = new Singleconfig($tempCacheFile);
         }
         $ftpObj->chdir($wd);
         return array($remoteCache, $remoteCfg, $ftpObj);
     }
 
-
+    /**
+     * @param string $ftpString
+     * @return \Magento\Object[]
+     */
     public function getRemoteCache($ftpString)
     {
 
-        $ftpObj = new \Magento\Connect\Ftp();
+        $ftpObj = new Ftp();
         $ftpObj->connect($ftpString);
         $remoteConfigExists = $ftpObj->fileExists("cache.cfg");
         if(!$remoteConfigExists) {
             $configFile= uniqid("temp_cachecfg_");
-            $remoteCfg = new \Magento\Connect\Singleconfig($configFile);
+            $remoteCfg = new Singleconfig($configFile);
             $remoteCfg->clear();
             $ftpObj->upload("cache.cfg", $configFile);
         } else {
             $configFile = uniqid("temp_cachecfg_");
             $ftpObj->get($configFile, "cache.cfg");
-            $remoteCfg = new \Magento\Connect\Singleconfig($configFile);
+            $remoteCfg = new Singleconfig($configFile);
         }
         return array($remoteCfg, $ftpObj);
     }
 
-
+    /**
+     * @param string $ftpString
+     * @return \Magento\Object[]
+     */
     public function getRemoteConfig($ftpString)
     {
-        $ftpObj = new \Magento\Connect\Ftp();
+        $ftpObj = new Ftp();
         $ftpObj->connect($ftpString);
         $cfgFile = "connect.cfg";
 
@@ -142,17 +156,22 @@ class Packager
         $remoteConfigExists = $ftpObj->fileExists($cfgFile);
         $tempConfigFile = uniqid($cfgFile."_temp");
         if(!$remoteConfigExists) {
-            $remoteCfg = new \Magento\Connect\Config($tempConfigFile);
+            $remoteCfg = new Config($tempConfigFile);
             $remoteCfg->store();
             $ftpObj->upload($cfgFile, $tempConfigFile);
         } else {
             $ftpObj->get($tempConfigFile, $cfgFile);
-            $remoteCfg = new \Magento\Connect\Config($tempConfigFile);
+            $remoteCfg = new Config($tempConfigFile);
         }
         $ftpObj->chdir($wd);
         return array($remoteCfg, $ftpObj);
     }
 
+    /**
+     * @param Singleconfig $cache
+     * @param Ftp $ftpObj
+     * @return void
+     */
     public function writeToRemoteCache($cache, $ftpObj)
     {
         $wd = $ftpObj->getcwd();
@@ -161,6 +180,11 @@ class Packager
         $ftpObj->chdir($wd);
     }
 
+    /**
+     * @param Singleconfig $cache
+     * @param Ftp $ftpObj
+     * @return void
+     */
     public function writeToRemoteConfig($cache, $ftpObj)
     {
         $wd = $ftpObj->getcwd();
@@ -171,11 +195,11 @@ class Packager
 
     /**
      *
-     * @param $chanName
-     * @param $package
-     * @param \Magento\Connect\Singleconfig $cacheObj
-     * @param $ftp
-     * @return unknown_type
+     * @param string $chanName
+     * @param string $package
+     * @param Singleconfig $cacheObj
+     * @param Config $configObj
+     * @return void
      */
     public function processUninstallPackage($chanName, $package, $cacheObj, $configObj)
     {
@@ -196,11 +220,11 @@ class Packager
 
     /**
      *
-     * @param $chanName
-     * @param $package
-     * @param \Magento\Connect\Singleconfig $cacheObj
-     * @param \Magento\Connect\Ftp $ftp
-     * @return unknown_type
+     * @param string $chanName
+     * @param string $package
+     * @param Singleconfig $cacheObj
+     * @param Ftp $ftp
+     * @return void
      */
     public function processUninstallPackageFtp($chanName, $package, $cacheObj, $ftp)
     {
@@ -213,11 +237,23 @@ class Packager
         $ftp->chdir($ftpDir);
     }
 
+    /**
+     * @param string $str
+     * @return string
+     */
     protected function convertFtpPath($str)
     {
         return str_replace("\\", "/", $str);
     }
 
+    /**
+     *
+     * @param string $package
+     * @param string $file
+     * @param Config $configObj
+     * @param Ftp $ftp
+     * @return void
+     */
     public function processInstallPackageFtp($package, $file, $configObj, $ftp)
     {
         $ftpDir = $ftp->getcwd();
@@ -249,6 +285,7 @@ class Packager
      * Package installation to FS
      * @param \Magento\Connect\Package $package
      * @param string $file
+     * @param Config $configObj
      * @return void
      * @throws \Exception
      */
@@ -284,11 +321,11 @@ class Packager
 
     /**
      * Get local modified files
-     * @param $chanName
-     * @param $package
-     * @param $cacheObj
-     * @param $configObj
-     * @return array
+     * @param string $chanName
+     * @param string $package
+     * @param Singleconfig $cacheObj
+     * @param Config $configObj
+     * @return string[]
      */
     public function getLocalModifiedFiles($chanName, $package, $cacheObj, $configObj)
     {
@@ -306,11 +343,11 @@ class Packager
     /**
      * Get remote modified files
      *
-     * @param $chanName
-     * @param $package
-     * @param $cacheObj
-     * @param \Magento\Connect\Ftp $ftp
-     * @return array
+     * @param string $chanName
+     * @param string $package
+     * @param Singleconfig $cacheObj
+     * @param Ftp $ftp
+     * @return string[]
      */
     public function getRemoteModifiedFiles($chanName, $package, $cacheObj, $ftp)
     {
@@ -333,11 +370,11 @@ class Packager
 
 
     /**
-     *
      * Get upgrades list
      *
      * @param string/array $channels
-     * @param \Magento\Connect\Singleconfig $cacheObject
+     * @param Singleconfig $cacheObject
+     * @param Config $configObj
      * @param \Magento\Connect\Rest $restObj optional
      * @param bool $checkConflicts
      * @return array
@@ -367,7 +404,7 @@ class Packager
             }
 
             $channel = $cacheObject->getChannel($chan);
-            $uri = $channel[\Magento\Connect\Singleconfig::K_URI];
+            $uri = $channel[Singleconfig::K_URI];
             $restObj->setChannel($uri);
             $remotePackages = $restObj->getPackagesHashed();
 
@@ -382,7 +419,7 @@ class Packager
                 }
                 $package = $remotePackages[$localName];
                 $neededToUpgrade = false;
-                $remoteVersion = $localVersion = trim($localData[\Magento\Connect\Singleconfig::K_VER]);
+                $remoteVersion = $localVersion = trim($localData[Singleconfig::K_VER]);
                 foreach($package as $version => $s) {
 
                     if( $cacheObject->compareStabilities($s, $state) < 0 ) {
@@ -415,10 +452,11 @@ class Packager
 
     /**
      * Get uninstall list
+     *
      * @param string $chanName
      * @param string $package
-     * @param \Magento\Connect\Singleconfig $cache
-     * @param \Magento\Connect\Config $config
+     * @param Singleconfig $cache
+     * @param Config $config
      * @param bool $withDepsRecursive
      * @return array
      */
@@ -485,14 +523,16 @@ class Packager
     /**
      * Get dependencies list/install order info
      *
-     *
      * @param string $chanName
      * @param string $package
-     * @param \Magento\Connect\Singleconfig $cache
-     * @param \Magento\Connect\Config $config
-     * @param mixed $versionMax
-     * @param mixed $versionMin
-     * @return mixed
+     * @param Singleconfig $cache
+     * @param Config $config
+     * @param string|false $versionMax
+     * @param string|false $versionMin
+     * @param bool $withDepsRecursive
+     * @param bool $forceRemote
+     * @return array
+     * @throws \Exception
      */
     public function getDependenciesList($chanName, $package, $cache, $config, $versionMax = false, $versionMin = false,
         $withDepsRecursive = true, $forceRemote = false
@@ -623,7 +663,7 @@ class Packager
      * Process dependencies hash
      * Makes topological sorting and gives operation order list
      *
-     * @param array $depsHash
+     * @param array &$depsHash
      * @param bool $sortReverse
      * @return array
      */
diff --git a/lib/Magento/Connect/Rest.php b/lib/Magento/Connect/Rest.php
index 6732c20acd2ede25b3f34e22544fc2c755010ac3..d95c4eef0fcceec170a275fb8460cf83dfb62331 100644
--- a/lib/Magento/Connect/Rest.php
+++ b/lib/Magento/Connect/Rest.php
@@ -23,6 +23,8 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect;
+use Magento\Connect\Channel\VO;
 
 /**
  * Class to work with remote REST interface
@@ -31,9 +33,6 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Connect;
-
 class Rest
 {
 
@@ -50,7 +49,6 @@ class Rest
      */
     protected $_loader = null;
 
-
     /**
      * XML parser
      * @var \Magento\Xml\Parser
@@ -64,14 +62,16 @@ class Rest
     protected $_chanUri = '';
 
     /**
-    * Protocol HTTP or FTP
-    *
-    * @var string http or ftp
-    */
+     * Protocol HTTP or FTP
+     *
+     * @var string http or ftp
+     */
     protected $_protocol = '';
 
     /**
      * Constructor
+     *
+     * @param string $protocol
      */
     public function __construct($protocol="http")
     {
@@ -89,7 +89,7 @@ class Rest
      * Set channel info
      *
      * @param string $uri
-     * @param string $name
+     * @return void
      */
     public function setChannel($uri)
     {
@@ -124,7 +124,8 @@ class Rest
 
     /**
      * Load URI response
-     * @param string $uri
+     * @param string $uriSuffix
+     * @return false|string
      */
     protected function loadChannelUri($uriSuffix)
     {
@@ -140,7 +141,9 @@ class Rest
 
     /**
      * Get channels list of URI
-     * @return array
+     *
+     * @return VO
+     * @throws \Exception
      */
     public function getChannelInfo()
     {
@@ -153,7 +156,7 @@ class Rest
         $out = $parser->loadXML($out)->xmlToArray();
 
         // TODO: add channel validator
-        $vo = new \Magento\Connect\Channel\VO();
+        $vo = new VO();
         $vo->fromArray($out['channel']);
         if(!$vo->validate()) {
             throw new \Exception("Invalid channel.xml file");
@@ -164,7 +167,8 @@ class Rest
 
     /**
      * Get packages list of channel
-     * @return array
+     *
+     * @return array|false
      */
     public function getPackages()
     {
@@ -189,7 +193,9 @@ class Rest
         return array();
     }
 
-
+    /**
+     * @return array|false
+     */
     public function getPackagesHashed()
     {
         $out = $this->loadChannelUri(self::PACKAGES_XML);
@@ -233,8 +239,8 @@ class Rest
 
     /**
      * Stub
-     * @param $n
-     * @return unknown_type
+     * @param string $n
+     * @return string
      */
     public function escapePackageName($n)
     {
@@ -244,6 +250,7 @@ class Rest
     /**
      * Get releases list of package on current channel
      * @param string $package package name
+     * @return false|array
      */
     public function getReleases($package)
     {
@@ -267,7 +274,7 @@ class Rest
 
     /**
      * Sort releases
-     * @param array $releases
+     * @param array &$releases
      * @return void
      */
     public function sortReleases(array &$releases)
@@ -279,19 +286,19 @@ class Rest
     /**
      * Sort releases callback
      * @param string $a
-     * @param srting $b
+     * @param string $b
      * @return int
      */
     protected function sortReleasesCallback($a, $b)
     {
-        return version_compare($a['v'],$b['v']);
+        return version_compare($a['v'], $b['v']);
     }
 
     /**
      * Get package info (package.xml)
      *
-     * @param $package
-     * @return unknown_type
+     * @param string $package
+     * @return \Magento\Connect\Package
      */
     public function getPackageInfo($package)
     {
@@ -304,8 +311,8 @@ class Rest
 
     /**
      *
-     * @param $package
-     * @param $version
+     * @param string $package
+     * @param string $version
      * @return \Magento\Connect\Package
      */
     public function getPackageReleaseInfo($package, $version)
@@ -319,8 +326,12 @@ class Rest
 
     /**
      * Get package archive file of release
+     *
      * @param string $package package name
      * @param string $version version
+     * @param string $targetFile
+     * @return true|void
+     * @throws \Exception
      */
     public function downloadPackageFileOfRelease($package, $version, $targetFile)
     {
@@ -354,8 +365,15 @@ class Rest
         return true;
     }
 
+    /**
+     * @var array
+     */
     protected $states = array('b'=>'beta', 'd'=>'dev', 's'=>'stable', 'a'=>'alpha');
 
+    /**
+     * @param string $s
+     * @return string
+     */
     public function shortStateToLong($s)
     {
         return isset($this->states[$s]) ? $this->states[$s] : 'dev';
diff --git a/lib/Magento/Connect/Singleconfig.php b/lib/Magento/Connect/Singleconfig.php
index 9b860e201e7835b56aaecb426ebf1bc026ed1345..e4d76bcbd7cef2d4268884762f343713b050d1be 100644
--- a/lib/Magento/Connect/Singleconfig.php
+++ b/lib/Magento/Connect/Singleconfig.php
@@ -23,6 +23,7 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
+namespace Magento\Connect;
 
 /**
  * Class to manipulate with channel/package cache file
@@ -31,9 +32,6 @@
  * @package     Magento_Connect
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-
-namespace Magento\Connect;
-
 class Singleconfig
 {
 
@@ -51,13 +49,13 @@ class Singleconfig
 
     /**
      *
-     * @var unknown_type
+     * @var bool
      */
     protected $_debug = false;
 
     /**
      *
-     * @var unknown_type
+     * @var Validator
      */
     protected $_validator;
 
@@ -78,6 +76,10 @@ class Singleconfig
     const K_PACK_DEPS = 'pack_deps';
     const K_CONFIG = 'config';
 
+    /**
+     * @param string $str
+     * @return string|false
+     */
     public function getValidUri($str)
     {
         $data = parse_url($str);
@@ -87,11 +89,18 @@ class Singleconfig
         return false;
     }
 
+    /**
+     * @return string
+     */
     public function getFilename()
     {
         return $this->_readFilename;
     }
 
+    /**
+     * @param string $uri
+     * @return string
+     */
     public function formatUri($uri)
     {
         $uri = rtrim($uri, "/");
@@ -102,7 +111,7 @@ class Singleconfig
 
     /**
      * Get data
-     * @return unknown_type
+     * @return array
      */
     public function getData()
     {
@@ -111,8 +120,7 @@ class Singleconfig
 
     /**
      * Constructor
-     * @param srting $file
-     * @return void
+     * @param string $file
      */
     public function __construct($file = "cache.cfg")
     {
@@ -126,7 +134,8 @@ class Singleconfig
 
     /**
      * Load cache from file
-     * @param string $file
+     *
+     * @param string|false $file
      * @return void
      */
     public function load($file = false)
@@ -183,7 +192,7 @@ class Singleconfig
 
     /**
      * Save contents
-     * @param string $file
+     * @param string|false $file
      * @return void
      */
     public function save($file = false)
@@ -217,7 +226,10 @@ class Singleconfig
         );
     }
 
-
+    /**
+     * @param string $chanName
+     * @return bool
+     */
     public function isChannel($chanName)
     {
         if($this->isChannelName($chanName)) {
@@ -251,7 +263,7 @@ class Singleconfig
 
     /**
      * Is channel name?
-     * @param $chanName
+     * @param string $chanName
      * @return bool
      */
     public function isChannelName($chanName)
@@ -271,7 +283,7 @@ class Singleconfig
 
     /**
      * Is channel uri?
-     * @param $uri
+     * @param string $uri
      * @return bool
      */
     public function isChannelUri($uri)
@@ -339,7 +351,7 @@ class Singleconfig
      * Set channel record
      * @param string $chanName
      * @param string $uri
-     * @param mixed $data
+     * @param array $data
      * @param array $packages
      * @return void
      */
@@ -357,7 +369,8 @@ class Singleconfig
      * Set package record
      * @param string $chanName
      * @param string $packageName
-     * @param mixed $data
+     * @param array $data
+     * @param string $oneField
      * @return void
      */
     protected function setPackageRecord($chanName, $packageName, $data, $oneField = null)
@@ -369,8 +382,6 @@ class Singleconfig
         }
     }
 
-
-
     /**
      * Unset package record
      * @param string $chanName
@@ -386,6 +397,7 @@ class Singleconfig
      * Get package record
      * @param string $chanName
      * @param string $packageName
+     * @param string $field
      * @return array
      */
     protected function fetchPackage($chanName, $packageName, $field = null)
@@ -477,9 +489,9 @@ class Singleconfig
 
     /**
      * Add channel
-     * @param $chanName
-     * @param $uri
-     * @param $data
+     * @param string $chanName
+     * @param string $uri
+     * @param array $data
      * @return void
      */
     public function addChannel($chanName, $uri, $data = array())
@@ -503,7 +515,7 @@ class Singleconfig
 
     /**
      * Delete channel
-     * @param $chanName
+     * @param string $chanName
      * @return void
      */
     public function deleteChannel($chanName)
@@ -531,8 +543,8 @@ class Singleconfig
     /**
      * Converts channel name, url or alias to channel name
      * throws exception if not found
-     * @param srting $chanName
-     * @return string
+     * @param string $chanName
+     * @return string|void
      */
     public function chanName($chanName)
     {
@@ -543,6 +555,10 @@ class Singleconfig
         return $channelData[self::K_NAME];
     }
 
+    /**
+     * @param string $chan
+     * @return string|void
+     */
     public function chanUrl($chan)
     {
         $channelData = $this->getChannel($chan);
@@ -555,7 +571,8 @@ class Singleconfig
 
     /**
      * Add package
-     * @param \Magento\Connect\Package $package
+     *
+     * @param Package $package
      * @return void
      */
     public function addPackage($package)
@@ -606,17 +623,29 @@ class Singleconfig
         return null;
     }
 
+    /**
+     * @param string $chanName
+     * @param string $package
+     * @return Package
+     * @throws \Exception
+     */
     public function getPackageObject($chanName, $package)
     {
         $chanName = $this->chanName($chanName);
         if($this->hasPackageRecord($chanName, $package)) {
             $data = $this->fetchPackage($chanName, $package);
-            return new \Magento\Connect\Package($data[self::K_XML]);
+            return new Package($data[self::K_XML]);
         }
         throw new \Exception("Cannot get package: '{$package}'");
     }
 
-
+    /**
+     * @param string $chanName
+     * @param string $package
+     * @param string|false $versionMin
+     * @param string|false $versionMax
+     * @return bool
+     */
     public function hasPackage($chanName, $package, $versionMin = false, $versionMax = false)
     {
         $chanName = $this->chanName($chanName);
@@ -628,6 +657,12 @@ class Singleconfig
         return $this->versionInRange($installedVersion, $versionMin, $versionMax);
     }
 
+    /**
+     * @param string $version
+     * @param string|false $versionMin
+     * @param string|false $versionMax
+     * @return bool
+     */
     public function versionInRange($version, $versionMin = false, $versionMax = false)
     {
         if(false === $versionMin) {
@@ -643,6 +678,13 @@ class Singleconfig
         return $minOk && $maxOk;
     }
 
+    /**
+     * @param string $min1
+     * @param string $max1
+     * @param string $min2
+     * @param string $max2
+     * @return bool
+     */
     public function hasVersionRangeIntersect($min1, $max1, $min2, $max2)
     {
         if(version_compare($min1, $min2, ">") && version_compare($max1, $max2, ">")) {
@@ -669,7 +711,7 @@ class Singleconfig
 
     /**
      * Output error - throw exception
-     * @param $message
+     * @param string $message
      * @throws \Exception
      * @return void
      */
@@ -678,23 +720,28 @@ class Singleconfig
         throw new \Exception($message);
     }
 
-
-
-
-
+    /**
+     * @param int $s1
+     * @param int $s2
+     * @return int
+     */
     public function compareStabilities($s1, $s2)
     {
         if(!$this->_validator) {
-            $this->_validator = new \Magento\Connect\Validator();
+            $this->_validator = new Validator();
         }
         return $this->_validator->compareStabilities($s1, $s2);
     }
 
-
-
+    /**
+     * @param array $restData
+     * @param string|false $argVersionMin
+     * @param string|false $argVersionMax
+     * @param string $preferredStability
+     * @return bool|string
+     */
     public function detectVersionFromRestArray($restData, $argVersionMin = false, $argVersionMax = false, $preferredStability = 'devel')
     {
-
         if(!is_array($restData)) {
             return false;
         }
@@ -710,7 +757,12 @@ class Singleconfig
         return false;
     }
 
-
+    /**
+     * @param string $chanName
+     * @param string $package
+     * @param array $data
+     * @return bool
+     */
     public function setPackageDependencies($chanName, $package, $data)
     {
         $chanName = $this->chanName($chanName);
@@ -722,6 +774,11 @@ class Singleconfig
         return false;
     }
 
+    /**
+     * @param string $chanName
+     * @param string $package
+     * @return array|false
+     */
     public function getPackageDependencies($chanName, $package)
     {
         $chanName = $this->chanName($chanName);
@@ -731,8 +788,12 @@ class Singleconfig
         return false;
     }
 
-
-
+    /**
+     * @param string $chanName
+     * @param string $package
+     * @param array $data
+     * @return bool
+     */
     public function setDependencyInfo($chanName, $package, $data)
     {
         $chanName = $this->chanName($chanName);
@@ -744,6 +805,11 @@ class Singleconfig
         return false;
     }
 
+    /**
+     * @param string $chanName
+     * @param string $package
+     * @return array|false
+     */
     public function getDependencyInfo($chanName, $package)
     {
         $chanName = $this->chanName($chanName);
@@ -753,13 +819,18 @@ class Singleconfig
         return false;
     }
 
-
-
+    /**
+     * @return array
+     */
     public function getChannelNames()
     {
         return array_keys($this->_data[self::K_CHAN]);
     }
 
+    /**
+     * @param string|false $channel
+     * @return array
+     */
     public function getPackagesData($channel = false)
     {
         if(false == $channel) {
@@ -772,6 +843,12 @@ class Singleconfig
         return $this->getChannel($channel);
     }
 
+    /**
+     * @param array $deps
+     * @param string $chanName
+     * @param string $packageName
+     * @return bool
+     */
     public function specifiedInDependencyList($deps, $chanName, $packageName)
     {
         foreach($deps as $dep) {
@@ -782,6 +859,12 @@ class Singleconfig
         return false;
     }
 
+    /**
+     * @param string $chanName
+     * @param string $packageName
+     * @param array $excludeList
+     * @return array
+     */
     public function requiredByOtherPackages($chanName, $packageName, $excludeList = array())
     {
         $out = array();
@@ -799,9 +882,10 @@ class Singleconfig
         return $out;
     }
 
-
-
-
+    /**
+     * @param string|false $chanName
+     * @return array
+     */
     public function getInstalledPackages($chanName = false)
     {
         if(false == $chanName) {
@@ -824,8 +908,6 @@ class Singleconfig
         return $out;
     }
 
-
-
     /**
      * Check if package conflicts with installed packages
      * Returns:
@@ -860,8 +942,4 @@ class Singleconfig
         }
         return count($conflicts) ? $conflicts : false;
     }
-
-
-
-
 }
diff --git a/lib/Magento/Connect/Structures/Graph.php b/lib/Magento/Connect/Structures/Graph.php
index c12442b7378982d0df0b7e9b4c706eaad1e0662e..c15b60ace87e68b5ae8167bf4665fcc4eabb60d3 100644
--- a/lib/Magento/Connect/Structures/Graph.php
+++ b/lib/Magento/Connect/Structures/Graph.php
@@ -23,30 +23,41 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Structures;
 
+use Magento\Connect\Structures\Node;
+
 class Graph
 {
+    /**
+     * @var Node[]
+     */
     protected $_nodes = array();
+
+    /**
+     * @var bool
+     */
     protected $_directed = false;
+
+    /**
+     * @var string
+     */
     protected $_nodeClassName = 'Magento\Connect\Structures\Node';
 
     const ACYCLIC_VISITED_KEY = 'acyclic-test-visited';
     const SORT_VISITED_KEY = 'topological-sort-visited';
     const SORT_LEVEL_KEY = 'topological-sort-level';
-     
+
     /**
      * Constructor
+     *
      * @param bool $directed directed graph?
-     * @return void
      */
     public function __construct($directed = true)
     {
         $this->_directed = $directed;
     }
 
-
     /**
      * Is graph directed?
      *
@@ -60,8 +71,9 @@ class Graph
     /**
      * Add node to list
      *
-     * @param \Magento\Connect\Structures\Graph_Node $newNode
+     * @param Node &$newNode
      * @return void
+     * @throws \Exception
      */
     public function addNode(&$newNode)
     {
@@ -79,7 +91,8 @@ class Graph
 
     /**
      * Remove a Node from the Graph
-     * @param  \Magento\Connect\Structures\Graph_Node  $node
+     * @param  Node &$node
+     * @return void
      */
     public function removeNode(&$node)
     {
@@ -88,7 +101,8 @@ class Graph
 
     /**
      * Return set of nodes
-     * @return   array
+     *
+     * @return Node[]
      */
     public function &getNodes()
     {
@@ -97,7 +111,8 @@ class Graph
 
     /**
      * Is asyclic
-     * @return unknown_type
+     *
+     * @return bool
      */
     public function isAcyclic()
     {
@@ -108,10 +123,11 @@ class Graph
     }
 
     /**
-     *
      * This is a variant of Graph::inDegree which does
      * not count nodes marked as visited.
      *
+     * @param Node &$node
+     * @param string $metadataKey
      * @return integer
      */
     protected static function _nonVisitedInDegree(&$node, $metadataKey)
@@ -128,7 +144,8 @@ class Graph
 
     /**
      * Is graph acyclic?
-     * @param $graph
+     *
+     * @param Graph &$graph
      * @return bool
      */
     protected static function _isAcyclic(&$graph)
@@ -180,8 +197,7 @@ class Graph
     }
 
     /**
-     *
-     * sort returns the graph's nodes, sorted by topological order.
+     * Sort returns the graph's nodes, sorted by topological order.
      *
      * The result is an array with
      * as many entries as topological levels.
@@ -202,7 +218,7 @@ class Graph
         foreach($nodeKeys as $key) {
             $k = $nodes[$key]->getMetadata(self::SORT_LEVEL_KEY);
             if (!array_key_exists($k, $result)) {
-                $result[$k] = array();   
+                $result[$k] = array();
             }
             $result[$k][] =& $nodes[$key];
             $nodes[$key]->unsetMetadata(self::SORT_LEVEL_KEY);
@@ -210,6 +226,10 @@ class Graph
         return $result;
     }
 
+    /**
+     * @param Graph &$graph
+     * @return void
+     */
     protected static function _topologicalSort(&$graph)
     {
         // Mark every node as not visited
diff --git a/lib/Magento/Connect/Structures/Node.php b/lib/Magento/Connect/Structures/Node.php
index 2002b9ee6f0bc5a00d83c722ca38c65cc847204f..efa5d71437c640ca4753164cba5a15bc3005d280 100644
--- a/lib/Magento/Connect/Structures/Node.php
+++ b/lib/Magento/Connect/Structures/Node.php
@@ -23,42 +23,56 @@
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
 namespace Magento\Connect\Structures;
 
+use Magento\Connect\Structures\Graph;
+
 class Node
 {
-    
-    protected $_data = null;    
-    protected $_metadata = array();    
-    protected $_arcs = array();    
+    /**
+     * @var mixed
+     */
+    protected $_data = null;
+
+    /**
+     * @var array
+     */
+    protected $_metadata = array();
+
+    /**
+     * @var array
+     */
+    protected $_arcs = array();
+
+    /**
+     * @var Graph
+     */
     protected $_graph = null;
-    
+
     /**
      * Node graph getter
      *
-     * @return \Magento\Connect\Structures\Graph
+     * @return Graph
      */
-    public function &getGraph() 
+    public function &getGraph()
     {
         return $this->_graph;
     }
 
     /**
-     *
-     * Node graph setter. 
-     * This method should not be called directly. 
+     * Node graph setter.
+     * This method should not be called directly.
      * Use Graph::addNode instead.
      *
-     * @param $graph
+     * @param Graph &$graph
+     * @return void
      */
-    public function setGraph(&$graph) 
+    public function setGraph(&$graph)
     {
         $this->_graph =& $graph;
     }
 
     /**
-     *
      * Node data getter.
      *
      * Each graph node can contain a reference to one variable. This is the getter for that reference.
@@ -66,45 +80,45 @@ class Node
      * @return   mixed   Data stored in node
      * @access   public
      */
-    public function &getData() 
+    public function &getData()
     {
         return $this->_data;
     }
 
     /**
      * Node data setter
-     * 
+     *
      * Each graph node can contain a reference to one variable. This is the setter for that reference.
-     *   
-     * @return   mixed   Data to store in node
+     *
+     * @param mixed $data Data to store in node
+     * @return void
      */
-    public function setData($data) 
+    public function setData($data)
     {
         $this->_data =& $data;
     }
 
     /**
-     *
      * Test for existence of metadata under a given key.
      *
-     * @param    string    Key to test
+     * @param    string  $key Key to test
      * @return   boolean
      * @access   public
      */
-    public function metadataKeyExists($key) 
+    public function metadataKeyExists($key)
     {
         return array_key_exists($key, $this->_metadata);
     }
 
     /**
-     *
      * Get node metadata
      *
-     * @param    string  $key 
+     * @param    string  $key
      * @param    boolean $nullIfNonexistent (defaults to false).
-     * @return   mixed   
+     * @return   mixed
+     * @throws   \Exception
      */
-    public function & getMetadata($key, $nullIfNonexistent = false) 
+    public function & getMetadata($key, $nullIfNonexistent = false)
     {
         if (array_key_exists($key, $this->_metadata)) {
             return $this->_metadata[$key];
@@ -112,26 +126,25 @@ class Node
                 $a = null;
                 return $a;
         } else {
-            throw new \Exception(__METHOD__." : requested key doesn't exist: {$key}");            
+            throw new \Exception(__METHOD__." : requested key doesn't exist: {$key}");
         }
     }
 
     /**
-     *
      * Delete metadata by key
      *
-     * @param    string  Key
+     * @param string $key Key
+     * @return void
      */
-    public function unsetMetadata($key) 
+    public function unsetMetadata($key)
     {
         if (array_key_exists($key, $this->_metadata)) {
             unset($this->_metadata[$key]);
-        }    
-        
+        }
+
     }
-        
+
     /**
-     *
      * Node metadata setter
      *
      * Each graph node can contain multiple 'metadata' entries, each stored under a different key, as in an
@@ -140,13 +153,18 @@ class Node
      *
      * @param    string  $key
      * @param    mixed   $data
+     * @return   void
      */
-    public function setMetadata($key, $data) 
+    public function setMetadata($key, $data)
     {
         $this->_metadata[$key] =& $data;
     }
 
-    protected function _connectTo(&$destinationNode) 
+    /**
+     * @param mixed &$destinationNode
+     * @return void
+     */
+    protected function _connectTo(&$destinationNode)
     {
         $this->_arcs[] =& $destinationNode;
     }
@@ -154,7 +172,9 @@ class Node
     /**
      * Connect this node to another one.
      * If the graph is not directed, the reverse arc, connecting $destinationNode to $this is also created.
-     * @param    Structures_Graph Node to connect to
+     * @param \Magento\Object &$destinationNode  Structures_Graph Node to connect to
+     * @return void
+     * @throws \Exception
      */
     public function connectTo(&$destinationNode)
     {
@@ -162,7 +182,7 @@ class Node
         if(!$destinationNode instanceof $class) {
             throw new \Exception(__METHOD__." : argument should be instance of {$class}");
         }
-         
+
         // Nodes must already be in graphs to be connected
         if ($this->_graph == null) {
             throw new \Exception(__METHOD__." : tried to connect to null graph");
@@ -180,10 +200,9 @@ class Node
         }
     }
 
-
     /**
      * Return nodes connected to this one.
-     * @return array 
+     * @return array
      */
     public function getNeighbours()
     {
@@ -193,14 +212,16 @@ class Node
     /**
      * Test whether this node has an arc to the target node
      * Returns true if the two nodes are connected
-     * @return boolean   
+     *
+     * @param Node &$target
+     * @return boolean
      */
     public function connectsTo(&$target)
     {
         $arcKeys = array_keys($this->_arcs);
         foreach($arcKeys as $key) {
             $arc =& $this->_arcs[$key];
-            if ($target === $arc) { 
+            if ($target === $arc) {
                 return true;
             }
         }
@@ -210,15 +231,15 @@ class Node
     /**
      * Calculate the in degree of the node.
      *
-     * The indegree for a node is the number of arcs 
-     * entering the node. 
-     * 
+     * The indegree for a node is the number of arcs
+     * entering the node.
+     *
      * For non directed graphs:
      *  always outdegree = indegree.
-     *  
+     *
      * @return int
      */
-    public function inDegree() 
+    public function inDegree()
     {
         $result = 0;
 
@@ -242,7 +263,7 @@ class Node
     /**
      * Calculate the out degree of the node.
      *
-     * The outdegree for a node is the number of arcs exiting the node. 
+     * The outdegree for a node is the number of arcs exiting the node.
      * For non directed graphs:
      *  always outdegree = indegree.
      *
@@ -255,5 +276,4 @@ class Node
         }
         return count($this->_arcs);
     }
-
 }
diff --git a/lib/Magento/Connect/Validator.php b/lib/Magento/Connect/Validator.php
index f49951d73bd0efbcb8640aafe1b4ec978df6a1f6..9ecaedf34db0b608a683b80dd81e18fb6270c821 100644
--- a/lib/Magento/Connect/Validator.php
+++ b/lib/Magento/Connect/Validator.php
@@ -36,85 +36,90 @@ namespace Magento\Connect;
 
 class Validator
 {
-	protected static $_stability = array(0=>'devel',1=>'alpha',2=>'beta',3=>'stable');
-
-	
-	public static function getStabilities()
-	{
-	    return self::$_stability;
-	}
-	
-	
-	
-	/**
-	 * Compare stabilities. Returns:
-	 * 
-	 * -1 if the first stability is lower than the second
-	 *  0 if they are equal
-	 *  1 if the second is lower. 
-	 * @param $s1
-	 * @param $s2
-	 * @return int
-	 */
-	public function compareStabilities($s1, $s2)
-	{
-	    $list = $this->getStabilities();
-	    $tmp = array_combine(array_values($list),array_keys($list));
-	    
-	    if(!isset($tmp[$s1], $tmp[$s2])) {
-	        throw new \Exception("Invalid stability in compareStabilities argument");
-	    }
-	    
-	    	    
-	    // 'stable' turns to 3
-	    // 'devel' turns to 0	    
-	    $s1 = $tmp[$s1];
-	    $s2 = $tmp[$s2];
-	    if($s1 === $s2) {
-	        return 0;
-	    } elseif($s1 > $s2) {
-	        return 1;
-	    } elseif($s1 < $s2) {
-	        return -1;
-	    }	    
-	}
-	
-	/**
-	 * Constructor
-	 */
-	public function __construct()
-	{
-
-	}
-
-	/**
-	 * Validate max len of string
-	 * @param string $str
-	 * @param int $maxLen
-	 * @return bool
-	 */
-	public function validateMaxLen($str, $maxLen)
-	{
-		return strlen((string) $str) <= (int) $maxLen;
-	}
-
-	/**
-    * Validate channel name and url
-    *
-    * @param mixed $str
-    * @return bool
-    */
+    /**
+     * @var string[]
+     */
+    protected static $_stability = array(0=>'devel',1=>'alpha',2=>'beta',3=>'stable');
+
+    /**
+     * @return string[]
+     */
+    public static function getStabilities()
+    {
+        return self::$_stability;
+    }
+
+    /**
+     * Compare stabilities.
+     *
+     * Returns:
+     * -1 if the first stability is lower than the second
+     *  0 if they are equal
+     *  1 if the second is lower.
+     *
+     * @param int $s1
+     * @param int $s2
+     * @return int
+     * @throws \Exception
+     */
+    public function compareStabilities($s1, $s2)
+    {
+        $list = $this->getStabilities();
+        $tmp = array_combine(array_values($list), array_keys($list));
+
+        if (!isset($tmp[$s1], $tmp[$s2])) {
+            throw new \Exception("Invalid stability in compareStabilities argument");
+        }
+
+        // 'stable' turns to 3
+        // 'devel' turns to 0
+        $s1 = $tmp[$s1];
+        $s2 = $tmp[$s2];
+        if ($s1 === $s2) {
+            return 0;
+        } elseif ($s1 > $s2) {
+            return 1;
+        } elseif ($s1 < $s2) {
+            return -1;
+        }
+    }
+
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+
+    }
+
+    /**
+     * Validate max len of string
+     * @param string $str
+     * @param int $maxLen
+     * @return bool
+     */
+    public function validateMaxLen($str, $maxLen)
+    {
+        return strlen((string) $str) <= (int) $maxLen;
+    }
+
+    /**
+     * Validate channel name and url
+     *
+     * @param string $str
+     * @return bool
+     */
     public function validateChannelNameOrUri($str)
-	{
-	    return ( $this->validateUrl($str) || $this->validatePackageName($str));
-	}
+    {
+        return ( $this->validateUrl($str) || $this->validatePackageName($str));
+    }
 
     /**
-    * Validate License url
-    *
-    * @param mixed $str
-    * @return boolean
-    */
+     * Validate License url
+     *
+     * @param string $str
+     * @return boolean
+     */
     public function validateLicenseUrl($str)
     {
         if ($str) {
@@ -128,292 +133,291 @@ class Validator
      * @param array $data
      * @return bool
      */
-	public function validateCompatible(array $data)
-	{
-	    if(!count($data)) {
-	    	/**
-	    	 * Allow empty
-	    	 */
+    public function validateCompatible(array $data)
+    {
+        if (!count($data)) {
+            /**
+             * Allow empty
+             */
             return true;
         }
         $count = 0;
-        foreach($data as $k=>$v) {
-           foreach(array('name','channel','min','max') as $fld) {
-           	  $$fld = trim($v[$fld]);
-           }
-           $count++;
-
-           $res = $this->validateUrl($channel) && strlen($channel);
-           if(!$res) {
-              $this->addError("Invalid or empty channel in compat. #{$count}");
-           }
-
-           $res = $this->validatePackageName($name) && strlen($name);
-           if(!$res) {
-              $this->addError("Invalid or empty name in compat. #{$count}");
-           }
-           $res1 = $this->validateVersion($min);
-           if(!$res1) {
-              $this->addError("Invalid or empty minVersion in compat. #{$count}");
-           }
-           $res2 = $this->validateVersion($max);
-           if(!$res2) {
-              $this->addError("Invalid or empty maxVersion in compat. #{$count}");
-           }
-           if($res1 && $res2 && $this->versionLower($max, $min)) {
-           	  $this->addError("Max version is lower than min in compat #{$count}");
-           }
+        foreach ($data as $k=>$v) {
+            foreach (array('name','channel','min','max') as $fld) {
+                 $$fld = trim($v[$fld]);
+            }
+            $count++;
+
+            $res = $this->validateUrl($channel) && strlen($channel);
+            if (!$res) {
+                $this->addError("Invalid or empty channel in compat. #{$count}");
+            }
+
+            $res = $this->validatePackageName($name) && strlen($name);
+            if (!$res) {
+                $this->addError("Invalid or empty name in compat. #{$count}");
+            }
+            $res1 = $this->validateVersion($min);
+            if (!$res1) {
+                $this->addError("Invalid or empty minVersion in compat. #{$count}");
+            }
+            $res2 = $this->validateVersion($max);
+            if (!$res2) {
+                $this->addError("Invalid or empty maxVersion in compat. #{$count}");
+            }
+            if ($res1 && $res2 && $this->versionLower($max, $min)) {
+                $this->addError("Max version is lower than min in compat #{$count}");
+            }
 
         }
         return ! $this->hasErrors();
-	}
-
-	/**
-	 * Validate authors of package
-	 * @param array $authors
-	 * @return bool
-	 */
-	public function validateAuthors(array $authors)
-	{
-		if(!count($authors)) {
-			$this->addError('Empty authors section');
-			return false;
-		}
-		$count = 0;
-		foreach($authors as $k=>$v) {
-		   $count++;
-		   array_map('trim', $v);
-		   $name = $v['name'];
-		   $login = $v['user'];
-		   $email = $v['email'];
-		   $res = $this->validateMaxLen($name, 256) && strlen($name);
-           if(!$res) {
-              $this->addError("Invalid or empty name for author #{$count}");
-           }
-		   $res = $this->validatePackageName($login) && strlen($login);
-		   if(!$res) {
-		   	  $this->addError("Invalid or empty login for author #{$count}");
-		   }
-		   $res = $this->validateEmail($email);
-		   if(!$res) {
-		   	  $this->addError("Invalid or empty email for author #{$count}");
-		   }
-		}
-		return ! $this->hasErrors();
-	}
-
-
-	/**
-	 * Validator errors
-	 * @var array
-	 */
-	private $_errors = array();
-
-	/**
-	 * Add error
-	 * @param string $err
-	 * @return
-	 */
-	private function addError($err)
-	{
-		$this->_errors[] = $err;
-	}
-
-	/**
-	 * Set validator errors
-	 * @param array $err
-	 * @return
-	 */
-
-	private function setErrors(array $err)
-	{
-		$this->_errors = $err;
-	}
-
-	/**
-	 * Clear validator errors
-	 * @return
-	 */
-	private function clearErrors()
-	{
-		$this->_errors = array();
-	}
-
-	/**
-	 * Check if there are validator errors set
-	 * @return unknown_type
-	 */
-	public function hasErrors()
-	{
-		return count($this->_errors) != 0;
-	}
-
-
-	/**
-	 * Get errors
-	 * @param bool $clear if true after this call erros will be cleared
-	 * @return array
-	 */
-	public function getErrors($clear = true)
-	{
-		$out = $this->_errors;
-		if($clear) {
-			$this->clearErrors();
-		}
-		return $out;
-	}
-
-	/**
-	 * Validate URL
-	 * @param string $str
-	 * @return bool
-	 */
-	public function validateUrl($str)
-	{
-		$regex = "@([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|"
-		."(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)"
-		."[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?@i";
-		return preg_match($regex, $str);
-	}
-
-
-	/**
-	 * Validates package stability
-	 * @param string $str
-	 * @return bool
-	 */
-	public function validateStability($str)
-	{
-		return in_array(strval($str), self::$_stability);
-	}
-
-	/**
-	 * Validate date format
-	 * @param $date
-	 * @return bool
-	 */
-	public function validateDate($date)
-	{
-		$subs = null;
-		$check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
-		if(!$check1) {
-			return false;
-		}
-		return checkdate($subs[2], $subs[3], $subs[1]);
-	}
-
-
-	/**
-	 * Validate email
-	 * @param string $email
-	 * @return bool
-	 */
-	public function validateEmail($email)
-	{
-		return preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email);
-	}
-
-	/**
-	 * Validate package name
-	 * @param $name
-	 * @return bool
-	 */
-	public function validatePackageName($name)
-	{
-		return preg_match("/^[a-zA-Z0-9_-]+$/i", $name);
-	}
-
-	/**
-	 * Validate version number
-	 * @param string $version
-	 * @return bool
-	 */
-	public function validateVersion($version)
-	{
-		return preg_match("/^[\d]+\.[\d]+\.[\d]+([[:alnum:]\.\-\_]+)?$/i", $version);
-	}
-
-	/**
-	 * Check versions are equal
-	 * @param string $v1
-	 * @param string $v2
-	 * @return bool
-	 */
-	public function versionEqual($v1, $v2)
-	{
-		return version_compare($v1, $v2, "==");
-	}
-
-	/**
-	 * Check version $v1 <= $v2
-	 * @param string $v1
-	 * @param string $v2
-	 * @return bool
-	 */
-	public function versionLowerEqual($v1, $v2)
-	{
-		return version_compare($v1, $v2, "le");
-	}
-
-
-	/**
-	 * Check if version $v1 lower than $v2
-	 * @param string $v1
-	 * @param string $v2
-	 * @return bool
-	 */
-	public function versionLower($v1, $v2)
-	{
-		return version_compare($v1, $v2, "<");
-	}
-
-	/**
-	 * Check version $v1 >= $v2
-	 * @param string $v1
-	 * @param string $v2
-	 * @return bool
-	 */
-	public function versionGreaterEqual($v1, $v2)
-	{
-		return version_compare($v1, $v2, "ge");
-	}
-
-
-	/**
-	 * Generic regex validation
-	 * @param string $str
-	 * @param string $regex
-	 * @return bool
-	 */
-	public function validateRegex($str, $regex)
-	{
-		return preg_match($regex, $str);
-	}
-
-
-	/**
-	 * Check if PHP extension loaded
-	 * @param string $name Extension name
-	 * @return bool
-	 */
-	public function validatePhpExtension($name)
-	{
-        return extension_loaded($name);
-	}
+    }
+
+    /**
+     * Validate authors of package
+     * @param array $authors
+     * @return bool
+     */
+    public function validateAuthors(array $authors)
+    {
+        if (!count($authors)) {
+            $this->addError('Empty authors section');
+            return false;
+        }
+        $count = 0;
+        foreach ($authors as $k=>$v) {
+            $count++;
+            array_map('trim', $v);
+            $name = $v['name'];
+            $login = $v['user'];
+            $email = $v['email'];
+            $res = $this->validateMaxLen($name, 256) && strlen($name);
+            if (!$res) {
+                $this->addError("Invalid or empty name for author #{$count}");
+            }
+            $res = $this->validatePackageName($login) && strlen($login);
+            if (!$res) {
+                $this->addError("Invalid or empty login for author #{$count}");
+            }
+            $res = $this->validateEmail($email);
+            if (!$res) {
+                $this->addError("Invalid or empty email for author #{$count}");
+            }
+        }
+        return ! $this->hasErrors();
+    }
+
+
+    /**
+     * Validator errors
+     * @var array
+     */
+    private $_errors = array();
+
+    /**
+     * Add error
+     * @param string $err
+     * @return void
+     */
+    private function addError($err)
+    {
+        $this->_errors[] = $err;
+    }
+
+    /**
+     * Set validator errors
+     * @param array $err
+     * @return void
+     */
+    private function setErrors(array $err)
+    {
+        $this->_errors = $err;
+    }
+
+    /**
+     * Clear validator errors
+     * @return void
+     */
+    private function clearErrors()
+    {
+        $this->_errors = array();
+    }
+
+    /**
+     * Check if there are validator errors set
+     * @return bool
+     */
+    public function hasErrors()
+    {
+        return count($this->_errors) != 0;
+    }
+
+
+    /**
+     * Get errors
+     * @param bool $clear if true after this call erros will be cleared
+     * @return array
+     */
+    public function getErrors($clear = true)
+    {
+        $out = $this->_errors;
+        if ($clear) {
+            $this->clearErrors();
+        }
+        return $out;
+    }
 
+    /**
+     * Validate URL
+     * @param string $str
+     * @return bool
+     */
+    public function validateUrl($str)
+    {
+        $regex = "@([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|"
+            ."(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)"
+            ."[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?@i";
+        return preg_match($regex, $str);
+    }
+
+
+    /**
+     * Validates package stability
+     * @param string $str
+     * @return bool
+     */
+    public function validateStability($str)
+    {
+        return in_array(strval($str), self::$_stability);
+    }
+
+    /**
+     * Validate date format
+     * @param string $date
+     * @return bool
+     */
+    public function validateDate($date)
+    {
+        $subs = null;
+        $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
+        if (!$check1) {
+            return false;
+        }
+        return checkdate($subs[2], $subs[3], $subs[1]);
+    }
+
+
+    /**
+     * Validate email
+     * @param string $email
+     * @return bool
+     */
+    public function validateEmail($email)
+    {
+        return preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email);
+    }
+
+    /**
+     * Validate package name
+     * @param string $name
+     * @return bool
+     */
+    public function validatePackageName($name)
+    {
+        return preg_match("/^[a-zA-Z0-9_-]+$/i", $name);
+    }
+
+    /**
+     * Validate version number
+     * @param string $version
+     * @return bool
+     */
+    public function validateVersion($version)
+    {
+        return preg_match("/^[\d]+\.[\d]+\.[\d]+([[:alnum:]\.\-\_]+)?$/i", $version);
+    }
+
+    /**
+     * Check versions are equal
+     * @param string $v1
+     * @param string $v2
+     * @return bool
+     */
+    public function versionEqual($v1, $v2)
+    {
+        return version_compare($v1, $v2, "==");
+    }
+
+    /**
+     * Check version $v1 <= $v2
+     * @param string $v1
+     * @param string $v2
+     * @return bool
+     */
+    public function versionLowerEqual($v1, $v2)
+    {
+        return version_compare($v1, $v2, "le");
+    }
+
+    /**
+     * Check if version $v1 lower than $v2
+     * @param string $v1
+     * @param string $v2
+     * @return bool
+     */
+    public function versionLower($v1, $v2)
+    {
+        return version_compare($v1, $v2, "<");
+    }
+
+    /**
+     * Check version $v1 >= $v2
+     * @param string $v1
+     * @param string $v2
+     * @return bool
+     */
+    public function versionGreaterEqual($v1, $v2)
+    {
+        return version_compare($v1, $v2, "ge");
+    }
 
-	public function validatePHPVersion($min, $max, $ver = PHP_VERSION)
-	{
-	    $minAccepted = true;
-	    if($min) {
-	        $minAccepted = version_compare($ver, $min, ">=");
-	    }
-	    $maxAccepted = true;
-	    if($max) {
-	        $maxAccepted = version_compate($ver, $max, "<=");
-	    }
-	    return (bool) $minAccepted && $maxAccepted;
-	}
+    /**
+     * Generic regex validation
+     * @param string $str
+     * @param string $regex
+     * @return bool
+     */
+    public function validateRegex($str, $regex)
+    {
+        return preg_match($regex, $str);
+    }
 
+    /**
+     * Check if PHP extension loaded
+     * @param string $name Extension name
+     * @return bool
+     */
+    public function validatePhpExtension($name)
+    {
+        return extension_loaded($name);
+    }
 
+    /**
+     * @param string|bool $min
+     * @param string|bool $max
+     * @param string $ver
+     * @return bool
+     */
+    public function validatePHPVersion($min, $max, $ver = PHP_VERSION)
+    {
+        $minAccepted = true;
+        if ($min) {
+            $minAccepted = version_compare($ver, $min, ">=");
+        }
+        $maxAccepted = true;
+        if ($max) {
+            $maxAccepted = version_compate($ver, $max, "<=");
+        }
+        return (bool) $minAccepted && $maxAccepted;
+    }
 }
diff --git a/lib/Magento/Css/PreProcessor/Adapter/AdapterException.php b/lib/Magento/Css/PreProcessor/Adapter/AdapterException.php
new file mode 100644
index 0000000000000000000000000000000000000000..6df6841e5b00b72eeb789d4cc4945acc2abab34a
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Adapter/AdapterException.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Adapter;
+
+/**
+ * LESS adapter exception
+ */
+class AdapterException extends \Exception
+{
+
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/CacheManager.php b/lib/Magento/Css/PreProcessor/Cache/CacheManager.php
new file mode 100644
index 0000000000000000000000000000000000000000..6b60741dac10d15220c16d928e745c236f8f2a07
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/CacheManager.php
@@ -0,0 +1,176 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache;
+
+use Magento\Exception;
+use Magento\Filesystem;
+
+/**
+ * Less cache manager
+ */
+class CacheManager implements CacheManagerInterface
+{
+    /**
+     * @var array
+     */
+    protected $importEntities = [];
+
+    /**
+     * @var string
+     */
+    protected $cachedFile;
+
+    /**
+     * @var string
+     */
+    protected $uniqueFileKey;
+
+    /**
+     * @var Import\Map\Storage
+     */
+    protected $storage;
+
+    /**
+     * @var Import\ImportEntityFactory
+     */
+    protected $importEntityFactory;
+
+    /**
+     * @param Import\Map\Storage $storage
+     * @param Import\ImportEntityFactory $importEntityFactory
+     * @param string $filePath
+     * @param array $params
+     */
+    public function __construct(
+        Import\Map\Storage $storage,
+        Import\ImportEntityFactory $importEntityFactory,
+        $filePath,
+        $params
+    ) {
+        $this->storage = $storage;
+        $this->importEntityFactory = $importEntityFactory;
+        $this->uniqueFileKey = $this->prepareKey($filePath, $params);
+
+        $this->loadImportEntities();
+    }
+
+    /**
+     * @param string $filePath
+     * @param array $params
+     * @return string
+     */
+    protected function prepareKey($filePath, $params)
+    {
+        if (!empty($params['themeModel'])) {
+            $themeModel = $params['themeModel'];
+            $params['themeModel'] = $themeModel->getId() ?: md5($themeModel->getThemePath());
+        }
+        ksort($params);
+        return $filePath . '|' . implode('|', $params);
+    }
+
+    /**
+     * @return $this
+     */
+    protected function loadImportEntities()
+    {
+        $importEntities = unserialize($this->storage->load($this->uniqueFileKey));
+        $this->cachedFile = isset($importEntities['cached_file']) ? $importEntities['cached_file'] : null;
+        $this->importEntities = isset($importEntities['imports']) ? $importEntities['imports'] : [];
+        if (!$this->isValid()) {
+            $this->clearCache();
+        }
+        return $this;
+    }
+
+    /**
+     * @return bool
+     */
+    protected function isValid()
+    {
+        if (empty($this->importEntities)) {
+            return false;
+        }
+
+        /** @var Import\ImportEntity $entity */
+        foreach ($this->importEntities as $entity) {
+            if (!$entity->isValid()) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * @return $this
+     */
+    public function clearCache()
+    {
+        $this->cachedFile = null;
+        $this->importEntities = [];
+        $this->storage->delete($this->uniqueFileKey);
+        return $this;
+    }
+
+    /**
+     * @return null|string
+     */
+    public function getCachedFile()
+    {
+        return $this->cachedFile;
+    }
+
+    /**
+     * @param string $filePath
+     * @param array $params
+     * @return $this
+     */
+    public function addEntityToCache($filePath, $params)
+    {
+        $fileKey = $this->prepareKey($filePath, $params);
+        $this->importEntities[$fileKey] = $this->importEntityFactory->create($filePath, $params);
+        return $this;
+    }
+
+    /**
+     * @param string $generatedFile
+     * @return $this
+     */
+    public function saveCache($generatedFile)
+    {
+        $this->storage->save($this->uniqueFileKey, $this->prepareSaveData($generatedFile));
+        return $this;
+    }
+
+    /**
+     * @param string $cachedFile
+     * @return string
+     */
+    protected function prepareSaveData($cachedFile)
+    {
+        return serialize(['cached_file' => $cachedFile, 'imports' => $this->importEntities]);
+    }
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/CacheManagerFactory.php b/lib/Magento/Css/PreProcessor/Cache/CacheManagerFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..94b1ea424cb361572ba8a81e88004ce71097858e
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/CacheManagerFactory.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache;
+
+/**
+ * Cache manager factory
+ */
+class CacheManagerFactory
+{
+    /**
+     * @var \Magento\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     */
+    public function __construct(\Magento\ObjectManager $objectManager)
+    {
+        $this->objectManager = $objectManager;
+    }
+
+    /**
+     * @param string $filePath
+     * @param array $params
+     * @return \Magento\Css\PreProcessor\Cache\CacheManager
+     * @throws \InvalidArgumentException
+     */
+    public function create($filePath, array $params)
+    {
+        /** @var \Magento\Css\PreProcessor\Cache\CacheManagerInterface $cacheManager */
+        $cacheManager = $this->objectManager->create(
+            'Magento\Css\PreProcessor\Cache\CacheManager',
+            array('filePath' => $filePath, 'params' => $params)
+        );
+
+        if (!$cacheManager instanceof \Magento\Css\PreProcessor\Cache\CacheManagerInterface) {
+            throw new \InvalidArgumentException(
+                'Cache Manager does not implement \Magento\Css\PreProcessor\Cache\CacheManagerInterface'
+            );
+        }
+
+        return $cacheManager;
+    }
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/CacheManagerInterface.php b/lib/Magento/Css/PreProcessor/Cache/CacheManagerInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..9bb56f46f534aa4d2259e340cc9a0b1b6ab5bf92
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/CacheManagerInterface.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache;
+
+/**
+ * Less cache manager interface
+ */
+interface CacheManagerInterface
+{
+    /**
+     * @return $this
+     */
+    public function clearCache();
+
+    /**
+     * @return null|string
+     */
+    public function getCachedFile();
+
+    /**
+     * @param string $filePath
+     * @param array $params
+     */
+    public function addEntityToCache($filePath, $params);
+
+    /**
+     * @param string $generatedFile
+     * @return $this
+     */
+    public function saveCache($generatedFile);
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntity.php b/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntity.php
new file mode 100644
index 0000000000000000000000000000000000000000..23021b06bc7f7e6b5327fab9f43c531d18c79fbc
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntity.php
@@ -0,0 +1,134 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache\Import;
+
+use Magento\Filesystem;
+
+/**
+ * Import entity
+ */
+class ImportEntity implements ImportEntityInterface
+{
+    /**
+     * @var \Magento\Filesystem\Directory\ReadInterface
+     */
+    protected $rootDirectory;
+
+    /**
+     * @var string
+     */
+    protected $originalFile;
+
+    /**
+     * @var int
+     */
+    protected $originalMtime;
+
+    /**
+     * @param Filesystem $filesystem
+     * @param \Magento\View\FileSystem $viewFileSystem
+     * @param string $filePath
+     * @param array $params
+     */
+    public function __construct(
+        Filesystem $filesystem,
+        \Magento\View\FileSystem $viewFileSystem,
+        $filePath,
+        array $params
+    ) {
+        $this->initRootDir($filesystem);
+
+        // @todo dependency from filesystem should be removed
+        $absoluteFilePath = $viewFileSystem->getViewFile($filePath, $params);
+        $relativePath = $this->rootDirectory->getRelativePath($absoluteFilePath);
+
+        $this->originalFile = $relativePath;
+        $this->originalMtime = $this->rootDirectory->stat($relativePath)['mtime'];
+    }
+
+    /**
+     * @return string
+     */
+    public function getOriginalFile()
+    {
+        return $this->originalFile;
+    }
+
+    /**
+     * @return int
+     */
+    public function getOriginalMtime()
+    {
+        return $this->originalMtime;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isValid()
+    {
+        if (!$this->isFileExist($this->getOriginalFile())) {
+            return false;
+        }
+        $originalFileMTime = $this->rootDirectory->stat($this->getOriginalFile())['mtime'];
+        return $originalFileMTime == $this->getOriginalMtime();
+    }
+
+    /**
+     * @param string $filePath
+     * @return bool
+     */
+    protected function isFileExist($filePath)
+    {
+        return $this->rootDirectory->isFile($filePath);
+    }
+
+    /**
+     * @return array
+     */
+    public function __sleep()
+    {
+        return ['originalFile', 'originalMtime'];
+    }
+
+    /**
+     * @return void
+     */
+    public function __wakeup()
+    {
+        $filesystem = \Magento\App\ObjectManager::getInstance()->get('Magento\Filesystem');
+        $this->initRootDir($filesystem);
+    }
+
+    /**
+     * @param Filesystem $filesystem
+     * @return $this
+     */
+    protected function initRootDir(\Magento\Filesystem $filesystem)
+    {
+        $this->rootDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR);
+        return $this;
+    }
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntityFactory.php b/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntityFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..bef6b96bd2de7d33024659332acd249143af518d
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntityFactory.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache\Import;
+
+/**
+ * Import entity factory
+ */
+class ImportEntityFactory
+{
+    /**
+     * @var \Magento\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     */
+    public function __construct(\Magento\ObjectManager $objectManager)
+    {
+        $this->objectManager = $objectManager;
+    }
+
+    /**
+     * @param string $filePath
+     * @param array $params
+     * @return \Magento\Css\PreProcessor\Cache\Import\ImportEntityInterface
+     * @throws \InvalidArgumentException
+     */
+    public function create($filePath, $params)
+    {
+        /** @var \Magento\Css\PreProcessor\Cache\Import\ImportEntityInterface $importEntity */
+        $importEntity = $this->objectManager->create(
+            'Magento\Css\PreProcessor\Cache\Import\ImportEntity',
+            array('filePath' => $filePath, 'params' => $params)
+        );
+
+        if (!$importEntity instanceof \Magento\Css\PreProcessor\Cache\Import\ImportEntityInterface) {
+            throw new \InvalidArgumentException(
+                'Import Entity does not implement \Magento\Css\PreProcessor\Cache\Import\ImportEntityInterface'
+            );
+        }
+
+        return $importEntity;
+    }
+}
+
+
diff --git a/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntityInterface.php b/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntityInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..f09da812f20bfc131e65ae5ff7bc030f3f541e63
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/Import/ImportEntityInterface.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache\Import;
+
+use \Magento\Filesystem;
+
+/**
+ * Import entity interface
+ */
+interface ImportEntityInterface
+{
+    /**
+     * @return string
+     */
+    public function getOriginalFile();
+
+    /**
+     * @return int
+     */
+    public function getOriginalMtime();
+
+    /**
+     * @return bool
+     */
+    public function isValid();
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/Import/Map/Storage.php b/lib/Magento/Css/PreProcessor/Cache/Import/Map/Storage.php
new file mode 100644
index 0000000000000000000000000000000000000000..adf98c6eae8a3fd624796d71f741e7258fa818d9
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/Import/Map/Storage.php
@@ -0,0 +1,100 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache\Import\Map;
+
+use Magento\App\Filesystem;
+
+/**
+ * Storage for import cache
+ */
+class Storage
+{
+    /**
+     * Maps directory for less files
+     */
+    const MAPS_DIR = "maps/less";
+
+    /**
+     * @var \Magento\Filesystem\Directory\WriteInterface
+     */
+    protected $mapsDirectory;
+
+    /**
+     * @param Filesystem $filesystem
+     */
+    public function __construct(
+        Filesystem $filesystem
+    ) {
+        $this->mapsDirectory = $filesystem->getDirectoryWrite(Filesystem::VAR_DIR);
+        if (!$this->mapsDirectory->isDirectory(self::MAPS_DIR)) {
+            $this->mapsDirectory->create(self::MAPS_DIR);
+        }
+    }
+
+    /**
+     * @param string $key
+     * @return string
+     */
+    public function load($key)
+    {
+        $mapFileName = $this->getMapFilePath($key);
+        if ($this->mapsDirectory->isFile($mapFileName)) {
+            return $this->mapsDirectory->readFile($mapFileName);
+        }
+
+        return false;
+    }
+
+    /**
+     * @param string $key
+     * @param string $data
+     * @return $this
+     */
+    public function save($key, $data)
+    {
+        $mapFileName = $this->getMapFilePath($key);
+        $this->mapsDirectory->writeFile($mapFileName, $data);
+        return $this;
+    }
+
+    /**
+     * @param string $key
+     * @return $this
+     */
+    public function delete($key)
+    {
+        $this->save($key, '');
+        return $this;
+    }
+
+    /**
+     * @param string $key
+     * @return string
+     */
+    protected function getMapFilePath($key)
+    {
+        return self::MAPS_DIR . '/' . md5($key) . '.ser';
+    }
+}
diff --git a/lib/Magento/Css/PreProcessor/Cache/Plugin.php b/lib/Magento/Css/PreProcessor/Cache/Plugin.php
new file mode 100644
index 0000000000000000000000000000000000000000..c4242834f02b6a79a00984a0c50a5eefad0f6667
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Cache/Plugin.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor\Cache;
+
+use Magento\Filesystem;
+use Magento\Css\PreProcessor\Cache;
+
+/**
+ * Plugin for less caching
+ */
+class Plugin
+{
+    /**
+     * @var CacheManagerFactory
+     */
+    protected $cacheManagerFactory;
+
+    /**
+     * @var \Magento\Logger
+     */
+    protected $logger;
+
+    /**
+     * @var \Magento\Css\PreProcessor\Cache\CacheManager
+     */
+    protected $cacheManager;
+
+    /**
+     * @param CacheManagerFactory $cacheManagerFactory
+     * @param \Magento\Logger $logger
+     */
+    public function __construct(
+        CacheManagerFactory $cacheManagerFactory,
+        \Magento\Logger $logger
+    ) {
+        $this->cacheManagerFactory = $cacheManagerFactory;
+        $this->logger = $logger;
+    }
+
+    /**
+     * @param array $arguments
+     * @param \Magento\Code\Plugin\InvocationChain $invocationChain
+     * @return string|null
+     */
+    public function aroundProcess(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain)
+    {
+        // check if source path already exist
+        if (isset($arguments[3])) {
+            return $invocationChain->proceed($arguments);
+        }
+
+        $this->initializeCacheManager($arguments[0], $arguments[1]);
+
+        $cachedFile = $this->cacheManager->getCachedFile();
+        if (null !== $cachedFile) {
+            return $cachedFile;
+        }
+
+        try {
+            $result = $invocationChain->proceed($arguments);
+            $this->cacheManager->saveCache($result);
+        } catch (Filesystem\FilesystemException $e) {
+            $this->logger->logException($e);
+            return null;
+        }
+        return $result;
+    }
+
+    /**
+     * @param string $lessFilePath
+     * @param array $params
+     * @return $this
+     */
+    protected function initializeCacheManager($lessFilePath, $params)
+    {
+        $this->cacheManager = $this->cacheManagerFactory->create($lessFilePath, $params);
+        return $this;
+    }
+
+    /**
+     * @param array $arguments
+     * @return array
+     */
+    public function beforeProcessLessInstructions(array $arguments)
+    {
+        if (null !== $this->cacheManager) {
+            list($lessFilePath, $params) = $arguments;
+            $this->cacheManager->addEntityToCache($lessFilePath, $params);
+        }
+        return $arguments;
+    }
+}
diff --git a/lib/Magento/Css/PreProcessor/Composite.php b/lib/Magento/Css/PreProcessor/Composite.php
new file mode 100644
index 0000000000000000000000000000000000000000..77af5a3efdfa69d9990b15baeb3ded688d8935d3
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Composite.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Css\PreProcessor;
+
+use Magento\View\Asset\PreProcessor\PreProcessorInterface;
+use \Magento\View\Asset\PreProcessorFactory;
+
+/**
+ * Css pre-processor composite
+ */
+class Composite implements PreProcessorInterface
+{
+    /**
+     * @var PreProcessorInterface[]
+     */
+    protected $preProcessors = array();
+
+    /**
+     * @var PreProcessorFactory
+     */
+    protected $preProcessorFactory;
+
+    /**
+     * @param PreProcessorFactory $preProcessorFactory
+     * @param array $preProcessors
+     */
+    public function __construct(
+        PreProcessorFactory $preProcessorFactory,
+        array $preProcessors = array()
+    ) {
+        $this->preProcessorFactory = $preProcessorFactory;
+        $this->preparePreProcessors($preProcessors);
+    }
+
+    /**
+     * @param string $filePath
+     * @param array $params
+     * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory
+     * @param null $sourcePath
+     * @return null|string
+     */
+    public function process($filePath, $params, $targetDirectory, $sourcePath = null)
+    {
+        foreach ($this->preProcessors as $preProcessor) {
+            $sourcePath = $preProcessor->process($filePath, $params, $targetDirectory, $sourcePath);
+        }
+
+        return $sourcePath;
+    }
+
+    /**
+     * @param array $preProcessors
+     * @return PreProcessorInterface[]
+     */
+    protected function preparePreProcessors($preProcessors)
+    {
+        if (empty($this->preProcessors)) {
+            foreach ($preProcessors as $preProcessorClass) {
+                $this->preProcessors[] = $this->preProcessorFactory->create($preProcessorClass);
+            }
+        }
+        return $this;
+    }
+}
diff --git a/lib/Magento/Css/PreProcessor/Less.php b/lib/Magento/Css/PreProcessor/Less.php
index 7a6515d76af90ff64cc1eccfbac35ae6d4719280..31556cdfc2a4addc8bee26e465acf9f300b62d2d 100644
--- a/lib/Magento/Css/PreProcessor/Less.php
+++ b/lib/Magento/Css/PreProcessor/Less.php
@@ -24,11 +24,20 @@
 
 namespace Magento\Css\PreProcessor;
 
+use \Magento\View\Asset\PreProcessor\PreProcessorInterface;
+
 /**
  * Css pre-processor less
  */
-class Less implements \Magento\View\Asset\PreProcessor\PreProcessorInterface
+class Less implements PreProcessorInterface
 {
+    /**#@+
+     * Temporary directories prefix group
+     */
+    const TMP_VIEW_DIR   = 'view';
+    const TMP_THEME_DIR  = 'theme_';
+    /**#@-*/
+
     /**
      * @var \Magento\View\FileSystem
      */
@@ -44,22 +53,32 @@ class Less implements \Magento\View\Asset\PreProcessor\PreProcessorInterface
      */
     protected $adapter;
 
+    /**
+     * @var \Magento\Logger
+     */
+    protected $logger;
+
     /**
      * @param \Magento\View\FileSystem $viewFileSystem
      * @param \Magento\Less\PreProcessor $lessPreProcessor
      * @param AdapterInterface $adapter
+     * @param \Magento\Logger $logger
      */
     public function __construct(
         \Magento\View\FileSystem $viewFileSystem,
         \Magento\Less\PreProcessor $lessPreProcessor,
-        \Magento\Css\PreProcessor\AdapterInterface $adapter
+        \Magento\Css\PreProcessor\AdapterInterface $adapter,
+        \Magento\Logger $logger
     ) {
         $this->viewFileSystem = $viewFileSystem;
         $this->lessPreProcessor = $lessPreProcessor;
         $this->adapter = $adapter;
+        $this->logger = $logger;
     }
 
     /**
+     * Process LESS file content
+     *
      * @param string $filePath
      * @param array $params
      * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory
@@ -68,21 +87,81 @@ class Less implements \Magento\View\Asset\PreProcessor\PreProcessorInterface
      */
     public function process($filePath, $params, $targetDirectory, $sourcePath = null)
     {
-        // if css file has being already discovered/prepared by previous pre-processor
+        // if css file has being already found_by_fallback or prepared_by_previous_pre-processor
         if ($sourcePath) {
             return $sourcePath;
         }
 
-        // TODO: if css file is already exist. May compare modification time of .less and .css files here.
-        $sourcePath = $this->viewFileSystem->getViewFile($filePath, $params);
+        $lessFilePath = $this->replaceExtension($filePath, 'css', 'less');
+        try {
+            $preparedLessFileSourcePath = $this->lessPreProcessor->processLessInstructions($lessFilePath, $params);
+        } catch (\Magento\Filesystem\FilesystemException $e) {
+            $this->logger->logException($e);
+            return $sourcePath;     // It's actually 'null'
+        }
+
+        try {
+            $cssContent = $this->adapter->process($preparedLessFileSourcePath);
+        } catch (\Magento\Css\PreProcessor\Adapter\AdapterException $e) {
+            $this->logger->logException($e);
+            return $sourcePath;     // It's actually 'null'
+        }
+
+        $tmpFilePath = $this->buildTmpFilePath($filePath, $params);
+
+        $targetDirectory->writeFile($tmpFilePath, $cssContent);
+        return $targetDirectory->getAbsolutePath($tmpFilePath);
+    }
+
+    /**
+     * Build unique file path for a view file that includes area/theme/locale/module parts
+     *
+     * @param string $file
+     * @param array $params - 'themeModel', 'area', 'locale', 'module' keys are used
+     * @return string
+     */
+    protected function buildTmpFilePath($file, array $params)
+    {
+        /** @var $theme \Magento\View\Design\ThemeInterface */
+        $theme = $params['themeModel'];
+        $designPath = null;
+        if ($theme->getThemePath()) {
+            $designPath = $theme->getThemePath();
+        } elseif ($theme->getId()) {
+            $designPath = self::TMP_THEME_DIR . $theme->getId();
+        }
+
+        $parts = array();
+        $parts[] = self::TMP_VIEW_DIR;
+        $parts[] = $params['area'];
+        if ($designPath) {
+            $parts[] = $designPath;
+        }
+        $parts[] = $params['locale'];
+        if ($params['module']) {
+            $parts[] = $params['module'];
+        }
+        $parts[] = $file;
 
-        $lessFilePath = str_replace('.css', '.less', $filePath);
-        $preparedLessFileSourcePath = $this->lessPreProcessor->processLessInstructions($lessFilePath, $params);
-        $cssContent = $this->adapter->process($preparedLessFileSourcePath);
+        $publicFile = join('/', $parts);
+
+        return $publicFile;
+    }
+
+    /**
+     * @param string $filePath
+     * @param string $search
+     * @param string $replace
+     * @return string
+     */
+    protected function replaceExtension($filePath, $search, $replace)
+    {
+        $extension = pathinfo($filePath, PATHINFO_EXTENSION);
+        if ($extension == $search) {
+            $dotPosition = strrpos($filePath, '.');
+            $filePath = substr($filePath, 0, $dotPosition + 1) . $replace;
+        }
 
-        // doesn't matter where exact file has been found, we use original file identifier
-        // see \Magento\View\Publisher::_buildPublishedFilePath() for details
-        $targetDirectory->writeFile($filePath, $cssContent);
-        return $targetDirectory->getAbsolutePath($filePath);
+        return $filePath;
     }
 }
diff --git a/lib/Magento/Data/Collection/Db.php b/lib/Magento/Data/Collection/Db.php
index e5e21378b1a38a348e0be09e13362c8f981fed63..039c12a4c2be70ed5533a59afcc3289631004b94 100644
--- a/lib/Magento/Data/Collection/Db.php
+++ b/lib/Magento/Data/Collection/Db.php
@@ -23,11 +23,6 @@
  * @copyright  Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
-
-/**
- * Base items collection class
- */
 namespace Magento\Data\Collection;
 
 use Magento\Data\Collection\Db\FetchStrategyInterface;
@@ -35,6 +30,9 @@ use Magento\DB\Adapter\AdapterInterface;
 use Magento\DB\Select;
 use Magento\Logger;
 
+/**
+ * Base items collection class
+ */
 class Db extends \Magento\Data\Collection
 {
     /**
diff --git a/lib/Magento/Error/Handler.php b/lib/Magento/Error/Handler.php
index 76bcb0fa983e6a3f0a84edb4e295f8a9b622f13c..0c3bdc9251ae284b34992989f5bf248da0a75cea 100644
--- a/lib/Magento/Error/Handler.php
+++ b/lib/Magento/Error/Handler.php
@@ -86,7 +86,6 @@ class Handler implements HandlerInterface
      * @param string $errorStr
      * @param string $errorFile
      * @param int $errorLine
-     * @return bool
      */
     public function handler($errorNo, $errorStr, $errorFile, $errorLine)
     {
diff --git a/lib/Magento/Error/HandlerInterface.php b/lib/Magento/Error/HandlerInterface.php
index 45d030e54a13dc1734875a440a090a22c6eee5ac..4d9521c8685d837771a2976b98adc88fdd1473b9 100644
--- a/lib/Magento/Error/HandlerInterface.php
+++ b/lib/Magento/Error/HandlerInterface.php
@@ -45,6 +45,7 @@ interface HandlerInterface
      *
      * @param \Exception $exception
      * @param string[] $params
+     * @return void
      */
     public function processException(\Exception $exception, array $params = array());
 }
diff --git a/lib/Magento/Event/Collection.php b/lib/Magento/Event/Collection.php
index 59bd5d5ec9de728b5a97e48fb19a97feec6a99fd..8ac2bc1cca8c1fdedcb55a46ffe30d15277958da 100644
--- a/lib/Magento/Event/Collection.php
+++ b/lib/Magento/Event/Collection.php
@@ -56,7 +56,6 @@ class Collection
     
     /**
      * Initializes global observers collection
-     * 
      */
     public function __construct()
     {
diff --git a/lib/Magento/Event/Config/Data.php b/lib/Magento/Event/Config/Data.php
index fa4914d152652b28e0542d3424e9996e652fdc17..e7a11667d4d2e03f1d9fcaacd1c0f1b23472c6e8 100644
--- a/lib/Magento/Event/Config/Data.php
+++ b/lib/Magento/Event/Config/Data.php
@@ -43,8 +43,8 @@ class Data extends \Magento\Config\Data\Scoped
      * @param \Magento\Event\Config\Reader $reader
      * @param \Magento\Config\ScopeInterface $configScope
      * @param \Magento\Config\CacheInterface $cache
-     * @param string $cacheId
      * @param \Magento\App\State $appState
+     * @param string $cacheId
      */
     public function __construct(
         \Magento\Event\Config\Reader $reader,
diff --git a/lib/Magento/Event/ConfigInterface.php b/lib/Magento/Event/ConfigInterface.php
index a22f415499d89407a02265466bf25d6733e41972..7d6d5b99c3f1cb0915ca6c2fb5e3875561d15cb3 100644
--- a/lib/Magento/Event/ConfigInterface.php
+++ b/lib/Magento/Event/ConfigInterface.php
@@ -30,7 +30,7 @@ interface ConfigInterface
     /**
      * Get observers by event name
      *
-     * @param $eventName
+     * @param string $eventName
      * @return array
      */
     public function getObservers($eventName);
diff --git a/lib/Magento/Event/InvokerInterface.php b/lib/Magento/Event/InvokerInterface.php
index 41929c18c80627666bb58b9197909ee98a5397f8..c3e1cf60040e18563b1da817c86fa54cdf3f3024 100644
--- a/lib/Magento/Event/InvokerInterface.php
+++ b/lib/Magento/Event/InvokerInterface.php
@@ -32,6 +32,7 @@ interface InvokerInterface
      *
      * @param array $configuration
      * @param \Magento\Event\Observer $observer
+     * @return void
      */
     public function dispatch(array $configuration, \Magento\Event\Observer $observer);
 }
diff --git a/lib/Magento/Event/ManagerInterface.php b/lib/Magento/Event/ManagerInterface.php
index 88cd4325e7eeae0d4699dbb39a2c155bf650c710..201faa306b75b50b907fb3f4a603d2b76b047458 100644
--- a/lib/Magento/Event/ManagerInterface.php
+++ b/lib/Magento/Event/ManagerInterface.php
@@ -33,6 +33,7 @@ interface ManagerInterface
      *
      * @param string $eventName
      * @param array $data
+     * @return void
      */
     public function dispatch($eventName, array $data = array());
 }
\ No newline at end of file
diff --git a/lib/Magento/Event/Observer/Collection.php b/lib/Magento/Event/Observer/Collection.php
index 76a9a1a5d52946fb3c9c60c1349deb3f76b05714..248799862a40553ad304ee7862f7bdbed6070bb8 100644
--- a/lib/Magento/Event/Observer/Collection.php
+++ b/lib/Magento/Event/Observer/Collection.php
@@ -45,7 +45,6 @@ class Collection
     
     /**
      * Initializes observers
-     *
      */
     public function __construct()
     {
@@ -77,7 +76,7 @@ class Collection
      * Adds an observer to the collection
      *
      * @param \Magento\Event\Observer $observer
-     * @return \Magento\Event\Observer\Collection
+     * @return $this
      */
     public function addObserver(\Magento\Event\Observer $observer)
     {
@@ -89,7 +88,7 @@ class Collection
      * Removes an observer from the collection by its name
      *
      * @param string $observerName
-     * @return \Magento\Event\Observer\Collection
+     * @return $this
      */
     public function removeObserverByName($observerName)
     {
@@ -101,7 +100,7 @@ class Collection
      * Dispatches an event to all observers in the collection
      *
      * @param \Magento\Event $event
-     * @return \Magento\Event\Observer\Collection
+     * @return $this
      */
     public function dispatch(\Magento\Event $event)
     {
diff --git a/lib/Magento/Exception/AuthenticationException.php b/lib/Magento/Exception/AuthenticationException.php
new file mode 100644
index 0000000000000000000000000000000000000000..513c3e9e671a1b38961f87743b979f6c4372e0f6
--- /dev/null
+++ b/lib/Magento/Exception/AuthenticationException.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Authentication exception
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+class AuthenticationException extends \Magento\Exception\Exception
+{
+    const UNKNOWN = 0;
+    const EMAIL_NOT_CONFIRMED = 1;
+    const INVALID_EMAIL_OR_PASSWORD = 2;
+}
diff --git a/lib/Magento/Exception/AuthorizationException.php b/lib/Magento/Exception/AuthorizationException.php
new file mode 100644
index 0000000000000000000000000000000000000000..1aa9e4034e4b537fae9a03eb46cadea0d1898cb0
--- /dev/null
+++ b/lib/Magento/Exception/AuthorizationException.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Authorization service exception
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+class AuthorizationException extends \Magento\Exception\Exception
+{
+    const UNAUTHENTICATED_USER = 0;
+    const NO_RECORD_ACCESS = 1;
+}
diff --git a/lib/Magento/Exception/Exception.php b/lib/Magento/Exception/Exception.php
new file mode 100644
index 0000000000000000000000000000000000000000..bff20c1e6194a0dd7e5a6e8b8533d68fb5e184f4
--- /dev/null
+++ b/lib/Magento/Exception/Exception.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Base service exception
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+abstract class Exception extends \Exception
+{
+    /**
+     * @var array
+     */
+    protected $_params = [];
+
+    /**
+     * Returns the parameters detailing specifics of this Exception
+     *
+     * @return array
+     */
+    public function getParams()
+    {
+        return $this->_params;
+    }
+}
diff --git a/lib/Magento/Exception/InputException.php b/lib/Magento/Exception/InputException.php
new file mode 100644
index 0000000000000000000000000000000000000000..0d47162c663910f143718443e5a6387213c942a0
--- /dev/null
+++ b/lib/Magento/Exception/InputException.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * Input service exception
+ *
+ * The top level data (code and message) is consistent across all Input Exceptions.
+ * InputException is inherently build to contain aggregates.  All failure specifics are stored in params.
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+class InputException extends \Magento\Exception\Exception
+{
+    // This will always be the value of $this->code
+    const INPUT_EXCEPTION = 0;
+
+    // These are possible code to be stored in params
+    const INVALID_FIELD_RANGE = 'INVALID_FIELD_RANGE';
+    const INVALID_FIELD_VALUE = 'INVALID_FIELD_VALUE';
+    const REQUIRED_FIELD = 'REQUIRED_FIELD';
+
+    /**
+     * @param string $message
+     * @param int    $code
+     */
+    public function __construct($message = 'One or more input exceptions have occurred.', $code = self::INPUT_EXCEPTION)
+    {
+        parent::__construct($message, $code);
+    }
+
+    /**
+     * Create an input exception with the first error to be stored in params
+     *
+     * @param string $code
+     * @param string $fieldName
+     * @param string $value
+     * @param array  $params
+     * @return InputException
+     */
+    public static function create($code, $fieldName, $value, array $params = [])
+    {
+        $exception = new self();
+        $exception->addError($code, $fieldName, $value, $params);
+        return $exception;
+    }
+
+    /**
+     * @param array $error a map of string keys to mixed values.
+     * @return string
+     */
+    public static function translateError($error)
+    {
+        switch ($error['code']) {
+            case InputException::INVALID_FIELD_VALUE:
+            case InputException::INVALID_FIELD_RANGE:
+                $message = __('Invalid value of "%1" provided for %2 field.', $error['value'], $error['fieldName']);
+                break;
+            case InputException::REQUIRED_FIELD:
+                $message = __('%1 is a required field.', $error['fieldName']);
+                break;
+            default:
+                $message = __('Unknown Error.');
+                break;
+        }
+        return $message;
+    }
+
+    /**
+     * Add another error to the parameters list of errors
+     *
+     * @param string $code      Error code
+     * @param string $fieldName Fieldname with bad input
+     * @param string $value     Bad input value
+     * @param array  $errorData Extra error debug data
+     * @return $this
+     */
+    public function addError($code, $fieldName, $value, array $errorData = [])
+    {
+        $printParams = empty($errorData) ? "[]\n" : print_r($errorData, true);
+        $this->message .= "\n{\n\tcode: $code\n\t$fieldName: $value\n\tparams: $printParams }\n";
+        $errorData['fieldName'] = $fieldName;
+        $errorData['code'] = $code;
+        $errorData['value'] = $value;
+        $this->_params[] = $errorData;
+        return $this;
+    }
+
+    /**
+     * Returns the input errors found
+     *
+     * @return array
+     */
+    public function getErrors()
+    {
+        return $this->getParams();
+    }
+}
diff --git a/lib/Magento/Exception/NoSuchEntityException.php b/lib/Magento/Exception/NoSuchEntityException.php
new file mode 100644
index 0000000000000000000000000000000000000000..dae6a3dc2b16a77663927330476c13c94f462e41
--- /dev/null
+++ b/lib/Magento/Exception/NoSuchEntityException.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * No such entity service exception
+ *
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+namespace Magento\Exception;
+
+class NoSuchEntityException extends \Magento\Exception\Exception
+{
+    const NO_SUCH_ENTITY = 0;
+
+    /**
+     * @param string $fieldName name of the field searched upon
+     * @param mixed  $value     the value of the field
+     */
+    public function __construct($fieldName, $value)
+    {
+        $message = "No such entity with $fieldName = $value";
+        $this->_params[$fieldName] = $value;
+        parent::__construct($message, self::NO_SUCH_ENTITY);
+    }
+
+    /**
+     * @param string $fieldName name of the field searched upon
+     * @param mixed  $value     the value of the field
+     * @return $this
+     */
+    public function addField($fieldName, $value)
+    {
+        $this->message .= "\n $fieldName = $value";
+        $this->_params[$fieldName] = $value;
+        return $this;
+    }
+}
diff --git a/lib/Magento/Exception/StateException.php b/lib/Magento/Exception/StateException.php
new file mode 100644
index 0000000000000000000000000000000000000000..7d148175626657837b01c0b8fd369dc9f4e944fe
--- /dev/null
+++ b/lib/Magento/Exception/StateException.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Magento\Exception;
+
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */ 
+class StateException extends Exception
+{
+    const INVALID_STATE = 1;
+    const EXPIRED = 3;
+    const INPUT_MISMATCH = 5;
+}
diff --git a/lib/Magento/Filesystem.php b/lib/Magento/Filesystem.php
index 79d58dc195eb00e80128e364f8cd89d9e98d5a56..fefc8aa00cf639ae8cc71bbfd5a8fa923f6677c6 100644
--- a/lib/Magento/Filesystem.php
+++ b/lib/Magento/Filesystem.php
@@ -189,17 +189,4 @@ class Filesystem
         $config = $this->directoryList->getConfig($code);
         return isset($config['uri']) ? $config['uri'] : '';
     }
-
-    /**
-     * Retrieve absolute path for for given code
-     *
-     * @param string $code
-     * @return string
-     */
-    public function getPath($code = '')
-    {
-        $config = $this->directoryList->getConfig($code);
-        $path = isset($config['path']) ? $config['path'] : '';
-        return str_replace('\\', '/', $path);
-    }
 }
diff --git a/lib/Magento/HTTP/Adapter/Curl.php b/lib/Magento/HTTP/Adapter/Curl.php
index 151c31f6d260e7a08f76825367ee395ef5a657f4..2ad0fe5b1b4d3e4fd03d786f947109b084f21820 100644
--- a/lib/Magento/HTTP/Adapter/Curl.php
+++ b/lib/Magento/HTTP/Adapter/Curl.php
@@ -139,11 +139,12 @@ class Curl implements \Zend_Http_Client_Adapter_Interface
     /**
      * Connect to the remote server
      *
-     * @deprecated since 1.4.0.0-rc1
      * @param string  $host
      * @param int     $port
      * @param boolean $secure
      * @return $this
+     *
+     * @deprecated since 1.4.0.0-rc1
      */
     public function connect($host, $port = 80, $secure = false)
     {
diff --git a/lib/Magento/HTTP/Client/Curl.php b/lib/Magento/HTTP/Client/Curl.php
index a128521d377a205fd9edbc6448adb917b6ca92f2..2ad12b39bf6140f7e6db3d031dad25dad65d902d 100644
--- a/lib/Magento/HTTP/Client/Curl.php
+++ b/lib/Magento/HTTP/Client/Curl.php
@@ -112,7 +112,7 @@ implements \Magento\HTTP\IClient
      * User overrides options hash
      * Are applied before curl_exec
      *
-     * @var array();
+     * @var array
      */
     protected $_curlUserOptions = array();
 
@@ -246,11 +246,12 @@ implements \Magento\HTTP\IClient
 
     /**
      * Make POST request
-     * @see lib/Magento/HTTP/\Magento\HTTP\Client#post($uri, $params)
      *
      * @param string $uri
      * @param array $params
      * @return void
+     *
+     * @see lib/Magento/HTTP/\Magento\HTTP\Client#post($uri, $params)
      */
     public function post($uri, $params)
     {
diff --git a/lib/Magento/HTTP/IClient.php b/lib/Magento/HTTP/IClient.php
index 3240ece902156603a18955b580041823857e432f..4253f1471b650d33cf715e5b6bf578eb368fc72e 100644
--- a/lib/Magento/HTTP/IClient.php
+++ b/lib/Magento/HTTP/IClient.php
@@ -38,6 +38,7 @@ interface IClient
     /**
      * Set request timeout
      * @param int $value
+     * @return void
      */
     function setTimeout($value);
     
@@ -45,6 +46,7 @@ interface IClient
     /**
      * Set request headers from hash
      * @param array $headers
+     * @return void
      */
     function setHeaders($headers);
     
@@ -52,6 +54,7 @@ interface IClient
      * Add header to request 
      * @param string $name
      * @param string $value
+     * @return void
      */
     function addHeader($name, $value);
     
@@ -59,6 +62,7 @@ interface IClient
     /**
      * Remove header from request
      * @param string $name
+     * @return void
      */
     function removeHeader($name);
 
@@ -68,6 +72,7 @@ interface IClient
      * for basic auth.
      * @param string $login
      * @param string $pass
+     * @return void
      */
     function setCredentials($login, $pass);
     
@@ -75,29 +80,35 @@ interface IClient
      * Add cookie to request 
      * @param string $name
      * @param string $value
+     * @return void
      */
     function addCookie($name, $value);
 
     /**
      * Remove cookie from request
      * @param string $name
+     * @return void
      */
     function removeCookie($name);
     
     /**
      * Set request cookies from hash
      * @param array $cookies
+     * @return void
      */ 
     function setCookies($cookies);
 
     /**
      * Remove cookies from request
+     *
+     * @return void
      */
     function removeCookies();
 
     /**
      * Make GET request
      * @param string full uri
+     * @return array
      */
     function get($uri);
 
@@ -105,6 +116,7 @@ interface IClient
      * Make POST request
      * @param string $uri full uri
      * @param array $params POST fields array
+     * @return void
      */ 
     function post($uri, $params);
     
@@ -136,12 +148,14 @@ interface IClient
      * Set additional option
      * @param string $key
      * @param string $value
+     * @return void
      */
     function setOption($key, $value);
 
     /**
      * Set additional options
      * @param array $arr
+     * @return void
      */
     function setOptions($arr);
 }
diff --git a/lib/Magento/Image.php b/lib/Magento/Image.php
index 53bd197821465a6355ec1d0737e6f0f5f9286547..28ee1654425e8737121239054149871b3c06fc4b 100644
--- a/lib/Magento/Image.php
+++ b/lib/Magento/Image.php
@@ -91,8 +91,8 @@ class Image
     /**
      * Save handled image into file
      *
-     * @param string $destination. Default value is NULL
-     * @param string $newFileName. Default value is NULL
+     * @param null|string $destination Default value is NULL
+     * @param null|string $newFileName Default value is NULL
      * @access public
      * @return void
      */
@@ -116,10 +116,10 @@ class Image
     /**
      * Crop an image.
      *
-     * @param int $top. Default value is 0
-     * @param int $left. Default value is 0
-     * @param int $right. Default value is 0
-     * @param int $bottom. Default value is 0
+     * @param int $top  Default value is 0
+     * @param int $left Default value is 0
+     * @param int $right Default value is 0
+     * @param int $bottom Default value is 0
      * @access public
      * @return void
      */
@@ -210,12 +210,13 @@ class Image
     /**
      * Adds watermark to our image.
      *
-     * @param string $watermarkImage. Absolute path to watermark image.
-     * @param int $positionX. Watermark X position.
-     * @param int $positionY. Watermark Y position.
-     * @param int $watermarkImageOpacity. Watermark image opacity.
-     * @param bool $repeat. Enable or disable watermark brick.
+     * @param string $watermarkImage Absolute path to watermark image.
+     * @param int $positionX Watermark X position.
+     * @param int $positionY Watermark Y position.
+     * @param int $watermarkImageOpacity Watermark image opacity.
+     * @param bool $repeat Enable or disable watermark brick.
      * @access public
+     * @throws \Exception
      * @return void
      */
     public function watermark($watermarkImage, $positionX=0, $positionY=0, $watermarkImageOpacity=30, $repeat=false)
@@ -238,7 +239,7 @@ class Image
     }
 
     /**
-     * process
+     * Process
      *
      * @access public
      * @return void
@@ -249,7 +250,7 @@ class Image
     }
 
     /**
-     * instruction
+     * Instruction
      *
      * @access public
      * @return void
@@ -275,7 +276,7 @@ class Image
      * Set watermark position
      *
      * @param string $position
-     * @return \Magento\Image
+     * @return $this
      */
     public function setWatermarkPosition($position)
     {
@@ -287,7 +288,7 @@ class Image
      * Set watermark image opacity
      *
      * @param int $imageOpacity
-     * @return \Magento\Image
+     * @return $this
      */
     public function setWatermarkImageOpacity($imageOpacity)
     {
@@ -299,7 +300,7 @@ class Image
      * Set watermark width
      *
      * @param int $width
-     * @return \Magento\Image
+     * @return $this
      */
     public function setWatermarkWidth($width)
     {
@@ -311,7 +312,7 @@ class Image
      * Set watermark height
      *
      * @param int $height
-     * @return \Magento\Image
+     * @return $this
      */
     public function setWatermarkHeight($height)
     {
@@ -345,7 +346,7 @@ class Image
      *
      * @param string $text
      * @param string $font Path to font file
-     * @return \Magento\Image
+     * @return $this
      */
     public function createPngFromString($text, $font = '')
     {
diff --git a/lib/Magento/Image/Adapter/AbstractAdapter.php b/lib/Magento/Image/Adapter/AbstractAdapter.php
index 06136409450e3d2133e227d4d06602c69bc69492..de4af62e74b6083aed9f1f390aa9d9fae2f27d41 100644
--- a/lib/Magento/Image/Adapter/AbstractAdapter.php
+++ b/lib/Magento/Image/Adapter/AbstractAdapter.php
@@ -55,62 +55,104 @@ abstract class AbstractAdapter implements AdapterInterface
      */
     const DEFAULT_FONT_SIZE = 15;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_fileType;
 
-    /** @var  string */
+    /**
+     * @var  string
+     */
     protected $_fileName ;
 
-    /** @var  string */
+    /**
+     * @var  string
+     */
     protected $_fileMimeType;
 
-    /** @var  string */
+    /**
+     * @var  string
+     */
     protected $_fileSrcName;
 
-    /** @var  string */
+    /**
+     * @var  string
+     */
     protected $_fileSrcPath;
 
+    /**
+     * @var resource
+     */
     protected $_imageHandler;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_imageSrcWidth;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_imageSrcHeight;
 
+    /**
+     * @var array
+     */
     protected $_requiredExtensions;
 
-    /** @var  string */
+    /**
+     * @var  string
+     */
     protected $_watermarkPosition;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_watermarkWidth;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_watermarkHeight;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_watermarkImageOpacity;
 
-    /** @var  int */
+    /**
+     * @var  int
+     */
     protected $_quality;
 
-    /** @var int int */
+    /**
+     * @var int
+     */
     protected $_fontSize = self::DEFAULT_FONT_SIZE;
 
-    /** @var  bool */
+    /**
+     * @var  bool
+     */
     protected $_keepAspectRatio;
 
-    /** @var  bool */
+    /**
+     * @var  bool
+     */
     protected $_keepFrame;
 
-    /** @var  bool */
+    /**
+     * @var  bool
+     */
     protected $_keepTransparency;
 
-    /** @var  array */
+    /**
+     * @var  array
+     */
     protected $_backgroundColor;
 
-    /** @var  bool */
+    /**
+     * @var  bool
+     */
     protected $_constrainOnly;
 
     /**
@@ -145,7 +187,7 @@ abstract class AbstractAdapter implements AdapterInterface
      * @param null|string $destination
      * @param null|string $newName
      * @return void
-     * @throws \Exception  if destination path is not writable
+     * @throws \Exception  If destination path is not writable
      */
     abstract public function save($destination = null, $newName = null);
 
@@ -200,7 +242,7 @@ abstract class AbstractAdapter implements AdapterInterface
      * Checks required dependencies
      *
      * @return void
-     * @throws \Exception if some of dependencies are missing
+     * @throws \Exception If some of dependencies are missing
      */
     abstract public function checkDependencies();
 
@@ -232,7 +274,7 @@ abstract class AbstractAdapter implements AdapterInterface
     /**
      * Initialize default values
      *
-     * @param \Magento\App\Filesystem $filesystem,
+     * @param \Magento\App\Filesystem $filesystem
      * @param array $data
      */
     public function __construct(\Magento\App\Filesystem $filesystem, array $data = array()) {
@@ -616,10 +658,10 @@ abstract class AbstractAdapter implements AdapterInterface
     /**
      * Create destination folder if not exists and return full file path
      *
-     * @throws \Exception
      * @param string $destination
      * @param string $newName
      * @return string
+     * @throws \Exception
      */
     protected function _prepareDestination($destination = null, $newName = null)
     {
diff --git a/lib/Magento/Image/Adapter/AdapterInterface.php b/lib/Magento/Image/Adapter/AdapterInterface.php
index 7844a17748f284bfe95dc622c9dba987426f4a7c..91db80554c944f397c246c555d1674646099bf5c 100644
--- a/lib/Magento/Image/Adapter/AdapterInterface.php
+++ b/lib/Magento/Image/Adapter/AdapterInterface.php
@@ -60,6 +60,8 @@ interface AdapterInterface
 
     /**
      * Reassign image dimensions
+     *
+     * @return void
      */
     public function refreshImageDimensions();
 
@@ -67,7 +69,7 @@ interface AdapterInterface
      * Checks required dependencies
      *
      * @return void
-     * @throws \Exception if some of dependencies are missing
+     * @throws \Exception If some of dependencies are missing
      */
     public function checkDependencies();
 
@@ -83,7 +85,7 @@ interface AdapterInterface
     /**
      * Open image for processing
      *
-     * @param $filename
+     * @param string $filename
      * @return void
      */
     public function open($filename);
@@ -115,7 +117,7 @@ interface AdapterInterface
      * @param null|string $destination
      * @param null|string $newName
      * @return void
-     * @throws \Exception  if destination path is not writable
+     * @throws \Exception  If destination path is not writable
      */
     public function save($destination = null, $newName = null);
 
diff --git a/lib/Magento/Image/Adapter/Gd2.php b/lib/Magento/Image/Adapter/Gd2.php
index 460b26a94975aef4b0bfd45b77520d50f97e6a81..5ea759341e0d030e29fec046582f13df6f4b5788 100644
--- a/lib/Magento/Image/Adapter/Gd2.php
+++ b/lib/Magento/Image/Adapter/Gd2.php
@@ -139,7 +139,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
      * @param null|string $destination
      * @param null|string $newName
      * @return void
-     * @throws \Exception  if destination path is not writable
+     * @throws \Exception  If destination path is not writable
      */
     public function save($destination = null, $newName = null)
     {
@@ -227,9 +227,9 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
      * Fill image with main background color.
      * Returns a color identifier.
      *
-     * @throws \Exception
-     * @param resource $imageResourceTo
+     * @param resource &$imageResourceTo
      * @return int
+     * @throws \Exception
      */
     private function _fillBackgroundColor(&$imageResourceTo)
     {
@@ -303,8 +303,8 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
      *
      * @param resource $imageResource
      * @param int $fileType one of the constants IMAGETYPE_*
-     * @param bool $isAlpha
-     * @param bool $isTrueColor
+     * @param bool &$isAlpha
+     * @param bool &$isTrueColor
      * @return boolean
      */
     private function _getTransparency($imageResource, $fileType, &$isAlpha = false, &$isTrueColor = false)
@@ -573,7 +573,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
      * Checks required dependencies
      *
      * @return void
-     * @throws \Exception if some of dependencies are missing
+     * @throws \Exception If some of dependencies are missing
      */
     public function checkDependencies()
     {
@@ -586,6 +586,8 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
 
     /**
      * Reassign image dimensions
+     *
+     * @return void
      */
     public function refreshImageDimensions()
     {
@@ -603,10 +605,11 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
         }
     }
 
-    /*
+    /**
      * Fixes saving PNG alpha channel
      *
      * @param resource $imageHandler
+     * @return void
      */
     private function _saveAlpha($imageHandler)
     {
@@ -656,7 +659,8 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
     /**
      * Create Image using standard font
      *
-     * @param $text
+     * @param string $text
+     * @return void
      */
     protected function _createImageFromText($text)
     {
@@ -675,6 +679,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
      *
      * @param string $text
      * @param string $font
+     * @return void
      * @throws \Exception
      */
     protected function _createImageFromTtfText($text, $font)
@@ -696,8 +701,9 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter
     /**
      * Create empty image with transparent background
      *
-     * @param $width
-     * @param $height
+     * @param int $width
+     * @param int $height
+     * @return void
      */
     protected function _createEmptyImage($width, $height)
     {
diff --git a/lib/Magento/Image/Adapter/ImageMagick.php b/lib/Magento/Image/Adapter/ImageMagick.php
index 24207dbde0f96e4809b99f8b3e6258bd8410b6c8..93c7d5399a28090b6725138dd9ca61f952be6490 100644
--- a/lib/Magento/Image/Adapter/ImageMagick.php
+++ b/lib/Magento/Image/Adapter/ImageMagick.php
@@ -121,7 +121,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter
      * @param null|string $destination
      * @param null|string $newName
      * @return void
-     * @throws \Exception  if destination path is not writable
+     * @throws \Exception  If destination path is not writable
      */
     public function save($destination = null, $newName = null)
     {
@@ -135,7 +135,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter
     /**
      * Apply options to image. Will be usable later when create an option container
      *
-     * @return \Magento\Image\Adapter\ImageMagick
+     * @return $this
      */
     protected function _applyOptions()
     {
@@ -365,7 +365,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter
      * Checks required dependencies
      *
      * @return void
-     * @throws \Exception if some of dependencies are missing
+     * @throws \Exception If some of dependencies are missing
      */
     public function checkDependencies()
     {
@@ -388,8 +388,6 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter
 
     /**
      * Standard destructor. Destroy stored information about image
-     *
-     * @return void
      */
     public function __destruct()
     {
@@ -399,7 +397,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter
     /**
      * Destroy stored information about image
      *
-     * @return \Magento\Image\Adapter\ImageMagick
+     * @return $this
      */
     public function destroy()
     {
diff --git a/lib/Magento/Io/File.php b/lib/Magento/Io/File.php
index 60ade58015eda43a550e40b5794dd23085508942..848a003c952163ddb448019a77bbd225e46db136 100644
--- a/lib/Magento/Io/File.php
+++ b/lib/Magento/Io/File.php
@@ -22,16 +22,11 @@
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
+namespace Magento\Io;
 
 /**
  * Filesystem client
- *
- * @category   Magento
- * @package    Magento_Io
- * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento\Io;
-
 class File extends AbstractIo
 {
     /**
@@ -555,7 +550,7 @@ class File extends AbstractIo
      * Get destination folder
      *
      * @param string $filePath
-     * @return bool
+     * @return bool|string
      */
     public function getDestinationFolder($filePath)
     {
@@ -708,7 +703,7 @@ class File extends AbstractIo
     {
         $ignoredDirectories = Array('.', '..');
 
-        if ( is_dir($this->_cwd)) {
+        if (is_dir($this->_cwd)) {
             $dir = $this->_cwd;
         } elseif (is_dir($this->_iwd)) {
             $dir = $this->_iwd;
@@ -734,7 +729,7 @@ class File extends AbstractIo
                 }
 
                 $listItem['text'] = $entry;
-                $listItem['mod_date'] = date ('Y-m-d H:i:s', filectime($fullPath));
+                $listItem['mod_date'] = date('Y-m-d H:i:s', filectime($fullPath));
                 $listItem['permissions'] = $this->_parsePermissions(fileperms($fullPath));
                 $listItem['owner'] = $this->_getFileOwner($fullPath);
 
diff --git a/lib/Magento/Less/PreProcessor.php b/lib/Magento/Less/PreProcessor.php
index 7560df5cfb3f69a00ed4d88e66b92d8feca26b8e..0ae62fc1825d4e6c208bde5398742cea0a9c4dbb 100644
--- a/lib/Magento/Less/PreProcessor.php
+++ b/lib/Magento/Less/PreProcessor.php
@@ -52,12 +52,7 @@ class PreProcessor
     protected $instructionFactory;
 
     /**
-     * @var \Magento\Logger
-     */
-    protected $logger;
-
-    /**
-     * @var array
+     * @var \Magento\Less\PreProcessorInterface[]
      */
     protected $preProcessors;
 
@@ -65,36 +60,33 @@ class PreProcessor
      * @param \Magento\View\FileSystem $viewFileSystem
      * @param \Magento\Filesystem $filesystem
      * @param InstructionFactory $instructionFactory
-     * @param \Magento\Logger $logger
      * @param array $preProcessors
      */
     public function __construct(
         \Magento\View\FileSystem $viewFileSystem,
         \Magento\Filesystem $filesystem,
         InstructionFactory $instructionFactory,
-        \Magento\Logger $logger,
         array $preProcessors = array()
     ) {
         $this->viewFileSystem = $viewFileSystem;
         $this->filesystem = $filesystem;
         $this->instructionFactory = $instructionFactory;
-        $this->logger = $logger;
-        $this->preProcessors = $preProcessors;
+        $this->preProcessors = $this->initLessPreProcessors($preProcessors);
     }
 
     /**
      * Instantiate instruction less preprocessors
      *
-     * @param array $params
+     * @param $preProcessors
      * @return \Magento\Less\PreProcessorInterface[]
      */
-    protected function getLessPreProcessors(array $params)
+    protected function initLessPreProcessors($preProcessors)
     {
-        $preProcessors = [];
-        foreach ($this->preProcessors as $preProcessorClass) {
-            $preProcessors[] = $this->instructionFactory->create($preProcessorClass['class'], $params);
+        $preProcessorsInstances = [];
+        foreach ($preProcessors as $preProcessorClass) {
+            $preProcessorsInstances[] = $this->instructionFactory->create($preProcessorClass['class']);
         }
-        return $preProcessors;
+        return $preProcessorsInstances;
     }
 
     /**
@@ -123,39 +115,54 @@ class PreProcessor
      * @param string $lessFileSourcePath
      * @return string
      */
-    protected function generateNewPath($lessFileSourcePath)
+    protected function generatePath($lessFileSourcePath)
     {
         $sourcePathPrefix = $this->getDirectoryRead()->getAbsolutePath();
         $targetPathPrefix = $this->getDirectoryWrite()->getAbsolutePath() . self::PUBLICATION_PREFIX_PATH . '/';
         return str_replace($sourcePathPrefix, $targetPathPrefix, $lessFileSourcePath);
     }
 
+    /**
+     * Save pre-processed less content to temporary folder
+     *
+     * @param string $lessFileSourcePath absolute path to source less file
+     * @param string $lessContent
+     * @return string absolute path to the pre-processed less file
+     */
+    protected function saveLessFile($lessFileSourcePath, $lessContent)
+    {
+        $lessFileTargetPath = $this->generatePath($lessFileSourcePath);
+        $directoryWrite = $this->getDirectoryWrite();
+        $directoryWrite->writeFile($directoryWrite->getRelativePath($lessFileTargetPath), $lessContent);
+        return $lessFileTargetPath;
+    }
+
     /**
      * Process less content throughout all existed instruction preprocessors
      *
      * @param string $lessFilePath
-     * @param array $params
+     * @param array $viewParams
      * @return string of saved or original preprocessed less file
      */
-    public function processLessInstructions($lessFilePath, $params)
+    public function processLessInstructions($lessFilePath, $viewParams)
     {
-        $lessFileSourcePath = $this->viewFileSystem->getViewFile($lessFilePath, $params);
+        $lessFileTargetPath = $lessFileSourcePath = $this->viewFileSystem->getViewFile($lessFilePath, $viewParams);
         $directoryRead = $this->getDirectoryRead();
         $lessContent = $lessSourceContent = $directoryRead->readFile(
             $directoryRead->getRelativePath($lessFileSourcePath)
         );
 
-        foreach ($this->getLessPreProcessors($params) as $processor) {
-            $lessContent = $processor->process($lessContent);
+        foreach ($this->preProcessors as $processor) {
+            $lessContent = $processor->process(
+                $lessContent,
+                $viewParams,
+                ['parentPath' => $lessFilePath, 'parentAbsolutePath' => $lessFileSourcePath]
+            );
         }
 
-        $lessFileTargetPath = $this->generateNewPath($lessFileSourcePath);
-        if ($lessFileSourcePath != $lessFileTargetPath && $lessSourceContent != $lessContent) {
-            $directoryWrite = $this->getDirectoryWrite();
-            $directoryWrite->writeFile($directoryWrite->getRelativePath($lessFileTargetPath), $lessContent);
-            return $lessFileTargetPath;
+        if ($lessSourceContent != $lessContent) {
+            $lessFileTargetPath = $this->saveLessFile($lessFileSourcePath, $lessContent);
         }
-
-        return $lessFileSourcePath;
+        return $lessFileTargetPath;
     }
 }
diff --git a/lib/Magento/Less/PreProcessor/ErrorHandler.php b/lib/Magento/Less/PreProcessor/ErrorHandler.php
new file mode 100644
index 0000000000000000000000000000000000000000..1ccbea697bcfa15d9854272693d3d38793fe0974
--- /dev/null
+++ b/lib/Magento/Less/PreProcessor/ErrorHandler.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Less\PreProcessor;
+
+/**
+ * Default Error Handler for less pre-processing
+ */
+class ErrorHandler implements ErrorHandlerInterface
+{
+    /**
+     * @var \Magento\Logger
+     */
+    protected $logger;
+
+    /**
+     * @param \Magento\Logger $logger
+     */
+    public function __construct(\Magento\Logger $logger)
+    {
+        $this->logger = $logger;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function processException(\Exception $e)
+    {
+        $this->logger->logException($e);
+    }
+}
\ No newline at end of file
diff --git a/lib/Magento/Less/PreProcessor/ErrorHandlerInterface.php b/lib/Magento/Less/PreProcessor/ErrorHandlerInterface.php
new file mode 100644
index 0000000000000000000000000000000000000000..13d4c7bd808aab4c688b84783d9d33af02503bc0
--- /dev/null
+++ b/lib/Magento/Less/PreProcessor/ErrorHandlerInterface.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Less\PreProcessor;
+
+/**
+ * Error handler interface
+ */
+interface ErrorHandlerInterface
+{
+    /**
+     * Process an exception which was thrown during processing a less instructions
+     *
+     * @param \Exception $e
+     * @return void
+     */
+    public function processException(\Exception $e);
+}
\ No newline at end of file
diff --git a/lib/Magento/Less/PreProcessor/Instruction/Import.php b/lib/Magento/Less/PreProcessor/Instruction/Import.php
index fac42869b7bf4a8867f1caec587cb26916ab934c..1f8421931083871a4b935956ce9145dcb3d4a4ed 100644
--- a/lib/Magento/Less/PreProcessor/Instruction/Import.php
+++ b/lib/Magento/Less/PreProcessor/Instruction/Import.php
@@ -25,6 +25,7 @@
 namespace Magento\Less\PreProcessor\Instruction;
 
 use Magento\Less\PreProcessorInterface;
+use Magento\Less\PreProcessor;
 
 /**
  * Less @import instruction preprocessor
@@ -37,60 +38,64 @@ class Import implements PreProcessorInterface
     const REPLACE_PATTERN =
         '#@import\s+(\((?P<type>\w+)\)\s+)?[\'\"](?P<path>(?![/\\\]|\w:[/\\\])[^\"\']+)[\'\"]\s*?(?P<media>.*?);#';
 
-    /**
-     * Import's path list where key is relative path and value is absolute path to the imported content
-     *
-     * @var array
-     */
-    protected $importPaths = [];
-
     /**
      * @var \Magento\Less\PreProcessor
      */
     protected $preProcessor;
 
     /**
-     * @var \Magento\Logger
+     * @var \Magento\View\RelatedFile
      */
-    protected $logger;
+    protected $relatedFile;
 
     /**
-     * @var array
+     * @var PreProcessor\ErrorHandlerInterface
      */
-    protected $viewParams;
+    protected $errorHandler;
 
     /**
-     * @param \Magento\Less\PreProcessor $preProcessor
-     * @param \Magento\Logger $logger
-     * @param array $viewParams
+     * @param PreProcessor $preProcessor
+     * @param PreProcessor\ErrorHandlerInterface $errorHandler
+     * @param \Magento\View\RelatedFile $relatedFile
      */
     public function __construct(
-        \Magento\Less\PreProcessor $preProcessor,
-        \Magento\Logger $logger,
-        array $viewParams = array()
+        PreProcessor $preProcessor,
+        PreProcessor\ErrorHandlerInterface $errorHandler,
+        \Magento\View\RelatedFile $relatedFile
     ) {
         $this->preProcessor = $preProcessor;
-        $this->logger = $logger;
-        $this->viewParams = $viewParams;
+        $this->errorHandler = $errorHandler;
+        $this->relatedFile = $relatedFile;
     }
 
     /**
      * Explode import paths
      *
-     * @param array $importPaths
-     * @return $this
+     * @param array $matchedPaths
+     * @param array $viewParams
+     * @param array $params
+     * @return array
      */
-    protected function generatePaths($importPaths)
+    protected function generatePaths($matchedPaths, $viewParams, array $params)
     {
-        foreach ($importPaths as $path) {
-            $path = $this->preparePath($path);
+        $importPaths = array();
+        foreach ($matchedPaths as $path) {
+            $resolvedPath = $this->relatedFile->buildPath(
+                $this->preparePath($path),
+                $params['parentAbsolutePath'],
+                $params['parentPath'],
+                $viewParams
+            );
             try {
-                $this->importPaths[$path] = $this->preProcessor->processLessInstructions($path, $this->viewParams);
+                $importPaths[$path] = $this->preProcessor->processLessInstructions(
+                    $resolvedPath,
+                    $viewParams
+                );
             } catch (\Magento\Filesystem\FilesystemException $e) {
-                $this->logger->logException($e);
+                $this->errorHandler->processException($e);
             }
         }
-        return $this;
+        return $importPaths;
     }
 
     /**
@@ -107,27 +112,32 @@ class Import implements PreProcessorInterface
     /**
      * {@inheritdoc}
      */
-    public function process($lessContent)
+    public function process($lessContent, array $viewParams, array $params = [])
     {
         $matches = [];
         preg_match_all(self::REPLACE_PATTERN, $lessContent, $matches);
-        $this->generatePaths($matches['path']);
-        return preg_replace_callback(self::REPLACE_PATTERN, array($this, 'replace'), $lessContent);
+        $importPaths = $this->generatePaths($matches['path'], $viewParams, $params);
+        $replaceCallback = function ($matchContent) use ($importPaths) {
+            return $this->replace($matchContent, $importPaths);
+        };
+        return preg_replace_callback(self::REPLACE_PATTERN, $replaceCallback, $lessContent);
     }
 
     /**
      * Replace import path to file
      *
      * @param array $matchContent
+     * @param $importPaths
      * @return string
      */
-    protected function replace($matchContent)
+    protected function replace($matchContent, $importPaths)
     {
-        $path = $this->preparePath($matchContent['path']);
-        if (empty($this->importPaths[$path])) {
+        $path = $matchContent['path'];
+        if (empty($importPaths[$path])) {
             return '';
         }
         $typeString  = empty($matchContent['type']) ? '' : '(' . $matchContent['type'] . ') ';
-        return "@import {$typeString}'{$this->importPaths[$path]}';";
+        $mediaString  = empty($matchContent['media']) ? '' : ' ' . $matchContent['media'];
+        return "@import {$typeString}'{$importPaths[$path]}'{$mediaString};";
     }
 }
diff --git a/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php b/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php
index c842e2ab9cb37349a4798c5a97f21fba2226c667..f54dadd8e05dd220ae6095b478e44c3abd7486a8 100644
--- a/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php
+++ b/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php
@@ -24,6 +24,7 @@
 
 namespace Magento\Less\PreProcessor\Instruction;
 
+use Magento\Less\PreProcessor;
 use Magento\Less\PreProcessorInterface;
 
 /**
@@ -42,60 +43,75 @@ class MagentoImport implements PreProcessorInterface
     protected $fileSource;
 
     /**
-     * @var \Magento\Logger
+     * @var PreProcessor\ErrorHandlerInterface
      */
-    protected $logger;
+    protected $errorHandler;
 
     /**
-     * @var array
+     * @var \Magento\View\RelatedFile
      */
-    protected $viewParams;
+    protected $relatedFile;
+
+    /**
+     * @var \Magento\View\Service
+     */
+    protected $viewService;
 
     /**
      * @param \Magento\View\Layout\File\SourceInterface $fileSource
      * @param \Magento\View\Service $viewService
-     * @param \Magento\Less\PreProcessor $preProcessor
-     * @param \Magento\Logger $logger
-     * @param array $viewParams
+     * @param \Magento\View\RelatedFile $relatedFile
+     * @param PreProcessor\ErrorHandlerInterface $errorHandler
      */
     public function __construct(
         \Magento\View\Layout\File\SourceInterface $fileSource,
         \Magento\View\Service $viewService,
-        \Magento\Less\PreProcessor $preProcessor,
-        \Magento\Logger $logger,
-        array $viewParams = array()
+        \Magento\View\RelatedFile $relatedFile,
+        PreProcessor\ErrorHandlerInterface $errorHandler
     ) {
         $this->fileSource = $fileSource;
-        $viewService->updateDesignParams($viewParams);
-        $this->logger = $logger;
-        $this->viewParams = $viewParams;
+        $this->viewService = $viewService;
+        $this->relatedFile = $relatedFile;
+        $this->errorHandler = $errorHandler;
     }
 
     /**
      * {@inheritdoc}
      */
-    public function process($lessContent)
+    public function process($lessContent, array $viewParams, array $paths = [])
     {
-        return preg_replace_callback(self::REPLACE_PATTERN, array($this, 'replace'), $lessContent);
+        $this->viewService->updateDesignParams($viewParams);
+        $replaceCallback = function ($matchContent) use ($viewParams, $paths) {
+            return $this->replace($matchContent, $viewParams, $paths);
+        };
+        return preg_replace_callback(self::REPLACE_PATTERN, $replaceCallback, $lessContent);
     }
 
     /**
      * Replace @magento_import to @import less instructions
      *
      * @param array $matchContent
+     * @param array $viewParams
+     * @param array $paths
      * @return string
      */
-    protected function replace($matchContent)
+    protected function replace($matchContent, $viewParams, $paths)
     {
         $importsContent = '';
         try {
-            $importFiles = $this->fileSource->getFiles($this->viewParams['themeModel'], $matchContent['path']);
+            $resolvedPath = $this->relatedFile->buildPath(
+                $matchContent['path'],
+                $paths['parentAbsolutePath'],
+                $paths['parentPath'],
+                $viewParams
+            );
+            $importFiles = $this->fileSource->getFiles($viewParams['themeModel'], $resolvedPath);
             /** @var $importFile \Magento\View\Layout\File */
             foreach ($importFiles as $importFile) {
                 $importsContent .= "@import '{$importFile->getFilename()}';\n";
             }
-        } catch(\LogicException $e) {
-            $this->logger->logException($e);
+        } catch (\LogicException $e) {
+            $this->errorHandler->processException($e);
         }
         return $importsContent;
     }
diff --git a/lib/Magento/Less/PreProcessor/InstructionFactory.php b/lib/Magento/Less/PreProcessor/InstructionFactory.php
index 56aad9b1df9c1cc4b9ff46cfaf9ebc7191ea1ae8..1118454c72d57cc618e2fd5fe7515a41c107bfce 100644
--- a/lib/Magento/Less/PreProcessor/InstructionFactory.php
+++ b/lib/Magento/Less/PreProcessor/InstructionFactory.php
@@ -50,13 +50,12 @@ class InstructionFactory
      * Create class instance with specified parameters
      *
      * @param string $className
-     * @param array $viewParams
      * @return \Magento\Less\PreProcessorInterface
      * @throws \InvalidArgumentException
      */
-    public function create($className, array $viewParams = array())
+    public function create($className)
     {
-        $preProcessor = $this->_objectManager->create($className, array('viewParams' => $viewParams));
+        $preProcessor = $this->_objectManager->create($className);
         if (!$preProcessor instanceof \Magento\Less\PreProcessorInterface) {
             throw new \InvalidArgumentException(
                 "{$className} aren't instance of \\Magento\\Less\\PreProcessorInterface"
diff --git a/lib/Magento/Less/PreProcessorInterface.php b/lib/Magento/Less/PreProcessorInterface.php
index 08fd5dc7a550a568fb916372fed3f0522c648289..a68ba7b1cffb6a0eab9f9df5a82f23be28be353e 100644
--- a/lib/Magento/Less/PreProcessorInterface.php
+++ b/lib/Magento/Less/PreProcessorInterface.php
@@ -33,7 +33,9 @@ interface PreProcessorInterface
      * Process less content to adapt magento view system
      *
      * @param string $lessContent
+     * @param array $viewParams
+     * @param array $params
      * @return string of processed content
      */
-    public function process($lessContent);
+    public function process($lessContent, array $viewParams, array $params = []);
 }
diff --git a/lib/Magento/Module/Declaration/Reader/Filesystem.php b/lib/Magento/Module/Declaration/Reader/Filesystem.php
index 04efefb19997dfaaf2703eca0bda8e12f687a8a8..560c494ccb53d5ca6df1c829dee19788afdf29a9 100644
--- a/lib/Magento/Module/Declaration/Reader/Filesystem.php
+++ b/lib/Magento/Module/Declaration/Reader/Filesystem.php
@@ -40,7 +40,7 @@ class Filesystem extends \Magento\Config\Reader\Filesystem
     protected $_allowedModules;
 
     /**
-     * {@inheritdoc}
+     * @var array
      */
     protected $_idAttributes = array(
         '/config/module' => 'name',
diff --git a/lib/Magento/Module/Updater.php b/lib/Magento/Module/Updater.php
index 401fdc41aaefcf811057e699cb4001d0dfb063f8..4a7774ec047ebcae9266698ba765f6566fd89456 100644
--- a/lib/Magento/Module/Updater.php
+++ b/lib/Magento/Module/Updater.php
@@ -55,7 +55,7 @@ class Updater implements \Magento\Module\UpdaterInterface
     protected $_appState;
 
     /**
-     * if it set to true, we will ignore applying scheme updates
+     * If it set to true, we will ignore applying scheme updates
      *
      * @var bool
      */
diff --git a/lib/Magento/Module/Updater/SetupInterface.php b/lib/Magento/Module/Updater/SetupInterface.php
index 5d2b723b7efc74b9a86146a2967efbcd83521f88..0b110572edd0d1d15d4cff695b1b596df6fab7b2 100644
--- a/lib/Magento/Module/Updater/SetupInterface.php
+++ b/lib/Magento/Module/Updater/SetupInterface.php
@@ -63,6 +63,8 @@ interface SetupInterface
 
     /**
      *  Apply data updates to the system after upgrading
+     *
+     * @return void
      */
     public function applyDataUpdates();
 }
diff --git a/lib/Magento/Module/UpdaterInterface.php b/lib/Magento/Module/UpdaterInterface.php
index 45a175388232cbf6de82b04d4cb44514eaf327d6..71dda49f93c96c52bc0946e81aeddbbe6d35e7f2 100644
--- a/lib/Magento/Module/UpdaterInterface.php
+++ b/lib/Magento/Module/UpdaterInterface.php
@@ -29,11 +29,15 @@ interface UpdaterInterface
 {
     /**
      * Apply database scheme updates whenever needed
+     *
+     * @return void
      */
     public function updateScheme();
 
     /**
      * Apply database data updates whenever needed
+     *
+     * @return void
      */
     public function updateData();
 }
diff --git a/lib/Magento/Mview/Config.php b/lib/Magento/Mview/Config.php
index 74f56b75fd8de39a5fe0af2a330665e66bd44750..2419f277d4442757ec74fc39679855eec6602a84 100644
--- a/lib/Magento/Mview/Config.php
+++ b/lib/Magento/Mview/Config.php
@@ -17,35 +17,46 @@
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
- *   
+ *
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
 
 namespace Magento\Mview;
 
-class Config extends \Magento\Config\Data implements ConfigInterface
+class Config implements ConfigInterface
 {
     /**
-     * @param \Magento\Mview\Config\Reader $reader
-     * @param \Magento\Config\CacheInterface $cache
-     * @param string $cacheId
+     * @var Config\Data
+     */
+    protected $configData;
+
+    /**
+     * @param Config\Data $configData
      */
-    public function __construct(
-        \Magento\Mview\Config\Reader $reader,
-        \Magento\Config\CacheInterface $cache,
-        $cacheId = 'mview_config'
-    ) {
-        parent::__construct($reader, $cache, $cacheId);
+    public function __construct(Config\Data $configData)
+    {
+        $this->configData = $configData;
+    }
+
+    /**
+     * Get views list
+     *
+     * @return array[]
+     */
+    public function getViews()
+    {
+        return $this->configData->get();
     }
 
     /**
-     * Get views configuration
+     * Get view by ID
      *
-     * @return mixed
+     * @param string $viewId
+     * @return array
      */
-    public function getAll()
+    public function getView($viewId)
     {
-        return $this->get();
+        return $this->configData->get($viewId);
     }
 }
diff --git a/lib/Magento/Mview/Config/Data.php b/lib/Magento/Mview/Config/Data.php
new file mode 100644
index 0000000000000000000000000000000000000000..c49458982e2c8e999e0ebef9810f51a03aabc9da
--- /dev/null
+++ b/lib/Magento/Mview/Config/Data.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *   
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Mview\Config;
+
+class Data extends \Magento\Config\Data
+{
+    /**
+     * @var \Magento\Mview\View\State\CollectionInterface
+     */
+    protected $stateCollection;
+
+    /**
+     * @param \Magento\Mview\Config\Reader $reader
+     * @param \Magento\Config\CacheInterface $cache
+     * @param \Magento\Mview\View\State\CollectionInterface $stateCollection
+     * @param string $cacheId
+     */
+    public function __construct(
+        \Magento\Mview\Config\Reader $reader,
+        \Magento\Config\CacheInterface $cache,
+        \Magento\Mview\View\State\CollectionInterface $stateCollection,
+        $cacheId = 'mview_config'
+    ) {
+        $this->stateCollection = $stateCollection;
+
+        $isCacheExists = $cache->test($cacheId);
+
+        parent::__construct($reader, $cache, $cacheId);
+
+        if (!$isCacheExists) {
+            $this->deleteNonexistentStates();
+        }
+    }
+
+    /**
+     * Delete all states that are not in configuration
+     */
+    protected function deleteNonexistentStates()
+    {
+        foreach ($this->stateCollection->getItems() as $state) {
+            /** @var \Magento\Mview\View\StateInterface $state */
+            if (!isset($this->_data[$state->getViewId()])) {
+                $state->delete();
+            }
+        }
+    }
+}
diff --git a/lib/Magento/Mview/Config/Data/Proxy.php b/lib/Magento/Mview/Config/Data/Proxy.php
new file mode 100644
index 0000000000000000000000000000000000000000..ec5ee1f2205ffb67393ceade397a4fa53a55302c
--- /dev/null
+++ b/lib/Magento/Mview/Config/Data/Proxy.php
@@ -0,0 +1,129 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\Mview\Config\Data;
+
+/**
+ * Proxy class for \Magento\Mview\Config\Data
+ */
+class Proxy extends \Magento\Mview\Config\Data
+{
+    /**
+     * Object Manager instance
+     *
+     * @var \Magento\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * Proxied instance name
+     *
+     * @var string
+     */
+    protected $instanceName;
+
+    /**
+     * Proxied instance
+     *
+     * @var \Magento\Mview\Config\Data
+     */
+    protected $subject;
+
+    /**
+     * Instance shareability flag
+     *
+     * @var bool
+     */
+    protected $isShared = null;
+
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     * @param string $instanceName
+     * @param bool $shared
+     */
+    public function __construct(
+        \Magento\ObjectManager $objectManager,
+        $instanceName = 'Magento\Mview\Config\Data',
+        $shared = true
+    ) {
+        $this->objectManager = $objectManager;
+        $this->instanceName = $instanceName;
+        $this->isShared = $shared;
+    }
+
+    /**
+     * @return array
+     */
+    public function __sleep()
+    {
+        return array('_subject', '_isShared');
+    }
+
+    /**
+     * Retrieve ObjectManager from global scope
+     */
+    public function __wakeup()
+    {
+        $this->objectManager = \Magento\App\ObjectManager::getInstance();
+    }
+
+    /**
+     * Clone proxied instance
+     */
+    public function __clone()
+    {
+        $this->subject = clone $this->_getSubject();
+    }
+
+    /**
+     * Get proxied instance
+     *
+     * @return \Magento\Mview\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)
+    {
+        $this->_getSubject()->merge($config);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function get($path = null, $default = null)
+    {
+        return $this->_getSubject()->get($path, $default);
+    }
+}
diff --git a/lib/Magento/Mview/ConfigInterface.php b/lib/Magento/Mview/ConfigInterface.php
index 9667aeffc1c6153c5481d699cab20e929ed3abf7..7e39dae872a6afe4cbdd2f91b492e90a0b712a86 100644
--- a/lib/Magento/Mview/ConfigInterface.php
+++ b/lib/Magento/Mview/ConfigInterface.php
@@ -17,7 +17,7 @@
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
  * needs please refer to http://www.magentocommerce.com for more information.
- *   
+ *
  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
@@ -27,18 +27,17 @@ namespace Magento\Mview;
 interface ConfigInterface
 {
     /**
-     * Get indexer's config
+     * Get views list
      *
-     * @return array
+     * @return array[]
      */
-    public function getAll();
+    public function getViews();
 
     /**
-     * Get config value by key
+     * Get view by ID
      *
-     * @param string $path
-     * @param mixed $default
-     * @return mixed
+     * @param string $viewId
+     * @return array
      */
-    public function get($path = null, $default = null);
+    public function getView($viewId);
 }
diff --git a/lib/Magento/Mview/View.php b/lib/Magento/Mview/View.php
index ef4f30a19089368276a5820124d701f5283081cc..c4aa6223063eae73245d3c63d3a537d8edbd520a 100644
--- a/lib/Magento/Mview/View.php
+++ b/lib/Magento/Mview/View.php
@@ -24,11 +24,6 @@
 
 namespace Magento\Mview;
 
-/**
- * @method string getActionClass()
- * @method string getGroup()
- * @method array getSubscriptions()
- */
 class View extends \Magento\Object implements ViewInterface
 {
     /**
@@ -61,6 +56,11 @@ class View extends \Magento\Object implements ViewInterface
      */
     protected $state;
 
+    /**
+     * @var \Magento\App\Resource
+     */
+    protected $resource;
+
     /**
      * @param ConfigInterface $config
      * @param ActionFactory $actionFactory
@@ -75,6 +75,7 @@ class View extends \Magento\Object implements ViewInterface
         View\StateInterface $state,
         View\ChangelogInterface $changelog,
         View\SubscriptionFactory $subscriptionFactory,
+        \Magento\App\Resource $resource,
         array $data = array()
     ) {
         $this->config = $config;
@@ -82,9 +83,40 @@ class View extends \Magento\Object implements ViewInterface
         $this->state = $state;
         $this->changelog = $changelog;
         $this->subscriptionFactory = $subscriptionFactory;
+        $this->resource = $resource;
         parent::__construct($data);
     }
 
+    /**
+     * Return view action class
+     *
+     * @return string
+     */
+    public function getActionClass()
+    {
+        return $this->getData('action_class');
+    }
+
+    /**
+     * Return view group
+     *
+     * @return string
+     */
+    public function getGroup()
+    {
+        return $this->getData('group');
+    }
+
+    /**
+     * Return view subscriptions
+     *
+     * @return array
+     */
+    public function getSubscriptions()
+    {
+        return $this->getData('subscriptions');
+    }
+
     /**
      * Fill view data from config
      *
@@ -94,7 +126,7 @@ class View extends \Magento\Object implements ViewInterface
      */
     public function load($viewId)
     {
-        $view = $this->config->get($viewId);
+        $view = $this->config->getView($viewId);
         if (empty($view) || empty($view['view_id']) || $view['view_id'] != $viewId) {
             throw new \InvalidArgumentException("{$viewId} view does not exist.");
         }
@@ -123,7 +155,7 @@ class View extends \Magento\Object implements ViewInterface
                     /** @var \Magento\Mview\View\SubscriptionInterface $subscription */
                     $subscription = $this->subscriptionFactory->create(array(
                         'view' => $this,
-                        'tableName' => $subscription['name'],
+                        'tableName' => $this->resource->getTableName($subscription['name']),
                         'columnName' => $subscription['column'],
                     ));
                     $subscription->create();
@@ -156,7 +188,7 @@ class View extends \Magento\Object implements ViewInterface
                     /** @var \Magento\Mview\View\SubscriptionInterface $subscription */
                     $subscription = $this->subscriptionFactory->create(array(
                         'view' => $this,
-                        'tableName' => $subscription['name'],
+                        'tableName' => $this->resource->getTableName($subscription['name']),
                         'columnName' => $subscription['column'],
                     ));
                     $subscription->remove();
@@ -167,6 +199,7 @@ class View extends \Magento\Object implements ViewInterface
 
                 // Update view state
                 $this->getState()
+                    ->setVersionId(null)
                     ->setMode(View\StateInterface::MODE_DISABLED)
                     ->save();
             } catch (\Exception $e) {
@@ -185,7 +218,7 @@ class View extends \Magento\Object implements ViewInterface
     public function update()
     {
         if ($this->getState()->getMode() == View\StateInterface::MODE_ENABLED
-            && $this->getState()->getStatus() != View\StateInterface::STATUS_WORKING
+            && $this->getState()->getStatus() == View\StateInterface::STATUS_IDLE
         ) {
             $currentVersionId = $this->getChangelog()->getVersion();
             $lastVersionId = $this->getState()->getVersionId();
@@ -197,13 +230,21 @@ class View extends \Magento\Object implements ViewInterface
                     ->save();
                 try {
                     $action->execute($ids);
+                    $this->getState()->loadByView($this->getId());
+                    $statusToRestore = $this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED
+                        ? View\StateInterface::STATUS_SUSPENDED
+                        : View\StateInterface::STATUS_IDLE;
                     $this->getState()
                         ->setVersionId($currentVersionId)
-                        ->setStatus(View\StateInterface::STATUS_IDLE)
+                        ->setStatus($statusToRestore)
                         ->save();
                 } catch (\Exception $exception) {
+                    $this->getState()->loadByView($this->getId());
+                    $statusToRestore = $this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED
+                        ? View\StateInterface::STATUS_SUSPENDED
+                        : View\StateInterface::STATUS_IDLE;
                     $this->getState()
-                        ->setStatus(View\StateInterface::STATUS_IDLE)
+                        ->setStatus($statusToRestore)
                         ->save();
                     throw $exception;
                 }
@@ -211,6 +252,27 @@ class View extends \Magento\Object implements ViewInterface
         }
     }
 
+    /**
+     * Suspend view updates and set version ID to changelog's end
+     */
+    public function suspend()
+    {
+        $this->getState()
+            ->setVersionId($this->getChangelog()->getVersion())
+            ->setStatus(View\StateInterface::STATUS_SUSPENDED)
+            ->save();
+    }
+
+    /**
+     * Resume view updates
+     */
+    public function resume()
+    {
+        if ($this->getState()->getStatus() == View\StateInterface::STATUS_SUSPENDED) {
+            $this->getState()->setStatus(View\StateInterface::STATUS_IDLE)->save();
+        }
+    }
+
     /**
      * Clear precessed changelog entries
      */
@@ -245,23 +307,43 @@ class View extends \Magento\Object implements ViewInterface
     }
 
     /**
-     * Return view mode
+     * Check whether view is enabled
      *
-     * @return string
+     * @return bool
      */
-    public function getMode()
+    public function isEnabled()
     {
-        return $this->getState()->getMode();
+        return $this->getState()->getMode() == View\StateInterface::MODE_ENABLED;
     }
 
     /**
-     * Return view status
+     * Check whether view is idle
      *
-     * @return string
+     * @return bool
+     */
+    public function isIdle()
+    {
+        return $this->getState()->getStatus() == \Magento\Mview\View\StateInterface::STATUS_IDLE;
+    }
+
+    /**
+     * Check whether view is working
+     *
+     * @return bool
+     */
+    public function isWorking()
+    {
+        return $this->getState()->getStatus() == \Magento\Mview\View\StateInterface::STATUS_WORKING;
+    }
+
+    /**
+     * Check whether view is suspended
+     *
+     * @return bool
      */
-    public function getStatus()
+    public function isSuspended()
     {
-        return $this->getState()->getStatus();
+        return $this->getState()->getStatus() == \Magento\Mview\View\StateInterface::STATUS_SUSPENDED;
     }
 
     /**
diff --git a/lib/Magento/Mview/View/Changelog.php b/lib/Magento/Mview/View/Changelog.php
index 90752202d2d197f875a826150cdbdb0441cd9516..91f964b66fb814e8e59d6eabe41ff5bab6616136 100644
--- a/lib/Magento/Mview/View/Changelog.php
+++ b/lib/Magento/Mview/View/Changelog.php
@@ -50,12 +50,18 @@ class Changelog implements ChangelogInterface
      */
     protected $viewId;
 
+    /**
+     * @var \Magento\App\Resource
+     */
+    protected $resource;
+
     /**
      * @param \Magento\App\Resource $resource
      */
     public function __construct(\Magento\App\Resource $resource)
     {
         $this->write = $resource->getConnection('core_write');
+        $this->resource = $resource;
         $this->checkConnection();
     }
 
@@ -78,7 +84,7 @@ class Changelog implements ChangelogInterface
      */
     public function create()
     {
-        $changelogTableName = $this->write->getTableName($this->getName());
+        $changelogTableName = $this->resource->getTableName($this->getName());
         if ($this->write->isTableExists($changelogTableName)) {
             throw new \Exception("Table {$changelogTableName} already exist");
         }
@@ -106,7 +112,7 @@ class Changelog implements ChangelogInterface
      */
     public function drop()
     {
-        $changelogTableName = $this->write->getTableName($this->getName());
+        $changelogTableName = $this->resource->getTableName($this->getName());
         if (!$this->write->isTableExists($changelogTableName)) {
             throw new \Exception("Table {$changelogTableName} does not exist");
         }
@@ -123,7 +129,7 @@ class Changelog implements ChangelogInterface
      */
     public function clear($versionId)
     {
-        $changelogTableName = $this->write->getTableName($this->getName());
+        $changelogTableName = $this->resource->getTableName($this->getName());
         if (!$this->write->isTableExists($changelogTableName)) {
             throw new \Exception("Table {$changelogTableName} does not exist");
         }
@@ -143,7 +149,7 @@ class Changelog implements ChangelogInterface
      */
     public function getList($fromVersionId, $toVersionId)
     {
-        $changelogTableName = $this->write->getTableName($this->getName());
+        $changelogTableName = $this->resource->getTableName($this->getName());
         if (!$this->write->isTableExists($changelogTableName)) {
             throw new \Exception("Table {$changelogTableName} does not exist");
         }
@@ -165,7 +171,7 @@ class Changelog implements ChangelogInterface
      */
     public function getVersion()
     {
-        $changelogTableName = $this->write->getTableName($this->getName());
+        $changelogTableName = $this->resource->getTableName($this->getName());
         if (!$this->write->isTableExists($changelogTableName)) {
             throw new \Exception("Table {$changelogTableName} does not exist");
         }
diff --git a/lib/Magento/Mview/View/Collection.php b/lib/Magento/Mview/View/Collection.php
index d3ccd8b7b1089e6667e8f039a8b75cab358a8d0d..01e30fd7c2777752452ff38fd95fdc093d33b9da 100644
--- a/lib/Magento/Mview/View/Collection.php
+++ b/lib/Magento/Mview/View/Collection.php
@@ -34,7 +34,7 @@ class Collection extends \Magento\Data\Collection implements CollectionInterface
     protected $_itemObjectClass = 'Magento\Mview\ViewInterface';
 
     /**
-     * @var \Magento\Indexer\Model\ConfigInterface
+     * @var \Magento\Mview\ConfigInterface
      */
     protected $config;
 
@@ -71,7 +71,7 @@ class Collection extends \Magento\Data\Collection implements CollectionInterface
     {
         if (!$this->isLoaded()) {
             $states = $this->statesFactory->create();
-            foreach (array_keys($this->config->getAll()) as $viewId) {
+            foreach (array_keys($this->config->getViews()) as $viewId) {
                 /** @var \Magento\Mview\ViewInterface $view */
                 $view = $this->getNewEmptyItem();
                 $view->load($viewId);
@@ -108,24 +108,4 @@ class Collection extends \Magento\Data\Collection implements CollectionInterface
         }
         return $result;
     }
-
-    /**
-     * Return views by given state status
-     *
-     * @param string $status
-     * @return \Magento\Mview\ViewInterface[]
-     */
-    public function getViewsByStateStatus($status)
-    {
-        $this->load();
-
-        $result = array();
-        foreach ($this as $view) {
-            /** @var \Magento\Mview\ViewInterface $view */
-            if ($view->getState()->getStatus() == $status) {
-                $result[] = $view;
-            }
-        }
-        return $result;
-    }
 }
diff --git a/lib/Magento/Mview/View/CollectionInterface.php b/lib/Magento/Mview/View/CollectionInterface.php
index 4193f94a451075905d7b051ec831c2daef76ddf8..cb0f42b3fd53818cbf1d1fff94be0702475ead13 100644
--- a/lib/Magento/Mview/View/CollectionInterface.php
+++ b/lib/Magento/Mview/View/CollectionInterface.php
@@ -34,14 +34,6 @@ interface CollectionInterface
      */
     public function getViewsByStateMode($mode);
 
-    /**
-     * Return views by given state status
-     *
-     * @param string $status
-     * @return \Magento\Mview\ViewInterface[]
-     */
-    public function getViewsByStateStatus($status);
-
     /**
      * Search all views by field value
      *
diff --git a/lib/Magento/Mview/View/StateInterface.php b/lib/Magento/Mview/View/StateInterface.php
index 90ac1d146df3cf3b4d44119a26d584f92cc51aaf..cadcfb5d7f518bf4a0fcc9fa26705aeaa689935f 100644
--- a/lib/Magento/Mview/View/StateInterface.php
+++ b/lib/Magento/Mview/View/StateInterface.php
@@ -38,6 +38,7 @@ interface StateInterface
      */
     const STATUS_IDLE = 'idle';
     const STATUS_WORKING = 'working';
+    const STATUS_SUSPENDED = 'suspended';
     /**#@-*/
 
     /**
diff --git a/lib/Magento/Mview/View/Subscription.php b/lib/Magento/Mview/View/Subscription.php
index b0d5ec9e3a8d7dd5b668df0d66b4f7163755f492..a5bed5f5c496a05ab0a579671c30b813f98e6374 100644
--- a/lib/Magento/Mview/View/Subscription.php
+++ b/lib/Magento/Mview/View/Subscription.php
@@ -70,6 +70,11 @@ class Subscription implements SubscriptionInterface
      */
     protected $linkedViews = array();
 
+    /**
+     * @var \Magento\App\Resource
+     */
+    protected $resource;
+
     /**
      * @param \Magento\App\Resource $resource
      * @param \Magento\DB\Ddl\TriggerFactory $triggerFactory
@@ -92,6 +97,7 @@ class Subscription implements SubscriptionInterface
         $this->view = $view;
         $this->tableName = $tableName;
         $this->columnName = $columnName;
+        $this->resource = $resource;
 
         // Force collection clear
         $this->viewCollection->clear();
@@ -219,14 +225,14 @@ class Subscription implements SubscriptionInterface
             case \Magento\DB\Ddl\Trigger::EVENT_INSERT:
             case \Magento\DB\Ddl\Trigger::EVENT_UPDATE:
                 return sprintf("INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);",
-                    $this->write->quoteIdentifier($changelog->getName()),
+                    $this->write->quoteIdentifier($this->resource->getTableName($changelog->getName())),
                     $this->write->quoteIdentifier($changelog->getColumnName()),
                     $this->write->quoteIdentifier($this->getColumnName())
                 );
 
             case \Magento\DB\Ddl\Trigger::EVENT_DELETE:
                 return sprintf("INSERT IGNORE INTO %s (%s) VALUES (OLD.%s);",
-                    $this->write->quoteIdentifier($changelog->getName()),
+                    $this->write->quoteIdentifier($this->resource->getTableName($changelog->getName())),
                     $this->write->quoteIdentifier($changelog->getColumnName()),
                     $this->write->quoteIdentifier($this->getColumnName())
                 );
diff --git a/lib/Magento/Mview/ViewInterface.php b/lib/Magento/Mview/ViewInterface.php
index 847da63dc9530540bf3874c8377ea1179d0389d4..01269bf4816f5beb832932f42a3b729947dcc500 100644
--- a/lib/Magento/Mview/ViewInterface.php
+++ b/lib/Magento/Mview/ViewInterface.php
@@ -26,6 +26,34 @@ namespace Magento\Mview;
 
 interface ViewInterface
 {
+    /**
+     * Return view ID
+     *
+     * @return string
+     */
+    public function getId();
+
+    /**
+     * Return view action class
+     *
+     * @return string
+     */
+    public function getActionClass();
+
+    /**
+     * Return view group
+     *
+     * @return string
+     */
+    public function getGroup();
+
+    /**
+     * Return view subscriptions
+     *
+     * @return array
+     */
+    public function getSubscriptions();
+
     /**
      * Fill view data from config
      *
@@ -52,10 +80,22 @@ interface ViewInterface
     public function unsubscribe();
 
     /**
-     * @return mixed
+     * Materialize view by IDs in changelog
+     *
+     * @throws \Exception
      */
     public function update();
 
+    /**
+     * Pause view updates and set version ID to changelog's end
+     */
+    public function suspend();
+
+    /**
+     * Resume view updates
+     */
+    public function resume();
+
     /**
      * Clear precessed changelog entries
      */
@@ -77,18 +117,39 @@ interface ViewInterface
     public function setState(View\StateInterface $state);
 
     /**
-     * Return view mode
+     * Check whether view is enabled
      *
-     * @return string
+     * @return bool
+     */
+    public function isEnabled();
+
+    /**
+     * Check whether view is idle
+     *
+     * @return bool
+     */
+    public function isIdle();
+
+    /**
+     * Check whether view is working
+     *
+     * @return bool
+     */
+    public function isWorking();
+
+    /**
+     * Check whether view is paused
+     *
+     * @return bool
      */
-    public function getMode();
+    public function isSuspended();
 
     /**
-     * Return view status
+     * Return view updated datetime
      *
      * @return string
      */
-    public function getStatus();
+    public function getUpdated();
 
     /**
      * Retrieve linked changelog
diff --git a/lib/Magento/OSInfo.php b/lib/Magento/OSInfo.php
new file mode 100644
index 0000000000000000000000000000000000000000..4410ac3d6d981b0824c95e406a83543fac98165d
--- /dev/null
+++ b/lib/Magento/OSInfo.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    Magento
+ * @package     Magento_OSInfo
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento;
+
+/**
+ * Wrapper on PHP_OS constant
+ */
+class OSInfo
+{
+    /**
+     * Operation system
+     *
+     * @var string
+     */
+    protected $os;
+
+    /**
+     * Initialize os
+     */
+    public function __construct()
+    {
+        $this->os = PHP_OS;
+    }
+
+    /**
+     * Check id system is Windows
+     *
+     * @return bool
+     */
+    public function isWindows()
+    {
+        return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
+    }
+}
diff --git a/lib/Magento/Oauth/Helper/Oauth.php b/lib/Magento/Oauth/Helper/Oauth.php
index dbe7e513ae21d2f58108f0872aec0bb37ce4a0fd..51fd51751e70f4cb1c7c6a4d148a53c6e0492569 100644
--- a/lib/Magento/Oauth/Helper/Oauth.php
+++ b/lib/Magento/Oauth/Helper/Oauth.php
@@ -26,7 +26,8 @@ namespace Magento\Oauth\Helper;
 
 class Oauth
 {
-    /**#@+
+    /**
+     * #@+
      * Lengths of token fields
      */
     const LENGTH_TOKEN = 32;
@@ -34,7 +35,8 @@ class Oauth
     const LENGTH_TOKEN_VERIFIER = 32;
     /**#@- */
 
-    /**#@+
+    /**
+     * #@+
      * Lengths of consumer fields
      */
     const LENGTH_CONSUMER_KEY = 32;
diff --git a/lib/Magento/Oauth/Helper/Request.php b/lib/Magento/Oauth/Helper/Request.php
index 9a311445ba12103604f7c1eccdc9093e6f67d7f6..6f516ab5e148aa95acdd12f082dddc932732c0f8 100644
--- a/lib/Magento/Oauth/Helper/Request.php
+++ b/lib/Magento/Oauth/Helper/Request.php
@@ -172,7 +172,7 @@ class Request
     /**
      * Retrieve protocol parameters from query string
      *
-     * @param array $protocolParams
+     * @param array &$protocolParams
      * @param array $queryString
      * @return void
      */
@@ -200,7 +200,7 @@ class Request
      * Process header parameters for Oauth
      *
      * @param string $authHeaderValue
-     * @param array $protocolParams
+     * @param array &$protocolParams
      * @return void
      */
     protected function _processHeader($authHeaderValue, &$protocolParams)
@@ -224,7 +224,7 @@ class Request
     /**
      * Process query string for Oauth
      *
-     * @param array $protocolParams
+     * @param array &$protocolParams
      * @param string $queryString
      * @return void
      */
diff --git a/lib/Magento/Oauth/NonceGeneratorInterface.php b/lib/Magento/Oauth/NonceGeneratorInterface.php
index b35a186a32056b143ca56ccb1b5813da8232ca28..f0bcbf96d5c57adbb887adc86eac31b4524fa57c 100644
--- a/lib/Magento/Oauth/NonceGeneratorInterface.php
+++ b/lib/Magento/Oauth/NonceGeneratorInterface.php
@@ -58,6 +58,7 @@ interface NonceGeneratorInterface
      * @param ConsumerInterface $consumer
      * @param string $nonce - The nonce value.
      * @param int $timestamp - The 'oauth_timestamp' value.
+     * @return void
      * @throws \Magento\Oauth\Exception - Exceptions are thrown for validation errors.
      */
     public function validateNonce(ConsumerInterface $consumer, $nonce, $timestamp);
diff --git a/lib/Magento/Oauth/Oauth.php b/lib/Magento/Oauth/Oauth.php
index 900e9a61373056f02b08780b088f4fc6d9a76b14..df06635a87575473e96b8f11752859013cb24641 100644
--- a/lib/Magento/Oauth/Oauth.php
+++ b/lib/Magento/Oauth/Oauth.php
@@ -26,16 +26,24 @@ namespace Magento\Oauth;
 
 class Oauth implements OauthInterface
 {
-    /** @var  \Magento\Oauth\Helper\Oauth */
+    /**
+     * @var  \Magento\Oauth\Helper\Oauth
+     */
     protected $_oauthHelper;
 
-    /** @var  \Zend_Oauth_Http_Utility */
+    /**
+     * @var  \Zend_Oauth_Http_Utility
+     */
     protected $_httpUtility;
 
-    /** @var \Magento\Oauth\NonceGeneratorInterface */
+    /**
+     * @var \Magento\Oauth\NonceGeneratorInterface
+     */
     protected $_nonceGenerator;
 
-    /** @var \Magento\Oauth\TokenProviderInterface */
+    /**
+     * @var \Magento\Oauth\TokenProviderInterface
+     */
     protected $_tokenProvider;
 
     /**
diff --git a/lib/Magento/Oauth/TokenProviderInterface.php b/lib/Magento/Oauth/TokenProviderInterface.php
index 5101dfe5df8a0675301d36bf895f6b68366d80b3..959a19ce89ac484341159c0f7095a53b2626f1cc 100644
--- a/lib/Magento/Oauth/TokenProviderInterface.php
+++ b/lib/Magento/Oauth/TokenProviderInterface.php
@@ -46,15 +46,16 @@ interface TokenProviderInterface
 
     /**
      * Create a request token for the specified consumer.
-     *
-     * @param ConsumerInterface $consumer
-     * @return array - The request token and secret.
+     * Example:
      * <pre>
      *     array(
      *         'oauth_token' => 'gshsjkndtyhwjhdbutfgbsnhtrequikf,
      *         'oauth_token_secret' => 'gshsjkndtyhwjhdbutfgbsnhtrequikf'
      *     )
      * </pre>
+     *
+     * @param ConsumerInterface $consumer
+     * @return array - The request token and secret.
      * @throws \Magento\Oauth\Exception - Validation errors.
      */
     public function createRequestToken($consumer);
@@ -72,15 +73,16 @@ interface TokenProviderInterface
 
     /**
      * Retrieve access token for the specified consumer given the consumer key.
-     *
-     * @param ConsumerInterface $consumer - The consumer given the 'oauth_consumer_key'.
-     * @return array - The access token and secret.
+     * Example:
      * <pre>
      *     array(
      *         'oauth_token' => 'gshsjkndtyhwjhdbutfgbsnhtrequikf,
      *         'oauth_token_secret' => 'gshsjkndtyhwjhdbutfgbsnhtrequikf'
      *     )
      * </pre>
+     *
+     * @param ConsumerInterface $consumer - The consumer given the 'oauth_consumer_key'.
+     * @return array - The access token and secret.
      * @throws \Magento\Oauth\Exception - Validation errors.
      */
     public function getAccessToken($consumer);
@@ -98,7 +100,7 @@ interface TokenProviderInterface
     /**
      * Validate an access token string.
      *
-     * @param string - The 'oauth_token' access token string.
+     * @param string $accessToken - The 'oauth_token' access token string.
      * @return int - Consumer ID if the access token is valid.
      * @throws \Magento\Oauth\Exception - Validation errors.
      */
diff --git a/lib/Magento/Object.php b/lib/Magento/Object.php
index 27daf11f41b630bb4ea34fe3ab771c893141f945..747e42b5df140f3b4a6c7598193b0d29533aed5e 100644
--- a/lib/Magento/Object.php
+++ b/lib/Magento/Object.php
@@ -23,7 +23,7 @@
  * @copyright  Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  */
-
+namespace Magento;
 
 /**
  * Universal data container with array access implementation
@@ -32,8 +32,6 @@
  * @package     Magento_Object
  * @author      Magento Core Team <core@magentocommerce.com>
  */
-namespace Magento;
-
 class Object implements \ArrayAccess
 {
 
@@ -74,7 +72,7 @@ class Object implements \ArrayAccess
     /**
      * Object delete flag
      *
-     * @var boolean
+     * @var bool
      */
     protected $_isDeleted = false;
 
@@ -95,7 +93,7 @@ class Object implements \ArrayAccess
      * Set _isDeleted flag value (if $isDeleted parameter is defined) and return current flag value
      *
      * @param boolean $isDeleted
-     * @return boolean
+     * @return bool
      */
     public function isDeleted($isDeleted = null)
     {
@@ -182,7 +180,7 @@ class Object implements \ArrayAccess
     /**
      * Overwrite data in the object.
      *
-     * $key can be string or array.
+     * The $key parameter can be string or array.
      * If $key is string, the attribute value will be overwritten by $value
      *
      * If $key is an array, it will overwrite all the data in the object.
@@ -367,7 +365,7 @@ class Object implements \ArrayAccess
      * Otherwise checks if the specified attribute is set.
      *
      * @param string $key
-     * @return boolean
+     * @return bool
      */
     public function hasData($key = '')
     {
@@ -401,7 +399,7 @@ class Object implements \ArrayAccess
     }
 
     /**
-     * "__" style wrapper for toArray method
+     * The "__" style wrapper for toArray method
      *
      * @param  array $keys
      * @return array
@@ -416,8 +414,8 @@ class Object implements \ArrayAccess
      *
      * @param array   $keys array of keys that must be represented
      * @param string  $rootName root node name
-     * @param boolean $addOpenTag flag that allow to add initial xml node
-     * @param boolean $addCdata flag that require wrap all values in CDATA
+     * @param bool $addOpenTag flag that allow to add initial xml node
+     * @param bool $addCdata flag that require wrap all values in CDATA
      * @return string
      */
     public function toXml(array $keys = array(), $rootName = 'item', $addOpenTag = false, $addCdata = true)
@@ -446,12 +444,12 @@ class Object implements \ArrayAccess
     }
 
     /**
-     * "__" style wrapper for toXml method
+     * The "__" style wrapper for toXml method
      *
      * @param array   $keys array of keys that must be represented
      * @param string  $rootName root node name
-     * @param boolean $addOpenTag flag that allow to add initial xml node
-     * @param boolean $addCdata flag that require wrap all values in CDATA
+     * @param bool $addOpenTag flag that allow to add initial xml node
+     * @param bool $addCdata flag that require wrap all values in CDATA
      * @return string
      */
     public function convertToXml(array $arrAttributes = array(), $rootName = 'item', $addOpenTag = false, $addCdata = true)
@@ -472,7 +470,7 @@ class Object implements \ArrayAccess
     }
 
     /**
-     * "__" style wrapper for toJson
+     * The "__" style wrapper for toJson
      *
      * @param  array $keys
      * @return string
@@ -536,9 +534,9 @@ class Object implements \ArrayAccess
     }
 
     /**
-     * checks whether the object is empty
+     * Checks whether the object is empty
      *
-     * @return boolean
+     * @return bool
      */
     public function isEmpty()
     {
@@ -549,10 +547,10 @@ class Object implements \ArrayAccess
     }
 
     /**
-     * Converts field names for setters and geters
+     * Converts field names for setters and getters
      *
      * $this->setMyField($value) === $this->setData('my_field', $value)
-     * Uses cache to eliminate unneccessary preg_replace
+     * Uses cache to eliminate unnecessary preg_replace
      *
      * @param string $name
      * @return string
@@ -631,7 +629,7 @@ class Object implements \ArrayAccess
      * Compare object data with original data
      *
      * @param string $field
-     * @return boolean
+     * @return bool
      */
     public function dataHasChangedFor($field)
     {
@@ -643,7 +641,7 @@ class Object implements \ArrayAccess
     /**
      * Clears data changes status
      *
-     * @param boolean $value
+     * @param bool $value
      * @return $this
      */
     public function setDataChanges($value)
@@ -656,8 +654,8 @@ class Object implements \ArrayAccess
      * Present object data as string in debug mode
      *
      * @param mixed $data
-     * @param array $objects
-     * @return string
+     * @param array &$objects
+     * @return array
      */
     public function debug($data = null, &$objects = array())
     {
@@ -685,10 +683,10 @@ class Object implements \ArrayAccess
     /**
      * Implementation of \ArrayAccess::offsetSet()
      *
-     * @link http://www.php.net/manual/en/arrayaccess.offsetset.php
      * @param string $offset
      * @param mixed $value
      * @return void
+     * @link http://www.php.net/manual/en/arrayaccess.offsetset.php
      */
     public function offsetSet($offset, $value)
     {
@@ -698,9 +696,9 @@ class Object implements \ArrayAccess
     /**
      * Implementation of \ArrayAccess::offsetExists()
      *
-     * @link http://www.php.net/manual/en/arrayaccess.offsetexists.php
      * @param string $offset
-     * @return boolean
+     * @return bool
+     * @link http://www.php.net/manual/en/arrayaccess.offsetexists.php
      */
     public function offsetExists($offset)
     {
@@ -710,9 +708,9 @@ class Object implements \ArrayAccess
     /**
      * Implementation of \ArrayAccess::offsetUnset()
      *
-     * @link http://www.php.net/manual/en/arrayaccess.offsetunset.php
      * @param string $offset
      * @return void
+     * @link http://www.php.net/manual/en/arrayaccess.offsetunset.php
      */
     public function offsetUnset($offset)
     {
@@ -722,9 +720,9 @@ class Object implements \ArrayAccess
     /**
      * Implementation of \ArrayAccess::offsetGet()
      *
-     * @link http://www.php.net/manual/en/arrayaccess.offsetget.php
      * @param string $offset
      * @return mixed
+     * @link http://www.php.net/manual/en/arrayaccess.offsetget.php
      */
     public function offsetGet($offset)
     {
diff --git a/lib/Magento/ObjectManager.php b/lib/Magento/ObjectManager.php
index 3b7257fba1539955b4a6b6e3db9a1cb6a88ee52a..3f2fd4a01389ab4148369a6f4a24537655008c31 100644
--- a/lib/Magento/ObjectManager.php
+++ b/lib/Magento/ObjectManager.php
@@ -32,6 +32,8 @@ interface ObjectManager
      * Set factory
      *
      * @param ObjectManager\Factory $factory
+     *
+     * @return void
      */
     public function setFactory(ObjectManager\Factory $factory);
 
@@ -56,6 +58,7 @@ interface ObjectManager
      * Configure object manager
      *
      * @param array $configuration
+     * @return void
      */
     public function configure(array $configuration);
 }
diff --git a/lib/Magento/ObjectManager/Config.php b/lib/Magento/ObjectManager/Config.php
index ed7fe64a9080783bd64931a8f68d0b199c8172a2..8a039f51f1a5efa851e3987637a24c3c7070291d 100644
--- a/lib/Magento/ObjectManager/Config.php
+++ b/lib/Magento/ObjectManager/Config.php
@@ -29,6 +29,8 @@ interface Config
      * Set class relations
      *
      * @param Relations $relations
+     *
+     * @return void
      */
     public function setRelations(Relations $relations);
 
@@ -36,6 +38,8 @@ interface Config
      * Set configuration cache instance
      *
      * @param ConfigCache $cache
+     *
+     * @return void
      */
     public function setCache(ConfigCache $cache);
 
diff --git a/lib/Magento/ObjectManager/Config/Config.php b/lib/Magento/ObjectManager/Config/Config.php
index 58001c0be9f441796ddd8482089a50780c5abaf7..8b14c5afebabf011fcb970ceb94cd38344b5ced9 100644
--- a/lib/Magento/ObjectManager/Config/Config.php
+++ b/lib/Magento/ObjectManager/Config/Config.php
@@ -251,6 +251,7 @@ class Config implements \Magento\ObjectManager\Config
      * Merge configuration
      *
      * @param array $configuration
+     * @return void
      */
     protected function _mergeConfiguration(array $configuration)
     {
@@ -290,6 +291,7 @@ class Config implements \Magento\ObjectManager\Config
      * Extend configuration
      *
      * @param array $configuration
+     * @return void
      */
     public function extend(array $configuration)
     {
diff --git a/lib/Magento/ObjectManager/Config/Mapper/Dom.php b/lib/Magento/ObjectManager/Config/Mapper/Dom.php
index 22c92336623776f61fad92ff62dc726863ef8f94..8d8d364d3b446ff1208447d64bf5288ff32ea44b 100644
--- a/lib/Magento/ObjectManager/Config/Mapper/Dom.php
+++ b/lib/Magento/ObjectManager/Config/Mapper/Dom.php
@@ -202,10 +202,11 @@ class Dom implements \Magento\Config\ConverterInterface
     /**
      * Retrieve value of the given node
      * Treat all child nodes as an assoc array
-     * @todo this method has high cyclomatic complexity in order to avoid performance issues
+     *
      * @param \DOMNode $valueNode
      * @return array|string
      * @throws \InvalidArgumentException
+     * @todo this method has high cyclomatic complexity in order to avoid performance issues
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      */
     protected function _processValueNode(\DOMNode $valueNode)
diff --git a/lib/Magento/ObjectManager/ConfigCache.php b/lib/Magento/ObjectManager/ConfigCache.php
index 6e4013aeaa1847e2194ba7184c799a33dd4bcdd0..0b4c447c8b511d043b645d769ec35711ed26ec98 100644
--- a/lib/Magento/ObjectManager/ConfigCache.php
+++ b/lib/Magento/ObjectManager/ConfigCache.php
@@ -39,6 +39,7 @@ interface ConfigCache
      *
      * @param array $config
      * @param string $key
+     * @return void
      */
     public function save(array $config, $key);
 }
diff --git a/lib/Magento/ObjectManager/Factory.php b/lib/Magento/ObjectManager/Factory.php
index 4b0cfbc563a641677435eaa3c2513bae644511ef..6d9fb84016dad708c2b03130bbc9c397e473412f 100644
--- a/lib/Magento/ObjectManager/Factory.php
+++ b/lib/Magento/ObjectManager/Factory.php
@@ -29,6 +29,7 @@ interface Factory
      * Set object manager
      *
      * @param \Magento\ObjectManager $objectManager
+     * @return void
      */
     public function setObjectManager(\Magento\ObjectManager $objectManager);
 
@@ -36,6 +37,7 @@ interface Factory
      * Set application arguments
      *
      * @param array $array
+     * @return void
      */
     public function setArguments($array);
 
diff --git a/lib/Magento/ObjectManager/Factory/Factory.php b/lib/Magento/ObjectManager/Factory/Factory.php
index 27240971bd4e640f9d61174f1e1ec3138b2728e9..87531d7e5c89caa7d920e216663e12e048daad91 100644
--- a/lib/Magento/ObjectManager/Factory/Factory.php
+++ b/lib/Magento/ObjectManager/Factory/Factory.php
@@ -199,6 +199,7 @@ class Factory implements \Magento\ObjectManager\Factory
      * Set application arguments
      *
      * @param array $arguments
+     * @return void
      */
     public function setArguments($arguments)
     {
diff --git a/lib/Magento/ObjectManager/ObjectManager.php b/lib/Magento/ObjectManager/ObjectManager.php
index a786b1398ec0f109bf7475a8c1128d1b78f76319..14b54a63b3c18b37502e0bab2fd3eebf9f741207 100644
--- a/lib/Magento/ObjectManager/ObjectManager.php
+++ b/lib/Magento/ObjectManager/ObjectManager.php
@@ -105,6 +105,7 @@ class ObjectManager implements \Magento\ObjectManager
      * Configure di instance
      *
      * @param array $configuration
+     * @return void
      */
     public function configure(array $configuration)
     {
diff --git a/lib/Magento/Phrase/Renderer/Placeholder.php b/lib/Magento/Phrase/Renderer/Placeholder.php
index 3a5b4f45a6333cd1da7862a9e54b2b9f1925aa68..c36da690799964ad7d9b3fe87490b3e5f1e8d00a 100644
--- a/lib/Magento/Phrase/Renderer/Placeholder.php
+++ b/lib/Magento/Phrase/Renderer/Placeholder.php
@@ -37,9 +37,9 @@ class Placeholder implements \Magento\Phrase\RendererInterface
     public function render($text, array $arguments)
     {
         if ($arguments) {
-            $placeholders = array();
-            for ($i = 1, $size = count($arguments); $i <= $size; $i++) {
-                $placeholders[] = "%$i";
+            $placeholders = [];
+            foreach (array_keys($arguments) as $key) {
+                $placeholders[] = "%" . (is_int($key) ? strval($key + 1) : $key);
             }
             $text = str_replace($placeholders, $arguments, $text);
         }
diff --git a/lib/Magento/Service/Entity/AbstractDto.php b/lib/Magento/Service/Entity/AbstractDto.php
index de1638f778c12a30ed439c449636ce8dc252e458..fd9dda8d8ffbe5bc0ac4f93e4a1f9c9e02f7f3bf 100644
--- a/lib/Magento/Service/Entity/AbstractDto.php
+++ b/lib/Magento/Service/Entity/AbstractDto.php
@@ -23,6 +23,10 @@
  */
 namespace Magento\Service\Entity;
 
+/**
+ * Class AbstractDto
+ * @SuppressWarnings(PHPMD.NumberOfChildren)
+ */
 abstract class AbstractDto
 {
     /**
@@ -54,8 +58,6 @@ abstract class AbstractDto
     /**
      * Return DTO data in array format.
      *
-     * This only handles use cases of nested DTOs and array of DTOs
-     *
      * @return array
      */
     public function __toArray()
diff --git a/lib/Magento/Service/Entity/AbstractDtoBuilder.php b/lib/Magento/Service/Entity/AbstractDtoBuilder.php
index 52e5164101212e934a005f3e5679fe932c37618a..95c2e601b931dfdbac99627c9b851d6b72f3e894 100644
--- a/lib/Magento/Service/Entity/AbstractDtoBuilder.php
+++ b/lib/Magento/Service/Entity/AbstractDtoBuilder.php
@@ -41,45 +41,35 @@ abstract class AbstractDtoBuilder
     /**
      * Populates the fields with an existing entity.
      *
-     * @param \Magento\Service\Entity\AbstractDto $prototype the prototype to base on
-     * @return AbstractDtoBuilder
+     * @param AbstractDto $prototype the prototype to base on
+     * @return $this
      */
-    public function populate(\Magento\Service\Entity\AbstractDto $prototype)
+    public function populate(AbstractDto $prototype)
     {
-        $this->_data = array();
-        foreach (get_class_methods(get_class($prototype)) as $method) {
-            if (substr($method, 0, 3) === 'get') {
-                $originalDataName = lcfirst(substr($method, 3));
-                $dataName = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $originalDataName));
-
-                if ($dataName === 'attribute' || $dataName === 'attributes') {
-                    continue;
-                } else {
-                    $value = $prototype->$method();
-                    if ($value !== null) {
-                        $this->_data[$dataName] = $prototype->$method();
-                    }
-                }
-            } elseif (substr($method, 0, 2) == 'is') {
-                $originalDataName = lcfirst(substr($method, 2));
-                $dataName = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $originalDataName));
-
-                $this->_data[$dataName] = $prototype->$method();
-            }
-        }
-
-        return $this;
+        return $this->populateWithArray($prototype->__toArray());
     }
 
     /**
      * Populates the fields with data from the array.
      *
+     * The $data array should be a map that only contain scalar types or arrays of scalar types.
+     * Keys for the map are snake_case attribute/field names.
+     *
      * @param array $data
-     * @return self
+     * @return $this
      */
     public function populateWithArray(array $data)
     {
-        $this->_data = $data;
+        $this->_data = [];
+        $dtoMethods = get_class_methods(get_class($this));
+        foreach ($data as $key => $value) {
+            $method = 'set' . $this->_snakeCaseToCamelCase($key);
+            if (in_array($method, $dtoMethods)) {
+                $this->$method($value);
+            } else {
+                $this->_data[$key] = $value;
+            }
+        }
 
         return $this;
     }
@@ -91,7 +81,7 @@ abstract class AbstractDtoBuilder
      */
     public function create()
     {
-        $dtoType = substr(get_class($this), 0, -7);
+        $dtoType = $this->_getDtoType();
         $retObj = new $dtoType($this->_data);
         $this->_data = array();
         return $retObj;
@@ -101,7 +91,7 @@ abstract class AbstractDtoBuilder
      * @param string $key
      * @param mixed $value
      *
-     * @return self
+     * @return $this
      */
     protected function _set($key, $value)
     {
@@ -109,4 +99,29 @@ abstract class AbstractDtoBuilder
         return $this;
     }
 
+    /**
+     * Return the Dto type class name
+     *
+     * @return string
+     */
+    protected function _getDtoType()
+    {
+        return substr(get_class($this), 0, -7);
+    }
+
+    /**
+     * Converts an input string from snake_case to upper CamelCase.
+     *
+     * @param string $input
+     * @return string
+     */
+    protected function _snakeCaseToCamelCase($input)
+    {
+        $output = '';
+        $segments = explode('_', $input);
+        foreach ($segments as $segment) {
+            $output .= ucfirst($segment);
+        }
+        return $output;
+    }
 }
diff --git a/lib/Magento/Shell.php b/lib/Magento/Shell.php
index e547b91c1fdd349327d01678803d9375b2889fae..fbaa80b5fdbfb323b890cb6d5d763b828c7c35dc 100644
--- a/lib/Magento/Shell.php
+++ b/lib/Magento/Shell.php
@@ -39,13 +39,20 @@ class Shell
     protected $_logger;
 
     /**
-     * Constructor
+     * Operation system info
      *
+     * @var OSInfo
+     */
+    protected $_osInfo;
+
+    /**
+     * @param OSInfo $osInfo
      * @param \Zend_Log $logger Logger instance to be used to log commands and their output
      */
-    public function __construct(\Zend_Log $logger = null)
+    public function __construct(OSInfo $osInfo, \Zend_Log $logger = null)
     {
         $this->_logger = $logger;
+        $this->_osInfo = $osInfo;
     }
 
     /**
@@ -72,6 +79,22 @@ class Shell
         return $output;
     }
 
+    /**
+     * Run external command in background
+     *
+     * @param string $command
+     * @throws \Magento\Exception
+     */
+    public function executeInBackground($command)
+    {
+        if ($this->_osInfo->isWindows()) {
+            $command = 'start /B "magento background task" ' . $command;
+        } else {
+            $command .=  ' > /dev/null 2>1 &';
+        }
+        pclose(popen($command, 'r'));
+    }
+
     /**
      * Log a message, if a logger is specified
      *
diff --git a/lib/Magento/Translate.php b/lib/Magento/Translate.php
index e1503ca941de89b29f42dffd2c3c7d7b8b4f022e..7511e2a75f5184eaa20b1a04344750541ac07a02 100644
--- a/lib/Magento/Translate.php
+++ b/lib/Magento/Translate.php
@@ -23,6 +23,8 @@
  */
 namespace Magento;
 
+use Magento\TranslateInterface;
+
 /**
  * Translate library
  *
@@ -47,7 +49,7 @@ class Translate implements \Magento\TranslateInterface
     const CONFIG_KEY_AREA   = 'area';
 
     /**
-     * Configuration locale kay
+     * Configuration locale key
      */
     const CONFIG_KEY_LOCALE = 'locale';
 
@@ -241,7 +243,7 @@ class Translate implements \Magento\TranslateInterface
      * @param string $area
      * @param \Magento\Object $initParams
      * @param bool $forceReload
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     public function init($area = null, $initParams = null, $forceReload = false)
     {
@@ -277,7 +279,7 @@ class Translate implements \Magento\TranslateInterface
      * Initialize configuration
      *
      * @param   array $config
-     * @return  \Magento\TranslateInterface
+     * @return  $this
      */
     protected function setConfig($config)
     {
@@ -323,7 +325,7 @@ class Translate implements \Magento\TranslateInterface
      * Load data from module translation files
      *
      * @param string $moduleName
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     protected function _loadModuleTranslation($moduleName)
     {
@@ -339,7 +341,7 @@ class Translate implements \Magento\TranslateInterface
      * Compose the list of locales which are required to translate text entity based on given locale
      *
      * @param string $locale
-     * @return array
+     * @return string[]
      */
     protected function _composeRequiredLocaleList($locale)
     {
@@ -356,7 +358,7 @@ class Translate implements \Magento\TranslateInterface
      * @param array $data
      * @param string|bool $scope
      * @param boolean $forceReload
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     protected function _addData($data, $scope = false, $forceReload = false)
     {
@@ -402,7 +404,7 @@ class Translate implements \Magento\TranslateInterface
      * Load current theme translation
      *
      * @param bool $forceReload
-     * @param string $area
+     * @param string|null $area
      * @return $this
      */
     protected function _loadThemeTranslation($forceReload = false, $area = null)
@@ -426,8 +428,8 @@ class Translate implements \Magento\TranslateInterface
     /**
      * Loading current translation from DB
      *
-     * @param boolean $forceReload
-     * @return \Magento\TranslateInterface
+     * @param bool $forceReload
+     * @return $this
      */
     protected function _loadDbTranslation($forceReload = false)
     {
@@ -457,7 +459,7 @@ class Translate implements \Magento\TranslateInterface
      * Retrieve translation file for theme
      *
      * @param string $locale
-     * @param string $area
+     * @param string|null $area
      * @return string
      */
     protected function _getThemeTranslationFile($locale, $area = null)
@@ -470,8 +472,8 @@ class Translate implements \Magento\TranslateInterface
     /**
      * Retrieve data from file
      *
-     * @param   string $file
-     * @return  array
+     * @param string $file
+     * @return array
      */
     protected function _getFileData($file)
     {
@@ -514,7 +516,7 @@ class Translate implements \Magento\TranslateInterface
      * Set locale
      *
      * @param string $locale
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     public function setLocale($locale)
     {
@@ -576,7 +578,7 @@ class Translate implements \Magento\TranslateInterface
      * Set Translate inline mode
      *
      * @param bool $flag
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     public function setTranslateInline($flag = false)
     {
@@ -637,7 +639,7 @@ class Translate implements \Magento\TranslateInterface
     /**
      * Saving data cache
      *
-     * @return \Magento\TranslateInterface
+     * @return $this
      */
     protected function _saveCache()
     {
diff --git a/lib/Magento/Translate/Inline.php b/lib/Magento/Translate/Inline.php
index 52069da6a853f1e7e7054142e086212c78daf368..e7a8ba3a3b48b68700f2164c85b33561849c8035 100644
--- a/lib/Magento/Translate/Inline.php
+++ b/lib/Magento/Translate/Inline.php
@@ -148,6 +148,8 @@ class Inline implements \Magento\Translate\InlineInterface
 
     /**
      * Disable inline translation functionality
+     *
+     * @return void
      */
     public function disable()
     {
@@ -157,7 +159,7 @@ class Inline implements \Magento\Translate\InlineInterface
     /**
      * Replace translation templates with HTML fragments
      *
-     * @param array|string $body
+     * @param array|string &$body
      * @param bool $isJson
      * @return $this
      */
@@ -185,8 +187,8 @@ class Inline implements \Magento\Translate\InlineInterface
     /**
      * Additional translation mode html attribute is not needed for base inline translation.
      *
-     * @param mixed|string $tagName
-     * @return string
+     * @param mixed|string|null $tagName
+     * @return null
      */
     public function getAdditionalHtmlAttribute($tagName = null)
     {
@@ -195,6 +197,9 @@ class Inline implements \Magento\Translate\InlineInterface
 
     /**
      * Create block to render script and html with added inline translation content.
+     *
+     * @param string $content
+     * @return void
      */
     protected function _insertInlineScriptsHtml($content)
     {
@@ -230,7 +235,7 @@ class Inline implements \Magento\Translate\InlineInterface
     /**
      * Strip inline translations from text
      *
-     * @param array|string $body
+     * @param array|string &$body
      * @return $this
      */
     protected function _stripInlineTranslations(&$body)
diff --git a/lib/Magento/Validator/Composite/VarienObject.php b/lib/Magento/Validator/Object.php
similarity index 95%
rename from lib/Magento/Validator/Composite/VarienObject.php
rename to lib/Magento/Validator/Object.php
index 91fdd00d9c897ddd4c3a57240c4e2a7f3137367a..c75d48995b959d96c0f3d02e0ce59ee2b847c2f3 100644
--- a/lib/Magento/Validator/Composite/VarienObject.php
+++ b/lib/Magento/Validator/Object.php
@@ -28,9 +28,9 @@
  * Validator encapsulates multiple validation rules for \Magento\Object.
  * Able to validate both individual fields and a whole object.
  */
-namespace Magento\Validator\Composite;
+namespace Magento\Validator;
 
-class VarienObject implements \Zend_Validate_Interface
+class Object implements \Zend_Validate_Interface
 {
     /**
      * Validation rules per scope (particular fields or entire entity)
@@ -51,7 +51,7 @@ class VarienObject implements \Zend_Validate_Interface
      *
      * @param \Zend_Validate_Interface $validator
      * @param string $fieldName Field name to apply validation to, or empty value to validate entity as a whole
-     * @return \Magento\Validator\Composite\VarienObject
+     * @return \Magento\Validator\Object
      */
     public function addRule(\Zend_Validate_Interface $validator, $fieldName = '')
     {
diff --git a/lib/Magento/View/Asset/PreProcessor/Composite.php b/lib/Magento/View/Asset/PreProcessor/Composite.php
new file mode 100644
index 0000000000000000000000000000000000000000..0992a13b73c2de8e11eab8927491e9f0df4452eb
--- /dev/null
+++ b/lib/Magento/View/Asset/PreProcessor/Composite.php
@@ -0,0 +1,100 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\View\Asset\PreProcessor;
+
+use \Magento\View\Asset\PreProcessorFactory;
+
+/**
+ * View asset pre-processor composite
+ */
+class Composite implements PreProcessorInterface
+{
+    /**
+     * @var array
+     */
+    protected $preProcessorsConfig = array();
+
+    /**
+     * @var PreProcessorInterface[]
+     */
+    protected $assetTypePreProcessors = array();
+
+    /**
+     * @var \Magento\View\Asset\PreProcessorFactory
+     */
+    protected $preProcessorFactory;
+
+    /**
+     * @param PreProcessorFactory $preProcessorFactory
+     * @param array $preProcessorsConfig
+     */
+    public function __construct(
+        PreProcessorFactory $preProcessorFactory,
+        array $preProcessorsConfig = array()
+    ) {
+        $this->preProcessorFactory = $preProcessorFactory;
+        $this->preProcessorsConfig = $preProcessorsConfig;
+    }
+
+    /**
+     * Process view asset pro-processors
+     *
+     * @param string $filePath
+     * @param array $params
+     * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory
+     * @param null|string $sourcePath
+     * @return null|string
+     */
+    public function process($filePath, $params, $targetDirectory, $sourcePath = null)
+    {
+        $assetType = pathinfo($filePath, PATHINFO_EXTENSION);
+
+        foreach ($this->getAssetTypePreProcessors($assetType) as $preProcessor) {
+            $sourcePath = $preProcessor->process($filePath, $params, $targetDirectory, $sourcePath);
+        }
+
+        return $sourcePath;
+    }
+
+    /**
+     * Get processors list for given asset type
+     *
+     * @param string $assetType
+     * @return PreProcessorInterface[]
+     */
+    protected function getAssetTypePreProcessors($assetType)
+    {
+        if (!isset($this->assetTypePreProcessors[$assetType])) {
+            $this->assetTypePreProcessors[$assetType] = array();
+            foreach ($this->preProcessorsConfig as $preProcessorDetails) {
+                if ($assetType === $preProcessorDetails['asset_type']) {
+                    $this->assetTypePreProcessors[$assetType][] = $this->preProcessorFactory
+                        ->create($preProcessorDetails['class']);
+                }
+            }
+        }
+        return $this->assetTypePreProcessors[$assetType];
+    }
+}
diff --git a/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php b/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php
index f4fd4072a460d4cff0f4c1c8372968e108ff1b5a..2bc563a2257101d9ea39de129f9a04d753983e79 100644
--- a/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php
+++ b/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php
@@ -26,11 +26,13 @@ namespace Magento\View\Asset\PreProcessor;
 
 /**
  * The pre-processors which implement this interface are supposed to publish processed content to the $targetDirectory
- * and return the path to the published file (as $sourcePath).
+ * and return the path to the published file.
  */
 interface PreProcessorInterface
 {
     /**
+     * Process content
+     *
      * @param string $filePath
      * @param array $params
      * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory
diff --git a/lib/Magento/View/Asset/PreProcessorFactory.php b/lib/Magento/View/Asset/PreProcessorFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..ee96ac031b9e8b3f1cd8e1fdc479090c3358f8b5
--- /dev/null
+++ b/lib/Magento/View/Asset/PreProcessorFactory.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\View\Asset;
+
+/**
+ * View asset pre-processor factory
+ */
+class PreProcessorFactory
+{
+    /**
+     * Object Manager instance
+     *
+     * @var \Magento\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * @param \Magento\ObjectManager $objectManager
+     */
+    public function __construct(\Magento\ObjectManager $objectManager)
+    {
+        $this->objectManager = $objectManager;
+    }
+
+    /**
+     * Create class instance with specified parameters
+     *
+     * @param string $instanceName
+     * @param array $data
+     * @return PreProcessor\PreProcessorInterface
+     * @throws \UnexpectedValueException
+     */
+    public function create($instanceName, array $data = array())
+    {
+        $processorInstance = $this->objectManager->create($instanceName, $data);
+        if (!($processorInstance instanceof PreProcessor\PreProcessorInterface)) {
+            throw new \UnexpectedValueException("$instanceName has to implement the pre-processor interface.");
+        }
+        return $processorInstance;
+    }
+}
diff --git a/lib/Magento/View/Design/ThemeInterface.php b/lib/Magento/View/Design/ThemeInterface.php
index 66b7074a5c2de49dfa7f88ac557d9e8dacce1024..e7376c6d9e50f7a2a2d9bdfca3a0f476e6302da5 100644
--- a/lib/Magento/View/Design/ThemeInterface.php
+++ b/lib/Magento/View/Design/ThemeInterface.php
@@ -26,6 +26,8 @@ namespace Magento\View\Design;
 
 /**
  * Interface ThemeInterface
+ *
+ * @method int|null getId()
  */
 interface ThemeInterface
 {
diff --git a/lib/Magento/View/FileSystem.php b/lib/Magento/View/FileSystem.php
index 31509e178e0447ccbcc9c8c41b0840d1d8cbad0b..83c76c1e814dd25a3400802cfbda9a398e169a1e 100644
--- a/lib/Magento/View/FileSystem.php
+++ b/lib/Magento/View/FileSystem.php
@@ -95,8 +95,9 @@ class FileSystem
         $filePath = $this->_viewService->extractScope($this->normalizePath($fileId), $params);
         $this->_viewService->updateDesignParams($params);
         $skipProxy = isset($params['skipProxy']) && $params['skipProxy'];
-        return $this->_resolutionPool->getViewStrategy($skipProxy)->getViewFile($params['area'],
-            $params['themeModel'], $params['locale'], $filePath, $params['module']);
+        return $this->_resolutionPool->getViewStrategy($skipProxy)->getViewFile(
+            $params['area'], $params['themeModel'], $params['locale'], $filePath, $params['module']
+        );
     }
 
     /**
diff --git a/lib/Magento/View/Publisher.php b/lib/Magento/View/Publisher.php
index f4951adaae1670676ee4b040991b098aa0255643..27fef205ff2e663f86e31ed0d3d1d44d40f120be 100644
--- a/lib/Magento/View/Publisher.php
+++ b/lib/Magento/View/Publisher.php
@@ -95,6 +95,16 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
      */
     protected $rootDirectory;
 
+    /**
+     * @var RelatedFile
+     */
+    protected $relatedFile;
+
+    /**
+     * @var \Magento\View\Asset\PreProcessor\PreProcessorInterface
+     */
+    protected $preProcessor;
+
     /**
      * @param \Magento\Logger $logger
      * @param \Magento\App\Filesystem $filesystem
@@ -102,7 +112,9 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
      * @param Service $viewService
      * @param FileSystem $viewFileSystem
      * @param \Magento\Module\Dir\Reader $modulesReader
-     * @param $allowDuplication
+     * @param RelatedFile $relatedFile
+     * @param \Magento\View\Asset\PreProcessor\PreProcessorInterface $preProcessor
+     * @param bool $allowDuplication
      */
     public function __construct(
         \Magento\Logger $logger,
@@ -111,6 +123,8 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
         \Magento\View\Service $viewService,
         \Magento\View\FileSystem $viewFileSystem,
         \Magento\Module\Dir\Reader $modulesReader,
+        RelatedFile $relatedFile,
+        \Magento\View\Asset\PreProcessor\PreProcessorInterface $preProcessor,
         $allowDuplication
     ) {
         $this->_filesystem = $filesystem;
@@ -121,6 +135,8 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
         $this->_modulesReader = $modulesReader;
         $this->_logger = $logger;
         $this->_allowDuplication = $allowDuplication;
+        $this->relatedFile = $relatedFile;
+        $this->preProcessor = $preProcessor;
     }
 
     /**
@@ -146,7 +162,7 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
      */
     protected function _publishRelatedViewFile($fileId, $parentFilePath, $parentFileName, $params)
     {
-        $relativeFilePath = $this->_getRelatedViewFile($fileId, $parentFilePath, $parentFileName, $params);
+        $relativeFilePath = $this->relatedFile->buildPath($fileId, $parentFilePath, $parentFileName, $params);
         return $this->_getPublishedFilePath($relativeFilePath, $params);
     }
 
@@ -162,16 +178,50 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
      */
     protected function _getPublishedFilePath($filePath, $params)
     {
+        //TODO: Do we need this? It throws exception in production mode!
         if (!$this->_viewService->isViewFileOperationAllowed()) {
             throw new \Magento\Exception('Filesystem operations are not permitted for view files');
         }
 
+        // 1. Fallback look-up for view files. Remember it can be file of any type: CSS, LESS, JS, image
         $sourcePath = $this->_viewFileSystem->getViewFile($filePath, $params);
 
+        // 2. If $sourcePath returned actually not exists replace it with null value.
         if (!$this->rootDirectory->isExist($this->rootDirectory->getRelativePath($sourcePath))) {
-            throw new \Magento\Exception("Unable to locate theme file '{$sourcePath}'.");
+            $sourcePath = null;
+        }
+
+        /**
+         * 3. Target directory to save temporary files in. It was 'pub/static' dir, but I guess it's more correct
+         * to have it in 'var/tmp' dir.
+         */
+        //TODO: Why should publisher control where pre-processors save temporary files
+        $targetDirectory = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::VAR_DIR);
+
+        /**
+         * 4. Execute asset pre-processors
+         *      in case if $sourcePath was null, then pre-processors will be executed and original source file
+         *          will be processed, then new $sourcePath targeting pre-processed file in 'var/tmp' dir
+         *          will be returned back
+         *      in case if $sourcePath was not null then $sourcePath passed will be returned back
+         */
+        $sourcePath = $this->preProcessor->process($filePath, $params, $targetDirectory, $sourcePath);
+
+        // 5. If $sourcePath returned still doesn't exists throw Exception
+        if ($sourcePath === null
+            || !$this->rootDirectory->isExist($this->rootDirectory->getRelativePath($sourcePath))
+        ) {
+            throw new \Magento\Exception("Unable to locate theme file '{$filePath}'.");
         }
-        if (!$this->_needToProcessFile($sourcePath)) {
+
+        /**
+         * 6.
+         * If $sourcePath points to file in 'pub/lib' dir - no publishing required
+         * If $sourcePath points to file with protected extension - no publishing, return unchanged
+         * If $sourcePath points to file in 'pub/static' dir - no publishing required
+         * If $sourcePath points to CSS file and developer mode is enabled - publish file
+         */
+        if ($this->canSkipFilePublication($sourcePath)) {
             return $sourcePath;
         }
 
@@ -192,27 +242,25 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
         $sourcePath = $this->_viewFileSystem->normalizePath($sourcePath);
         $targetPath = $this->_buildPublishedFilePath($filePath, $params, $sourcePath);
 
-        /* Validate whether file needs to be published */
-        $isCssFile = $this->_getExtension($filePath) == self::CONTENT_TYPE_CSS;
-        if ($isCssFile) {
-            $cssContent = $this->_getPublicCssContent($sourcePath, $targetPath, $filePath, $params);
-        }
-
         $targetDirectory = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::STATIC_VIEW_DIR);
         $sourcePathRelative = $this->rootDirectory->getRelativePath($sourcePath);
         $targetPathRelative = $targetDirectory->getRelativePath($targetPath);
 
+        if ($this->_getExtension($filePath) == self::CONTENT_TYPE_CSS) {
+            $cssContent = $this->_getPublicCssContent($sourcePath, $targetPath, $filePath, $params);
+        }
+
         $fileMTime = $this->rootDirectory->stat($sourcePathRelative)['mtime'];
+
         if (!$targetDirectory->isExist($targetPathRelative)
-            || $fileMTime != $targetDirectory->stat($targetPathRelative)['mtime']) {
+            || $fileMTime != $targetDirectory->stat($targetPathRelative)['mtime']
+        ) {
             if (isset($cssContent)) {
                 $targetDirectory->writeFile($targetPathRelative, $cssContent);
                 $targetDirectory->touch($targetPathRelative, $fileMTime);
             } elseif ($this->rootDirectory->isFile($sourcePathRelative)) {
                 $this->rootDirectory->copyFile($sourcePathRelative, $targetPathRelative, $targetDirectory);
                 $targetDirectory->touch($targetPathRelative, $fileMTime);
-            } elseif (!$targetDirectory->isDirectory($targetPathRelative)) {
-                $targetDirectory->create($targetPathRelative);
             }
         }
 
@@ -244,18 +292,22 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
     /**
      * Determine whether a file needs to be published
      *
-     * Js files are never processed. All other files must be processed either if they are not published already,
+     * All files located in 'pub/lib' dir should not be published cause it's already publicly accessible.
+     * All other files must be processed either if they are not published already (located in 'pub/static'),
      * or if they are css-files and we're working in developer mode.
      *
      * @param string $filePath
      * @return bool
+     *
+     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      */
-    protected function _needToProcessFile($filePath)
+    protected function canSkipFilePublication($filePath)
     {
-        $jsPath = $this->_filesystem->getPath(\Magento\App\Filesystem::PUB_LIB_DIR) . '/';
         $filePath = str_replace('\\', '/', $filePath);
-        if (strncmp($filePath, $jsPath, strlen($jsPath)) === 0) {
-            return false;
+
+        $pubLibDir = $this->_filesystem->getPath(\Magento\App\Filesystem::PUB_LIB_DIR) . '/';
+        if (strncmp($filePath, $pubLibDir, strlen($pubLibDir)) === 0) {
+            return true;
         }
 
         $protectedExtensions = array(
@@ -264,16 +316,19 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
             self::CONTENT_TYPE_XML
         );
         if (in_array($this->_getExtension($filePath), $protectedExtensions)) {
+            return true;
+        }
+
+        $pubStaticDir = $this->_filesystem->getPath(\Magento\App\Filesystem::STATIC_VIEW_DIR) . '/';
+        if (strncmp($filePath, $pubStaticDir, strlen($pubStaticDir)) !== 0) {
             return false;
         }
 
-        $themePath = $this->_filesystem->getPath(\Magento\App\Filesystem::STATIC_VIEW_DIR) . '/';
-        if (strncmp($filePath, $themePath, strlen($themePath)) !== 0) {
+        if ($this->_viewService->getAppMode() !== \Magento\App\State::MODE_DEVELOPER) {
             return true;
         }
 
-        return ($this->_viewService->getAppMode() == \Magento\App\State::MODE_DEVELOPER)
-        && $this->_getExtension($filePath) == self::CONTENT_TYPE_CSS;
+        return $this->_getExtension($filePath) !== self::CONTENT_TYPE_CSS;
     }
 
     /**
@@ -284,8 +339,7 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
      */
     protected function _getExtension($filePath)
     {
-        $dotPosition = strrpos($filePath, '.');
-        return strtolower(substr($filePath, $dotPosition + 1));
+        return strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
     }
 
     /**
@@ -356,12 +410,7 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
             return $relatedPathPublic;
         };
         try {
-            $content = $this->_cssUrlResolver->replaceCssRelativeUrls(
-                $content,
-                $this->_viewFileSystem->normalizePath($sourcePath),
-                $this->_viewFileSystem->normalizePath($publicPath),
-                $callback
-            );
+            $content = $this->_cssUrlResolver->replaceCssRelativeUrls($content, $sourcePath, $publicPath, $callback);
         } catch (\Magento\Exception $e) {
             $this->_logger->logException($e);
         }
@@ -378,37 +427,4 @@ class Publisher implements \Magento\View\PublicFilesManagerInterface
     {
         return $this->_viewService->getPublicDir() . '/' . $file;
     }
-
-    /**
-     * Get relative $fileUrl based on information about parent file path and name.
-     *
-     * @param string $fileId URL to the file that was extracted from $parentFilePath
-     * @param string $parentFilePath path to the file
-     * @param string $parentFileName original file name identifier that was requested for processing
-     * @param array $params theme/module parameters array
-     * @return string
-     */
-    protected function _getRelatedViewFile($fileId, $parentFilePath, $parentFileName, &$params)
-    {
-        if (strpos($fileId, \Magento\View\Service::SCOPE_SEPARATOR)) {
-            $filePath = $this->_viewService->extractScope($this->_viewFileSystem->normalizePath($fileId), $params);
-        } else {
-            /* Check if module file overridden on theme level based on _module property and file path */
-            $themesPath = $this->_filesystem->getPath(\Magento\App\Filesystem::THEMES_DIR);
-            if ($params['module'] && strpos($parentFilePath, $themesPath) === 0) {
-                /* Add module directory to relative URL */
-                $filePath = dirname($params['module'] . '/' . $parentFileName)
-                    . '/' . $fileId;
-                if (strpos($filePath, $params['module']) === 0) {
-                    $filePath = ltrim(str_replace($params['module'], '', $filePath), '/');
-                } else {
-                    $params['module'] = false;
-                }
-            } else {
-                $filePath = dirname($parentFileName) . '/' . $fileId;
-            }
-        }
-
-        return $filePath;
-    }
 }
diff --git a/lib/Magento/View/RelatedFile.php b/lib/Magento/View/RelatedFile.php
new file mode 100644
index 0000000000000000000000000000000000000000..bcf2ad31b859cb4635002ca9432ba8fce06d7ef4
--- /dev/null
+++ b/lib/Magento/View/RelatedFile.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+ */
+
+namespace Magento\View;
+
+/**
+ * File path resolver
+ */
+class RelatedFile
+{
+    /**
+     * @var Service
+     */
+    protected $viewService;
+
+    /**
+     * @var FileSystem
+     */
+    protected $viewFileSystem;
+
+    /**
+     * @var \Magento\Filesystem
+     */
+    protected $filesystem;
+
+    /**
+     * @param Service $viewService
+     * @param FileSystem $viewFileSystem
+     * @param \Magento\App\Filesystem $filesystem
+     */
+    public function __construct(
+        Service $viewService,
+        FileSystem $viewFileSystem,
+        \Magento\App\Filesystem $filesystem
+    ) {
+        $this->viewService = $viewService;
+        $this->viewFileSystem = $viewFileSystem;
+        $this->filesystem = $filesystem;
+    }
+
+    /**
+     * Get relative $fileUrl based on information about parent file path and name.
+     *
+     * @param string $relatedFilePath URL to the file that was extracted from $parentPath
+     * @param string $parentPath path to the file
+     * @param string $parentRelativePath original file name identifier that was requested for processing
+     * @param array $params theme/module parameters array
+     * @return string
+     */
+    public function buildPath($relatedFilePath, $parentPath, $parentRelativePath, &$params)
+    {
+        if (strpos($relatedFilePath, \Magento\View\Service::SCOPE_SEPARATOR)) {
+            $filePath = $this->viewService->extractScope(
+                $this->viewFileSystem->normalizePath($relatedFilePath),
+                $params
+            );
+        } else {
+            /* Check if module file overridden on theme level based on _module property and file path */
+            $themesPath = $this->filesystem->getPath(\Magento\App\Filesystem::THEMES_DIR);
+            if ($params['module'] && strpos($parentPath, $themesPath) === 0) {
+                /* Add module directory to relative URL */
+                $filePath = dirname($params['module'] . '/' . $parentRelativePath) . '/' . $relatedFilePath;
+                if (strpos($filePath, $params['module']) === 0) {
+                    $filePath = ltrim(str_replace($params['module'], '', $filePath), '/');
+                } else {
+                    $params['module'] = false;
+                }
+            } else {
+                $filePath = dirname($parentRelativePath) . '/' . $relatedFilePath;
+            }
+        }
+
+        return $this->viewFileSystem->normalizePath($filePath);
+    }
+}
diff --git a/lib/Magento/View/Url/CssResolver.php b/lib/Magento/View/Url/CssResolver.php
index 4fa3a98b82c920ec6e51aefd1bf0f4eb9eb240a7..bc172ca8cda4583d0713a3465083357d7d36dd2b 100644
--- a/lib/Magento/View/Url/CssResolver.php
+++ b/lib/Magento/View/Url/CssResolver.php
@@ -80,9 +80,7 @@ class CssResolver
                 $filePath = dirname($originalPath) . '/' . $originalRelativeUrl;
             }
             $filePath = $this->viewFileSystem->normalizePath(str_replace('\\', '/', $filePath));
-            $relativePath = $this->_getFileRelativePath(
-                str_replace('\\', '/', $newPath), $filePath
-            );
+            $relativePath = $this->_getFileRelativePath(str_replace('\\', '/', $newPath), $filePath);
             $urlNotationNew = str_replace($originalRelativeUrl, $relativePath, $urlNotation);
             $cssContent = str_replace($urlNotation, $urlNotationNew, $cssContent);
         }
diff --git a/lib/Magento/Xml/Generator.php b/lib/Magento/Xml/Generator.php
index 4da87b191ace59d51ec935e8767224758fec4aa7..9344b6a7475acc61b7c5c1e0ce1a171217e6e9f5 100644
--- a/lib/Magento/Xml/Generator.php
+++ b/lib/Magento/Xml/Generator.php
@@ -32,15 +32,24 @@ class Generator
      */
     const DEFAULT_ENTITY_ITEM_NAME = 'item';
 
-    /** @var \DOMDocument|null */
+    /**
+     * @var \DOMDocument|null
+     */
     protected $_dom = null;
 
-    /** @var \DOMDocument */
+    /**
+     * @var \DOMDocument
+     */
     protected $_currentDom;
 
-    /** @var string */
+    /**
+     * @var string
+     */
     protected $_defaultIndexedArrayItemName;
 
+    /**
+     *
+     */
     public function __construct()
     {
         $this->_dom = new \DOMDocument('1.0');
diff --git a/lib/Magento/Xml/Parser.php b/lib/Magento/Xml/Parser.php
index 1ad76b8dc8dc5ed8871faf85e90a4d746e0ba690..60bd221e195279ace7f8731c05e6b30ea72027e4 100644
--- a/lib/Magento/Xml/Parser.php
+++ b/lib/Magento/Xml/Parser.php
@@ -28,15 +28,24 @@ namespace Magento\Xml;
 
 class Parser
 {
-    /** @var \DOMDocument|null */
+    /**
+     * @var \DOMDocument|null
+     */
     protected $_dom = null;
 
-    /** @var \DOMDocument */
+    /**
+     * @var \DOMDocument
+     */
     protected $_currentDom;
 
-    /** @var array */
+    /**
+     * @var array
+     */
     protected $_content = array();
 
+    /**
+     *
+     */
     public function __construct()
     {
         $this->_dom = new \DOMDocument;
diff --git a/pub/cron.php b/pub/cron.php
index 18b9f3bb54c52e3ea9cef28447d6a625230ed674..7e00cc661c173991c1d38cb98a74b221d84a105a 100644
--- a/pub/cron.php
+++ b/pub/cron.php
@@ -33,5 +33,4 @@ $params = array(
     \Magento\Core\Model\Store::CUSTOM_ENTRY_POINT_PARAM => true
 );
 $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params);
-$entryPoint->run('Magento\App\Cron');
-
+$entryPoint->run('Magento\App\Cron', array('parameters' => array('group::')));
diff --git a/pub/lib/mage/backend/suggest.js b/pub/lib/mage/backend/suggest.js
index dc776279f5739ce6ba0f5713590fd12b209f72f9..28dc7826e6e84eb3b049ffbe1f308b2a04f8f5c9 100644
--- a/pub/lib/mage/backend/suggest.js
+++ b/pub/lib/mage/backend/suggest.js
@@ -35,13 +35,13 @@
             template: '{{if items.length}}{{if !term && !$data.allShown() && $data.recentShown()}}' +
                 '<h5 class="title">${recentTitle}</h5>' +
                 '{{/if}}' +
-                '<ul data-mage-init="{&quot;menu&quot;:[]}">' +
+                '<ul data-mage-init=\'{"menu":[]}\'>' +
                 '{{each items}}' +
                 '{{if !$data.itemSelected($value)}}<li {{html optionData($value)}}>' +
                 '<a href="#">${$value.label}</a></li>{{/if}}' +
                 '{{/each}}' +
                 '{{if !term && !$data.allShown() && $data.recentShown()}}' +
-                '<li data-mage-init="{actionLink:{event:&quot;showAll&quot;}}" class="show-all">' +
+                '<li data-mage-init=\'{"actionLink":{"event":"showAll"}}\' class="show-all">' +
                 '<a href="#">${showAllTitle}</a></li>' +
                 '{{/if}}' +
                 '</ul>{{else}}<span class="mage-suggest-no-records">${noRecordsText}</span>{{/if}}',
@@ -781,7 +781,7 @@
                 '<li class="mage-suggest-search-field"></li></ul>',
             choiceTemplate: '<li class="mage-suggest-choice button"><div>${text}</div>' +
                 '<span class="mage-suggest-choice-close" tabindex="-1" ' +
-                'data-mage-init="{&quot;actionLink&quot;:{&quot;event&quot;:&quot;removeOption&quot;}}"></span></li>',
+                'data-mage-init=\'{"actionLink":{"event":"removeOption"}}\'></span></li>',
             selectedClass: 'mage-suggest-selected'
         },
 
diff --git a/pub/lib/mage/mage.js b/pub/lib/mage/mage.js
index 00988e6af028fca5c30e4081db6a92af53e7017c..587eb47f0419bb8bbcb8f71d5cad962b55fa90e1 100644
--- a/pub/lib/mage/mage.js
+++ b/pub/lib/mage/mage.js
@@ -66,7 +66,7 @@
     $.fn.mage = function(name) {
         var args = Array.prototype.slice.call(arguments, 1);
         return this.each(function(){
-            var inits = _getInitData(this);
+            var inits = $(this).data('mage-init') || {};
             if (name) {
                 inits[name] = args;
             }
@@ -147,27 +147,6 @@
         _onload(init.resources, handler);
     }
 
-    /**
-     * Define init-data from an element,
-     *     if JSON is not well-formed then evaluate init-data by manually
-     * @param {Element} elem
-     * @return {Object}
-     * @private
-     */
-    function _getInitData(elem) {
-        /*jshint evil:true*/
-        var inits = $(elem).data('mage-init') || {};
-        // in case it's not well-formed JSON inside data attribute, evaluate it manually
-        if (typeof inits === 'string') {
-            try {
-                inits = eval('(' + inits + ')');
-            } catch (e) {
-                inits = {};
-            }
-        }
-        return inits;
-    }
-
     /**
      * Find all elements with data attribute and initialize them
      * @param {Element} elem - context 
diff --git a/pub/lib/mage/redirect-url.js b/pub/lib/mage/redirect-url.js
index 7d690f9d7d5e5409d09770af960b6a65c4e41266..0ea29904f242f44ce2cca71da3a4fdaa16655ec2 100644
--- a/pub/lib/mage/redirect-url.js
+++ b/pub/lib/mage/redirect-url.js
@@ -1,4 +1,4 @@
-/**
+/**
  * Magento
  *
  * NOTICE OF LICENSE
@@ -15,49 +15,49 @@
  *
  * Do not edit or add to this file if you wish to upgrade Magento to newer
  * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category    mage
- * @package     mage
- * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
- * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
- */
-/*jshint evil:true browser:true jquery:true */
-(function ($) {
-    $.widget('mage.redirectUrl', {
-        options: {
-            event: 'click',
-            url: undefined
-        },
-
-        /**
-         * This method binds elements found in this widget.
-         * @private
-         */
-        _bind: function() {
-            var handlers = {};
-            handlers[this.options.event] = '_onEvent';
-            this._on(handlers);
-        },
-
-        /**
-         * This method constructs a new widget.
-         * @private
-         */
-        _create: function() {
-            this._bind();
-        },
-
-        /**
-         * This method set the url for the redirect.
-         * @private
-         */
-        _onEvent: function(){
-            if (this.options.url) {
-                location.href = this.options.url;
-            } else {
-                location.href = this.element.val();
-            }
-        }
-    });
-})(jQuery);
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category    mage
+ * @package     mage
+ * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ */
+/*jshint browser:true jquery:true */
+(function ($) {
+    $.widget('mage.redirectUrl', {
+        options: {
+            event: 'click',
+            url: undefined
+        },
+
+        /**
+         * This method binds elements found in this widget.
+         * @private
+         */
+        _bind: function() {
+            var handlers = {};
+            handlers[this.options.event] = '_onEvent';
+            this._on(handlers);
+        },
+
+        /**
+         * This method constructs a new widget.
+         * @private
+         */
+        _create: function() {
+            this._bind();
+        },
+
+        /**
+         * This method set the url for the redirect.
+         * @private
+         */
+        _onEvent: function(){
+            if (this.options.url) {
+                location.href = this.options.url;
+            } else {
+                location.href = this.element.val();
+            }
+        }
+    });
+})(jQuery);