reverted:
--- b/panels_ipe/js/panels_ipe_menu.js
+++ /dev/null
@@ -1,28 +0,0 @@
-(function($, menu_class, active_class) {
-  'use strict';
-
-  Drupal.behaviors.panelsIpeMenu = {
-    attach: function(context) {
-      var $context = context instanceof Document ? $('body') : $(context);
-
-      $context.once(menu_class, function() {
-        var $menus = $context.find('.' + menu_class);
-
-        $menus.children('a').bind('click', function(event) {
-          event.preventDefault();
-
-          var $menu = $(this).parent();
-
-          $menus.not($menu).removeClass(active_class);
-          $menu.toggleClass(active_class);
-        });
-
-        $(document).bind('click', function(event) {
-          if (!$(event.target).parents().hasClass(menu_class)) {
-            $menus.removeClass(active_class);
-          }
-        });
-      });
-    }
-  };
-})(jQuery, 'panels-ipe-menu', 'opened');
diff -u b/panels_ipe/panels_ipe.module b/panels_ipe/panels_ipe.module
--- b/panels_ipe/panels_ipe.module
+++ b/panels_ipe/panels_ipe.module
@@ -36,7 +36,7 @@
 /**
  * Implements hook_theme().
  */
-function panels_ipe_theme($existing, $type, $theme, $path) {
+function panels_ipe_theme(array $existing, $type, $theme, $path) {
   return array(
     'panels_ipe_pane_wrapper' => array(
       'variables' => array(
@@ -84,19 +84,15 @@
 }
 
 /**
- * Implements hook_footer().
+ * Implements hook_page_alter().
  *
  * Adds the IPE control container.
  */
-function panels_ipe_page_alter(&$page) {
-  $buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
-
-  if (empty($buttons)) {
-    return;
-  }
-
+function panels_ipe_page_alter(array &$page) {
   $page['page_bottom']['panels_ipe'] = array(
-    '#markup' => theme('panels_ipe_toolbar', array('buttons' => $buttons)),
+    '#markup' => theme_panels_ipe_toolbar(array(
+      'buttons' => panels_ipe_toolbar_add_button(),
+    )),
   );
 }
 
@@ -107,9 +103,9 @@
  *
  * @see panels_ipe_theme()
  */
-function theme_panels_ipe_placeholder_pane($vars) {
+function theme_panels_ipe_placeholder_pane(array $variables) {
   $output = '<div class="panels-ipe-placeholder-content">';
-  $output .= '<h3>' . $vars['region_title'] . '</h3>';
+  $output .= '<h3>' . $variables['region_title'] . '</h3>';
   $output .= '</div>';
 
   return $output;
@@ -120,9 +116,10 @@
  *
  * @see panels_ipe_theme()
  */
-function theme_panels_ipe_add_pane_button($vars) {
-  $links = theme('links', array(
-    'links' => $vars['links'],
+function theme_panels_ipe_add_pane_button(array $variables) {
+  $links = theme_links(array(
+    'links' => $variables['links'],
+    'heading' => '',
     'attributes' => array(
       'class' => array('panels-ipe-linkbar', 'inline'),
     ),
@@ -136,9 +133,9 @@
  *
  * @see panels_ipe_theme()
  */
-function theme_panels_ipe_pane_wrapper($vars) {
-  $links = $vars['links'];
-  $pane = $vars['pane'];
+function theme_panels_ipe_pane_wrapper(array $variables) {
+  $links = $variables['links'];
+  $pane = $variables['pane'];
 
   if (!empty($pane->locks['type']) && $pane->locks['type'] == 'immovable') {
     $links = '<div class="panels-ipe-dragbar panels-ipe-nodraghandle clearfix">' . $links . '</div>';
@@ -149,7 +146,7 @@
 
   $handlebar = '<div class="panels-ipe-handlebar-wrapper panels-ipe-on">' . $links . '</div>';
 
-  return $handlebar . $vars['output'];
+  return $handlebar . $variables['output'];
 }
 
 /**
@@ -157,10 +154,10 @@
  *
  * @see panels_ipe_theme()
  */
-function theme_panels_ipe_toolbar($vars) {
+function theme_panels_ipe_toolbar(array $variables) {
   $output = "<div id='panels-ipe-control-container' class='clearfix'>";
 
-  foreach ($vars['buttons'] as $key => $ipe_buttons) {
+  foreach ($variables['buttons'] as $key => $ipe_buttons) {
     $output .= '<div id="panels-ipe-control-' . $key . '" class="panels-ipe-control">';
 
     // Controls in this container will appear when the IPE is not on.
@@ -186,8 +183,8 @@
  *
  * @see panels_ipe_theme()
  */
-function theme_panels_ipe_region_wrapper($vars) {
-  return $vars['controls'] . $vars['output'];
+function theme_panels_ipe_region_wrapper(array $variables) {
+  return $variables['controls'] . $variables['output'];
 }
 
 /**
@@ -195,10 +192,10 @@
  *
  * @see panels_ipe_theme()
  */
-function template_preprocess_panels_ipe_pane_wrapper(&$vars) {
+function template_preprocess_panels_ipe_pane_wrapper(array &$variables) {
   /* @var \panels_renderer_editor $renderer */
-  $renderer = $vars['renderer'];
-  $pane = $vars['pane'];
+  $renderer = $variables['renderer'];
+  $pane = $variables['pane'];
 
   $groups = $renderer->get_pane_links_array($pane, ctools_get_content_type($pane->type));
   $links = array();
@@ -224,7 +221,7 @@
     'attributes' => array(),
   );
 
-  $vars['links'] = theme_links(array(
+  $variables['links'] = theme_links(array(
     'links' => $links,
     'heading' => '',
     'attributes' => array(
@@ -240,16 +237,16 @@
  *
  * @see panels_ipe_theme()
  */
-function template_preprocess_panels_ipe_add_pane_button(&$vars) {
+function template_preprocess_panels_ipe_add_pane_button(array &$variables) {
   /* @var \panels_renderer_editor $renderer */
-  $renderer = $vars['renderer'];
-  $region_id = $vars['region_id'];
+  $renderer = $variables['renderer'];
+  $region_id = $variables['region_id'];
 
-  $vars['links'] = array();
+  $variables['links'] = array();
 
   // Add option to configure style in IPE.
   if (user_access('administer panels styles')) {
-    $vars['links']['style'] = array(
+    $variables['links']['style'] = array(
       'title' => '<span>' . t('Region style') . '</span>',
       'href' => $renderer->get_url('style-type', 'region', $region_id),
       'html' => TRUE,
@@ -261,7 +258,7 @@
   }
 
   // Add option to add items in the IPE.
-  $vars['links']['add-pane'] = array(
+  $variables['links']['add-pane'] = array(
     'title' => '<span>' . t('Add new pane') . '</span>',
     'href' => $renderer->get_url('select-content', $region_id),
     'html' => TRUE,
@@ -274,10 +271,10 @@
   $context = array(
     'region_id' => $region_id,
     'renderer' => $renderer,
-    'display' => $vars['display'],
+    'display' => $variables['display'],
   );
 
-  drupal_alter('panels_ipe_region_links', $vars['links'], $context);
+  drupal_alter('panels_ipe_region_links', $variables['links'], $context);
 }
 
 /**
@@ -294,7 +291,19 @@
  *
+ * @param string $cache_key
+ *   Cache key.
+ * @param string $id
+ *   The ID of a button.
+ * @param array $button
+ *   An array for render.
+ *
  * @see panels_ipe_page_alter()
  */
-function panels_ipe_toolbar_add_button($cache_key, $id, $button) {
+function panels_ipe_toolbar_add_button($cache_key = '', $id = '', array $button = array()) {
   $buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
-  $buttons[$cache_key][$id] = $button;
+
+  if (!empty($cache_key)) {
+    $buttons[$cache_key][$id] = $button;
+  }
+
+  return $buttons;
 }
diff -u b/plugins/display_renderers/panels_renderer_editor.class.php b/plugins/display_renderers/panels_renderer_editor.class.php
--- b/plugins/display_renderers/panels_renderer_editor.class.php
+++ b/plugins/display_renderers/panels_renderer_editor.class.php
@@ -453,7 +453,7 @@
     }
 
     if (panels_get_caches() && user_access('use panels caching features')) {
-      $info = panels_get_cache(isset($pane->cache['method']) ? $pane->cache['method'] : 0);
+      $info = panels_get_cache(isset($pane->cache['method']) ? $pane->cache['method'] : NULL);
 
       $cache_links['title'] = array(
         'title' => isset($info['title']) ? $info['title'] : t('No caching'),
only in patch2:
unchanged:
--- a/panels_ipe/includes/panels_ipe.pipelines.inc
+++ b/panels_ipe/includes/panels_ipe.pipelines.inc
@@ -11,7 +11,7 @@
 function panels_ipe_default_panels_renderer_pipeline() {
   $pipelines = array();
 
-  $pipeline = new stdClass;
+  $pipeline = new \stdClass();
   $pipeline->disabled = FALSE; /* Edit this to true to make a default pipeline disabled initially */
   $pipeline->api_version = 1;
   $pipeline->name = 'ipe';
only in patch2:
unchanged:
--- a/panels_ipe/plugins/display_renderers/ipe.inc
+++ b/panels_ipe/plugins/display_renderers/ipe.inc
@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Panels renderer plugin.
+ */
 
 $plugin = array(
   'renderer' => 'panels_renderer_ipe',
only in patch2:
unchanged:
--- a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php
+++ b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php
@@ -1,20 +1,33 @@
 <?php
+/**
+ * @file
+ * Renderer class.
+ */
 
 /**
  * Renderer class for all In-Place Editor (IPE) behavior.
  */
-class panels_renderer_ipe extends panels_renderer_editor {
-  // The IPE operates in normal render mode, not admin mode.
-  var $admin = FALSE;
-
-  function render() {
-    $output = parent::render();
-    return "<div id='panels-ipe-display-{$this->clean_key}' class='panels-ipe-display-container'>$output</div>";
-  }
+class panels_renderer_ipe extends \panels_renderer_editor {
+  /**
+   * The IPE operates in normal render mode, not admin mode.
+   *
+   * @var bool
+   */
+  public $admin = FALSE;
+  /**
+   * @var string
+   */
+  public $clean_key = '';
+  /**
+   * @var \stdClass
+   */
+  public $cache;
 
-  function add_meta() {
-    ctools_include('display-edit', 'panels');
-    ctools_include('content');
+  /**
+   * {@inheritdoc}
+   */
+  public function render() {
+    ctools_include('cleanstring');
 
     if (empty($this->display->cache_key)) {
       $this->cache = panels_edit_cache_get_default($this->display);
@@ -23,9 +36,23 @@ class panels_renderer_ipe extends panels_renderer_editor {
     // actually need to load it if we already have our cache key, and doing
     // so is a waste of resources.
 
-    ctools_include('cleanstring');
     $this->clean_key = ctools_cleanstring($this->display->cache_key);
-    $button = array(
+
+    $output = '<div id="panels-ipe-display-' . $this->clean_key . '" class="panels-ipe-display-container">';
+    $output .= parent::render();
+    $output .= '</div>';
+
+    return $output;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function add_meta() {
+    ctools_include('display-edit', 'panels');
+    ctools_include('content');
+
+    panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', array(
       '#type' => 'link',
       '#title' => t('Customize this page'),
       '#href' => $this->get_url('save_form'),
@@ -40,39 +67,42 @@ class panels_renderer_ipe extends panels_renderer_editor {
       ),
       '#prefix' => '<div class="panels-ipe-pseudobutton-container">',
       '#suffix' => '</div>',
-    );
-
-    panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button);
+    ));
 
     // @todo this actually should be an IPE setting instead.
     if (user_access('change layouts in place editing')) {
-      $button = array(
+      panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', array(
         '#type' => 'link',
         '#title' => t('Change layout'),
         '#href' => $this->get_url('change_layout'),
-        '#options' => array('query' => drupal_get_destination()),
+        '#options' => array(
+          'query' => drupal_get_destination(),
+        ),
         '#attributes' => array(
-          'class' => array('panels-ipe-change-layout', 'panels-ipe-pseudobutton', 'ctools-modal-layout'),
+          'class' => array(
+            'panels-ipe-change-layout',
+            'panels-ipe-pseudobutton',
+            'ctools-modal-layout',
+          ),
         ),
         '#ajax' => array(
           'progress' => 'throbber',
           'ipe_cache_key' => $this->clean_key,
         ),
 
-      '#prefix' => '<div class="panels-ipe-pseudobutton-container">',
-      '#suffix' => '</div>',
-      );
-
-      panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', $button);
+        '#prefix' => '<div class="panels-ipe-pseudobutton-container">',
+        '#suffix' => '</div>',
+      ));
     }
 
     ctools_include('ajax');
     ctools_include('modal');
+
     ctools_modal_add_js();
+    ctools_add_js('panels_ipe', 'panels_ipe');
 
     ctools_add_css('panels_dnd', 'panels');
     ctools_add_css('panels_admin', 'panels');
-    ctools_add_js('panels_ipe', 'panels_ipe');
     ctools_add_css('panels_ipe', 'panels_ipe');
 
     drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting');
@@ -85,15 +115,22 @@ class panels_renderer_ipe extends panels_renderer_editor {
   }
 
   /**
+   * Render panels pane.
+   *
    * Override & call the parent, then pass output through to the dnd wrapper
    * theme function.
    *
-   * @param $pane
+   * @param \stdClass $pane
+   *   Panels pane.
+   *
+   * @return string
+   *   HTML output of the pane.
    */
-  function render_pane(&$pane) {
+  public function render_pane(\stdClass $pane) {
     $output = parent::render_pane($pane);
+
     if (empty($output)) {
-      return;
+      return '';
     }
 
     // If there are region locks, add them.
@@ -102,7 +139,8 @@ class panels_renderer_ipe extends panels_renderer_editor {
       $javascript = &drupal_static('drupal_add_js', array());
 
       // drupal_add_js breaks as we add these, but we can't just lump them
-      // together because panes can be rendered independently. So game the system:
+      // together because panes can be rendered independently. So game the
+      // system:
       if (empty($key)) {
         $settings['Panels']['RegionLock'][$pane->pid] = $pane->locks['regions'];
         drupal_add_js($settings, 'setting');
@@ -115,19 +153,24 @@ class panels_renderer_ipe extends panels_renderer_editor {
       else {
         $javascript['settings']['data'][$key]['Panels']['RegionLock'][$pane->pid] = $pane->locks['regions'];
       }
-
     }
 
     if (empty($pane->IPE_empty)) {
       // Add an inner layer wrapper to the pane content before placing it into
-      // draggable portlet
+      // draggable portlet.
       $output = "<div class=\"panels-ipe-portlet-content\">$output</div>";
     }
     else {
       $output = "<div class=\"panels-ipe-portlet-content panels-ipe-empty-pane\">$output</div>";
     }
+
     // Hand it off to the plugin/theme for placing draggers/buttons
-    $output = theme('panels_ipe_pane_wrapper', array('output' => $output, 'pane' => $pane, 'display' => $this->display, 'renderer' => $this));
+    $output = theme('panels_ipe_pane_wrapper', array(
+      'pane' => $pane,
+      'output' => $output,
+      'display' => $this->display,
+      'renderer' => $this,
+    ));
 
     if (!empty($pane->locks['type']) && $pane->locks['type'] == 'immovable') {
       return "<div id=\"panels-ipe-paneid-{$pane->pid}\" class=\"panels-ipe-nodrag panels-ipe-portlet-wrapper panels-ipe-portlet-marker\">" . $output . "</div>";
@@ -136,28 +179,44 @@ class panels_renderer_ipe extends panels_renderer_editor {
     return "<div id=\"panels-ipe-paneid-{$pane->pid}\" class=\"panels-ipe-portlet-wrapper panels-ipe-portlet-marker\">" . $output . "</div>";
   }
 
-  function prepare_panes($panes) {
+  /**
+   * {@inheritdoc}
+   */
+  public function prepare_panes($panes) {
     // Set to admin mode just for this to ensure all panes are represented.
     $this->admin = TRUE;
-    $panes = parent::prepare_panes($panes);
+    parent::prepare_panes($panes);
     $this->admin = FALSE;
   }
 
-  function render_pane_content(&$pane) {
+  /**
+   * Render content of a panel.
+   *
+   * @param \stdClass $pane
+   *   Panels pane.
+   *
+   * @return \stdClass
+   *   Pane content object.
+   */
+  public function render_pane_content(\stdClass $pane) {
     if (!empty($pane->shown) && panels_pane_access($pane, $this->display)) {
       $content = parent::render_pane_content($pane);
     }
-    // Ensure that empty panes have some content.
-    if (empty($content) || empty($content->content)) {
-      if (empty($content)) {
-        $content = new stdClass();
-      }
 
+    if (empty($content)) {
+      $content = new \stdClass();
+    }
+
+    // Ensure that empty panes have some content.
+    if (empty($content->content)) {
       // Get the administrative title.
       $content_type = ctools_get_content_type($pane->type);
       $title = ctools_content_admin_title($content_type, $pane->subtype, $pane->configuration, $this->display->context);
 
-      $content->content = t('Placeholder for empty or inaccessible "@title"', array('@title' => html_entity_decode($title, ENT_QUOTES)));
+      $content->content = t('Placeholder for empty or inaccessible "@title"', array(
+        '@title' => html_entity_decode($title, ENT_QUOTES),
+      ));
+
       // Add these to prevent notices.
       $content->type = 'panels_ipe';
       $content->subtype = 'panels_ipe';
@@ -168,49 +227,65 @@ class panels_renderer_ipe extends panels_renderer_editor {
   }
 
   /**
-   * Add an 'empty' pane placeholder above all the normal panes.
+   * Add an "empty" pane placeholder above all the normal panes.
    *
-   * @param $region_id
-   * @param $panes
+   * @param string $region_id
+   *   The ID of a region.
+   * @param array $panes
+   *   An array with panes.
+   *
+   * @return string
+   *   HTML output of a region.
    */
-  function render_region($region_id, $panes) {
+  public function render_region($region_id, array $panes) {
     // Generate this region's 'empty' placeholder pane from the IPE plugin.
-    $empty_ph = theme('panels_ipe_placeholder_pane', array('region_id' => $region_id, 'region_title' => $this->plugins['layout']['regions'][$region_id]));
+    $empty_ph = theme('panels_ipe_placeholder_pane', array(
+      'region_id' => $region_id,
+      'region_title' => $this->plugins['layout']['regions'][$region_id],
+    ));
 
     // Wrap the placeholder in some guaranteed markup.
     $control = '<div class="panels-ipe-placeholder panels-ipe-on panels-ipe-portlet-marker panels-ipe-portlet-static">' . $empty_ph . theme('panels_ipe_add_pane_button', array('region_id' => $region_id, 'display' => $this->display, 'renderer' => $this)) . "</div>";
 
-    $output = parent::render_region($region_id, $panes);
-    $output = theme('panels_ipe_region_wrapper', array('output' => $output, 'region_id' => $region_id, 'display' => $this->display, 'controls' => $control, 'renderer' => $this));
-    $classes = 'panels-ipe-region';
-
-    return "<div id='panels-ipe-regionid-$region_id' class='panels-ipe-region'>$output</div>";
+    return sprintf('<div id="panels-ipe-regionid-%s" class="panels-ipe-region">%s</div>', $region_id, theme('panels_ipe_region_wrapper', array(
+      'output' => parent::render_region($region_id, $panes),
+      'region_id' => $region_id,
+      'display' => $this->display,
+      'controls' => $control,
+      'renderer' => $this,
+    )));
   }
 
   /**
    * This is a generic lock test.
+   *
+   * @param string $url
+   * @param string $break
+   *
+   * @return bool
    */
-  function ipe_test_lock($url, $break) {
+  public function ipe_test_lock($url, $break) {
     if (!empty($this->cache->locked)) {
-      if ($break != 'break') {
-        $account  = user_load($this->cache->locked->uid);
-        $name     = format_username($account);
-        $lock_age = format_interval(time() - $this->cache->locked->updated);
-
-        $message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array('!user' => $name, '!age' => $lock_age));
-
+      if ($break == 'break') {
+        // Break the lock.
+        panels_edit_cache_break_lock($this->cache);
+      }
+      else {
         $this->commands[] = array(
           'command' => 'unlockIPE',
-          'message' => $message,
+          'message' => t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array(
+            '!user' => format_username(user_load($this->cache->locked->uid)),
+            '!age' => format_interval(time() - $this->cache->locked->updated),
+          )),
           'break_path' => url($this->get_url($url, 'break')),
           'key' => $this->clean_key,
         );
+
         return TRUE;
       }
-
-      // Break the lock.
-      panels_edit_cache_break_lock($this->cache);
     }
+
+    return FALSE;
   }
 
   /**
@@ -223,22 +298,24 @@ class panels_renderer_ipe extends panels_renderer_editor {
    * and the client side has already given all indications that things are
    * now in a 'normal' state.
    */
-  function ajax_unlock_ipe() {
+  public function ajax_unlock_ipe() {
     panels_edit_cache_clear($this->cache);
     $this->commands[] = array();
   }
 
   /**
    * AJAX entry point to create the controller form for an IPE.
+   *
+   * @param string $break
    */
-  function ajax_save_form($break = NULL) {
+  public function ajax_save_form($break = '') {
     if ($this->ipe_test_lock('save-form', $break)) {
       return;
     }
 
     // Reset the $_POST['ajax_html_ids'] values to preserve
     // proper IDs on form elements when they are rebuilt
-    // by the Panels IPE without refreshing the page
+    // by the Panels IPE without refreshing the page.
     $_POST['ajax_html_ids'] = array();
 
     $form_state = array(
@@ -247,21 +324,24 @@ class panels_renderer_ipe extends panels_renderer_editor {
       'content_types' => $this->cache->content_types,
       'rerender' => FALSE,
       'no_redirect' => TRUE,
-      // Panels needs this to make sure that the layout gets callbacks
+      // Panels needs this to make sure that the layout gets callbacks.
       'layout' => $this->plugins['layout'],
     );
 
-    $output = drupal_build_form('panels_ipe_edit_control_form', $form_state);
     if (empty($form_state['executed'])) {
+      $output = drupal_build_form('panels_ipe_edit_control_form', $form_state);
       // At this point, we want to save the cache to ensure that we have a lock.
       $this->cache->ipe_locked = TRUE;
+
       panels_edit_cache_set($this->cache);
+
       $this->commands[] = array(
         'command' => 'initIPE',
         'key' => $this->clean_key,
         'data' => drupal_render($output),
         'lockPath' => url($this->get_url('unlock_ipe')),
       );
+
       return;
     }
 
@@ -273,6 +353,7 @@ class panels_renderer_ipe extends panels_renderer_editor {
         'command' => 'cancelIPE',
         'key' => $this->clean_key,
       );
+
       return;
     }
 
@@ -280,10 +361,10 @@ class panels_renderer_ipe extends panels_renderer_editor {
     if (!empty($form_state['clicked_button']['#save-display'])) {
       // Saved. Save the cache.
       panels_edit_cache_save($this->cache);
-      // A rerender should fix IDs on added panes as well as ensure style changes are
-      // rendered.
+      // A rerender should fix IDs on added panes as well as ensure style
+      // changes are rendered.
       $this->meta_location = 'inline';
-      $this->commands[] = ajax_command_replace("#panels-ipe-display-{$this->clean_key}", panels_render_display($this->display, $this));
+      $this->commands[] = ajax_command_replace("#panels-ipe-display-$this->clean_key", panels_render_display($this->display, $this));
     }
     else {
       // Cancelled. Clear the cache.
@@ -298,8 +379,10 @@ class panels_renderer_ipe extends panels_renderer_editor {
 
   /**
    * AJAX entry point to create the controller form for an IPE.
+   *
+   * @param string $break
    */
-  function ajax_change_layout($break = NULL) {
+  public function ajax_change_layout($break = '') {
     if ($this->ipe_test_lock('change_layout', $break)) {
       return;
     }
@@ -319,13 +402,16 @@ class panels_renderer_ipe extends panels_renderer_editor {
       $layouts = panels_common_get_allowed_layouts('panels_page');
     }
 
-    // Filter out builders
-    $layouts = array_filter($layouts, '_panels_builder_filter');
-
-    // Define the current layout
-    $current_layout = $this->plugins['layout']['name'];
-
-    $output = panels_common_print_layout_links($layouts, $this->get_url('set_layout'), array('attributes' => array('class' => array('use-ajax'))), $current_layout);
+    $output = panels_common_print_layout_links(
+      array_filter($layouts, '_panels_builder_filter'),
+      $this->get_url('set_layout'),
+      array(
+        'attributes' => array(
+          'class' => array('use-ajax'),
+        ),
+      ),
+      $this->plugins['layout']['name']
+    );
 
     $this->commands[] = ctools_modal_command_display(t('Change layout'), $output);
     $this->commands[] = array(
@@ -335,9 +421,10 @@ class panels_renderer_ipe extends panels_renderer_editor {
     );
   }
 
-  function ajax_set_layout($layout) {
+  public function ajax_set_layout($layout) {
     ctools_include('context');
     ctools_include('display-layout', 'panels');
+
     $form_state = array(
       'layout' => $layout,
       'display' => $this->display,
@@ -347,14 +434,17 @@ class panels_renderer_ipe extends panels_renderer_editor {
 
     // Reset the $_POST['ajax_html_ids'] values to preserve
     // proper IDs on form elements when they are rebuilt
-    // by the Panels IPE without refreshing the page
+    // by the Panels IPE without refreshing the page.
     $_POST['ajax_html_ids'] = array();
 
     $output = drupal_build_form('panels_change_layout', $form_state);
     $output = drupal_render($output);
+
     if (!empty($form_state['executed'])) {
       if (isset($form_state['back'])) {
-        return $this->ajax_change_layout();
+        $this->ajax_change_layout();
+
+        return;
       }
 
       if (!empty($form_state['clicked_button']['#save-display'])) {
@@ -366,14 +456,16 @@ class panels_renderer_ipe extends panels_renderer_editor {
         // renderer in order to get the right settings.
         $layout = panels_get_layout($this->display->layout);
         $this->plugins['layout'] = $layout;
+
         if (!isset($layout['regions'])) {
           $this->plugins['layout']['regions'] = panels_get_regions($layout, $this->display);
         }
 
         $this->meta_location = 'inline';
 
-        $this->commands[] = ajax_command_replace("#panels-ipe-display-{$this->clean_key}", panels_render_display($this->display, $this));
+        $this->commands[] = ajax_command_replace("#panels-ipe-display-$this->clean_key", panels_render_display($this->display, $this));
         $this->commands[] = ctools_modal_command_dismiss();
+
         return;
       }
     }
@@ -384,35 +476,25 @@ class panels_renderer_ipe extends panels_renderer_editor {
   /**
    * Create a command array to redraw a pane.
    */
-  function command_update_pane($pid) {
-    if (is_object($pid)) {
-      $pane = $pid;
-    }
-    else {
-      $pane = $this->display->content[$pid];
-    }
+  public function command_update_pane($pid) {
+    $pane = is_object($pid) ? $pid : $this->display->content[$pid];
 
     $this->commands[] = ajax_command_replace("#panels-ipe-paneid-$pane->pid", $this->render_pane($pane));
-    $this->commands[] = ajax_command_changed("#panels-ipe-display-{$this->clean_key}");
+    $this->commands[] = ajax_command_changed("#panels-ipe-display-$this->clean_key");
   }
 
   /**
    * Create a command array to add a new pane.
    */
-  function command_add_pane($pid) {
-    if (is_object($pid)) {
-      $pane = $pid;
-    }
-    else {
-      $pane = $this->display->content[$pid];
-    }
+  public function command_add_pane($pid) {
+    $pane = is_object($pid) ? $pid : $this->display->content[$pid];
 
     $this->commands[] = array(
       'command' => 'insertNewPane',
       'regionId' => $pane->panel,
       'renderedPane' => $this->render_pane($pane),
     );
-    $this->commands[] = ajax_command_changed("#panels-ipe-display-{$this->clean_key}");
+    $this->commands[] = ajax_command_changed("#panels-ipe-display-$this->clean_key");
     $this->commands[] = array(
       'command' => 'addNewPane',
       'key' => $this->clean_key,
@@ -464,5 +546,6 @@ function panels_ipe_edit_control_form($form, &$form_state) {
     '#attributes' => array('class' => array('panels-ipe-cancel')),
     '#value' => t('Cancel'),
   );
+
   return $form;
 }
