diff --git a/web/pgadmin/tools/backup/static/js/backup.js b/web/pgadmin/tools/backup/static/js/backup.js
index a6fbafef..367f3548 100644
--- a/web/pgadmin/tools/backup/static/js/backup.js
+++ b/web/pgadmin/tools/backup/static/js/backup.js
@@ -1,827 +1,1041 @@
 // Backup dialog
 define([
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
-  'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node'
-], function(gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, pgNode) {
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
+  'underscore.string', 'pgadmin.alertifyjs', 'backbone', 'pgadmin.backgrid',
+  'pgadmin.backform', 'pgadmin.browser',
+], function(
+  gettext, url_for, $, _, S, alertify, Backbone, Backgrid, Backform, pgBrowser
+) {
 
   // if module is already initialized, refer to that.
   if (pgBrowser.Backup) {
     return pgBrowser.Backup;
   }
 
-/*
-=====================
-TODO LIST FOR BACKUP:
-=====================
-1) Add Object tree on object tab which allows user to select
-   objects which can be backed up
-2) Allow user to select/deselect objects
-3) If database is selected in browser
-   show all database children objects selected in Object tree
-4) If schema is selected in browser
-   show all schema children objects selected in Object tree
-5) If table is selected then show table/schema/database selected
-   in Object tree
-6) if root objects like database/schema is not selected and their
-   children are selected then add them separately with in tables attribute
-   with schema.
-*/
-
-    var CustomSwitchControl = Backform.CustomSwitchControl = Backform.SwitchControl.extend({
-        template: _.template([
-          '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
-          '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
-          '  <div class="checkbox">',
-          '    <label>',
-          '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>"',
-          '        name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%>',
-          '        <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
-          '    </label>',
-          '  </div>',
-          '</div>',
-          '<% if (helpMessage && helpMessage.length) { %>',
-          '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
-          '<% } %>'
-        ].join("\n")),
-        className: 'pgadmin-control-group form-group pg-el-md-6 pg-el-xs-12'
-    });
-
-    //Backup Model (Server Node)
-    var BackupModel = Backbone.Model.extend({
-      idAttribute: 'id',
-      defaults: {
-        file: undefined,
-        role: undefined,
-        dqoute: false,
-        verbose: true,
-        type: undefined /* global, server */
+  /*
+  =====================
+  TODO LIST FOR BACKUP:
+  =====================
+  1) Add Object tree on object tab which allows user to select
+     objects which can be backed up
+  2) Allow user to select/deselect objects
+  3) If database is selected in browser
+     show all database children objects selected in Object tree
+  4) If schema is selected in browser
+     show all schema children objects selected in Object tree
+  5) If table is selected then show table/schema/database selected
+     in Object tree
+  6) if root objects like database/schema is not selected and their
+     children are selected then add them separately with in tables attribute
+     with schema.
+  */
+
+  Backform.CustomSwitchControl = Backform.SwitchControl.extend({
+    template: _.template([
+      '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
+      '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
+      '  <div class="checkbox">',
+      '    <label>',
+      '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>"',
+      '        name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%>',
+      '        <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
+      '    </label>',
+      '  </div>',
+      '</div>',
+      '<% if (helpMessage && helpMessage.length) { %>',
+      '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
+      '<% } %>',
+    ].join('\n')),
+    className: 'pgadmin-control-group form-group pg-el-md-6 pg-el-xs-12',
+  });
+
+  //Backup Model (Server Node)
+  var BackupModel = Backbone.Model.extend({
+    idAttribute: 'id',
+    defaults: {
+      file: undefined,
+      role: undefined,
+      dqoute: false,
+      verbose: true,
+      type: undefined,
+      /* global, server */
+    },
+    schema: [{
+      id: 'file',
+      label: gettext('Filename'),
+      type: 'text',
+      disabled: false,
+      control: Backform.FileControl,
+      dialog_type: 'create_file',
+      supp_types: ['*', 'sql', 'backup'],
+    }, {
+      id: 'role',
+      label: gettext('Role name'),
+      control: 'node-list-by-name',
+      node: 'role',
+      select2: {
+        allowClear: false,
       },
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Miscellaneous'),
       schema: [{
-        id: 'file', label: gettext('Filename'),
-        type: 'text', disabled: false, control: Backform.FileControl,
-        dialog_type: 'create_file', supp_types: ['*', 'sql', 'backup']
-      },{
-        id: 'role', label: gettext('Role name'),
-        control: 'node-list-by-name', node: 'role',
-        select2: { allowClear: false }
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Miscellaneous'),
-        schema:[{
-          id: 'verbose', label: gettext('Verbose messages'),
-          control: Backform.CustomSwitchControl, disabled: false,
-          group: gettext('Miscellaneous')
-        },{
-          id: 'dqoute', label: gettext('Force double quote on identifiers'),
-          control: Backform.CustomSwitchControl, disabled: false,
-          group: gettext('Miscellaneous')
-        }]
-      },{
-        id: 'server_note', label: gettext('Note'),
-        text: gettext('The backup format will be PLAIN'),
-        type: 'note', visible: function(m){
-          return m.get('type') === 'server';
-        }
-      },{
-        id: 'globals_note', label: gettext('Note'),
-        text: gettext('Only objects global to the entire database will be backed up in PLAIN format'),
-        type: 'note', visible: function(m){
-          return m.get('type') === 'globals';
-        }
-     },{
-     }],
-      validate: function() {
-        // TODO: HOW TO VALIDATE ???
-        return null;
-      }
-    });
-
-    //Backup Model (Objects like Database/Schema/Table)
-    var BackupObjectModel = Backbone.Model.extend({
-      idAttribute: 'id',
-      defaults: {
-        file: undefined,
-        role: undefined,
-        format: 'custom',
-        verbose: true,
-        blobs: true,
-        encoding: undefined,
-        schemas: [],
-        tables: [],
-        database: undefined
+        id: 'verbose',
+        label: gettext('Verbose messages'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous'),
+      }, {
+        id: 'dqoute',
+        label: gettext('Force double quote on identifiers'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous'),
+      }],
+    }, {
+      id: 'server_note',
+      label: gettext('Note'),
+      text: gettext('The backup format will be PLAIN'),
+      type: 'note',
+      visible: function(m) {
+        return m.get('type') === 'server';
+      },
+    }, {
+      id: 'globals_note',
+      label: gettext('Note'),
+      text: gettext('Only objects global to the entire database will be backed up in PLAIN format'),
+      type: 'note',
+      visible: function(m) {
+        return m.get('type') === 'globals';
       },
+    }, {}],
+    validate: function() {
+      // TODO: HOW TO VALIDATE ???
+      return null;
+    },
+  });
+
+  //Backup Model (Objects like Database/Schema/Table)
+  var BackupObjectModel = Backbone.Model.extend({
+    idAttribute: 'id',
+    defaults: {
+      file: undefined,
+      role: undefined,
+      format: 'custom',
+      verbose: true,
+      blobs: true,
+      encoding: undefined,
+      schemas: [],
+      tables: [],
+      database: undefined,
+    },
+    schema: [{
+      id: 'file',
+      label: gettext('Filename'),
+      type: 'text',
+      disabled: false,
+      control: Backform.FileControl,
+      dialog_type: 'create_file',
+      supp_types: ['*', 'sql', 'backup'],
+    }, {
+      id: 'format',
+      label: gettext('Format'),
+      type: 'text',
+      disabled: false,
+      control: 'select2',
+      select2: {
+        allowClear: false,
+        width: '100%',
+      },
+      options: [{
+        label: gettext('Custom'),
+        value: 'custom',
+      },
+      {
+        label: gettext('Tar'),
+        value: 'tar',
+      },
+      {
+        label: gettext('Plain'),
+        value: 'plain',
+      },
+      {
+        label: gettext('Directory'),
+        value: 'directory',
+      },
+      ],
+    }, {
+      id: 'ratio',
+      label: gettext('Compression ratio'),
+      type: 'int',
+      min: 0,
+      max: 9,
+      disabled: false,
+    }, {
+      id: 'encoding',
+      label: gettext('Encoding'),
+      type: 'text',
+      disabled: false,
+      node: 'database',
+      control: 'node-ajax-options',
+      url: 'get_encodings',
+    }, {
+      id: 'no_of_jobs',
+      label: gettext('Number of jobs'),
+      type: 'int',
+      deps: ['format'],
+      disabled: function(m) {
+        return !(m.get('format') === 'Directory');
+      },
+    }, {
+      id: 'role',
+      label: gettext('Role name'),
+      control: 'node-list-by-name',
+      node: 'role',
+      select2: {
+        allowClear: false,
+      },
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Sections'),
+      group: gettext('Dump options'),
       schema: [{
-        id: 'file', label: gettext('Filename'),
-        type: 'text', disabled: false, control: Backform.FileControl,
-        dialog_type: 'create_file', supp_types: ['*', 'sql', 'backup']
-      },{
-        id: 'format', label: gettext('Format'),
-        type: 'text', disabled: false,
-        control: 'select2', select2: {
-            allowClear: false,
-            width: "100%"
+        id: 'pre_data',
+        label: gettext('Pre-data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Sections'),
+        deps: ['only_data', 'only_schema'],
+        disabled: function(m) {
+          return m.get('only_data') ||
+            m.get('only_schema');
+        },
+      }, {
+        id: 'data',
+        label: gettext('Data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Sections'),
+        deps: ['only_data', 'only_schema'],
+        disabled: function(m) {
+          return m.get('only_data') ||
+            m.get('only_schema');
+        },
+      }, {
+        id: 'post_data',
+        label: gettext('Post-data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Sections'),
+        deps: ['only_data', 'only_schema'],
+        disabled: function(m) {
+          return m.get('only_data') ||
+            m.get('only_schema');
         },
-        options: [
-          {label: gettext('Custom'), value: "custom"},
-          {label: gettext('Tar'), value: "tar"},
-          {label: gettext('Plain'), value: "plain"},
-          {label: gettext('Directory'), value: "directory"}
-        ]
-      },{
-        id: 'ratio', label: gettext('Compression ratio'),
-        type: 'int', min: 0, max:9, disabled: false
-      },{
-        id: 'encoding', label: gettext('Encoding'),
-        type: 'text', disabled: false,  node: 'database',
-        control: 'node-ajax-options', url: 'get_encodings'
-      },{
-        id: 'no_of_jobs', label: gettext('Number of jobs'),
-        type: 'int', deps: ['format'], disabled: function(m) {
-          return !(m.get('format') === "Directory");
-        }
-      },{
-        id: 'role', label: gettext('Role name'),
-        control: 'node-list-by-name', node: 'role',
-        select2: { allowClear: false }
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Sections'),
-        group: gettext('Dump options'),
-        schema:[{
-          id: 'pre_data', label: gettext('Pre-data'),
-          control: Backform.CustomSwitchControl, group: gettext('Sections'),
-          deps: ['only_data', 'only_schema'], disabled: function(m) {
-            return m.get('only_data')
-                   || m.get('only_schema');
-          }
-        },{
-          id: 'data', label: gettext('Data'),
-          control: Backform.CustomSwitchControl, group: gettext('Sections'),
-          deps: ['only_data', 'only_schema'], disabled: function(m) {
-            return m.get('only_data')
-                   || m.get('only_schema');
-          }
-        },{
-          id: 'post_data', label: gettext('Post-data'),
-          control: Backform.CustomSwitchControl, group: gettext('Sections'),
-          deps: ['only_data', 'only_schema'], disabled: function(m) {
-            return m.get('only_data')
-                   || m.get('only_schema');
-          }
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Type of objects'),
-        group: gettext('Dump options'),
-        schema:[{
-          id: 'only_data', label: gettext('Only data'),
-          control: Backform.CustomSwitchControl, group: gettext('Type of objects'),
-          deps: ['pre_data', 'data', 'post_data','only_schema'], disabled: function(m) {
-            return m.get('pre_data')
-                   || m.get('data')
-                   || m.get('post_data')
-                   || m.get('only_schema');
-          }
-        },{
-          id: 'only_schema', label: gettext('Only schema'),
-          control: Backform.CustomSwitchControl, group: gettext('Type of objects'),
-          deps: ['pre_data', 'data', 'post_data', 'only_data'], disabled: function(m) {
-            return m.get('pre_data')
-                   || m.get('data')
-                   || m.get('post_data')
-                   || m.get('only_data');
-          }
-        },{
-          id: 'blobs', label: gettext('Blobs'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Type of objects')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Do not save'),
-        group: gettext('Dump options'),
-        schema:[{
-          id: 'dns_owner', label: gettext('Owner'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        },{
-          id: 'dns_privilege', label: gettext('Privilege'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        },{
-          id: 'dns_tablespace', label: gettext('Tablespace'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        },{
-          id: 'dns_unlogged_tbl_data', label: gettext('Unlogged table data'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Queries'),
-        group: gettext('Dump options'),
-        schema:[{
-          id: 'use_column_inserts', label: gettext('Use Column Inserts'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Queries')
-        },{
-          id: 'use_insert_commands', label: gettext('Use Insert Commands'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Queries')
-        },{
-          id: 'include_create_database', label: gettext('Include CREATE DATABASE statement'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Queries')
-        },{
-          id: 'include_drop_database', label: gettext('Include DROP DATABASE statement'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Queries')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Disable'),
-        group: gettext('Dump options'),
-        schema:[{
-          id: 'disable_trigger', label: gettext('Trigger'),
-          control: Backform.CustomSwitchControl, group: gettext('Disable'),
-          deps: ['only_data'], disabled: function(m) {
-            return !(m.get('only_data'));
-          }
-        },{
-          id: 'disable_quoting', label: gettext('$ quoting'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Disable')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Miscellaneous'),
-        group: gettext('Dump options'),
-        schema:[{
-          id: 'with_oids', label: gettext('With OID(s)'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Miscellaneous')
-        },{
-          id: 'verbose', label: gettext('Verbose messages'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Miscellaneous')
-        },{
-          id: 'dqoute', label: gettext('Force double quote on identifiers'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Miscellaneous')
-        },{
-          id: 'use_set_session_auth', label: gettext('Use SET SESSION AUTHORIZATION'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Miscellaneous')
-        }]
       }],
-      validate: function() {
-        return null;
-      }
-    });
-
-    // Create an Object Backup of pgBrowser class
-    pgBrowser.Backup  = {
-      init: function() {
-        if (this.initialized)
-          return;
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Type of objects'),
+      group: gettext('Dump options'),
+      schema: [{
+        id: 'only_data',
+        label: gettext('Only data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Type of objects'),
+        deps: ['pre_data', 'data', 'post_data', 'only_schema'],
+        disabled: function(m) {
+          return m.get('pre_data') ||
+            m.get('data') ||
+            m.get('post_data') ||
+            m.get('only_schema');
+        },
+      }, {
+        id: 'only_schema',
+        label: gettext('Only schema'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Type of objects'),
+        deps: ['pre_data', 'data', 'post_data', 'only_data'],
+        disabled: function(m) {
+          return m.get('pre_data') ||
+            m.get('data') ||
+            m.get('post_data') ||
+            m.get('only_data');
+        },
+      }, {
+        id: 'blobs',
+        label: gettext('Blobs'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Type of objects'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Do not save'),
+      group: gettext('Dump options'),
+      schema: [{
+        id: 'dns_owner',
+        label: gettext('Owner'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }, {
+        id: 'dns_privilege',
+        label: gettext('Privilege'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }, {
+        id: 'dns_tablespace',
+        label: gettext('Tablespace'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }, {
+        id: 'dns_unlogged_tbl_data',
+        label: gettext('Unlogged table data'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Queries'),
+      group: gettext('Dump options'),
+      schema: [{
+        id: 'use_column_inserts',
+        label: gettext('Use Column Inserts'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Queries'),
+      }, {
+        id: 'use_insert_commands',
+        label: gettext('Use Insert Commands'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Queries'),
+      }, {
+        id: 'include_create_database',
+        label: gettext('Include CREATE DATABASE statement'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Queries'),
+      }, {
+        id: 'include_drop_database',
+        label: gettext('Include DROP DATABASE statement'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Queries'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Disable'),
+      group: gettext('Dump options'),
+      schema: [{
+        id: 'disable_trigger',
+        label: gettext('Trigger'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Disable'),
+        deps: ['only_data'],
+        disabled: function(m) {
+          return !(m.get('only_data'));
+        },
+      }, {
+        id: 'disable_quoting',
+        label: gettext('$ quoting'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Disable'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Miscellaneous'),
+      group: gettext('Dump options'),
+      schema: [{
+        id: 'with_oids',
+        label: gettext('With OID(s)'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous'),
+      }, {
+        id: 'verbose',
+        label: gettext('Verbose messages'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous'),
+      }, {
+        id: 'dqoute',
+        label: gettext('Force double quote on identifiers'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous'),
+      }, {
+        id: 'use_set_session_auth',
+        label: gettext('Use SET SESSION AUTHORIZATION'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous'),
+      }],
+    }],
+    validate: function() {
+      return null;
+    },
+  });
 
-        this.initialized = true;
-
-        // Define list of nodes on which backup context menu option appears
-        var backup_supported_nodes = [
-              'database', 'schema', 'table', 'partition'
-            ];
-
-        /**
-          Enable/disable backup menu in tools based
-          on node selected
-          if selected node is present in supported_nodes,
-          menu will be enabled otherwise disabled.
-          Also, hide it for system view in catalogs
-        */
-        var menu_enabled = function(itemData, item, data) {
-          var t = pgBrowser.tree, i = item, d = itemData;
-          var parent_item = t.hasParent(i) ? t.parent(i): null,
-              parent_data = parent_item ? t.itemData(parent_item) : null;
-            if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
-                if (_.indexOf(backup_supported_nodes, d._type) !== -1 &&
-                parent_data._type != 'catalog') {
-                    if (d._type == 'database' && d.allowConn)
-                      return true;
-                    else if(d._type != 'database')
-                      return true;
-                    else
-                      return false;
-                }
-                else
-                  return false;
-            }
+  // Create an Object Backup of pgBrowser class
+  pgBrowser.Backup = {
+    init: function() {
+      if (this.initialized)
+        return;
+
+      this.initialized = true;
+
+      // Define list of nodes on which backup context menu option appears
+      var backup_supported_nodes = [
+        'database', 'schema', 'table', 'partition',
+      ];
+
+      /**
+        Enable/disable backup menu in tools based
+        on node selected
+        if selected node is present in supported_nodes,
+        menu will be enabled otherwise disabled.
+        Also, hide it for system view in catalogs
+      */
+      var menu_enabled = function(itemData, item) {
+        var t = pgBrowser.tree,
+          i = item,
+          d = itemData,
+          parent_item = t.hasParent(i) ? t.parent(i) : null,
+          parent_data = parent_item ? t.itemData(parent_item) : null;
+
+        if (!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+          if (_.indexOf(backup_supported_nodes, d._type) !== -1 &&
+            parent_data._type != 'catalog') {
+            if (d._type == 'database' && d.allowConn)
+              return true;
+            else if (d._type != 'database')
+              return true;
             else
               return false;
-        };
-
-        var menu_enabled_server = function(itemData, item, data) {
-          var t = pgBrowser.tree, i = item, d = itemData;
-          var parent_item = t.hasParent(i) ? t.parent(i): null,
-              parent_data = parent_item ? t.itemData(parent_item) : null;
-              // If server node selected && connected
-              if(!_.isUndefined(d) && !_.isNull(d))
-                return (('server' === d._type) && d.connected);
-              else
-                false;
-        };
-
-        // Define the nodes on which the menus to be appear
-        var menus = [{
-          name: 'backup_global', module: this,
-          applies: ['tools'], callback: 'start_backup_global',
-          priority: 12, label: gettext('Backup Globals...'),
-          icon: 'fa fa-floppy-o', enable: menu_enabled_server
-        },{
-          name: 'backup_server', module: this,
-          applies: ['tools'], callback: 'start_backup_server',
-          priority: 12, label: gettext('Backup Server...'),
-          icon: 'fa fa-floppy-o', enable: menu_enabled_server
-        },{
-          name: 'backup_global_ctx', module: this, node: 'server',
-          applies: ['context'], callback: 'start_backup_global',
-          priority: 12, label: gettext('Backup Globals...'),
-          icon: 'fa fa-floppy-o', enable: menu_enabled_server
-        },{
-          name: 'backup_server_ctx', module: this, node: 'server',
-          applies: ['context'], callback: 'start_backup_server',
-          priority: 12, label: gettext('Backup Server...'),
-          icon: 'fa fa-floppy-o', enable: menu_enabled_server
-        },{
-          name: 'backup_object', module: this,
-          applies: ['tools'], callback: 'backup_objects',
-          priority: 11, label: gettext('Backup...'),
-          icon: 'fa fa-floppy-o', enable: menu_enabled
-        }];
-
-        for (var idx = 0; idx < backup_supported_nodes.length; idx++) {
-          menus.push({
-            name: 'backup_' + backup_supported_nodes[idx],
-            node: backup_supported_nodes[idx], module: this,
-            applies: ['context'], callback: 'backup_objects',
-            priority: 11, label: gettext('Backup...'),
-            icon: 'fa fa-floppy-o', enable: menu_enabled
-            });
-        }
-
-        pgAdmin.Browser.add_menus(menus);
-        return this;
-      },
-      start_backup_global: function(action, item) {
-        var params = {'globals': true };
-        this.start_backup_global_server.apply(
-          this, [action, item, params]
-        );
-      },
-      start_backup_server: function(action, item) {
-        var params = {'server': true };
-        this.start_backup_global_server.apply(
-          this, [action, item, params]
-        );
-      },
+          } else
+            return false;
+        } else
+          return false;
+      };
+
+      var menu_enabled_server = function(itemData) {
+        // If server node selected && connected
+        if (!_.isUndefined(itemData) && !_.isNull(itemData))
+          return (('server' === itemData._type) && itemData.connected);
+        else
+          return false;
+      };
+
+      // Define the nodes on which the menus to be appear
+      var menus = [{
+        name: 'backup_global',
+        module: this,
+        applies: ['tools'],
+        callback: 'start_backup_global',
+        priority: 12,
+        label: gettext('Backup Globals...'),
+        icon: 'fa fa-floppy-o',
+        enable: menu_enabled_server,
+      }, {
+        name: 'backup_server',
+        module: this,
+        applies: ['tools'],
+        callback: 'start_backup_server',
+        priority: 12,
+        label: gettext('Backup Server...'),
+        icon: 'fa fa-floppy-o',
+        enable: menu_enabled_server,
+      }, {
+        name: 'backup_global_ctx',
+        module: this,
+        node: 'server',
+        applies: ['context'],
+        callback: 'start_backup_global',
+        priority: 12,
+        label: gettext('Backup Globals...'),
+        icon: 'fa fa-floppy-o',
+        enable: menu_enabled_server,
+      }, {
+        name: 'backup_server_ctx',
+        module: this,
+        node: 'server',
+        applies: ['context'],
+        callback: 'start_backup_server',
+        priority: 12,
+        label: gettext('Backup Server...'),
+        icon: 'fa fa-floppy-o',
+        enable: menu_enabled_server,
+      }, {
+        name: 'backup_object',
+        module: this,
+        applies: ['tools'],
+        callback: 'backup_objects',
+        priority: 11,
+        label: gettext('Backup...'),
+        icon: 'fa fa-floppy-o',
+        enable: menu_enabled,
+      }];
+
+      for (var idx = 0; idx < backup_supported_nodes.length; idx++) {
+        menus.push({
+          name: 'backup_' + backup_supported_nodes[idx],
+          node: backup_supported_nodes[idx],
+          module: this,
+          applies: ['context'],
+          callback: 'backup_objects',
+          priority: 11,
+          label: gettext('Backup...'),
+          icon: 'fa fa-floppy-o',
+          enable: menu_enabled,
+        });
+      }
 
-      // Callback to draw Backup Dialog for globals/server
-      start_backup_global_server: function(action, item, params) {
-        var i = item || pgBrowser.tree.selected(),
-          server_data = null;
-
-        while (i) {
-          var node_data = pgBrowser.tree.itemData(i);
-          if (node_data._type == 'server') {
-            server_data = node_data;
-            break;
-          }
-
-          if (pgBrowser.tree.hasParent(i)) {
-            i = $(pgBrowser.tree.parent(i));
-          } else {
-            alertify.alert(
-              gettext("Backup Error"),
-              gettext("Please select server or child node from the browser tree.")
-            );
-            break;
-          }
+      pgBrowser.add_menus(menus);
+      return this;
+    },
+    start_backup_global: function(action, item) {
+      var params = {
+        'globals': true,
+      };
+      this.start_backup_global_server.apply(
+        this, [action, item, params]
+      );
+    },
+    start_backup_server: function(action, item) {
+      var params = {
+        'server': true,
+      };
+      this.start_backup_global_server.apply(
+        this, [action, item, params]
+      );
+    },
+
+    // Callback to draw Backup Dialog for globals/server
+    start_backup_global_server: function(action, item, params) {
+      var i = item || pgBrowser.tree.selected(),
+        server_data = null;
+
+      while (i) {
+        var node_data = pgBrowser.tree.itemData(i);
+        if (node_data._type == 'server') {
+          server_data = node_data;
+          break;
         }
 
-        if (!server_data) {
-          return;
+        if (pgBrowser.tree.hasParent(i)) {
+          i = $(pgBrowser.tree.parent(i));
+        } else {
+          alertify.alert(
+            gettext('Backup Error'),
+            gettext('Please select server or child node from the browser tree.')
+          );
+          break;
         }
+      }
 
-        var module = 'paths',
-          preference_name = 'pg_bin_dir',
-          msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
+      if (!server_data) {
+        return;
+      }
 
-        if ((server_data.type && server_data.type == 'ppas') ||
-            server_data.server_type == 'ppas') {
-          preference_name = 'ppas_bin_dir';
-          msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
-        }
+      var module = 'paths',
+        preference_name = 'pg_bin_dir',
+        msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
 
-        var preference = pgBrowser.get_preference(module, preference_name);
+      if ((server_data.type && server_data.type == 'ppas') ||
+        server_data.server_type == 'ppas') {
+        preference_name = 'ppas_bin_dir';
+        msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+      }
 
-        if(preference) {
-          if (!preference.value) {
-            alertify.alert(gettext('Configuration required'), msg);
-            return;
-          }
-        } else {
-          alertify.alert(
-            gettext('Backup Error'),
-            S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value()
-          );
+      var preference = pgBrowser.get_preference(module, preference_name);
+
+      if (preference) {
+        if (!preference.value) {
+          alertify.alert(gettext('Configuration required'), msg);
           return;
         }
+      } else {
+        alertify.alert(
+          gettext('Backup Error'),
+          S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value()
+        );
+        return;
+      }
 
-        var of_type = undefined;
+      var of_type = undefined;
 
-        // Set Notes according to type of backup
-        if (!_.isUndefined(params['globals']) && params['globals']) {
-          of_type = 'globals';
-        } else {
-          of_type = 'server';
-        }
+      // Set Notes according to type of backup
+      if (!_.isUndefined(params['globals']) && params['globals']) {
+        of_type = 'globals';
+      } else {
+        of_type = 'server';
+      }
 
-        var DialogName = 'BackupDialog_' + of_type,
-            DialogTitle = ((of_type == 'globals') ?
-              gettext('Backup Globals...') :
-                gettext('Backup Server...'));
-
-        if(!alertify[DialogName]) {
-          alertify.dialog(DialogName ,function factory() {
-            return {
-               main: function(title) {
-                this.set('title', title);
-               },
-               build: function() {
-                alertify.pgDialogBuild.apply(this);
-               },
-               setup:function() {
-                return {
-                  buttons: [{
-                      text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
-                      attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Backup')}
-                    },{
-                      text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
-                      attrs:{
-                        name:'dialog_help', type:'button', label: gettext('Backup'),
-                        url: url_for('help.static', {'filename': 'backup_dialog.html'})
-                      }
-                    },{
-                      text: gettext('Backup'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
-                      'data-btn-name': 'backup'
-                    },{
-                      text: gettext('Cancel'), key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
-                      'data-btn-name': 'cancel'
-                  }],
-                  // Set options for dialog
-                  options: {
-                    title: DialogTitle,
-                    //disable both padding and overflow control.
-                    padding : !1,
-                    overflow: !1,
-                    model: 0,
-                    resizable: true,
-                    maximizable: true,
-                    pinnable: false,
-                    closableByDimmer: false,
-                    modal: false
-                  }
-                };
-              },
-              hooks: {
-                // Triggered when the dialog is closed
-                onclose: function() {
-                  if (this.view) {
-                    // clear our backform model/view
-                    this.view.remove({data: true, internal: true, silent: true});
-                  }
+      var DialogName = 'BackupDialog_' + of_type,
+        DialogTitle = ((of_type == 'globals') ?
+          gettext('Backup Globals...') :
+          gettext('Backup Server...'));
+
+      if (!alertify[DialogName]) {
+        alertify.dialog(DialogName, function factory() {
+          return {
+            main: function(title) {
+              this.set('title', title);
+            },
+            build: function() {
+              alertify.pgDialogBuild.apply(this);
+            },
+            setup: function() {
+              return {
+                buttons: [{
+                  text: '',
+                  className: 'btn btn-default pull-left fa fa-lg fa-info',
+                  attrs: {
+                    name: 'object_help',
+                    type: 'button',
+                    url: 'backup.html',
+                    label: gettext('Backup'),
+                  },
+                }, {
+                  text: '',
+                  key: 112,
+                  className: 'btn btn-default pull-left fa fa-lg fa-question',
+                  attrs: {
+                    name: 'dialog_help',
+                    type: 'button',
+                    label: gettext('Backup'),
+                    url: url_for('help.static', {
+                      'filename': 'backup_dialog.html',
+                    }),
+                  },
+                }, {
+                  text: gettext('Backup'),
+                  key: 13,
+                  className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
+                  'data-btn-name': 'backup',
+                }, {
+                  text: gettext('Cancel'),
+                  key: 27,
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+                  'data-btn-name': 'cancel',
+                }],
+                // Set options for dialog
+                options: {
+                  title: DialogTitle,
+                  //disable both padding and overflow control.
+                  padding: !1,
+                  overflow: !1,
+                  model: 0,
+                  resizable: true,
+                  maximizable: true,
+                  pinnable: false,
+                  closableByDimmer: false,
+                  modal: false,
+                },
+              };
+            },
+            hooks: {
+              // Triggered when the dialog is closed
+              onclose: function() {
+                if (this.view) {
+                  // clear our backform model/view
+                  this.view.remove({
+                    data: true,
+                    internal: true,
+                    silent: true,
+                  });
                 }
               },
-              prepare: function() {
-                var self = this;
-                // Disable Backup button until user provides Filename
-                this.__internal.buttons[2].element.disabled = true;
-
-                var $container = $("<div class='backup_dialog'></div>");
-                // Find current/selected node
-                var t = pgBrowser.tree,
-                  i = t.selected(),
-                  d = i && i.length == 1 ? t.itemData(i) : undefined,
-                  node = d && pgBrowser.Nodes[d._type];
+            },
+            prepare: function() {
+              var self = this;
+              // Disable Backup button until user provides Filename
+              this.__internal.buttons[2].element.disabled = true;
+
+              var $container = $('<div class=\'backup_dialog\'></div>');
+              // Find current/selected node
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = i && i.length == 1 ? t.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (!d)
+                return;
+              // Create treeInfo
+              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+              // Instance of backbone model
+              var newModel = new BackupModel({
+                  type: of_type,
+                }, {
+                  node_info: treeInfo,
+                }),
+                fields = Backform.generateViewSchema(
+                  treeInfo, newModel, 'create', node, treeInfo.server, true
+                );
+
+              var view = this.view = new Backform.Dialog({
+                el: $container,
+                model: newModel,
+                schema: fields,
+              });
+              // Add our class to alertify
+              $(this.elements.body.childNodes[0]).addClass(
+                'alertify_tools_dialog_properties obj_properties'
+              );
+              // Render dialog
+              view.render();
+
+              this.elements.content.appendChild($container.get(0));
+
+              // Listen to model & if filename is provided then enable Backup button
+              this.view.model.on('change', function() {
+                if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
+                  this.errorModel.clear();
+                  self.__internal.buttons[2].element.disabled = false;
+                } else {
+                  self.__internal.buttons[2].element.disabled = true;
+                  this.errorModel.set('file', gettext('Please provide a filename'));
+                }
+              });
+            },
+            // Callback functions when click on the buttons of the Alertify dialogs
+            callback: function(e) {
+              // Fetch current server id
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = i && i.length == 1 ? t.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (e.button.element.name == 'dialog_help' || e.button.element.name == 'object_help') {
+                e.cancel = true;
+                pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+                  node, i, e.button.element.getAttribute('label'));
+                return;
+              }
+
+              if (e.button['data-btn-name'] === 'backup') {
 
                 if (!d)
                   return;
-                // Create treeInfo
-                var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-                // Instance of backbone model
-                var newModel = new BackupModel(
-                  {type: of_type}, {node_info: treeInfo}
-                  ),
-                  fields = Backform.generateViewSchema(
-                    treeInfo, newModel, 'create', node, treeInfo.server, true
-                  );
 
-                var view = this.view = new Backform.Dialog({
-                  el: $container, model: newModel, schema: fields
-                });
-                // Add our class to alertify
-                $(this.elements.body.childNodes[0]).addClass(
-                  'alertify_tools_dialog_properties obj_properties'
-                );
-                // Render dialog
-                view.render();
-
-                this.elements.content.appendChild($container.get(0));
+                var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
 
-                // Listen to model & if filename is provided then enable Backup button
-                this.view.model.on('change', function() {
-                    if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
-                      this.errorModel.clear();
-                      self.__internal.buttons[2].element.disabled = false;
+                var self = this,
+                  baseUrl = url_for('backup.create_server_job', {
+                    'sid': treeInfo.server._id,
+                  }),
+                  args = this.view.model.toJSON();
+
+                $.ajax({
+                  url: baseUrl,
+                  method: 'POST',
+                  data: {
+                    'data': JSON.stringify(args),
+                  },
+                  success: function(res) {
+                    if (res.success) {
+                      alertify.success(gettext('Backup job created.'), 5);
+                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
                     } else {
-                      self.__internal.buttons[2].element.disabled = true;
-                      this.errorModel.set('file', gettext('Please provide a filename'))
+                      console.warn(res);
                     }
-                });
-              },
-              // Callback functions when click on the buttons of the Alertify dialogs
-              callback: function(e) {
-                // Fetch current server id
-                  var t = pgBrowser.tree,
-                    i = t.selected(),
-                    d = i && i.length == 1 ? t.itemData(i) : undefined,
-                    node = d && pgBrowser.Nodes[d._type];
-
-                if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
-                  e.cancel = true;
-                  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
-                    node, i, e.button.element.getAttribute('label'));
-                  return;
-                }
-
-                if (e.button['data-btn-name'] === "backup") {
-
-                  if (!d)
-                    return;
-
-                  var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-
-                  var self = this,
-                    baseUrl = url_for('backup.create_server_job', {'sid': treeInfo.server._id}),
-                    args =  this.view.model.toJSON();
-
-                  $.ajax({
-                    url: baseUrl,
-                    method: 'POST',
-                    data:{ 'data': JSON.stringify(args) },
-                    success: function(res) {
-                      if (res.success) {
-                        alertify.success(gettext('Backup job created.'), 5);
-                        pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
-                      } else {
-                        console.log(res);
-                      }
-                    },
-                    error: function(xhr, status, error) {
-                      try {
-                        var err = $.parseJSON(xhr.responseText);
-                        alertify.alert(
-                          gettext('Backup job failed.'),
-                          err.errormsg
-                        );
-                      } catch (e) {}
+                  },
+                  error: function(xhr) {
+                    try {
+                      var err = $.parseJSON(xhr.responseText);
+                      alertify.alert(
+                        gettext('Backup job failed.'),
+                        err.errormsg
+                      );
+                    } catch (e) {
+                      console.warn(e.stack || e);
                     }
-                  });
-                }
+                  },
+                });
               }
+            },
           };
-       });
+        });
       }
-        alertify[DialogName](true).resizeTo('60%','50%');
-     },
-
-      // Callback to draw Backup Dialog for objects
-      backup_objects: function(action, treeItem) {
-
-        var i = treeItem || pgBrowser.tree.selected(),
-          server_data = null;
-
-        while (i) {
-          var node_data = pgBrowser.tree.itemData(i);
-          if (node_data._type == 'server') {
-            server_data = node_data;
-            break;
-          }
-
-          if (pgBrowser.tree.hasParent(i)) {
-            i = $(pgBrowser.tree.parent(i));
-          } else {
-            alertify.alert(
-              gettext("Backup Error"),
-              gettext("Please select server or child node from tree.")
-            );
-            break;
-          }
-        }
+      alertify[DialogName](true).resizeTo('60%', '50%');
+    },
 
-        if (!server_data) {
-          return;
-        }
+    // Callback to draw Backup Dialog for objects
+    backup_objects: function(action, treeItem) {
 
-        var module = 'paths',
-          preference_name = 'pg_bin_dir',
-          msg = gettext('Please set binary path for PostgreSQL Server from preferences.');
+      var i = treeItem || pgBrowser.tree.selected(),
+        server_data = null;
 
-        if ((server_data.type && server_data.type == 'ppas') ||
-            server_data.server_type == 'ppas') {
-          preference_name = 'ppas_bin_dir';
-          msg = gettext('Please set binary path for EDB Postgres Advanced Server from preferences.');
+      while (i) {
+        var node_data = pgBrowser.tree.itemData(i);
+        if (node_data._type == 'server') {
+          server_data = node_data;
+          break;
         }
 
-        var preference = pgBrowser.get_preference(module, preference_name);
-
-        if(preference) {
-          if (!preference.value) {
-            alertify.alert(gettext('Configuration required'), msg);
-            return;
-          }
+        if (pgBrowser.tree.hasParent(i)) {
+          i = $(pgBrowser.tree.parent(i));
         } else {
           alertify.alert(
             gettext('Backup Error'),
-            S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value()
+            gettext('Please select server or child node from tree.')
           );
-          return;
+          break;
         }
+      }
+
+      if (!server_data) {
+        return;
+      }
+
+      var module = 'paths',
+        preference_name = 'pg_bin_dir',
+        msg = gettext('Please set binary path for PostgreSQL Server from preferences.');
 
-        var title = S(gettext('Backup (%s: %s)')),
-            tree = pgBrowser.tree,
-            item = treeItem || tree.selected(),
-            data = item && item.length == 1 && tree.itemData(item),
-            node = data && data._type && pgBrowser.Nodes[data._type];
+      if ((server_data.type && server_data.type == 'ppas') ||
+        server_data.server_type == 'ppas') {
+        preference_name = 'ppas_bin_dir';
+        msg = gettext('Please set binary path for EDB Postgres Advanced Server from preferences.');
+      }
+
+      var preference = pgBrowser.get_preference(module, preference_name);
 
-        if (!node)
+      if (preference) {
+        if (!preference.value) {
+          alertify.alert(gettext('Configuration required'), msg);
           return;
+        }
+      } else {
+        alertify.alert(
+          gettext('Backup Error'),
+          S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value()
+        );
+        return;
+      }
 
-        title = title.sprintf(node.label, data.label).value();
-
-        if(!alertify.backup_objects) {
-          // Create Dialog title on the fly with node details
-          alertify.dialog('backup_objects' ,function factory() {
-            return {
-               main: function(title) {
-                this.set('title', title);
-               },
-               build: function() {
-                alertify.pgDialogBuild.apply(this);
-               },
-               setup:function() {
-                return {
-                  buttons: [{
-                      text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
-                      attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Backup')}
-                    },{
-                      text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
-                      attrs:{
-                        name:'dialog_help', type:'button', label: gettext('Backup'),
-                        url: url_for('help.static', {'filename': 'backup_dialog.html'})
-                      }
-                    },{
-                      text: gettext('Backup'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
-                      'data-btn-name': 'backup'
-                    },{
-                      text: gettext('Cancel'), key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
-                      'data-btn-name': 'cancel'
-                  }],
-                  // Set options for dialog
-                  options: {
-                    title: title,
-                    //disable both padding and overflow control.
-                    padding : !1,
-                    overflow: !1,
-                    model: 0,
-                    resizable: true,
-                    maximizable: true,
-                    pinnable: false,
-                    closableByDimmer: false,
-                    modal: false
-                  }
-                };
-              },
-              hooks: {
-                // triggered when the dialog is closed
-                onclose: function() {
-                  if (this.view) {
-                    this.view.remove({data: true, internal: true, silent: true});
-                  }
+      var title = S(gettext('Backup (%s: %s)')),
+        tree = pgBrowser.tree,
+        item = treeItem || tree.selected(),
+        data = item && item.length == 1 && tree.itemData(item),
+        node = data && data._type && pgBrowser.Nodes[data._type];
+
+      if (!node)
+        return;
+
+      title = title.sprintf(node.label, data.label).value();
+
+      if (!alertify.backup_objects) {
+        // Create Dialog title on the fly with node details
+        alertify.dialog('backup_objects', function factory() {
+          return {
+            main: function(title) {
+              this.set('title', title);
+            },
+            build: function() {
+              alertify.pgDialogBuild.apply(this);
+            },
+            setup: function() {
+              return {
+                buttons: [{
+                  text: '',
+                  className: 'btn btn-default pull-left fa fa-lg fa-info',
+                  attrs: {
+                    name: 'object_help',
+                    type: 'button',
+                    url: 'backup.html',
+                    label: gettext('Backup'),
+                  },
+                }, {
+                  text: '',
+                  key: 112,
+                  className: 'btn btn-default pull-left fa fa-lg fa-question',
+                  attrs: {
+                    name: 'dialog_help',
+                    type: 'button',
+                    label: gettext('Backup'),
+                    url: url_for('help.static', {
+                      'filename': 'backup_dialog.html',
+                    }),
+                  },
+                }, {
+                  text: gettext('Backup'),
+                  key: 13,
+                  className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
+                  'data-btn-name': 'backup',
+                }, {
+                  text: gettext('Cancel'),
+                  key: 27,
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+                  'data-btn-name': 'cancel',
+                }],
+                // Set options for dialog
+                options: {
+                  title: title,
+                  //disable both padding and overflow control.
+                  padding: !1,
+                  overflow: !1,
+                  model: 0,
+                  resizable: true,
+                  maximizable: true,
+                  pinnable: false,
+                  closableByDimmer: false,
+                  modal: false,
+                },
+              };
+            },
+            hooks: {
+              // triggered when the dialog is closed
+              onclose: function() {
+                if (this.view) {
+                  this.view.remove({
+                    data: true,
+                    internal: true,
+                    silent: true,
+                  });
                 }
               },
-              prepare: function() {
-                var self = this;
-                // Disable Backup button until user provides Filename
-                this.__internal.buttons[2].element.disabled = true;
-                var $container = $("<div class='backup_dialog'></div>");
-                var t = pgBrowser.tree,
-                  i = t.selected(),
-                  d = i && i.length == 1 ? t.itemData(i) : undefined,
-                  node = d && pgBrowser.Nodes[d._type];
+            },
+            prepare: function() {
+              var self = this;
+              // Disable Backup button until user provides Filename
+              this.__internal.buttons[2].element.disabled = true;
+              var $container = $('<div class=\'backup_dialog\'></div>');
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = i && i.length == 1 ? t.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (!d)
+                return;
+
+              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+
+              var newModel = new BackupObjectModel({}, {
+                  node_info: treeInfo,
+                }),
+                fields = Backform.generateViewSchema(
+                  treeInfo, newModel, 'create', node, treeInfo.server, true
+                );
 
-                if (!d)
-                  return;
+              var view = this.view = new Backform.Dialog({
+                el: $container,
+                model: newModel,
+                schema: fields,
+              });
 
-                var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+              $(this.elements.body.childNodes[0]).addClass(
+                'alertify_tools_dialog_properties obj_properties'
+              );
 
-                var newModel = new BackupObjectModel(
-                  {}, {node_info: treeInfo}
-                  ),
-                  fields = Backform.generateViewSchema(
-                    treeInfo, newModel, 'create', node, treeInfo.server, true
-                  );
+              view.render();
 
-                var view = this.view = new Backform.Dialog({
-                  el: $container, model: newModel, schema: fields
-                });
+              this.elements.content.appendChild($container.get(0));
 
-                $(this.elements.body.childNodes[0]).addClass(
-                  'alertify_tools_dialog_properties obj_properties'
-                );
+              // Listen to model & if filename is provided then enable Backup button
+              this.view.model.on('change', function() {
+                if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
+                  this.errorModel.clear();
+                  self.__internal.buttons[2].element.disabled = false;
+                } else {
+                  self.__internal.buttons[2].element.disabled = true;
+                  this.errorModel.set('file', gettext('Please provide filename'));
+                }
+              });
+
+            },
+            // Callback functions when click on the buttons of the Alertify dialogs
+            callback: function(e) {
+              // Fetch current server id
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = i && i.length == 1 ? t.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (e.button.element.name == 'dialog_help' || e.button.element.name == 'object_help') {
+                e.cancel = true;
+                pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+                  node, i, e.button.element.getAttribute('label'));
+                return;
+              }
 
-                view.render();
+              if (e.button['data-btn-name'] === 'backup') {
+                if (!d)
+                  return;
 
-                this.elements.content.appendChild($container.get(0));
+                var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
 
-                 // Listen to model & if filename is provided then enable Backup button
-                this.view.model.on('change', function() {
-                    if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
-                      this.errorModel.clear();
-                      self.__internal.buttons[2].element.disabled = false;
-                    } else {
-                      self.__internal.buttons[2].element.disabled = true;
-                      this.errorModel.set('file', gettext('Please provide filename'))
-                    }
-                });
+                // Set current database into model
+                this.view.model.set('database', treeInfo.database._label);
 
-              },
-              // Callback functions when click on the buttons of the Alertify dialogs
-              callback: function(e) {
-                // Fetch current server id
-                  var t = pgBrowser.tree,
-                    i = t.selected(),
-                    d = i && i.length == 1 ? t.itemData(i) : undefined,
-                    node = d && pgBrowser.Nodes[d._type];
-
-                if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
-                  e.cancel = true;
-                  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
-                    node, i, e.button.element.getAttribute('label'));
-                  return;
+                // We will remove once object tree is implemented
+                // If selected node is Schema then add it in model
+                if (d._type == 'schema') {
+                  var schemas = [];
+                  schemas.push(d._label);
+                  this.view.model.set('schemas', schemas);
+                }
+                // If selected node is Table then add it in model along with
+                // its schema
+                if (d._type == 'table') {
+                  this.view.model.set(
+                    'tables', [
+                      [treeInfo.schema._label, d._label],
+                    ]
+                  );
                 }
 
-                if (e.button['data-btn-name'] === "backup") {
-                  if (!d)
-                    return;
-
-                  var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-
-                  // Set current database into model
-                  this.view.model.set('database', treeInfo.database._label);
-
-                  // We will remove once object tree is implemented
-                  // If selected node is Schema then add it in model
-                  if(d._type == 'schema') {
-                    var schemas = [];
-                    schemas.push(d._label);
-                    this.view.model.set('schemas', schemas);
-                  }
-                  // If selected node is Table then add it in model along with
-                  // its schema
-                  if(d._type == 'table') {
-                    this.view.model.set(
-                      'tables', [[treeInfo.schema._label, d._label]]
-                    );
-                  }
-
-                  // Remove ratio attribute from model if it has empty string.
-                  // The valid value can be between 0 to 9.
-                  if (_.isEmpty(this.view.model.get('ratio'))) {
-                    this.view.model.unset('ratio');
-                  }
-
-                  var self = this,
-                    baseUrl = url_for('backup.create_object_job', {'sid': treeInfo.server._id}),
-                      args =  this.view.model.toJSON();
-
-                  $.ajax({
-                    url: baseUrl,
-                    method: 'POST',
-                    data:{ 'data': JSON.stringify(args) },
-                    success: function(res) {
-                      if (res.success) {
-                        alertify.success(gettext('Backup job created.'), 5);
-                        pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
-                      }
-                    },
-                    error: function(xhr, status, error) {
-                      try {
-                        var err = $.parseJSON(xhr.responseText);
-                        alertify.alert(
-                          gettext('Backup job failed.'),
-                          err.errormsg
-                        );
-                      } catch (e) {}
-                    }
-                  });
+                // Remove ratio attribute from model if it has empty string.
+                // The valid value can be between 0 to 9.
+                if (_.isEmpty(this.view.model.get('ratio'))) {
+                  this.view.model.unset('ratio');
                 }
+
+                var self = this,
+                  baseUrl = url_for('backup.create_object_job', {
+                    'sid': treeInfo.server._id,
+                  }),
+                  args = this.view.model.toJSON();
+
+                $.ajax({
+                  url: baseUrl,
+                  method: 'POST',
+                  data: {
+                    'data': JSON.stringify(args),
+                  },
+                  success: function(res) {
+                    if (res.success) {
+                      alertify.success(gettext('Backup job created.'), 5);
+                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
+                    }
+                  },
+                  error: function(xhr) {
+                    try {
+                      var err = $.parseJSON(xhr.responseText);
+                      alertify.alert(
+                        gettext('Backup job failed.'),
+                        err.errormsg
+                      );
+                    } catch (e) {
+                      console.warn(e.stack || e);
+                    }
+                  },
+                });
               }
-            };
-          });
-        }
-        alertify.backup_objects(title).resizeTo('65%','60%');
+            },
+          };
+        });
       }
-    };
-    return pgBrowser.Backup;
-  });
+      alertify.backup_objects(title).resizeTo('65%', '60%');
+    },
+  };
+  return pgBrowser.Backup;
+});
diff --git a/web/pgadmin/tools/debugger/static/js/debugger.js b/web/pgadmin/tools/debugger/static/js/debugger.js
index f9050442..68383351 100644
--- a/web/pgadmin/tools/debugger/static/js/debugger.js
+++ b/web/pgadmin/tools/debugger/static/js/debugger.js
@@ -1,456 +1,554 @@
 define([
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify',
-  'sources/pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'codemirror',
-  'backform', 'pgadmin.tools.debugger.ui', 'wcdocker', 'pgadmin.backform',
-  'pgadmin.backgrid', 'pgadmin.browser.frame'
-], function(gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform, get_function_arguments) {
-
-  pgAdmin = pgAdmin || window.pgAdmin || {};
-
-  var pgTools = pgAdmin.Tools = pgAdmin.Tools || {};
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
+  'underscore.string', 'alertify', 'sources/pgadmin', 'pgadmin.browser',
+  'backbone', 'pgadmin.backgrid', 'codemirror', 'pgadmin.backform',
+  'pgadmin.tools.debugger.ui', 'wcdocker', 'pgadmin.browser.frame',
+], function(
+  gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
+  CodeMirror, Backform, get_function_arguments
+) {
+  var pgTools = pgAdmin.Tools = pgAdmin.Tools || {},
+    wcDocker = window.wcDocker;
 
   /* Return back, this has been called more than once */
   if (pgAdmin.Tools.Debugger)
     return pgAdmin.Tools.Debugger;
 
   pgTools.Debugger = {
-      init: function() {
-        // We do not want to initialize the module multiple times.
-        if (this.initialized)
-            return;
-
-        this.initialized = true;
-
-        // Initialize the context menu to display the debugging options when user open the context menu for functions
-        pgBrowser.add_menus([{
-          name: 'direct_debugger', node: 'function', module: this,
-          applies: ['object', 'context'], callback: 'get_function_information',
-          category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
-          data: {object: 'function'}, icon: 'fa fa-arrow-circle-right',
-          enable: 'can_debug'
-        },{
-          name: 'global_debugger', node: 'function', module: this,
-          applies: ['object', 'context'], callback: 'check_func_debuggable',
-          category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
-          data: {object: 'function', debug_type: 'indirect'},
-          icon: 'fa fa-arrow-circle-right', enable: 'can_debug'
-        },{
-          name: 'procedure_direct_debugger', node: 'procedure', module: this,
-          applies: ['object', 'context'], callback: 'get_function_information',
-          category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
-          data: {object: 'procedure'}, icon: 'fa fa-arrow-circle-right',
-          enable: 'can_debug'
-        }, {
-          name: 'procedure_indirect_debugger', node: 'procedure', module: this,
-          applies: ['object', 'context'], callback: 'check_func_debuggable',
-          category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
-          data: {object: 'procedure', debug_type: 'indirect'},
-          icon: 'fa fa-arrow-circle-right', enable: 'can_debug'
-        }, {
-          name: 'trigger_function_indirect_debugger', node: 'trigger_function', module: this,
-          applies: ['object', 'context'], callback: 'check_func_debuggable',
-          priority: 10, label: gettext('Set breakpoint'), category: gettext('Debugging'),
-          icon: 'fa fa-arrow-circle-right',
-          data: {object:'trigger_function', debug_type: 'indirect'}, enable: 'can_debug'
-        }, {
-          name: 'trigger_indirect_debugger', node: 'trigger', module: this,
-          applies: ['object', 'context'], callback: 'check_func_debuggable',
-          priority: 10, label: gettext('Set breakpoint'), category: gettext('Debugging'),
-          icon: 'fa fa-arrow-circle-right',
-          data: {object:'trigger', debug_type: 'indirect'}, enable: 'can_debug'
-        }, {
-          name: 'package_function_direct_debugger', node: 'edbfunc', module: this,
-          applies: ['object', 'context'], callback: 'get_function_information',
-          category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
-          data: {object: 'edbfunc'}, icon: 'fa fa-arrow-circle-right',
-          enable: 'can_debug'
-        },{
-          name: 'package_function_global_debugger', node: 'edbfunc', module: this,
-          applies: ['object', 'context'], callback: 'check_func_debuggable',
-          category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
-          data: {object: 'edbfunc', debug_type: 'indirect'},
-          icon: 'fa fa-arrow-circle-right', enable: 'can_debug'
-        },{
-          name: 'package_procedure_direct_debugger', node: 'edbproc', module: this,
-          applies: ['object', 'context'], callback: 'get_function_information',
-          category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
-          data: {object: 'edbproc'}, icon: 'fa fa-arrow-circle-right',
-          enable: 'can_debug'
-        }, {
-          name: 'package_procedure_global_debugger', node: 'edbproc', module: this,
-          applies: ['object', 'context'], callback: 'check_func_debuggable',
-          category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
-          data: {object: 'edbproc', debug_type: 'indirect'},
-          icon: 'fa fa-arrow-circle-right', enable: 'can_debug'
-        }]);
-
-        // Create and load the new frame required for debugger panel
-        this.frame = new pgBrowser.Frame({
-          name: 'frm_debugger',
-          title: gettext('Debugger'),
-          width: 500,
-          isCloseable: true,
-          isPrivate: true,
-          icon: 'fa fa-arrow-circle-right',
-          url: 'about:blank'
-        });
-
-        this.frame.load(pgBrowser.docker);
-      },
-      // It will check weather the function is actually debuggable or not with pre-required condition.
-      can_debug: function(itemData, item, data) {
-        var t = pgBrowser.tree, i = item, d = itemData;
-        // To iterate over tree to check parent node
-        while (i) {
-          if ('catalog' == d._type) {
-            //Check if we are not child of catalog
-            return false;
-          }
-          i = t.hasParent(i) ? t.parent(i) : null;
-          d = i ? t.itemData(i) : null;
+    init: function() {
+      // We do not want to initialize the module multiple times.
+      if (this.initialized)
+        return;
+
+      this.initialized = true;
+
+      // Initialize the context menu to display the debugging options when user open the context menu for functions
+      pgBrowser.add_menus([{
+        name: 'direct_debugger',
+        node: 'function',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'get_function_information',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Debug'),
+        data: {
+          object: 'function',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'global_debugger',
+        node: 'function',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'check_func_debuggable',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Set breakpoint'),
+        data: {
+          object: 'function',
+          debug_type: 'indirect',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'procedure_direct_debugger',
+        node: 'procedure',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'get_function_information',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Debug'),
+        data: {
+          object: 'procedure',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'procedure_indirect_debugger',
+        node: 'procedure',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'check_func_debuggable',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Set breakpoint'),
+        data: {
+          object: 'procedure',
+          debug_type: 'indirect',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'trigger_function_indirect_debugger',
+        node: 'trigger_function',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'check_func_debuggable',
+        priority: 10,
+        label: gettext('Set breakpoint'),
+        category: gettext('Debugging'),
+        icon: 'fa fa-arrow-circle-right',
+        data: {
+          object: 'trigger_function',
+          debug_type: 'indirect',
+        },
+        enable: 'can_debug',
+      }, {
+        name: 'trigger_indirect_debugger',
+        node: 'trigger',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'check_func_debuggable',
+        priority: 10,
+        label: gettext('Set breakpoint'),
+        category: gettext('Debugging'),
+        icon: 'fa fa-arrow-circle-right',
+        data: {
+          object: 'trigger',
+          debug_type: 'indirect',
+        },
+        enable: 'can_debug',
+      }, {
+        name: 'package_function_direct_debugger',
+        node: 'edbfunc',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'get_function_information',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Debug'),
+        data: {
+          object: 'edbfunc',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'package_function_global_debugger',
+        node: 'edbfunc',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'check_func_debuggable',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Set breakpoint'),
+        data: {
+          object: 'edbfunc',
+          debug_type: 'indirect',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'package_procedure_direct_debugger',
+        node: 'edbproc',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'get_function_information',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Debug'),
+        data: {
+          object: 'edbproc',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }, {
+        name: 'package_procedure_global_debugger',
+        node: 'edbproc',
+        module: this,
+        applies: ['object', 'context'],
+        callback: 'check_func_debuggable',
+        category: gettext('Debugging'),
+        priority: 10,
+        label: gettext('Set breakpoint'),
+        data: {
+          object: 'edbproc',
+          debug_type: 'indirect',
+        },
+        icon: 'fa fa-arrow-circle-right',
+        enable: 'can_debug',
+      }]);
+
+      // Create and load the new frame required for debugger panel
+      this.frame = new pgBrowser.Frame({
+        name: 'frm_debugger',
+        title: gettext('Debugger'),
+        width: 500,
+        isCloseable: true,
+        isPrivate: true,
+        icon: 'fa fa-arrow-circle-right',
+        url: 'about:blank',
+      });
+
+      this.frame.load(pgBrowser.docker);
+    },
+    // It will check weather the function is actually debuggable or not with pre-required condition.
+    can_debug: function(itemData, item, data) {
+      var t = pgBrowser.tree,
+        i = item,
+        d = itemData;
+      // To iterate over tree to check parent node
+      while (i) {
+        if ('catalog' == d._type) {
+          //Check if we are not child of catalog
+          return false;
         }
+        i = t.hasParent(i) ? t.parent(i) : null;
+        d = i ? t.itemData(i) : null;
+      }
 
-        // Find the function is really available in database
-        var tree = pgBrowser.tree,
-          info = tree.selected(),
-          d_ = info && info.length == 1 ? tree.itemData(info) : undefined,
-          node = d_ && pgBrowser.Nodes[d_._type];
+      // Find the function is really available in database
+      var tree = pgBrowser.tree,
+        info = tree.selected(),
+        d_ = info && info.length == 1 ? tree.itemData(info) : undefined,
+        node = d_ && pgBrowser.Nodes[d_._type];
 
-        if (!d_)
-          return false;
+      if (!d_)
+        return false;
 
-        var treeInfo = node.getTreeNodeHierarchy.apply(node, [info]);
+      var treeInfo = node.getTreeNodeHierarchy.apply(node, [info]);
 
-        // For indirect debugging user must be super user
-        if(data && data.debug_type && data.debug_type == 'indirect'
-            && !treeInfo.server.user.is_superuser)
-          return false;
+      // For indirect debugging user must be super user
+      if (data && data.debug_type && data.debug_type == 'indirect' &&
+        !treeInfo.server.user.is_superuser)
+        return false;
 
-        // Fetch object owner
-        var obj_owner = treeInfo.function && treeInfo.function.funcowner ||
-            treeInfo.procedure && treeInfo.procedure.funcowner ||
-            treeInfo.edbfunc && treeInfo.edbfunc.funcowner ||
-            treeInfo.edbproc && treeInfo.edbproc.funcowner;
+      // Fetch object owner
+      var obj_owner = treeInfo.function && treeInfo.function.funcowner ||
+        treeInfo.procedure && treeInfo.procedure.funcowner ||
+        treeInfo.edbfunc && treeInfo.edbfunc.funcowner ||
+        treeInfo.edbproc && treeInfo.edbproc.funcowner;
 
-        // Must be a super user or object owner to create breakpoints of any kind
-        if (!(treeInfo.server.user.is_superuser || obj_owner == treeInfo.server.user.name))
-          return false;
+      // Must be a super user or object owner to create breakpoints of any kind
+      if (!(treeInfo.server.user.is_superuser || obj_owner == treeInfo.server.user.name))
+        return false;
 
-        // For trigger node, language will be undefined - we should allow indirect debugging for trigger node
-        if ((d_.language == undefined && d_._type == 'trigger') ||
-            (d_.language == undefined && d_._type == 'edbfunc') ||
-            (d_.language == undefined && d_._type == 'edbproc')) {
-          return true;
-        }
+      // For trigger node, language will be undefined - we should allow indirect debugging for trigger node
+      if ((d_.language == undefined && d_._type == 'trigger') ||
+        (d_.language == undefined && d_._type == 'edbfunc') ||
+        (d_.language == undefined && d_._type == 'edbproc')) {
+        return true;
+      }
 
-        if (d_.language != 'plpgsql' && d_.language != 'edbspl') {
-           return false;
-        }
+      if (d_.language != 'plpgsql' && d_.language != 'edbspl') {
+        return false;
+      }
 
-        return true;
-      },
-      /*
-        For the direct debugging, we need to fetch the function information to display in the dialog so "generate_url"
-        will dynamically generate the URL from the server_id, database_id, schema_id and function id.
-      */
-      generate_url: function(_url, treeInfo, node) {
-        var url = '{BASEURL}{URL}/{OBJTYPE}{REF}',
-            ref = '';
-
-        _.each(
-          _.sortBy(
-            _.values(
-              _.pick(treeInfo,
-              function(v, k, o) {
+      return true;
+    },
+    /*
+      For the direct debugging, we need to fetch the function information to display in the dialog so "generate_url"
+      will dynamically generate the URL from the server_id, database_id, schema_id and function id.
+    */
+    generate_url: function(_url, treeInfo, node) {
+      var url = '{BASEURL}{URL}/{OBJTYPE}{REF}',
+        ref = '';
+
+      _.each(
+        _.sortBy(
+          _.values(
+            _.pick(treeInfo,
+              function(v, k) {
                 return (k != 'server_group');
               })
-            ),
-            function(o) { return o.priority; }
           ),
           function(o) {
-            ref = S('%s/%s').sprintf(ref, encodeURI(o._id)).value();
-          });
-
-        var args = {
-          'URL': _url,
-          'BASEURL': url_for('debugger.index'),
-          'REF': ref,
-          'OBJTYPE': encodeURI(node.type)
-        };
-
-        return url.replace(/{(\w+)}/g, function(match, arg) {
-          return args[arg];
-        });
-      },
-
-      check_func_debuggable: function(args, item) {
-        var input = args || {},
-          t = pgBrowser.tree,
-          i = item || t.selected(),
-          d = i && i.length == 1 ? t.itemData(i) : undefined,
-          node = d && pgBrowser.Nodes[d._type];
-
-        if (!d)
-          return;
-
-        var objName = d.label,
-            treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
-            _url = this.generate_url('init', treeInfo, node);
-
-        var self = this;
-        $.ajax({
-          url: _url,
-          cache: false,
-          success: function(res) {
-            self.start_global_debugger();
-          },
-          error: function(xhr, status, error) {
-            try {
-              var err = $.parseJSON(xhr.responseText);
-              if (err.success == 0) {
-                Alertify.alert(gettext('Debugger Error'), err.errormsg);
-              }
-            } catch (e) {}
+            return o.priority;
           }
+        ),
+        function(o) {
+          ref = S('%s/%s').sprintf(ref, encodeURI(o._id)).value();
         });
-      },
-
-      //Callback function when user start the indirect debugging ( Listen to another session to invoke the target )
-      start_global_debugger: function(args, item) {
-        // Initialize the target and create asynchronous connection and unique transaction ID
-        var t = pgBrowser.tree,
-          i = t.selected(),
-          d = i && i.length == 1 ? t.itemData(i) : undefined,
-          node = d && pgBrowser.Nodes[d._type];
-
-        if (!d)
-          return;
-
-        var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-
-        if (d._type == "function") {
-          var baseUrl = url_for(
-                          'debugger.initialize_target_for_function', {
-                            'debug_type': 'indirect',
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.function._id
-                          }
-                        );
-        }
-        else if (d._type == "procedure") {
-          var baseUrl = url_for(
-                          'debugger.initialize_target_for_function', {
-                            'debug_type': 'indirect',
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.procedure._id
-                          }
-                        );
-        }
-        else if (d._type == "trigger_function") {
-          var baseUrl = url_for(
-                          'debugger.initialize_target_for_function', {
-                            'debug_type': 'indirect',
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.trigger_function._id
-                          }
-                        );
-        }
-        else if (d._type == "trigger" && "table" in treeInfo) {
-          var baseUrl = url_for(
-                          'debugger.initialize_target_for_trigger', {
-                            'debug_type': 'indirect',
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.table._id,
-                            'tri_id': treeInfo.trigger._id
-                          }
-                        );
-        }
-        else if (d._type == "trigger" && "view" in treeInfo) {
-          var baseUrl = url_for(
-                          'debugger.initialize_target_for_trigger', {
-                            'debug_type': 'indirect',
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.view._id,
-                            'tri_id': treeInfo.trigger._id
-                          }
-                        );
-        }
 
-        $.ajax({
-          url: baseUrl,
-          method: 'GET',
-          success: function(res) {
-            var url = url_for('debugger.direct', {'trans_id': res.data.debuggerTransId});
+      var args = {
+        'URL': _url,
+        'BASEURL': url_for('debugger.index'),
+        'REF': ref,
+        'OBJTYPE': encodeURI(node.type),
+      };
+
+      return url.replace(/{(\w+)}/g, function(match, arg) {
+        return args[arg];
+      });
+    },
+
+    check_func_debuggable: function(args, item) {
+      var t = pgBrowser.tree,
+        i = item || t.selected(),
+        d = i && i.length == 1 ? t.itemData(i) : undefined,
+        node = d && pgBrowser.Nodes[d._type];
+
+      if (!d)
+        return;
+
+      var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
+        _url = this.generate_url('init', treeInfo, node);
+
+      var self = this;
+      $.ajax({
+        url: _url,
+        cache: false,
+        success: function() {
+          self.start_global_debugger();
+        },
+        error: function(xhr) {
+          try {
+            var err = $.parseJSON(xhr.responseText);
+            if (err.success == 0) {
+              Alertify.alert(gettext('Debugger Error'), err.errormsg);
+            }
+          } catch (e) {
+            console.warn(e.stack || e);
+          }
+        },
+      });
+    },
+
+    //Callback function when user start the indirect debugging ( Listen to another session to invoke the target )
+    start_global_debugger: function(args, item) {
+      // Initialize the target and create asynchronous connection and unique transaction ID
+      var t = pgBrowser.tree,
+        i = item || t.selected(),
+        d = i && i.length == 1 ? t.itemData(i) : undefined,
+        node = d && pgBrowser.Nodes[d._type];
+
+      if (!d)
+        return;
+
+      var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
+        baseUrl;
+
+      if (d._type == 'function') {
+        baseUrl = url_for(
+          'debugger.initialize_target_for_function', {
+            'debug_type': 'indirect',
+            'sid': treeInfo.server._id,
+            'did': treeInfo.database._id,
+            'scid': treeInfo.schema._id,
+            'func_id': treeInfo.function._id,
+          }
+        );
+      } else if (d._type == 'procedure') {
+        baseUrl = url_for(
+          'debugger.initialize_target_for_function', {
+            'debug_type': 'indirect',
+            'sid': treeInfo.server._id,
+            'did': treeInfo.database._id,
+            'scid': treeInfo.schema._id,
+            'func_id': treeInfo.procedure._id,
+          }
+        );
+      } else if (d._type == 'trigger_function') {
+        baseUrl = url_for(
+          'debugger.initialize_target_for_function', {
+            'debug_type': 'indirect',
+            'sid': treeInfo.server._id,
+            'did': treeInfo.database._id,
+            'scid': treeInfo.schema._id,
+            'func_id': treeInfo.trigger_function._id,
+          }
+        );
+      } else if (d._type == 'trigger' && 'table' in treeInfo) {
+        baseUrl = url_for(
+          'debugger.initialize_target_for_trigger', {
+            'debug_type': 'indirect',
+            'sid': treeInfo.server._id,
+            'did': treeInfo.database._id,
+            'scid': treeInfo.schema._id,
+            'func_id': treeInfo.table._id,
+            'tri_id': treeInfo.trigger._id,
+          }
+        );
+      } else if (d._type == 'trigger' && 'view' in treeInfo) {
+        baseUrl = url_for(
+          'debugger.initialize_target_for_trigger', {
+            'debug_type': 'indirect',
+            'sid': treeInfo.server._id,
+            'did': treeInfo.database._id,
+            'scid': treeInfo.schema._id,
+            'func_id': treeInfo.view._id,
+            'tri_id': treeInfo.trigger._id,
+          }
+        );
+      }
+
+      $.ajax({
+        url: baseUrl,
+        method: 'GET',
+        success: function(res) {
+          var url = url_for('debugger.direct', {
+            'trans_id': res.data.debuggerTransId,
+          });
 
-            if (res.data.newBrowserTab) {
-              window.open(url, '_blank');
-            } else {
-              pgBrowser.Events.once(
-                'pgadmin-browser:frame:urlloaded:frm_debugger', function(frame) {
+          if (res.data.newBrowserTab) {
+            window.open(url, '_blank');
+          } else {
+            pgBrowser.Events.once(
+              'pgadmin-browser:frame:urlloaded:frm_debugger',
+              function(frame) {
                 frame.openURL(url);
               });
 
-              // Create the debugger panel as per the data received from user input dialog.
-              var dashboardPanel = pgBrowser.docker.findPanels(
+            // Create the debugger panel as per the data received from user input dialog.
+            var dashboardPanel = pgBrowser.docker.findPanels(
                 'properties'
               ),
               panel = pgBrowser.docker.addPanel(
                 'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
               );
 
-              panel.focus();
+            panel.focus();
 
-              // Panel Closed event
-              panel.on(wcDocker.EVENT.CLOSED, function() {
-                var closeUrl = url_for('debugger.close', {'trans_id': res.data.debuggerTransId});
-                $.ajax({
-                  url: closeUrl,
-                  method: 'DELETE'
-                });
+            // Panel Closed event
+            panel.on(wcDocker.EVENT.CLOSED, function() {
+              var closeUrl = url_for('debugger.close', {
+                'trans_id': res.data.debuggerTransId,
+              });
+              $.ajax({
+                url: closeUrl,
+                method: 'DELETE',
               });
+            });
+          }
+        },
+        error: function(xhr) {
+          try {
+            var err = $.parseJSON(xhr.responseText);
+            if (err.success == 0) {
+              Alertify.alert(gettext('Debugger Error'), err.errormsg);
             }
-          },
-          error: function(xhr, status, error) {
-            try {
-              var err = $.parseJSON(xhr.responseText);
-              if (err.success == 0) {
-                Alertify.alert(gettext('Debugger Error'), err.errormsg);
-              }
-            } catch (e) {}
+          } catch (e) {
+            console.warn(e.stack || e);
           }
-        });
-      },
-
-      /*
-        Get the function information for the direct debugging to display the functions arguments and  other informations
-        in the user input dialog
-      */
-      get_function_information: function(args, item) {
-        var input = args || {},
-          t = pgBrowser.tree,
-          i = item || t.selected(),
-          d = i && i.length == 1 ? t.itemData(i) : undefined,
-          node = d && pgBrowser.Nodes[d._type];
-
-        if (!d)
-          return;
-
-        var objName = d.label,
-            treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
-            _url = this.generate_url('init', treeInfo, node);
-
-        var self = this;
-        $.ajax({
-          url: _url,
-          cache: false,
-          success: function(res) {
-
-            // Open Alertify the dialog to take the input arguments from user if function having input arguments
-            if (res.data[0]['require_input']) {
-              get_function_arguments(res.data[0], 0);
+        },
+      });
+    },
+
+    /*
+      Get the function information for the direct debugging to display the functions arguments and  other informations
+      in the user input dialog
+    */
+    get_function_information: function(args, item) {
+      var t = pgBrowser.tree,
+        i = item || t.selected(),
+        d = i && i.length == 1 ? t.itemData(i) : undefined,
+        node = d && pgBrowser.Nodes[d._type];
+
+      if (!d)
+        return;
+
+      var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
+        _url = this.generate_url('init', treeInfo, node);
+
+      $.ajax({
+        url: _url,
+        cache: false,
+        success: function(res) {
+
+          // Open Alertify the dialog to take the input arguments from user if function having input arguments
+          if (res.data[0]['require_input']) {
+            get_function_arguments(res.data[0], 0);
+          } else {
+            // Initialize the target and create asynchronous connection and unique transaction ID
+            // If there is no arguments to the functions then we should not ask for for function arguments and
+            // Directly open the panel
+            var t = pgBrowser.tree,
+              i = t.selected(),
+              d = i && i.length == 1 ? t.itemData(i) : undefined,
+              node = d && pgBrowser.Nodes[d._type];
+
+            if (!d)
+              return;
+
+            var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
+              baseUrl;
+
+            if (d._type == 'function') {
+              baseUrl = url_for(
+                'debugger.initialize_target_for_function', {
+                  'debug_type': 'direct',
+                  'sid': treeInfo.server._id,
+                  'did': treeInfo.database._id,
+                  'scid': treeInfo.schema._id,
+                  'func_id': treeInfo.function._id,
+                }
+              );
+            } else {
+              baseUrl = url_for(
+                'debugger.initialize_target_for_function', {
+                  'debug_type': 'direct',
+                  'sid': treeInfo.server._id,
+                  'did': treeInfo.database._id,
+                  'scid': treeInfo.schema._id,
+                  'func_id': treeInfo.procedure._id,
+                }
+              );
             }
-            else {
-              // Initialize the target and create asynchronous connection and unique transaction ID
-              // If there is no arguments to the functions then we should not ask for for function arguments and
-              // Directly open the panel
-              var t = pgBrowser.tree,
-                i = t.selected(),
-                d = i && i.length == 1 ? t.itemData(i) : undefined,
-                node = d && pgBrowser.Nodes[d._type];
-
-              if (!d)
-                return;
-
-              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-
-              if (d._type == "function") {
-                var baseUrl = url_for(
-                                'debugger.initialize_target_for_function', {
-                                  'debug_type': 'direct',
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.function._id
-                                }
-                              );
-              }
-              else {
-                var baseUrl = url_for(
-                                'debugger.initialize_target_for_function', {
-                                  'debug_type': 'direct',
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.procedure._id
-                                }
-                              );
-              }
 
-              $.ajax({
-                url: baseUrl,
-                method: 'GET',
-                success: function(res) {
+            $.ajax({
+              url: baseUrl,
+              method: 'GET',
+              success: function(res) {
 
-                  var url = url_for('debugger.direct', {'trans_id': res.data.debuggerTransId});
+                var url = url_for('debugger.direct', {
+                  'trans_id': res.data.debuggerTransId,
+                });
 
-                  if (res.data.newBrowserTab) {
-                    window.open(url, '_blank');
-                  } else {
-                    pgBrowser.Events.once(
-                      'pgadmin-browser:frame:urlloaded:frm_debugger', function(frame) {
+                if (res.data.newBrowserTab) {
+                  window.open(url, '_blank');
+                } else {
+                  pgBrowser.Events.once(
+                    'pgadmin-browser:frame:urlloaded:frm_debugger',
+                    function(frame) {
                       frame.openURL(url);
                     });
 
-                    // Create the debugger panel as per the data received from user input dialog.
-                    var dashboardPanel = pgBrowser.docker.findPanels(
+                  // Create the debugger panel as per the data received from user input dialog.
+                  var dashboardPanel = pgBrowser.docker.findPanels(
                       'properties'
-                      ),
-                      panel = pgBrowser.docker.addPanel(
-                        'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
-                        );
-
-                    panel.focus();
-
-                    // Register Panel Closed event
-                    panel.on(wcDocker.EVENT.CLOSED, function() {
-                      var closeUrl = url_for('debugger.close', {'trans_id': res.data.debuggerTransId});
-                      $.ajax({
-                        url: closeUrl,
-                        method: 'DELETE'
-                      });
+                    ),
+                    panel = pgBrowser.docker.addPanel(
+                      'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
+                    );
+
+                  panel.focus();
+
+                  // Register Panel Closed event
+                  panel.on(wcDocker.EVENT.CLOSED, function() {
+                    var closeUrl = url_for('debugger.close', {
+                      'trans_id': res.data.debuggerTransId,
+                    });
+                    $.ajax({
+                      url: closeUrl,
+                      method: 'DELETE',
                     });
-                  }
-                },
-                error: function(e) {
-                  Alertify.alert(
-                    gettext('Debugger Target Initialization Error'),
-                    e.responseJSON.errormsg
-                  );
+                  });
                 }
-              });
+              },
+              error: function(e) {
+                Alertify.alert(
+                  gettext('Debugger Target Initialization Error'),
+                  e.responseJSON.errormsg
+                );
+              },
+            });
+          }
+        },
+        error: function(xhr) {
+          try {
+            var err = $.parseJSON(xhr.responseText);
+            if (err.success == 0) {
+              Alertify.alert(gettext('Debugger Error'), err.errormsg);
             }
-          },
-          error: function(xhr, status, error) {
-            try {
-              var err = $.parseJSON(xhr.responseText);
-              if (err.success == 0) {
-                Alertify.alert(gettext('Debugger Error'), err.errormsg);
-              }
-            } catch (e) {}
+          } catch (e) {
+            console.warn(e.stack || e);
           }
-        });
-      }
-    };
+        },
+      });
+    },
+  };
 
-    return pgAdmin.Tools.Debugger;
-  });
+  return pgAdmin.Tools.Debugger;
+});
diff --git a/web/pgadmin/tools/debugger/static/js/debugger_ui.js b/web/pgadmin/tools/debugger/static/js/debugger_ui.js
index 339af36f..3a35cebb 100644
--- a/web/pgadmin/tools/debugger/static/js/debugger_ui.js
+++ b/web/pgadmin/tools/debugger/static/js/debugger_ui.js
@@ -1,72 +1,72 @@
 define([
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
-  'sources/pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'codemirror',
-  'backform', 'wcdocker', 'pgadmin.backform', 'pgadmin.backgrid',
-  'pgadmin.browser.panel'
-], function(gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform ) {
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
+  'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser',
+  'pgadmin.backgrid', 'wcdocker',
+], function(
+  gettext, url_for, $, _, Backbone, Alertify, pgAdmin, pgBrowser, Backgrid
+) {
+
+  var wcDocker = window.wcDocker;
 
   /*
    * Function used to return the respective Backgrid control based on the data type
    * of function input argument.
    */
   var cellFunction = function(model) {
-    var self = this,
-    variable_type = model.get("type");
+    var variable_type = model.get('type');
 
     // if variable type is an array then we need to render the custom control to take the input from user.
-    if (variable_type.indexOf("[]") !=-1) {
-      if (variable_type.indexOf("integer") != -1) {
+    if (variable_type.indexOf('[]') != -1) {
+      if (variable_type.indexOf('integer') != -1) {
         return Backgrid.Extension.InputIntegerArrayCell;
       }
       return Backgrid.Extension.InputStringArrayCell;
     }
 
-    switch(variable_type) {
-      case "bool":
-        return Backgrid.BooleanCell;
-        break;
-
-      case "integer":
+    switch (variable_type) {
+    case 'bool':
+      return Backgrid.BooleanCell;
+    case 'integer':
         // As we are getting this value as text from sqlite database so we need to type cast it.
-        if (model.get('value') != undefined) {
-          model.set({'value': parseInt(model.get('value'))},{silent:true});
-        }
-
-        return Backgrid.IntegerCell;
-        break;
+      if (model.get('value') != undefined) {
+        model.set({
+          'value': parseInt(model.get('value')),
+        }, {
+          silent: true,
+        });
+      }
 
-      case "real":
+      return Backgrid.IntegerCell;
+    case 'real':
         // As we are getting this value as text from sqlite database so we need to type cast it.
-        if (model.get('value') != undefined) {
-          model.set({'value': parseFloat(model.get('value'))} ,{silent:true});
-        }
-        return Backgrid.NumberCell;
-        break;
-
-      case "string":
-        return Backgrid.StringCell;
-        break;
-      case "date":
-        return Backgrid.DateCell;
-        break;
-      default:
-        return Backgrid.Cell;
-        break;
+      if (model.get('value') != undefined) {
+        model.set({
+          'value': parseFloat(model.get('value')),
+        }, {
+          silent: true,
+        });
+      }
+      return Backgrid.NumberCell;
+    case 'string':
+      return Backgrid.StringCell;
+    case 'date':
+      return Backgrid.DateCell;
+    default:
+      return Backgrid.Cell;
     }
-  }
+  };
 
   /*
    * Function used to return the respective Backgrid string or boolean control based on the data type
    * of function input argument.
    */
   var cellExprControlFunction = function(model) {
-    var self = this,
-    variable_type = model.get("type");
-    if (variable_type.indexOf("[]") !=-1) {
+    var variable_type = model.get('type');
+    if (variable_type.indexOf('[]') != -1) {
       return Backgrid.StringCell;
     }
     return Backgrid.BooleanCell;
-  }
+  };
 
   /**
    *  DebuggerInputArgsModel used to represent input parameters for the function to debug
@@ -84,8 +84,8 @@ define([
     },
     validate: function() {
       if (_.isUndefined(this.get('value')) ||
-          _.isNull(this.get('value')) ||
-          String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') {
+        _.isNull(this.get('value')) ||
+        String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') {
         var msg = gettext('Please enter a value for the parameter.');
         this.errorModel.set('value', msg);
         return msg;
@@ -93,39 +93,38 @@ define([
         this.errorModel.unset('value');
       }
       return null;
-    }
+    },
   });
 
   // Collection which contains the model for function informations.
   var DebuggerInputArgCollections = Backbone.Collection.extend({
-    model: DebuggerInputArgsModel
+    model: DebuggerInputArgsModel,
   });
 
   // function will enable/disable the use_default column based on the value received.
   var disableDefaultCell = function(d) {
     if (d instanceof Backbone.Model) {
-        return d.get('use_default');
+      return d.get('use_default');
     }
     return false;
   };
 
   // Enable/Disable the control based on the array data type of the function input arguments
   var disableExpressionControl = function(d) {
-    var argType = d.get('type');
     if (d instanceof Backbone.Model) {
       var argType = d.get('type');
-      if (argType.indexOf("[]") !=-1) {
+      if (argType.indexOf('[]') != -1) {
         return false;
       }
       return true;
     }
   };
 
-  var res =  function(args, restart_debug) {
+  var res = function(args, restart_debug) {
     if (!Alertify.debuggerInputArgsDialog) {
       Alertify.dialog('debuggerInputArgsDialog', function factory() {
         return {
-          main:function(title, data, restart_debug) {
+          main: function(title, data, restart_debug) {
             this.set('title', title);
             this.data = data;
             this.restart_debug = restart_debug;
@@ -143,53 +142,50 @@ define([
               if (!d)
                 return;
 
-              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
+                _Url;
 
-              if (d._type == "function") {
+              if (d._type == 'function') {
                 // Get the existing function parameters available from sqlite database
-                var _Url = url_for('debugger.get_arguments', {
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.function._id
-                           });
-              }
-              else if (d._type == "procedure") {
+                _Url = url_for('debugger.get_arguments', {
+                  'sid': treeInfo.server._id,
+                  'did': treeInfo.database._id,
+                  'scid': treeInfo.schema._id,
+                  'func_id': treeInfo.function._id,
+                });
+              } else if (d._type == 'procedure') {
                 // Get the existing function parameters available from sqlite database
-                var _Url = url_for('debugger.get_arguments', {
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.procedure._id
-                           });
-              }
-              else if (d._type == "edbfunc") {
+                _Url = url_for('debugger.get_arguments', {
+                  'sid': treeInfo.server._id,
+                  'did': treeInfo.database._id,
+                  'scid': treeInfo.schema._id,
+                  'func_id': treeInfo.procedure._id,
+                });
+              } else if (d._type == 'edbfunc') {
                 // Get the existing function parameters available from sqlite database
-                var _Url = url_for('debugger.get_arguments', {
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.edbfunc._id
-                           });
-              }
-              else if (d._type == "edbproc") {
+                _Url = url_for('debugger.get_arguments', {
+                  'sid': treeInfo.server._id,
+                  'did': treeInfo.database._id,
+                  'scid': treeInfo.schema._id,
+                  'func_id': treeInfo.edbfunc._id,
+                });
+              } else if (d._type == 'edbproc') {
                 // Get the existing function parameters available from sqlite database
-                var _Url = url_for('debugger.get_arguments', {
-                            'sid': treeInfo.server._id,
-                            'did': treeInfo.database._id,
-                            'scid': treeInfo.schema._id,
-                            'func_id': treeInfo.edbproc._id
-                           });
+                _Url = url_for('debugger.get_arguments', {
+                  'sid': treeInfo.server._id,
+                  'did': treeInfo.database._id,
+                  'scid': treeInfo.schema._id,
+                  'func_id': treeInfo.edbproc._id,
+                });
               }
-            }
-            else {
+            } else {
               // Get the existing function parameters available from sqlite database
-              var _Url = url_for('debugger.get_arguments', {
-                          'sid': this.data.server_id,
-                          'did': this.data.database_id,
-                          'scid': this.data.schema_id,
-                          'func_id': this.data.function_id
-                         });
+              _Url = url_for('debugger.get_arguments', {
+                'sid': this.data.server_id,
+                'did': this.data.database_id,
+                'scid': this.data.schema_id,
+                'func_id': this.data.function_id,
+              });
             }
             $.ajax({
               url: _Url,
@@ -204,112 +200,160 @@ define([
                       'is_null': res.data.result[i]['is_null'],
                       'is_expression': res.data.result[i]['is_expression'],
                       'use_default': res.data.result[i]['use_default'],
-                      'value': res.data.result[i]['value']
+                      'value': res.data.result[i]['value'],
                     });
                   }
                 }
               },
-              error: function(e) {
+              error: function() {
                 Alertify.alert(
                   gettext('Debugger Error'),
                   gettext('Unable to fetch the arguments from server')
                 );
-              }
+              },
             });
 
             var argname, argtype, argmode, default_args_count, default_args, arg_cnt;
 
             var value_header = Backgrid.HeaderCell.extend({
-                // Add fixed width to the "value" column
-                className: 'width_percent_25'
+              // Add fixed width to the "value" column
+              className: 'width_percent_25',
             });
 
             var def_val_list = [],
-            gridCols = [
-              {name: 'name', label: gettext('Name'), type:'text', editable: false, cell:'string' },
-              {name: 'type', label: gettext('Type'), type: 'text', editable: false, cell:'string' },
-              {name: 'is_null', label: gettext('Null?'), type: 'boolean', cell: 'boolean' },
-              {name: 'expr', label: gettext('Expression?'), type: 'boolean', cellFunction: cellExprControlFunction, editable: disableExpressionControl },
-              {name: 'value', label: gettext('Value'), type: 'text', editable: true, cellFunction: cellFunction, headerCell: value_header },
-              {name: 'use_default', label: gettext('Use Default?'), type: 'boolean', cell:"boolean", editable: disableDefaultCell },
-              {name: 'default_value', label: gettext('Default value'), type: 'text', editable: false, cell:'string' }
-            ];
+              gridCols = [{
+                name: 'name',
+                label: gettext('Name'),
+                type: 'text',
+                editable: false,
+                cell: 'string',
+              },
+              {
+                name: 'type',
+                label: gettext('Type'),
+                type: 'text',
+                editable: false,
+                cell: 'string',
+              },
+              {
+                name: 'is_null',
+                label: gettext('Null?'),
+                type: 'boolean',
+                cell: 'boolean',
+              },
+              {
+                name: 'expr',
+                label: gettext('Expression?'),
+                type: 'boolean',
+                cellFunction: cellExprControlFunction,
+                editable: disableExpressionControl,
+              },
+              {
+                name: 'value',
+                label: gettext('Value'),
+                type: 'text',
+                editable: true,
+                cellFunction: cellFunction,
+                headerCell: value_header,
+              },
+              {
+                name: 'use_default',
+                label: gettext('Use Default?'),
+                type: 'boolean',
+                cell: 'boolean',
+                editable: disableDefaultCell,
+              },
+              {
+                name: 'default_value',
+                label: gettext('Default value'),
+                type: 'text',
+                editable: false,
+                cell: 'string',
+              },
+              ];
 
             var my_obj = [];
             var func_obj = [];
 
             // Below will calculate the input argument id required to store in sqlite database
-            var input_arg_id = this.input_arg_id = [];
+            var input_arg_id = this.input_arg_id = [],
+              k;
             if (this.data['proargmodes'] != null) {
-              var argmode_1 = this.data['proargmodes'].split(",");
-              for (var k = 0; k < argmode_1.length; k++) {
+              var argmode_1 = this.data['proargmodes'].split(',');
+              for (k = 0; k < argmode_1.length; k++) {
                 if (argmode_1[k] == 'i' || argmode_1[k] == 'b') {
-                  input_arg_id.push(k)
+                  input_arg_id.push(k);
                 }
               }
-            }
-            else {
-              var argtype_1 = this.data['proargtypenames'].split(",");
-              for (var k = 0; k < argtype_1.length; k++) {
-                  input_arg_id.push(k)
+            } else {
+              var argtype_1 = this.data['proargtypenames'].split(',');
+              for (k = 0; k < argtype_1.length; k++) {
+                input_arg_id.push(k);
               }
             }
 
-            argtype = this.data['proargtypenames'].split(",");
+            argtype = this.data['proargtypenames'].split(',');
 
             if (this.data['proargmodes'] != null) {
-                argmode = this.data['proargmodes'].split(",");
+              argmode = this.data['proargmodes'].split(',');
             }
 
             if (this.data['pronargdefaults']) {
               default_args_count = this.data['pronargdefaults'];
-              default_args = this.data['proargdefaults'].split(",");
+              default_args = this.data['proargdefaults'].split(',');
               arg_cnt = default_args_count;
             }
 
+            var vals, values, index, use_def_value, j;
+
             if (this.data['proargnames'] != null) {
-              argname = this.data['proargnames'].split(",");
+              argname = this.data['proargnames'].split(',');
 
               // It will assign default values to "Default value" column
-              for (var j = (argname.length - 1); j >= 0; j--) {
+              for (j = (argname.length - 1); j >= 0; j--) {
                 if (this.data['proargmodes'] != null) {
                   if (arg_cnt && (argmode[j] == 'i' || argmode[j] == 'b')) {
                     arg_cnt = arg_cnt - 1;
-                    def_val_list[j] = default_args[arg_cnt]
-                  }
-                  else {
-                    def_val_list[j] = "<No default value>";
+                    def_val_list[j] = default_args[arg_cnt];
+                  } else {
+                    def_val_list[j] = '<No default value>';
                   }
-                }
-                else {
+                } else {
                   if (arg_cnt) {
                     arg_cnt = arg_cnt - 1;
-                    def_val_list[j] = default_args[arg_cnt]
-                  }
-                  else {
-                    def_val_list[j] = "<No default value>";
+                    def_val_list[j] = default_args[arg_cnt];
+                  } else {
+                    def_val_list[j] = '<No default value>';
                   }
                 }
               }
 
-              if (argtype.length != 0)
-              {
+              if (argtype.length != 0) {
                 for (i = 0; i < argtype.length; i++) {
                   if (this.data['proargmodes'] != null) {
                     if (argmode[i] == 'i' || argmode[i] == 'b') {
-                      var use_def_value = false
-                      if (def_val_list[i] != "<No default value>") {
+                      use_def_value = false;
+                      if (def_val_list[i] != '<No default value>') {
                         use_def_value = true;
                       }
-                      my_obj.push({ "name": argname[i], "type": argtype[i], "use_default": use_def_value, "default_value": def_val_list[i]});
+                      my_obj.push({
+                        'name': argname[i],
+                        'type': argtype[i],
+                        'use_default': use_def_value,
+                        'default_value': def_val_list[i],
+                      });
                     }
-                  }
-                  else {
-                    var use_def_value = false
-                    if (def_val_list[i] != "<No default value>") {
+                  } else {
+                    use_def_value = false;
+                    if (def_val_list[i] != '<No default value>') {
                       use_def_value = true;
                     }
-                    my_obj.push({ "name": argname[i], "type": argtype[i], "use_default": use_def_value, "default_value": def_val_list[i]});
+                    my_obj.push({
+                      'name': argname[i],
+                      'type': argtype[i],
+                      'use_default': use_def_value,
+                      'default_value': def_val_list[i],
+                    });
                   }
 
 
@@ -319,27 +363,38 @@ define([
               // Need to update the func_obj variable from sqlite database if available
               if (func_args_data.length != 0) {
                 for (i = 0; i < func_args_data.length; i++) {
-                  var index = func_args_data[i]['arg_id'];
-                  var values = [];
-                  if (argtype[index].indexOf("[]") !=-1) {
-                      var vals = func_args_data[i]['value'].split(",");
-                      if (argtype[index].indexOf("integer") != -1) {
-                        _.each(vals, function(val){
-                            values.push({'value': parseInt(val)});
-                        });
-                      }
-                      _.each(vals, function(val){
-                            values.push({'value': val});
+                  index = func_args_data[i]['arg_id'];
+                  values = [];
+                  if (argtype[index].indexOf('[]') != -1) {
+                    vals = func_args_data[i]['value'].split(',');
+                    if (argtype[index].indexOf('integer') != -1) {
+                      _.each(vals, function(val) {
+                        values.push({
+                          'value': parseInt(val),
                         });
+                      });
+                    }
+                    _.each(vals, function(val) {
+                      values.push({
+                        'value': val,
+                      });
+                    });
                   } else {
                     values = func_args_data[i]['value'];
                   }
 
-                  func_obj.push({ "name": argname[index], "type": argtype[index], "is_null": func_args_data[i]['is_null'] ? true: false, "expr": func_args_data[i]['is_expression']? true: false, "value": values, "use_default": func_args_data[i]['use_default']? true: false, "default_value": def_val_list[index]});
+                  func_obj.push({
+                    'name': argname[index],
+                    'type': argtype[index],
+                    'is_null': func_args_data[i]['is_null'] ? true : false,
+                    'expr': func_args_data[i]['is_expression'] ? true : false,
+                    'value': values,
+                    'use_default': func_args_data[i]['use_default'] ? true : false,
+                    'default_value': def_val_list[index],
+                  });
                 }
               }
-            }
-            else {
+            } else {
               /*
                Generate the name parameter if function do not have arguments name
                like dbgparam1, dbgparam2 etc.
@@ -347,55 +402,65 @@ define([
               var myargname = [];
 
               for (i = 0; i < argtype.length; i++) {
-                myargname[i] = "dbgparam" + (i+1);
+                myargname[i] = 'dbgparam' + (i + 1);
               }
 
               // If there is no default arguments
               if (!this.data['pronargdefaults']) {
                 for (i = 0; i < argtype.length; i++) {
-                  my_obj.push({ "name": myargname[i], "type": argtype[i], "use_default": false, "default_value": "<No default value>"});
-                  def_val_list[i] = "<No default value>";
+                  my_obj.push({
+                    'name': myargname[i],
+                    'type': argtype[i],
+                    'use_default': false,
+                    'default_value': '<No default value>',
+                  });
+                  def_val_list[i] = '<No default value>';
                 }
-              }
-              else {
+              } else {
                 // If there is default arguments
                 //Below logic will assign default values to "Default value" column
-                for (var j = (myargname.length - 1);j >= 0; j--) {
+                for (j = (myargname.length - 1); j >= 0; j--) {
                   if (this.data['proargmodes'] == null) {
                     if (arg_cnt) {
                       arg_cnt = arg_cnt - 1;
-                      def_val_list[j] = default_args[arg_cnt]
-                    }
-                    else {
-                      def_val_list[j] = "<No default value>";
+                      def_val_list[j] = default_args[arg_cnt];
+                    } else {
+                      def_val_list[j] = '<No default value>';
                     }
-                  }
-                  else {
+                  } else {
                     if (arg_cnt && (argmode[j] == 'i' || argmode[j] == 'b')) {
                       arg_cnt = arg_cnt - 1;
-                      def_val_list[j] = default_args[arg_cnt]
-                    }
-                    else {
-                      def_val_list[j] = "<No default value>";
+                      def_val_list[j] = default_args[arg_cnt];
+                    } else {
+                      def_val_list[j] = '<No default value>';
                     }
                   }
                 }
 
                 for (i = 0; i < argtype.length; i++) {
                   if (this.data['proargmodes'] == null) {
-                    var use_def_value = false
-                    if (def_val_list[i] != "<No default value>") {
+                    use_def_value = false;
+                    if (def_val_list[i] != '<No default value>') {
                       use_def_value = true;
                     }
-                    my_obj.push({ "name": myargname[i], "type": argtype[i], "use_default": use_def_value, "default_value": def_val_list[i]});
-                  }
-                  else {
+                    my_obj.push({
+                      'name': myargname[i],
+                      'type': argtype[i],
+                      'use_default': use_def_value,
+                      'default_value': def_val_list[i],
+                    });
+                  } else {
                     if (argmode[i] == 'i' || argmode[i] == 'b') {
-                      var use_def_value = false
-                      if (def_val_list[i] != "<No default value>") {
+                      use_def_value = false;
+                      if (def_val_list[i] != '<No default value>') {
                         use_def_value = true;
                       }
-                      my_obj.push({ "name": myargname[i], "type": argtype[i], "use_default": use_def_value, "default_value": def_val_list[i]});
+                      my_obj.push({
+                        'name': myargname[i],
+                        'type': argtype[i],
+                        'use_default': use_def_value,
+                        'default_value': def_val_list[i],
+                      });
                     }
                   }
                 }
@@ -404,43 +469,56 @@ define([
               // Need to update the func_obj variable from sqlite database if available
               if (func_args_data.length != 0) {
                 for (i = 0; i < func_args_data.length; i++) {
-                  var index = func_args_data[i]['arg_id'];
-                  var values = [];
-                  if (argtype[index].indexOf("[]") !=-1) {
-                      var vals = func_args_data[i]['value'].split(",");
-                      if (argtype[index].indexOf("integer") != -1) {
-                        _.each(vals, function(val){
-                            values.push({'value': parseInt(val)});
-                        });
-                      }
-                      _.each(vals, function(val){
-                            values.push({'value': val});
+                  index = func_args_data[i]['arg_id'];
+                  values = [];
+                  if (argtype[index].indexOf('[]') != -1) {
+                    vals = func_args_data[i]['value'].split(',');
+                    if (argtype[index].indexOf('integer') != -1) {
+                      _.each(vals, function(val) {
+                        values.push({
+                          'value': parseInt(val),
                         });
+                      });
+                    }
+                    _.each(vals, function(val) {
+                      values.push({
+                        'value': val,
+                      });
+                    });
                   } else {
                     values = func_args_data[i]['value'];
                   }
-                  func_obj.push({ "name": myargname[index], "type": argtype[index], "is_null": func_args_data[i]['is_null'] ? true: false, "expr": func_args_data[i]['is_expression']? true: false, "value": values, "use_default": func_args_data[i]['use_default']? true: false, "default_value": def_val_list[index]});
+                  func_obj.push({
+                    'name': myargname[index],
+                    'type': argtype[index],
+                    'is_null': func_args_data[i]['is_null'] ? true : false,
+                    'expr': func_args_data[i]['is_expression'] ? true : false,
+                    'value': values,
+                    'use_default': func_args_data[i]['use_default'] ? true : false,
+                    'default_value': def_val_list[index],
+                  });
                 }
               }
             }
 
             // Check if the arguments already available in the sqlite database then we should use the existing arguments
             if (func_args_data.length == 0) {
-              var debuggerInputArgsColl = this.debuggerInputArgsColl = new DebuggerInputArgCollections(my_obj);
-            }
-            else {
-              var debuggerInputArgsColl = this.debuggerInputArgsColl = new DebuggerInputArgCollections(func_obj);
+              this.debuggerInputArgsColl =
+                new DebuggerInputArgCollections(my_obj);
+            } else {
+              this.debuggerInputArgsColl =
+                new DebuggerInputArgCollections(func_obj);
             }
 
             // Initialize a new Grid instance
             if (this.grid) {
-                this.grid.remove();
-                this.grid = null;
+              this.grid.remove();
+              this.grid = null;
             }
             var grid = this.grid = new Backgrid.Grid({
               columns: gridCols,
-              collection: debuggerInputArgsColl,
-              className: "backgrid table-bordered"
+              collection: this.debuggerInputArgsColl,
+              className: 'backgrid table-bordered',
             });
 
             grid.render();
@@ -449,36 +527,43 @@ define([
             // For keyboard navigation in the grid
             // we'll set focus on checkbox from the first row if any
             var grid_checkbox = $(grid.el).find('input:checkbox').first();
-            if (grid_checkbox.length){
+            if (grid_checkbox.length) {
               setTimeout(function() {
                 grid_checkbox.click();
               }, 250);
             }
 
           },
-          setup:function() {
+          setup: function() {
             return {
-              buttons:[
-                { text: "Debug", key: 13, className: "btn btn-primary" },
-                { text: "Cancel", key: 27, className: "btn btn-primary" }
+              buttons: [{
+                text: 'Debug',
+                key: 13,
+                className: 'btn btn-primary',
+              },
+              {
+                text: 'Cancel',
+                key: 27,
+                className: 'btn btn-primary',
+              },
               ],
               // Set options for dialog
               options: {
                 //disable both padding and overflow control.
-                padding : !1,
+                padding: !1,
                 overflow: !1,
                 model: 0,
                 resizable: true,
                 maximizable: true,
                 pinnable: false,
                 closableByDimmer: false,
-                modal: false
-              }
+                modal: false,
+              },
             };
           },
           // Callback functions when click on the buttons of the Alertify dialogs
           callback: function(e) {
-            if (e.button.text === "Debug") {
+            if (e.button.text === 'Debug') {
 
               // Initialize the target once the debug button is clicked and
               // create asynchronous connection and unique transaction ID
@@ -503,193 +588,199 @@ define([
 
               this.grid.collection.each(function(m) {
 
-                  // Check if value is set to NULL then we should ignore the value field
-                  if (m.get('is_null')) {
-                    args_value_list.push({ 'name': m.get('name'),
-                                       'type': m.get('type'),
-                                       'value': 'NULL'});
-                  }
-                  else {
-                    // Check if default value to be used or not
-                    if (m.get('use_default')) {
-                      args_value_list.push({ 'name': m.get('name'),
-                                       'type': m.get('type'),
-                                       'value': m.get('default_value')});
-                    }
-                    else {
-                      args_value_list.push({ 'name': m.get('name'),
-                                       'type': m.get('type'),
-                                       'value': m.get('value')});
-                    }
-                  }
-
-                  if (self.restart_debug == 0) {
-                    var f_id;
-                    if (d._type == "function") {
-                      f_id = treeInfo.function._id;
-                    }
-                    else if (d._type == "procedure") {
-                      f_id = treeInfo.procedure._id;
-                    }
-                    else if (d._type == "edbfunc") {
-                      f_id = treeInfo.edbfunc._id;
-                    }
-                    else if (d._type == "edbproc") {
-                      f_id = treeInfo.edbproc._id;
-                    }
-
-                    // Below will format the data to be stored in sqlite database
-                    sqlite_func_args_list.push({
-                      'server_id': treeInfo.server._id,
-                      'database_id': treeInfo.database._id,
-                      'schema_id': treeInfo.schema._id ,
-                      'function_id': f_id,
-                      'arg_id': self.input_arg_id[int_count],
-                      'is_null': m.get('is_null')  ? 1 : 0,
-                      'is_expression': m.get('expr') ? 1 : 0,
-                      'use_default': m.get('use_default') ? 1 : 0,
-                      'value': m.get('value')
+                // Check if value is set to NULL then we should ignore the value field
+                if (m.get('is_null')) {
+                  args_value_list.push({
+                    'name': m.get('name'),
+                    'type': m.get('type'),
+                    'value': 'NULL',
+                  });
+                } else {
+                  // Check if default value to be used or not
+                  if (m.get('use_default')) {
+                    args_value_list.push({
+                      'name': m.get('name'),
+                      'type': m.get('type'),
+                      'value': m.get('default_value'),
                     });
-                  }
-                  else {
-                    // Below will format the data to be stored in sqlite database
-                    sqlite_func_args_list.push({
-                      'server_id': self.data.server_id,
-                      'database_id': self.data.database_id,
-                      'schema_id': self.data.schema_id ,
-                      'function_id': self.data.function_id,
-                      'arg_id': self.input_arg_id[int_count],
-                      'is_null': m.get('is_null')  ? 1 : 0,
-                      'is_expression': m.get('expr') ? 1 : 0,
-                      'use_default': m.get('use_default') ? 1 : 0,
-                      'value': m.get('value')
+                  } else {
+                    args_value_list.push({
+                      'name': m.get('name'),
+                      'type': m.get('type'),
+                      'value': m.get('value'),
                     });
                   }
+                }
+
+                if (self.restart_debug == 0) {
+                  var f_id;
+                  if (d._type == 'function') {
+                    f_id = treeInfo.function._id;
+                  } else if (d._type == 'procedure') {
+                    f_id = treeInfo.procedure._id;
+                  } else if (d._type == 'edbfunc') {
+                    f_id = treeInfo.edbfunc._id;
+                  } else if (d._type == 'edbproc') {
+                    f_id = treeInfo.edbproc._id;
+                  }
+
+                  // Below will format the data to be stored in sqlite database
+                  sqlite_func_args_list.push({
+                    'server_id': treeInfo.server._id,
+                    'database_id': treeInfo.database._id,
+                    'schema_id': treeInfo.schema._id,
+                    'function_id': f_id,
+                    'arg_id': self.input_arg_id[int_count],
+                    'is_null': m.get('is_null') ? 1 : 0,
+                    'is_expression': m.get('expr') ? 1 : 0,
+                    'use_default': m.get('use_default') ? 1 : 0,
+                    'value': m.get('value'),
+                  });
+                } else {
+                  // Below will format the data to be stored in sqlite database
+                  sqlite_func_args_list.push({
+                    'server_id': self.data.server_id,
+                    'database_id': self.data.database_id,
+                    'schema_id': self.data.schema_id,
+                    'function_id': self.data.function_id,
+                    'arg_id': self.input_arg_id[int_count],
+                    'is_null': m.get('is_null') ? 1 : 0,
+                    'is_expression': m.get('expr') ? 1 : 0,
+                    'use_default': m.get('use_default') ? 1 : 0,
+                    'value': m.get('value'),
+                  });
+                }
 
-                  int_count = int_count + 1;
+                int_count = int_count + 1;
               });
 
+              var baseUrl;
+
               // If debugging is not started again then we should initialize the target otherwise not
               if (self.restart_debug == 0) {
-                var baseUrl;
-                if (d._type == "function") {
+                if (d._type == 'function') {
                   baseUrl = url_for('debugger.initialize_target_for_function', {
-                                  'debug_type': 'direct',
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.function._id
-                                });
-                }
-                else if (d._type == "procedure") {
+                    'debug_type': 'direct',
+                    'sid': treeInfo.server._id,
+                    'did': treeInfo.database._id,
+                    'scid': treeInfo.schema._id,
+                    'func_id': treeInfo.function._id,
+                  });
+                } else if (d._type == 'procedure') {
                   baseUrl = url_for('debugger.initialize_target_for_function', {
-                                  'debug_type': 'direct',
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.procedure._id
-                                });
-                }
-                else if (d._type == "edbfunc") {
+                    'debug_type': 'direct',
+                    'sid': treeInfo.server._id,
+                    'did': treeInfo.database._id,
+                    'scid': treeInfo.schema._id,
+                    'func_id': treeInfo.procedure._id,
+                  });
+                } else if (d._type == 'edbfunc') {
                   baseUrl = url_for('debugger.initialize_target_for_function', {
-                                  'debug_type': 'direct',
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.edbfunc._id
-                                });
-                }
-                else if (d._type == "edbproc") {
+                    'debug_type': 'direct',
+                    'sid': treeInfo.server._id,
+                    'did': treeInfo.database._id,
+                    'scid': treeInfo.schema._id,
+                    'func_id': treeInfo.edbfunc._id,
+                  });
+                } else if (d._type == 'edbproc') {
                   baseUrl = url_for('debugger.initialize_target_for_function', {
-                                  'debug_type': 'direct',
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.edbproc._id
-                                });
+                    'debug_type': 'direct',
+                    'sid': treeInfo.server._id,
+                    'did': treeInfo.database._id,
+                    'scid': treeInfo.schema._id,
+                    'func_id': treeInfo.edbproc._id,
+                  });
                 }
 
                 $.ajax({
                   url: baseUrl,
                   method: 'POST',
-                  data:{'data':JSON.stringify(args_value_list)},
+                  data: {
+                    'data': JSON.stringify(args_value_list),
+                  },
                   success: function(res) {
 
-                    var url = url_for('debugger.direct', {'trans_id': res.data.debuggerTransId});
+                    var url = url_for(
+                      'debugger.direct', {
+                        'trans_id': res.data.debuggerTransId,
+                      }
+                    );
 
                     if (res.data.newBrowserTab) {
                       window.open(url, '_blank');
                     } else {
                       pgBrowser.Events.once(
-                        'pgadmin-browser:frame:urlloaded:frm_debugger', function(frame) {
-                        frame.openURL(url);
-                      });
+                        'pgadmin-browser:frame:urlloaded:frm_debugger',
+                        function(frame) {
+                          frame.openURL(url);
+                        });
 
                       // Create the debugger panel as per the data received from user input dialog.
                       var dashboardPanel = pgBrowser.docker.findPanels('properties'),
-                          panel = pgBrowser.docker.addPanel(
-                            'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
-                          );
+                        panel = pgBrowser.docker.addPanel(
+                          'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
+                        );
 
                       panel.focus();
 
                       // Panel Closed event
                       panel.on(wcDocker.EVENT.CLOSED, function() {
-                        var closeUrl = url_for('debugger.close', {'trans_id': res.data.debuggerTransId});
+                        var closeUrl = url_for('debugger.close', {
+                          'trans_id': res.data.debuggerTransId,
+                        });
                         $.ajax({
                           url: closeUrl,
-                          method: 'DELETE'
+                          method: 'DELETE',
                         });
                       });
                     }
-
-                    if (d._type == "function") {
-                      var _Url = url_for('debugger.set_arguments', {
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.function._id,
-                                 });
-                    }
-                    else if (d._type == "procedure") {
-                      var _Url = url_for('debugger.set_arguments', {
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.procedure._id,
-                                 });
-                    }
-                    else if (d._type == "edbfunc") {
+                    var _Url;
+
+                    if (d._type == 'function') {
+                      _Url = url_for('debugger.set_arguments', {
+                        'sid': treeInfo.server._id,
+                        'did': treeInfo.database._id,
+                        'scid': treeInfo.schema._id,
+                        'func_id': treeInfo.function._id,
+                      });
+                    } else if (d._type == 'procedure') {
+                      _Url = url_for('debugger.set_arguments', {
+                        'sid': treeInfo.server._id,
+                        'did': treeInfo.database._id,
+                        'scid': treeInfo.schema._id,
+                        'func_id': treeInfo.procedure._id,
+                      });
+                    } else if (d._type == 'edbfunc') {
                       // Get the existing function parameters available from sqlite database
-                      var _Url = url_for('debugger.set_arguments', {
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.edbfunc._id,
-                                 });
-                    }
-                    else if (d._type == "edbproc") {
+                      _Url = url_for('debugger.set_arguments', {
+                        'sid': treeInfo.server._id,
+                        'did': treeInfo.database._id,
+                        'scid': treeInfo.schema._id,
+                        'func_id': treeInfo.edbfunc._id,
+                      });
+                    } else if (d._type == 'edbproc') {
                       // Get the existing function parameters available from sqlite database
-                      var _Url = url_for('debugger.set_arguments', {
-                                  'sid': treeInfo.server._id,
-                                  'did': treeInfo.database._id,
-                                  'scid': treeInfo.schema._id,
-                                  'func_id': treeInfo.edbproc._id,
-                                 });
+                      _Url = url_for('debugger.set_arguments', {
+                        'sid': treeInfo.server._id,
+                        'did': treeInfo.database._id,
+                        'scid': treeInfo.schema._id,
+                        'func_id': treeInfo.edbproc._id,
+                      });
                     }
 
                     $.ajax({
                       url: _Url,
                       method: 'POST',
-                      data:{'data':JSON.stringify(sqlite_func_args_list)},
-                      success: function(res) {
+                      data: {
+                        'data': JSON.stringify(sqlite_func_args_list),
                       },
-                      error: function(e) {
+                      success: function() {},
+                      error: function() {
                         Alertify.alert(
                           gettext('Debugger Error'),
                           gettext('Unable to set the arguments on the server')
                         );
-                      }
+                      },
                     });
                   },
                   error: function(e) {
@@ -697,46 +788,49 @@ define([
                       gettext('Debugger Target Initialization Error'),
                       e.responseJSON.errormsg
                     );
-                  }
+                  },
                 });
-              }
-              else {
+              } else {
                 // If the debugging is started again then we should only set the arguments and start the listener again
-                var baseUrl = url_for('debugger.start_listener', {'trans_id': self.data.trans_id});
+                baseUrl = url_for('debugger.start_listener', {
+                  'trans_id': self.data.trans_id,
+                });
 
                 $.ajax({
                   url: baseUrl,
                   method: 'POST',
-                  data:{'data':JSON.stringify(args_value_list)},
-                  success: function(res) {
+                  data: {
+                    'data': JSON.stringify(args_value_list),
                   },
+                  success: function() {},
                   error: function(e) {
                     Alertify.alert(
                       gettext('Debugger Listener Startup Error'),
                       e.responseJSON.errormsg
                     );
-                  }
+                  },
                 });
 
                 // Set the new input arguments given by the user during debugging
                 var _Url = url_for('debugger.set_arguments', {
-                            'sid': self.data.server_id,
-                            'did': self.data.database_id,
-                            'scid': self.data.schema_id,
-                            'func_id': self.data.function_id
-                           });
+                  'sid': self.data.server_id,
+                  'did': self.data.database_id,
+                  'scid': self.data.schema_id,
+                  'func_id': self.data.function_id,
+                });
                 $.ajax({
                   url: _Url,
                   method: 'POST',
-                  data:{'data':JSON.stringify(sqlite_func_args_list)},
-                  success: function(res) {
+                  data: {
+                    'data': JSON.stringify(sqlite_func_args_list),
                   },
-                  error: function(e) {
+                  success: function() {},
+                  error: function() {
                     Alertify.alert(
                       gettext('Debugger Error'),
                       gettext('Unable to set the arguments on the server')
                     );
-                  }
+                  },
                 });
 
               }
@@ -744,15 +838,15 @@ define([
               return true;
             }
 
-            if (e.button.text === "Cancel") {
+            if (e.button.text === 'Cancel') {
               //close the dialog...
               return false;
             }
           },
-          build:function() {
+          build: function() {
             Alertify.pgDialogBuild.apply(this);
           },
-          prepare:function() {
+          prepare: function() {
             // Add our class to alertify
             $(this.elements.body.childNodes[0]).addClass(
               'alertify_tools_dialog_properties obj_properties'
@@ -764,8 +858,7 @@ define([
             */
             if (this.func_args_data.length == 0) {
               this.__internal.buttons[0].element.disabled = true;
-            }
-            else {
+            } else {
               this.__internal.buttons[0].element.disabled = false;
             }
 
@@ -773,45 +866,42 @@ define([
              Listen to the grid change event so that if any value changed by user then we can enable/disable the
              debug button.
             */
-            this.grid.listenTo(this.debuggerInputArgsColl,"backgrid:edited",
+            this.grid.listenTo(this.debuggerInputArgsColl, 'backgrid:edited',
               (function(obj) {
 
                 return function() {
 
-                  var self = this;
                   var enable_btn = false;
 
-                  for (var    i = 0; i < this.collection.length; i++ ) {
+                  for (var i = 0; i < this.collection.length; i++) {
 
                     // TODO: Need to check the "NULL" and "Expression" column value to enable/disable the "Debug" button
-                    if (this.collection.models[i].get('value') == "" ||
-                        this.collection.models[i].get('value') == null ||
-                        this.collection.models[i].get('value') == undefined) {
-                          enable_btn = true;
-
-                          if (this.collection.models[i].get('use_default')) {
-                            obj.__internal.buttons[0].element.disabled = false;
-                          }
-                          else{
-                            obj.__internal.buttons[0].element.disabled = true;
-                            break;
-                          }
+                    if (this.collection.models[i].get('value') == '' ||
+                      this.collection.models[i].get('value') == null ||
+                      this.collection.models[i].get('value') == undefined) {
+                      enable_btn = true;
+
+                      if (this.collection.models[i].get('use_default')) {
+                        obj.__internal.buttons[0].element.disabled = false;
+                      } else {
+                        obj.__internal.buttons[0].element.disabled = true;
+                        break;
+                      }
                     }
                   }
                   if (!enable_btn)
                     obj.__internal.buttons[0].element.disabled = false;
-                }
-              }
-              )(this)
+                };
+              })(this)
             );
-          }
+          },
         };
       });
     }
 
-    Alertify.debuggerInputArgsDialog('Debugger',args, restart_debug).resizeTo('60%', '60%');
+    Alertify.debuggerInputArgsDialog('Debugger', args, restart_debug).resizeTo('60%', '60%');
 
   };
 
   return res;
-});
+});
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/static/js/direct.js b/web/pgadmin/tools/debugger/static/js/direct.js
index 2085654a..d0dbad79 100644
--- a/web/pgadmin/tools/debugger/static/js/direct.js
+++ b/web/pgadmin/tools/debugger/static/js/direct.js
@@ -1,15 +1,16 @@
 define([
-  'sources/gettext', 'sources/url_for' ,'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
-  'sources/pgadmin','pgadmin.browser', 'backbone', 'backgrid', 'sources/../bundle/codemirror', 'backform',
-  'pgadmin.tools.debugger.ui',
-  'wcdocker', 'pgadmin.backform',
-  'pgadmin.backgrid'
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
+  'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
+  'pgadmin.backgrid', 'pgadmin.backform', 'sources/../bundle/codemirror',
+  'pgadmin.tools.debugger.ui', 'wcdocker',
 ], function(
-  gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
-  codemirror, Backform, debug_function_again
+  gettext, url_for, $, _, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
+  Backform, codemirror, debug_function_again
 ) {
 
-  var CodeMirror = codemirror.default;
+  var CodeMirror = codemirror.default,
+    wcDocker = window.wcDocker;
+
   if (pgAdmin.Browser.tree != null) {
     pgAdmin = pgAdmin || window.pgAdmin || {};
   }
@@ -19,7 +20,7 @@ define([
   if (pgTools.DirectDebug)
     return pgTools.DirectDebug;
 
-  var controller = new (function() {});
+  var controller = new(function() {});
 
   _.extend(
     controller, Backbone.Events, {
@@ -33,14 +34,12 @@ define([
         trans_id :- Unique Transaction ID, line_no - line no. to set the breakpoint, set_type = 0 - clear , 1 - set
       */
       set_breakpoint: function(trans_id, line_no, set_type) {
-        var self = this;
-
         // Make ajax call to set/clear the break point by user
         var baseUrl = url_for('debugger.set_breakpoint', {
-                        'trans_id': trans_id,
-                        'line_no': line_no,
-                        'set_type': set_type
-                      });
+          'trans_id': trans_id,
+          'line_no': line_no,
+          'set_type': set_type,
+        });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -49,12 +48,12 @@ define([
               // Breakpoint has been set by the user
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while setting debugging breakpoint.')
             );
-          }
+          },
         });
       },
 
@@ -72,22 +71,21 @@ define([
 
         for (var i = 0; i < br_list.length; i++) {
           if (br_list[i].linenumber != -1) {
-            breakpoint_list.push(br_list[i].linenumber)
+            breakpoint_list.push(br_list[i].linenumber);
           }
         }
 
-        for (var i = 0;i< breakpoint_list.length;i++) {
+        for (i = 0; i < breakpoint_list.length; i++) {
           var info = pgTools.DirectDebug.editor.lineInfo((breakpoint_list[i] - 1));
 
           if (info.gutterMarkers != undefined) {
-            pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), "breakpoints", null);
-          }
-          else {
-            pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), "breakpoints", function() {
-            var marker = document.createElement("div");
-            marker.style.color = "#822";
-            marker.innerHTML = "●";
-            return marker;
+            pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', null);
+          } else {
+            pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', function() {
+              var marker = document.createElement('div');
+              marker.style.color = '#822';
+              marker.innerHTML = '●';
+              return marker;
             }());
           }
         }
@@ -95,14 +93,13 @@ define([
 
       // Function to get the breakpoint information from the server
       GetBreakpointInformation: function(trans_id) {
-        var self = this;
         var result = '';
 
         // Make ajax call to listen the database message
         var baseUrl = url_for('debugger.execute_query', {
-                        'trans_id': trans_id,
-                        'query_type': 'get_breakpoints'
-                      });
+          'trans_id': trans_id,
+          'query_type': 'get_breakpoints',
+        });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -110,20 +107,19 @@ define([
           success: function(res) {
             if (res.data.status === 'Success') {
               result = res.data.result;
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while fetching breakpoint information.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while fetching breakpoint information.')
             );
-          }
+          },
         });
 
         return result;
@@ -134,10 +130,10 @@ define([
         var self = this;
         // Make ajax call to listen the database message
         var baseUrl = url_for(
-                        'debugger.start_execution', {
-                          'trans_id': trans_id,
-                          'port_num': port_num
-                      });
+          'debugger.start_execution', {
+            'trans_id': trans_id,
+            'port_num': port_num,
+          });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -145,20 +141,19 @@ define([
             if (res.data.status === 'Success') {
               // If status is Success then find the port number to attach the executer.
               self.execute_query(trans_id);
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while starting debugging session.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while starting debugging session.')
             );
-          }
+          },
         });
       },
 
@@ -167,20 +162,26 @@ define([
         var self = this;
         // Make ajax call to listen the database message
         var baseUrl = url_for(
-                        'debugger.execute_query', {
-                          'trans_id': trans_id,
-                          'query_type': 'wait_for_breakpoint'
-                      });
+          'debugger.execute_query', {
+            'trans_id': trans_id,
+            'query_type': 'wait_for_breakpoint',
+          });
         $.ajax({
           url: baseUrl,
           method: 'GET',
           success: function(res) {
             if (res.data.status === 'Success') {
               // set the return code to the code editor text area
-              if (res.data.result[0].src != null && res.data.result[0].linenumber != null) {
+              if (
+                res.data.result[0].src != null &&
+                res.data.result[0].linenumber != null
+              ) {
                 pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-                var active_line_no = self.active_line_no = (res.data.result[0].linenumber - 2);
-                pgTools.DirectDebug.editor.addLineClass((res.data.result[0].linenumber - 2), 'wrap', 'CodeMirror-activeline-background');
+                self.active_line_no = (res.data.result[0].linenumber - 2);
+                pgTools.DirectDebug.editor.addLineClass(
+                  (res.data.result[0].linenumber - 2), 'wrap',
+                  'CodeMirror-activeline-background'
+                );
               }
 
               // Call function to create and update local variables ....
@@ -188,20 +189,19 @@ define([
               if (pgTools.DirectDebug.debug_type) {
                 self.poll_end_execution_result(trans_id);
               }
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while executing requested debugging information.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing requested debugging information.')
             );
-          }
+          },
         });
       },
 
@@ -211,10 +211,10 @@ define([
 
         // Make ajax call to listen the database message
         var baseUrl = url_for(
-                        'debugger.execute_query', {
-                          'trans_id': trans_id,
-                          'query_type': 'get_variables'
-                      });
+          'debugger.execute_query', {
+            'trans_id': trans_id,
+            'query_type': 'get_variables',
+          });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -230,20 +230,19 @@ define([
                 }
                 pgTools.DirectDebug.debug_restarted = false;
               }
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while fetching variable information.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while fetching variable information.')
             );
-          }
+          },
         });
       },
 
@@ -253,10 +252,10 @@ define([
 
         // Make ajax call to listen the database message
         var baseUrl = url_for(
-                        'debugger.execute_query', {
-                          'trans_id': trans_id,
-                          'query_type': 'get_stack_info'
-                      });
+          'debugger.execute_query', {
+            'trans_id': trans_id,
+            'query_type': 'get_stack_info',
+          });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -265,20 +264,19 @@ define([
               // Call function to create and update stack information
               self.AddStackInformation(res.data.result);
               self.GetLocalVariables(pgTools.DirectDebug.trans_id);
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while fetching stack information.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while fetching stack information.')
             );
-          }
+          },
         });
       },
 
@@ -287,430 +285,430 @@ define([
         other updated information from the server.
       */
       poll_result: function(trans_id) {
-      var self = this;
-
-      // Do we need to poll?
-      if(!pgTools.DirectDebug.is_polling_required){
-        return;
-      }
-
-      // Make ajax call to listen the database message
-      var baseUrl = url_for('debugger.poll_result', {'trans_id': trans_id});
-
-      /*
-        During the execution we should poll the result in minimum seconds but once the execution is completed
-        and wait for the another debugging session then we should decrease the polling frequency.
-      */
-      if (pgTools.DirectDebug.polling_timeout_idle) {
-        // poll the result after 1 second
-        var  poll_timeout = 1000;
-      }
-      else {
-        // poll the result after 200 ms
-        var  poll_timeout = 200;
-      }
+        var self = this;
 
-      setTimeout(
-        function() {
-        $.ajax({
-          url: baseUrl,
-          method: 'GET',
-          beforeSend: function(jqXHR, settings) {
-            // set cursor to progress before every poll.
-            $('.debugger-container').addClass('show_progress');
-          },
-          success: function(res) {
-            // remove progress cursor
-            $('.debugger-container').removeClass('show_progress');
+        // Do we need to poll?
+        if (!pgTools.DirectDebug.is_polling_required) {
+          return;
+        }
 
-            if (res.data.status === 'Success') {
-              // If no result then poll again to wait for results.
-              if (res.data.result == null || res.data.result.length == 0) {
-                self.poll_result(trans_id);
-              }
-              else {
-                if (res.data.result[0].src != undefined || res.data.result[0].src != null) {
-                pgTools.DirectDebug.polling_timeout_idle = false;
-                pgTools.DirectDebug.docker.finishLoading(50);
-                pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-                self.UpdateBreakpoint(trans_id);
-                pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
-                pgTools.DirectDebug.editor.addLineClass((res.data.result[0].linenumber - 2), 'wrap', 'CodeMirror-activeline-background');
-                self.active_line_no = (res.data.result[0].linenumber - 2);
+        // Make ajax call to listen the database message
+        var baseUrl = url_for('debugger.poll_result', {
+            'trans_id': trans_id,
+          }),
+          poll_timeout;
+
+        /*
+          During the execution we should poll the result in minimum seconds but once the execution is completed
+          and wait for the another debugging session then we should decrease the polling frequency.
+        */
+        if (pgTools.DirectDebug.polling_timeout_idle) {
+          // Poll the result after 1 second
+          poll_timeout = 1000;
+        } else {
+          // Poll the result after 200 ms
+          poll_timeout = 200;
+        }
 
-                // Update the stack, local variables and parameters information
-                self.GetStackInformation(trans_id);
+        setTimeout(
+          function() {
+            $.ajax({
+              url: baseUrl,
+              method: 'GET',
+              beforeSend: function() {
+                // set cursor to progress before every poll.
+                $('.debugger-container').addClass('show_progress');
+              },
+              success: function(res) {
+                // remove progress cursor
+                $('.debugger-container').removeClass('show_progress');
 
-                }
-                else if (!pgTools.DirectDebug.debug_type && !pgTools.DirectDebug.first_time_indirect_debug) {
-                  pgTools.DirectDebug.docker.finishLoading(50);
-                  if (self.active_line_no != undefined) {
-                    pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
+                if (res.data.status === 'Success') {
+                  // If no result then poll again to wait for results.
+                  if (res.data.result == null || res.data.result.length == 0) {
+                    self.poll_result(trans_id);
+                  } else {
+                    if (res.data.result[0].src != undefined || res.data.result[0].src != null) {
+                      pgTools.DirectDebug.polling_timeout_idle = false;
+                      pgTools.DirectDebug.docker.finishLoading(50);
+                      pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
+                      self.UpdateBreakpoint(trans_id);
+                      pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
+                      pgTools.DirectDebug.editor.addLineClass((res.data.result[0].linenumber - 2), 'wrap', 'CodeMirror-activeline-background');
+                      self.active_line_no = (res.data.result[0].linenumber - 2);
+
+                      // Update the stack, local variables and parameters information
+                      self.GetStackInformation(trans_id);
+
+                    } else if (!pgTools.DirectDebug.debug_type && !pgTools.DirectDebug.first_time_indirect_debug) {
+                      pgTools.DirectDebug.docker.finishLoading(50);
+                      if (self.active_line_no != undefined) {
+                        pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
+                      }
+                      self.clear_all_breakpoint(trans_id);
+                      self.execute_query(trans_id);
+                      pgTools.DirectDebug.first_time_indirect_debug = true;
+                      pgTools.DirectDebug.polling_timeout_idle = false;
+                    } else {
+                      pgTools.DirectDebug.polling_timeout_idle = false;
+                      pgTools.DirectDebug.docker.finishLoading(50);
+                      // If the source is really changed then only update the breakpoint information
+                      if (res.data.result[0].src != pgTools.DirectDebug.editor.getValue()) {
+                        pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
+                        self.UpdateBreakpoint(trans_id);
+                      }
+
+                      pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
+                      pgTools.DirectDebug.editor.addLineClass((res.data.result[0].linenumber - 2), 'wrap', 'CodeMirror-activeline-background');
+                      self.active_line_no = (res.data.result[0].linenumber - 2);
+
+                      // Update the stack, local variables and parameters information
+                      self.GetStackInformation(trans_id);
+                    }
+
+                    // Enable all the buttons as we got the results
+                    self.enable('stop', true);
+                    self.enable('step_over', true);
+                    self.enable('step_into', true);
+                    self.enable('continue', true);
+                    self.enable('toggle_breakpoint', true);
+                    self.enable('clear_all_breakpoints', true);
                   }
-                  self.clear_all_breakpoint(trans_id);
-                  self.execute_query(trans_id);
-                  pgTools.DirectDebug.first_time_indirect_debug = true;
-                  pgTools.DirectDebug.polling_timeout_idle = false;
-                }
-                else {
-                  pgTools.DirectDebug.polling_timeout_idle = false;
-                  pgTools.DirectDebug.docker.finishLoading(50);
-                  // If the source is really changed then only update the breakpoint information
-                  if (res.data.result[0].src != pgTools.DirectDebug.editor.getValue()) {
-                    pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-                    self.UpdateBreakpoint(trans_id);
+                } else if (res.data.status === 'Busy') {
+                  pgTools.DirectDebug.polling_timeout_idle = true;
+                  // If status is Busy then poll the result by recursive call to the poll function
+                  if (!pgTools.DirectDebug.debug_type) {
+                    pgTools.DirectDebug.docker.startLoading(gettext('Waiting for another session to invoke the target...'));
+
+                    // As we are waiting for another session to invoke the target,disable all the buttons
+                    self.enable('stop', false);
+                    self.enable('step_over', false);
+                    self.enable('step_into', false);
+                    self.enable('continue', false);
+                    self.enable('toggle_breakpoint', false);
+                    self.enable('clear_all_breakpoints', false);
+                    pgTools.DirectDebug.first_time_indirect_debug = false;
+                    self.poll_result(trans_id);
+                  } else {
+                    self.poll_result(trans_id);
                   }
-
-                  pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
-                  pgTools.DirectDebug.editor.addLineClass((res.data.result[0].linenumber - 2), 'wrap', 'CodeMirror-activeline-background');
-                  self.active_line_no = (res.data.result[0].linenumber - 2);
-
-                  // Update the stack, local variables and parameters information
-                  self.GetStackInformation(trans_id);
+                } else if (res.data.status === 'NotConnected') {
+                  Alertify.alert(
+                    gettext('Debugger Error'),
+                    gettext('Error while polling result.')
+                  );
                 }
+              },
+              error: function() {
+                Alertify.alert(
+                  gettext('Debugger Error'),
+                  gettext('Error while polling result.')
+                );
+              },
+            });
+          }, poll_timeout);
 
-                // Enable all the buttons as we got the results
-                self.enable('stop', true);
-                self.enable('step_over', true);
-                self.enable('step_into', true);
-                self.enable('continue', true);
-                self.enable('toggle_breakpoint', true);
-                self.enable('clear_all_breakpoints', true);
-              }
-            }
-            else if (res.data.status === 'Busy') {
-              pgTools.DirectDebug.polling_timeout_idle = true;
-              // If status is Busy then poll the result by recursive call to the poll function
-              if (!pgTools.DirectDebug.debug_type) {
-                pgTools.DirectDebug.docker.startLoading(gettext('Waiting for another session to invoke the target...'));
-
-                // As we are waiting for another session to invoke the target,disable all the buttons
-                self.enable('stop', false);
-                self.enable('step_over', false);
-                self.enable('step_into', false);
-                self.enable('continue', false);
-                self.enable('toggle_breakpoint', false);
-                self.enable('clear_all_breakpoints', false);
-                pgTools.DirectDebug.first_time_indirect_debug = false;
-                self.poll_result(trans_id);
-              }
-              else {
-                self.poll_result(trans_id);
-              }
-            }
-            else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while polling result.')
-              );
-            }
-          },
-          error: function(e) {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while polling result.')
-            );
-          }
-        });
-      }, poll_timeout );
-
-    },
+      },
 
-    // This function will update messages tab
-    update_messages: function(msg) {
-      // To prevent xss
-      msg = _.escape(msg);
+      // This function will update messages tab
+      update_messages: function(msg) {
+        // To prevent xss
+        msg = _.escape(msg);
 
-      var old_msgs='', new_msgs='';
+        var old_msgs = '',
+          new_msgs = '';
         old_msgs = pgTools.DirectDebug.messages_panel.$container.find('.messages').html();
-        if(old_msgs) {
+        if (old_msgs) {
           new_msgs = (old_msgs + '\n' + msg)
-                        .replace(/(?:\r\n|\r|\n)/g, '<br />') // Newlines with <br>
-                        .replace(/(<br\ ?\/?>)+/g, '<br />'); // multiple <br> with single <br>
+            .replace(/(?:\r\n|\r|\n)/g, '<br />') // Newlines with <br>
+            .replace(/(<br\ ?\/?>)+/g, '<br />'); // multiple <br> with single <br>
         } else {
           new_msgs = msg;
         }
         pgTools.DirectDebug.messages_panel.$container.find('.messages').html(new_msgs);
-    },
-
-    /*
-      For the direct debugging, we need to check weather the functions execution is completed or not. After completion
-      of the debugging, we will stop polling the result  until new execution starts.
-    */
-    poll_end_execution_result: function(trans_id) {
-      var self = this;
-
-      // Do we need to poll?
-      if(!pgTools.DirectDebug.is_polling_required){
-        return;
-      }
-
-      // Make ajax call to listen the database message
-      var baseUrl = url_for('debugger.poll_end_execution_result', {'trans_id': trans_id});
+      },
 
       /*
-        During the execution we should poll the result in minimum seconds but once the execution is completed
-        and wait for the another debugging session then we should decrease the polling frequency.
+        For the direct debugging, we need to check weather the functions execution is completed or not. After completion
+        of the debugging, we will stop polling the result  until new execution starts.
       */
-      if (pgTools.DirectDebug.polling_timeout_idle) {
-        // poll the result to check that execution is completed or not after 1200 ms
-        var  poll_end_timeout = 1200;
-      }
-      else {
-        // poll the result to check that execution is completed or not after 350 ms
-        var  poll_end_timeout = 250;
-      }
+      poll_end_execution_result: function(trans_id) {
+        var self = this;
 
-      setTimeout(
-        function() {
-          $.ajax({
-          url: baseUrl,
-          method: 'GET',
-          success: function(res) {
-            if (res.data.status === 'Success') {
-              if(res.data.result == undefined ) {
-                /*
-                 "result" is undefined only in case of EDB procedure. As Once the EDB procedure execution is completed
-                 then we are not getting any result so we need ignore the result.
-                */
-                pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
-                pgTools.DirectDebug.direct_execution_completed = true;
-                pgTools.DirectDebug.polling_timeout_idle = true;
-
-                //Set the alertify message to inform the user that execution is completed.
-                Alertify.success(res.info, 3);
-
-                // Update the message tab of the debugger
-                if (res.data.status_message) {
-                  self.update_messages(res.data.status_message);
-                }
+        // Do we need to poll?
+        if (!pgTools.DirectDebug.is_polling_required) {
+          return;
+        }
 
-                // remove progress cursor
-                $('.debugger-container').removeClass('show_progress');
+        // Make ajax call to listen the database message
+        var baseUrl = url_for('debugger.poll_end_execution_result', {
+            'trans_id': trans_id,
+          }),
+          poll_end_timeout;
+
+        /*
+         * During the execution we should poll the result in minimum seconds
+         * but once the execution is completed and wait for the another
+         * debugging session then we should decrease the polling frequency.
+         */
+        if (pgTools.DirectDebug.polling_timeout_idle) {
+          // Poll the result to check that execution is completed or not
+          // after 1200 ms
+          poll_end_timeout = 1200;
+        } else {
+          // Poll the result to check that execution is completed or not
+          // after 350 ms
+          poll_end_timeout = 250;
+        }
 
-                // Execution completed so disable the buttons other than "Continue/Start" button because user can still
-                // start the same execution again.
-                self.enable('stop', false);
-                self.enable('step_over', false);
-                self.enable('step_into', false);
-                self.enable('toggle_breakpoint', false);
-                self.enable('clear_all_breakpoints', false);
-                self.enable('continue', true);
-                // Stop further polling
-                pgTools.DirectDebug.is_polling_required = false;
-              }
-              else {
-                // Call function to create and update local variables ....
-                if (res.data.result != null) {
-                  pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
-                  self.AddResults(res.data.col_info, res.data.result);
-                  pgTools.DirectDebug.results_panel.focus();
+        setTimeout(
+          function() {
+            $.ajax({
+              url: baseUrl,
+              method: 'GET',
+              success: function(res) {
+                if (res.data.status === 'Success') {
+                  if (res.data.result == undefined) {
+                    /*
+                     "result" is undefined only in case of EDB procedure. As Once the EDB procedure execution is completed
+                     then we are not getting any result so we need ignore the result.
+                    */
+                    pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
+                    pgTools.DirectDebug.direct_execution_completed = true;
+                    pgTools.DirectDebug.polling_timeout_idle = true;
+
+                    //Set the alertify message to inform the user that execution is completed.
+                    Alertify.success(res.info, 3);
+
+                    // Update the message tab of the debugger
+                    if (res.data.status_message) {
+                      self.update_messages(res.data.status_message);
+                    }
+
+                    // remove progress cursor
+                    $('.debugger-container').removeClass('show_progress');
+
+                    // Execution completed so disable the buttons other than "Continue/Start" button because user can still
+                    // start the same execution again.
+                    self.enable('stop', false);
+                    self.enable('step_over', false);
+                    self.enable('step_into', false);
+                    self.enable('toggle_breakpoint', false);
+                    self.enable('clear_all_breakpoints', false);
+                    self.enable('continue', true);
+                    // Stop further polling
+                    pgTools.DirectDebug.is_polling_required = false;
+                  } else {
+                    // Call function to create and update local variables ....
+                    if (res.data.result != null) {
+                      pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
+                      self.AddResults(res.data.col_info, res.data.result);
+                      pgTools.DirectDebug.results_panel.focus();
+                      pgTools.DirectDebug.direct_execution_completed = true;
+                      pgTools.DirectDebug.polling_timeout_idle = true;
+
+                      //Set the alertify message to inform the user that execution is completed.
+                      Alertify.success(res.info, 3);
+
+                      // Update the message tab of the debugger
+                      if (res.data.status_message) {
+                        self.update_messages(res.data.status_message);
+                      }
+
+                      // remove progress cursor
+                      $('.debugger-container').removeClass('show_progress');
+
+                      // Execution completed so disable the buttons other than "Continue/Start" button because user can still
+                      // start the same execution again.
+                      self.enable('stop', false);
+                      self.enable('step_over', false);
+                      self.enable('step_into', false);
+                      self.enable('toggle_breakpoint', false);
+                      self.enable('clear_all_breakpoints', false);
+                      self.enable('continue', true);
+
+                      // Stop further pooling
+                      pgTools.DirectDebug.is_polling_required = false;
+                    }
+                  }
+                } else if (res.data.status === 'Busy') {
+                  // If status is Busy then poll the result by recursive call to the poll function
+                  self.poll_end_execution_result(trans_id);
+                  // Update the message tab of the debugger
+                  if (res.data.status_message) {
+                    self.update_messages(res.data.status_message);
+                  }
+                } else if (res.data.status === 'NotConnected') {
+                  Alertify.alert(
+                    gettext('Debugger poll end execution error'),
+                    res.data.result
+                  );
+                } else if (res.data.status === 'ERROR') {
                   pgTools.DirectDebug.direct_execution_completed = true;
-                  pgTools.DirectDebug.polling_timeout_idle = true;
+                  pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
 
-                  //Set the alertify message to inform the user that execution is completed.
-                  Alertify.success(res.info, 3);
+                  //Set the Alertify message to inform the user that execution is completed with error.
+                  if (!pgTools.DirectDebug.is_user_aborted_debugging) {
+                    Alertify.error(res.info, 3);
+                  }
 
                   // Update the message tab of the debugger
                   if (res.data.status_message) {
                     self.update_messages(res.data.status_message);
                   }
 
+                  pgTools.DirectDebug.messages_panel.focus();
+
                   // remove progress cursor
                   $('.debugger-container').removeClass('show_progress');
 
-                  // Execution completed so disable the buttons other than "Continue/Start" button because user can still
-                  // start the same execution again.
+                  // Execution completed so disable the buttons other than
+                  // "Continue/Start" button because user can still start the
+                  // same execution again.
                   self.enable('stop', false);
                   self.enable('step_over', false);
                   self.enable('step_into', false);
                   self.enable('toggle_breakpoint', false);
                   self.enable('clear_all_breakpoints', false);
-                  self.enable('continue', true);
+                  // If debugging is stopped by user then do not enable
+                  // continue/restart button
+                  if (!pgTools.DirectDebug.is_user_aborted_debugging) {
+                    self.enable('continue', true);
+                    pgTools.DirectDebug.is_user_aborted_debugging = false;
+                  }
 
                   // Stop further pooling
                   pgTools.DirectDebug.is_polling_required = false;
                 }
-              }
-            }
-            else if (res.data.status === 'Busy') {
-              // If status is Busy then poll the result by recursive call to the poll function
-              self.poll_end_execution_result(trans_id);
-              // Update the message tab of the debugger
-              if (res.data.status_message) {
-                self.update_messages(res.data.status_message);
-              }
-            }
-            else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger poll end execution error'),
-                res.data.result
-              );
-            }
-            else if (res.data.status === 'ERROR') {
-              pgTools.DirectDebug.direct_execution_completed = true;
-              pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
-
-              //Set the Alertify message to inform the user that execution is completed with error.
-              if(!pgTools.DirectDebug.is_user_aborted_debugging) {
-                Alertify.error(res.info, 3);
-              }
-
-              // Update the message tab of the debugger
-              if (res.data.status_message) {
-                self.update_messages(res.data.status_message);
-              }
-
-              pgTools.DirectDebug.messages_panel.focus();
-
-              // remove progress cursor
-              $('.debugger-container').removeClass('show_progress');
-
-              // Execution completed so disable the buttons other than
-              // "Continue/Start" button because user can still start the
-              // same execution again.
-              self.enable('stop', false);
-              self.enable('step_over', false);
-              self.enable('step_into', false);
-              self.enable('toggle_breakpoint', false);
-              self.enable('clear_all_breakpoints', false);
-              // If debugging is stopped by user then do not enable
-              // continue/restart button
-              if(!pgTools.DirectDebug.is_user_aborted_debugging)
-              {
-                self.enable('continue', true);
-                pgTools.DirectDebug.is_user_aborted_debugging = false;
-              }
+              },
+              error: function() {
+                Alertify.alert(
+                  gettext('Debugger Error'),
+                  gettext('Error while polling result.')
+                );
+              },
+            });
+          }, poll_end_timeout);
 
-              // Stop further pooling
-              pgTools.DirectDebug.is_polling_required = false;
-            }
-          },
-          error: function(e) {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while polling result.')
-            );
-          }
-        });
-      }, poll_end_timeout);
+      },
 
-    },
+      Restart: function(trans_id) {
 
-    Restart: function(trans_id) {
+        var self = this,
+          baseUrl = url_for('debugger.restart', {
+            'trans_id': trans_id,
+          });
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
 
-      var self = this,
-        baseUrl = url_for('debugger.restart', {'trans_id': trans_id});
-      self.enable('stop', false);
-      self.enable('step_over', false);
-      self.enable('step_into', false);
-      self.enable('toggle_breakpoint', false);
-      self.enable('clear_all_breakpoints', false);
-      self.enable('continue', false);
+        // Clear msg tab
+        pgTools.DirectDebug.messages_panel.$container.find('.messages').html('');
 
-      // Clear msg tab
-      pgTools.DirectDebug.messages_panel.$container.find('.messages').html('');
+        $.ajax({
+          url: baseUrl,
+          success: function(res) {
+            // Restart the same function debugging with previous arguments
+            var restart_dbg = res.data.restart_debug ? 1 : 0;
 
-      $.ajax({
-        url: baseUrl,
-        success: function(res) {
-          // Restart the same function debugging with previous arguments
-          var restart_dbg = res.data.restart_debug ? 1 : 0;
+            // Start pooling again
+            pgTools.DirectDebug.polling_timeout_idle = false;
+            pgTools.DirectDebug.is_polling_required = true;
+            self.poll_end_execution_result(trans_id);
+            self.poll_result(trans_id);
 
-          // Start pooling again
-          pgTools.DirectDebug.polling_timeout_idle = false;
-          pgTools.DirectDebug.is_polling_required = true;
-          self.poll_end_execution_result(trans_id);
-          self.poll_result(trans_id);
+            if (restart_dbg) {
+              pgTools.DirectDebug.debug_restarted = true;
+            }
 
-          if (restart_dbg) {
-            pgTools.DirectDebug.debug_restarted = true;
-          }
+            /*
+             Need to check if restart debugging really require to open the input dialog ?
+             If yes then we will get the previous arguments from database and populate the input dialog
+             If no then we should directly start the listener.
+            */
+            if (res.data.result.require_input) {
+              debug_function_again(res.data.result, restart_dbg);
+            } else {
+              // Debugging of void function is started again so we need to start the listener again
+              var baseUrl = url_for('debugger.start_listener', {
+                'trans_id': trans_id,
+              });
+
+              $.ajax({
+                url: baseUrl,
+                method: 'GET',
+                success: function() {
+                  if (pgTools.DirectDebug.debug_type) {
+                    self.poll_end_execution_result(trans_id);
+                  }
+                },
+                error: function() {
+                  Alertify.alert(
+                    gettext('Debugger Error'),
+                    gettext('Error while polling result.')
+                  );
+                },
+              });
+            }
+          },
+          error: function(xhr) {
+            try {
+              var err = $.parseJSON(xhr.responseText);
+              if (err.success == 0) {
+                Alertify.alert(gettext('Debugger Error'), err.errormsg);
+              }
+            } catch (e) {
+              console.warn(e.stack || e);
+            }
+          },
+        });
+      },
 
-          /*
-           Need to check if restart debugging really require to open the input dialog ?
-           If yes then we will get the previous arguments from database and populate the input dialog
-           If no then we should directly start the listener.
-          */
-          if (res.data.result.require_input) {
-            var res_val = debug_function_again(res.data.result, restart_dbg);
-          }
-          else {
-            // Debugging of void function is started again so we need to start the listener again
-            var baseUrl = url_for('debugger.start_listener', {'trans_id': trans_id});
+      // Continue the execution until the next breakpoint
+      Continue: function(trans_id) {
+        var self = this;
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
 
-            $.ajax({
-              url: baseUrl,
-              method: 'GET',
-              success: function(res) {
-                if (pgTools.DirectDebug.debug_type) {
-                  self.poll_end_execution_result(trans_id);
-                }
-              },
-              error: function(e) {
+        //Check first if previous execution was completed or not
+        if (pgTools.DirectDebug.direct_execution_completed &&
+          pgTools.DirectDebug.direct_execution_completed == pgTools.DirectDebug.polling_timeout_idle) {
+          self.Restart(trans_id);
+        } else {
+          // Make ajax call to listen the database message
+          var baseUrl = url_for('debugger.execute_query', {
+            'trans_id': trans_id,
+            'query_type': 'continue',
+          });
+          $.ajax({
+            url: baseUrl,
+            method: 'GET',
+            success: function(res) {
+              if (res.data.status) {
+                self.poll_result(trans_id);
+              } else {
                 Alertify.alert(
                   gettext('Debugger Error'),
-                  gettext('Error while polling result.')
+                  gettext('Error while executing continue in debugging session.')
                 );
               }
-            });
-          }
-        },
-        error: function(xhr, status, error) {
-          try {
-            var err = $.parseJSON(xhr.responseText);
-            if (err.success == 0) {
-              Alertify.alert(gettext('Debugger Error'), err.errormsg);
-            }
-          } catch (e) {}
-        }
-      });
-    },
-
-    // Continue the execution until the next breakpoint
-    Continue: function(trans_id) {
-      var self = this;
-      self.enable('stop', false);
-      self.enable('step_over', false);
-      self.enable('step_into', false);
-      self.enable('toggle_breakpoint', false);
-      self.enable('clear_all_breakpoints', false);
-      self.enable('continue', false);
-
-      //Check first if previous execution was completed or not
-      if (pgTools.DirectDebug.direct_execution_completed &&
-          pgTools.DirectDebug.direct_execution_completed == pgTools.DirectDebug.polling_timeout_idle) {
-        self.Restart(trans_id);
-      }
-      else {
-        // Make ajax call to listen the database message
-        var baseUrl = url_for('debugger.execute_query', {
-                        'trans_id': trans_id,
-                        'query_type': 'continue'
-                      });
-        $.ajax({
-          url: baseUrl,
-          method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              self.poll_result(trans_id);
-            }
-            else {
+            },
+            error: function() {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while executing continue in debugging session.')
               );
-            }
-          },
-          error: function(e) {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while executing continue in debugging session.')
-            );
-          }
-        });
-      }
-    },
+            },
+          });
+        }
+      },
 
       Step_over: function(trans_id) {
         var self = this;
@@ -723,29 +721,28 @@ define([
 
         // Make ajax call to listen the database message
         var baseUrl = url_for('debugger.execute_query', {
-                        'trans_id': trans_id,
-                        'query_type': 'step_over'
-                      });
+          'trans_id': trans_id,
+          'query_type': 'step_over',
+        });
         $.ajax({
           url: baseUrl,
           method: 'GET',
           success: function(res) {
             if (res.data.status) {
               self.poll_result(trans_id);
-            }
-            else {
+            } else {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while executing step over in debugging session.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing step over in debugging session.')
             );
-          }
+          },
         });
       },
 
@@ -760,29 +757,28 @@ define([
 
         // Make ajax call to listen the database message
         var baseUrl = url_for('debugger.execute_query', {
-                        'trans_id': trans_id,
-                        'query_type': 'step_into'
-                      });
+          'trans_id': trans_id,
+          'query_type': 'step_into',
+        });
         $.ajax({
           url: baseUrl,
           method: 'GET',
           success: function(res) {
             if (res.data.status) {
               self.poll_result(trans_id);
-            }
-            else {
+            } else {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while executing step into in debugging session.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing step into in debugging session.')
             );
-          }
+          },
         });
       },
 
@@ -797,10 +793,10 @@ define([
 
         // Make ajax call to listen the database message
         var baseUrl = url_for(
-                        'debugger.execute_query', {
-                          'trans_id': trans_id,
-                          'query_type': 'abort_target'
-                      });
+          'debugger.execute_query', {
+            'trans_id': trans_id,
+            'query_type': 'abort_target',
+          });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -821,20 +817,19 @@ define([
               // Set the Alertify message to inform the user that execution
               // is completed.
               Alertify.success(res.info, 3);
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while executing stop in debugging session.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing stop in debugging session.')
             );
-          }
+          },
         });
       },
 
@@ -854,18 +849,17 @@ define([
         // If gutterMarker is undefined that means there is no marker defined previously
         // So we need to set the breakpoint command here...
         if (info.gutterMarkers == undefined) {
-            baseUrl = url_for('debugger.set_breakpoint', {
-                        'trans_id': trans_id,
-                        'line_no': self.active_line_no + 1,
-                        'set_type': '1'
-                      });
-        }
-        else {
-            baseUrl = url_for('debugger.set_breakpoint', {
-                        'trans_id': trans_id,
-                        'line_no': self.active_line_no + 1,
-                        'set_type': '0'
-                      });
+          baseUrl = url_for('debugger.set_breakpoint', {
+            'trans_id': trans_id,
+            'line_no': self.active_line_no + 1,
+            'set_type': '1',
+          });
+        } else {
+          baseUrl = url_for('debugger.set_breakpoint', {
+            'trans_id': trans_id,
+            'line_no': self.active_line_no + 1,
+            'set_type': '0',
+          });
         }
 
         $.ajax({
@@ -877,14 +871,13 @@ define([
               var info = pgTools.DirectDebug.editor.lineInfo(self.active_line_no);
 
               if (info.gutterMarkers != undefined) {
-                pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, "breakpoints", null);
-              }
-              else {
-                pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, "breakpoints", function() {
-                    var marker = document.createElement("div");
-                    marker.style.color = "#822";
-                    marker.innerHTML = "●";
-                    return marker;
+                pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, 'breakpoints', null);
+              } else {
+                pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, 'breakpoints', function() {
+                  var marker = document.createElement('div');
+                  marker.style.color = '#822';
+                  marker.innerHTML = '●';
+                  return marker;
                 }());
               }
               self.enable('stop', true);
@@ -893,20 +886,19 @@ define([
               self.enable('toggle_breakpoint', true);
               self.enable('clear_all_breakpoints', true);
               self.enable('continue', true);
-            }
-            else if (res.data.status === 'NotConnected') {
+            } else if (res.data.status === 'NotConnected') {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while toggling breakpoint.')
               );
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while toggling breakpoint.')
             );
-          }
+          },
         });
       },
 
@@ -929,17 +921,21 @@ define([
 
         for (var i = 0; i < br_list.length; i++) {
           if (br_list[i].linenumber != -1) {
-            breakpoint_list.push(br_list[i].linenumber)
+            breakpoint_list.push(br_list[i].linenumber);
           }
         }
 
         // Make ajax call to listen the database message
-        var baseUrl = url_for('debugger.clear_all_breakpoint', {'trans_id': trans_id});
+        var baseUrl = url_for('debugger.clear_all_breakpoint', {
+          'trans_id': trans_id,
+        });
 
         $.ajax({
           url: baseUrl,
           method: 'POST',
-          data: { 'breakpoint_list': breakpoint_list.join() },
+          data: {
+            'breakpoint_list': breakpoint_list.join(),
+          },
           success: function(res) {
             if (res.data.status) {
               for (var i = 0; i < breakpoint_list.length; i++) {
@@ -947,24 +943,24 @@ define([
 
                 if (info) {
                   if (info.gutterMarkers != undefined) {
-                    pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), "breakpoints", null);
+                    pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', null);
                   }
                 }
               }
             }
-          self.enable('stop', true);
-          self.enable('step_over', true);
-          self.enable('step_into', true);
-          self.enable('toggle_breakpoint', true);
-          self.enable('clear_all_breakpoints', true);
-          self.enable('continue', true);
+            self.enable('stop', true);
+            self.enable('step_over', true);
+            self.enable('step_into', true);
+            self.enable('toggle_breakpoint', true);
+            self.enable('clear_all_breakpoints', true);
+            self.enable('continue', true);
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while clearing all breakpoint.')
             );
-          }
+          },
         });
       },
 
@@ -973,8 +969,8 @@ define([
 
         // Remove the existing created grid and update the stack values
         if (self.stack_grid) {
-            self.stack_grid.remove();
-            self.stack_grid = null;
+          self.stack_grid.remove();
+          self.stack_grid = null;
         }
 
         var DebuggerStackModel = Backbone.Model.extend({
@@ -982,31 +978,45 @@ define([
             frame_id: 0,
             name: undefined,
             value: undefined,
-            line_no: undefined
-          }
+            line_no: undefined,
+          },
         });
 
         // Collection which contains the model for function informations.
         var StackCollection = Backbone.Collection.extend({
-          model: DebuggerStackModel
+          model: DebuggerStackModel,
         });
 
-        var stackGridCols = [
-          {name: 'name', label: gettext('Name'), type:'text',
-            editable: false, cell:'string'},
-          {name: 'value', label: gettext('Value'), type:'text',
-            editable: false, cell:'string'},
-          {name: 'line_no', label: gettext('Line No.'), type:'text',
-            editable: false, cell:'string'}
+        var stackGridCols = [{
+          name: 'name',
+          label: gettext('Name'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
+        {
+          name: 'value',
+          label: gettext('Value'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
+        {
+          name: 'line_no',
+          label: gettext('Line No.'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
         ];
 
         var my_obj = [];
         for (var i = 0; i < result.length; i++) {
           my_obj.push({
-            "frame_id": i,
-            "name": result[i].targetname,
-            "value": result[i].args,
-            "line_no": result[i].linenumber
+            'frame_id': i,
+            'name': result[i].targetname,
+            'value': result[i].args,
+            'line_no': result[i].linenumber,
           });
         }
 
@@ -1017,32 +1027,32 @@ define([
         var stack_grid = this.stack_grid = new Backgrid.Grid({
           columns: stackGridCols,
           row: Backgrid.Row.extend({
-            highlightColor: "#D9EDF7",
-            disabledColor: "#F1F1F1",
+            highlightColor: '#D9EDF7',
+            disabledColor: '#F1F1F1',
             events: {
-              click: "rowClick"
+              click: 'rowClick',
             },
-            rowClick: function(e) {
+            rowClick: function() {
               //Find which row is selected and depending on that send the frame id
               self.frame_id = this.model.get('frame_id');
               this.model.trigger('backgrid:row:selected', this);
-              self.stack_grid.$el.find("td").css(
-                "background-color", this.disabledColor
+              self.stack_grid.$el.find('td').css(
+                'background-color', this.disabledColor
               );
-              this.$el.find("td").css("background-color", this.highlightColor);
-            }
+              this.$el.find('td').css('background-color', this.highlightColor);
+            },
           }),
           collection: stackColl,
-          className: "backgrid table-bordered"
+          className: 'backgrid table-bordered',
         });
 
         stack_grid.render();
 
         // Render the stack grid into stack panel
         pgTools.DirectDebug.stack_pane_panel
-                           .$container
-                           .find('.stack_pane')
-                           .append(stack_grid.el);
+          .$container
+          .find('.stack_pane')
+          .append(stack_grid.el);
 
       },
 
@@ -1051,29 +1061,29 @@ define([
 
         // Remove the existing created grid and update the result values
         if (self.result_grid) {
-            self.result_grid.remove();
-            self.result_grid = null;
+          self.result_grid.remove();
+          self.result_grid = null;
         }
 
         var DebuggerResultsModel = Backbone.Model.extend({
           defaults: {
-            name: undefined
-          }
+            name: undefined,
+          },
         });
 
         // Collection which contains the model for function informations.
         var ResultsCollection = Backbone.Collection.extend({
-          model: DebuggerResultsModel
+          model: DebuggerResultsModel,
         });
 
         var resultGridCols = [];
-        if(_.size(columns)) {
+        if (_.size(columns)) {
           _.each(columns, function(c) {
             var column = {
-                            type:'text',
-                            editable: false,
-                            cell:'string'
-                         };
+              type: 'text',
+              editable: false,
+              cell: 'string',
+            };
             column['name'] = column['label'] = c.name;
             resultGridCols.push(column);
           });
@@ -1083,7 +1093,7 @@ define([
         var result_grid = this.result_grid = new Backgrid.Grid({
           columns: resultGridCols,
           collection: new ResultsCollection(result),
-          className: "backgrid table-bordered"
+          className: 'backgrid table-bordered',
         });
 
         result_grid.render();
@@ -1098,35 +1108,54 @@ define([
 
         // Remove the existing created grid and update the variables values
         if (self.variable_grid) {
-            self.variable_grid.remove();
-            self.variable_grid = null;
+          self.variable_grid.remove();
+          self.variable_grid = null;
         }
 
         var DebuggerVariablesModel = Backbone.Model.extend({
           defaults: {
             name: undefined,
             type: undefined,
-            value: undefined
-          }
+            value: undefined,
+          },
         });
 
         // Collection which contains the model for function informations.
         var VariablesCollection = Backbone.Collection.extend({
-          model: DebuggerVariablesModel
+          model: DebuggerVariablesModel,
         });
 
-        var gridCols = [
-          {name: 'name', label: gettext('Name'), type:'text', editable: false, cell:'string'},
-          {name: 'type', label: gettext('Type'), type: 'text', editable: false, cell:'string'},
-          {name: 'value', label: gettext('Value'), type: 'text', cell: 'string'}
+        var gridCols = [{
+          name: 'name',
+          label: gettext('Name'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
+        {
+          name: 'type',
+          label: gettext('Type'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
+        {
+          name: 'value',
+          label: gettext('Value'),
+          type: 'text',
+          cell: 'string',
+        },
         ];
 
         var my_obj = [];
-        if (result.length != 0)
-        {
+        if (result.length != 0) {
           for (var i = 0; i < result.length; i++) {
             if (result[i].varclass == 'L') {
-              my_obj.push({ "name": result[i].name, "type": result[i].dtype, "value": result[i].value});
+              my_obj.push({
+                'name': result[i].name,
+                'type': result[i].dtype,
+                'value': result[i].value,
+              });
             }
           }
         }
@@ -1135,7 +1164,7 @@ define([
         var variable_grid = this.variable_grid = new Backgrid.Grid({
           columns: gridCols,
           collection: new VariablesCollection(my_obj),
-          className: "backgrid table-bordered"
+          className: 'backgrid table-bordered',
         });
 
         variable_grid.render();
@@ -1150,37 +1179,56 @@ define([
 
         // Remove the existing created grid and update the parameter values
         if (self.param_grid) {
-            self.param_grid.remove();
-            self.param_grid = null;
+          self.param_grid.remove();
+          self.param_grid = null;
         }
 
         var DebuggerParametersModel = Backbone.Model.extend({
           defaults: {
             name: undefined,
             type: undefined,
-            value: undefined
-          }
+            value: undefined,
+          },
         });
 
         // Collection which contains the model for function informations.
         var ParametersCollection = self.ParametersCollection = Backbone.Collection.extend({
-          model: DebuggerParametersModel
+          model: DebuggerParametersModel,
         });
 
         self.ParametersCollection.prototype.on('change', self.deposit_parameter_value, self);
 
-        var paramGridCols = [
-          {name: 'name', label: gettext('Name'), type:'text', editable: false, cell:'string'},
-          {name: 'type', label: gettext('Type'), type: 'text', editable: false, cell:'string'},
-          {name: 'value', label: gettext('Value'), type: 'text', cell: 'string'}
+        var paramGridCols = [{
+          name: 'name',
+          label: gettext('Name'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
+        {
+          name: 'type',
+          label: gettext('Type'),
+          type: 'text',
+          editable: false,
+          cell: 'string',
+        },
+        {
+          name: 'value',
+          label: gettext('Value'),
+          type: 'text',
+          cell: 'string',
+        },
         ];
 
         var param_obj = [];
-        if (result.length != 0)
-        {
+        if (result.length != 0) {
           for (var i = 0; i < result.length; i++) {
             if (result[i].varclass == 'A') {
-              param_obj.push({ "name": result[i].name, "type": result[i].dtype, "value": result[i].value});
+              param_obj.push({
+                'name': result[i].name,
+                'type': result[i].dtype,
+                'value': result[i].value,
+              });
             }
           }
         }
@@ -1189,7 +1237,7 @@ define([
         var param_grid = this.param_grid = new Backgrid.Grid({
           columns: paramGridCols,
           collection: new ParametersCollection(param_obj),
-          className: "backgrid table-bordered"
+          className: 'backgrid table-bordered',
         });
 
         param_grid.render();
@@ -1204,16 +1252,22 @@ define([
         // variable name and value list that is changed by user
         var name_value_list = [];
 
-        name_value_list.push({ 'name': model.get('name'),'type': model.get('type'), 'value': model.get('value')});
+        name_value_list.push({
+          'name': model.get('name'),
+          'type': model.get('type'),
+          'value': model.get('value'),
+        });
 
         // Make ajax call to listen the database message
         var baseUrl = url_for('debugger.deposit_value', {
-                        'trans_id': pgTools.DirectDebug.trans_id
-                      });
+          'trans_id': pgTools.DirectDebug.trans_id,
+        });
         $.ajax({
           url: baseUrl,
           method: 'POST',
-          data:{'data':JSON.stringify(name_value_list)},
+          data: {
+            'data': JSON.stringify(name_value_list),
+          },
           success: function(res) {
             if (res.data.status) {
               // Get the updated variables value
@@ -1226,23 +1280,23 @@ define([
               }
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while depositing variable value.')
             );
-          }
+          },
         });
       },
 
-      select_frame: function(model, selected) {
+      select_frame: function() {
         var self = this;
 
         // Make ajax call to listen the database message
         var baseUrl = url_for('debugger.select_frame', {
-                        'trans_id': pgTools.DirectDebug.trans_id,
-                        'frame_id': self.frame_id
-                      });
+          'trans_id': pgTools.DirectDebug.trans_id,
+          'frame_id': self.frame_id,
+        });
         $.ajax({
           url: baseUrl,
           method: 'GET',
@@ -1250,23 +1304,27 @@ define([
             if (res.data.status) {
               pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
               self.UpdateBreakpoint(pgTools.DirectDebug.trans_id);
-              //active_line_no = self.active_line_no = (res.data.result[0].linenumber - 2);
-              pgTools.DirectDebug.editor.addLineClass((res.data.result[0].linenumber - 2), 'wrap', 'CodeMirror-activeline-background');
+              // active_line_no =
+              //   self.active_line_no = (res.data.result[0].linenumber - 2);
+              pgTools.DirectDebug.editor.addLineClass(
+                (res.data.result[0].linenumber - 2), 'wrap',
+                'CodeMirror-activeline-background'
+              );
 
               // Call function to create and update local variables ....
               self.GetLocalVariables(pgTools.DirectDebug.trans_id);
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while selecting frame.')
             );
-          }
+          },
         });
       },
     }
-  )
+  );
 
   /*
     Debugger tool var view to create the button toolbar and listen to the button click event and inform the
@@ -1283,12 +1341,12 @@ define([
       controller.on('pgDebugger:button:state:clear_all_breakpoints', this.enable_clear_all_breakpoints, this);
     },
     events: {
-        'click .btn-stop': 'on_stop',
-        'click .btn-clear-breakpoint': 'on_clear_all_breakpoint',
-        'click .btn-toggle-breakpoint': 'on_toggle_breakpoint',
-        'click .btn-continue': 'on_continue',
-        'click .btn-step-over': 'on_step_over',
-        'click .btn-step-into': 'on_step_into'
+      'click .btn-stop': 'on_stop',
+      'click .btn-clear-breakpoint': 'on_clear_all_breakpoint',
+      'click .btn-toggle-breakpoint': 'on_toggle_breakpoint',
+      'click .btn-continue': 'on_continue',
+      'click .btn-step-over': 'on_step_over',
+      'click .btn-step-into': 'on_step_into',
     },
     enable_stop: function(enable) {
       var $btn = this.$el.find('.btn-stop');
@@ -1392,7 +1450,9 @@ define([
       _.bindAll(pgTools.DirectDebug, 'messages');
 
       if (this.initialized)
-          return;
+        return;
+
+      var baseUrl;
 
       this.initialized = true;
       this.trans_id = trans_id;
@@ -1404,21 +1464,24 @@ define([
       this.is_user_aborted_debugging = false;
       this.is_polling_required = true; // Flag to stop unwanted ajax calls
 
-      var docker = this.docker = new wcDocker(
-          '#container', {
+      this.docker = new wcDocker(
+        '#container', {
           allowContextMenu: false,
           allowCollapse: false,
-          themePath: url_for('static', {'filename': 'css'}),
-          theme: 'webcabin.overrides.css'
+          themePath: url_for('static', {
+            'filename': 'css',
+          }),
+          theme: 'webcabin.overrides.css',
         });
-
       this.panels = [];
 
       // Below code will be executed for indirect debugging
       // indirect debugging - 0  and for direct debugging - 1
       if (trans_id != undefined && !debug_type) {
         // Make ajax call to execute the and start the target for execution
-        var baseUrl = url_for('debugger.start_listener', {'trans_id': trans_id });
+        baseUrl = url_for('debugger.start_listener', {
+          'trans_id': trans_id,
+        });
 
         $.ajax({
           url: baseUrl,
@@ -1429,18 +1492,18 @@ define([
               controller.poll_result(trans_id);
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while starting debugging listener.')
             );
-          }
+          },
         });
-      }
-      else if (trans_id != undefined && debug_type)
-      {
+      } else if (trans_id != undefined && debug_type) {
         // Make ajax call to execute the and start the target for execution
-        var baseUrl = url_for('debugger.start_listener', {'trans_id': trans_id });
+        baseUrl = url_for('debugger.start_listener', {
+          'trans_id': trans_id,
+        });
 
         $.ajax({
           url: baseUrl,
@@ -1450,15 +1513,14 @@ define([
               self.messages(trans_id);
             }
           },
-          error: function(e) {
+          error: function() {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while starting debugging listener.')
             );
-          }
+          },
         });
-      }
-      else
+      } else
         this.intializePanels();
     },
 
@@ -1466,7 +1528,9 @@ define([
     messages: function(trans_id) {
       var self = this;
       // Make ajax call to listen the database message
-      var baseUrl = url_for('debugger.messages', {'trans_id': trans_id });
+      var baseUrl = url_for('debugger.messages', {
+        'trans_id': trans_id,
+      });
 
       $.ajax({
         url: baseUrl,
@@ -1477,24 +1541,22 @@ define([
             // If status is Success then find the port number to attach the executer.
             //self.start_execution(trans_id, res.data.result);
             controller.start_execution(trans_id, res.data.result);
-          }
-          else if (res.data.status === 'Busy') {
+          } else if (res.data.status === 'Busy') {
             // If status is Busy then poll the result by recursive call to the poll function
             self.messages(trans_id);
-          }
-          else if (res.data.status === 'NotConnected') {
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Not connected to server or connection with the server has been closed.'),
               res.data.result
             );
           }
         },
-        error: function(e) {
+        error: function() {
           Alertify.alert(
             gettext('Debugger Error'),
             gettext('Error while fetching messages information.')
           );
-        }
+        },
       });
 
     },
@@ -1504,21 +1566,19 @@ define([
       var self = this;
 
       // If breakpoint gutter is clicked and execution is not completed then only set the breakpoint
-      if (gutter == "breakpoints" && !pgTools.DirectDebug.polling_timeout_idle ) {
+      if (gutter == 'breakpoints' && !pgTools.DirectDebug.polling_timeout_idle) {
         // We may want to check, if break-point is allowed at this moment or not
         var info = cm.lineInfo(m);
 
         // If gutterMarker is undefined that means there is no marker defined previously
         // So we need to set the breakpoint command here...
         if (info.gutterMarkers == undefined) {
-          controller.set_breakpoint(self.trans_id,m+1,1); //set the breakpoint
-        }
-        else {
+          controller.set_breakpoint(self.trans_id, m + 1, 1); //set the breakpoint
+        } else {
           if (info.gutterMarkers.breakpoints == undefined) {
-            controller.set_breakpoint(self.trans_id,m+1,1); //set the breakpoint
-          }
-          else {
-            controller.set_breakpoint(self.trans_id,m+1,0); //clear the breakpoint
+            controller.set_breakpoint(self.trans_id, m + 1, 1); //set the breakpoint
+          } else {
+            controller.set_breakpoint(self.trans_id, m + 1, 0); //clear the breakpoint
           }
         }
 
@@ -1526,17 +1586,17 @@ define([
         // we need to find out 'breakpoints' information
         var markers = info.gutterMarkers;
         if (markers != undefined && info.gutterMarkers.breakpoints == undefined)
-          markers = info.gutterMarkers.breakpoints
+          markers = info.gutterMarkers.breakpoints;
 
         cm.setGutterMarker(
-          m, "breakpoints", markers ? null : function() {
-            var marker = document.createElement("div");
+          m, 'breakpoints', markers ? null : function() {
+            var marker = document.createElement('div');
 
-            marker.style.color = "#822";
-            marker.innerHTML = "●";
+            marker.style.color = '#822';
+            marker.innerHTML = '●';
 
             return marker;
-        }());
+          }());
       }
     },
 
@@ -1545,101 +1605,101 @@ define([
       var self = this;
       this.registerPanel(
         'code', false, '100%', '50%',
-        function(panel) {
-
-            // Create the parameters panel to display the arguments of the functions
-            var parameters = new pgAdmin.Browser.Panel({
-              name: 'parameters',
-              title: gettext('Parameters'),
-              width: '100%',
-              height:'100%',
-              isCloseable: false,
-              isPrivate: true,
-              content: '<div id ="parameters" class="parameters"></div>'
-            })
+        function() {
 
-            // Create the Local variables panel to display the local variables of the function.
-            var local_variables = new pgAdmin.Browser.Panel({
-              name: 'local_variables',
-              title: gettext('Local variables'),
-              width: '100%',
-              height:'100%',
-              isCloseable: false,
-              isPrivate: true,
-              content: '<div id ="local_variables" class="local_variables"></div>'
-            })
+          // Create the parameters panel to display the arguments of the functions
+          var parameters = new pgAdmin.Browser.Panel({
+            name: 'parameters',
+            title: gettext('Parameters'),
+            width: '100%',
+            height: '100%',
+            isCloseable: false,
+            isPrivate: true,
+            content: '<div id ="parameters" class="parameters"></div>',
+          });
 
-            // Create the messages panel to display the message returned from the database server
-            var messages = new pgAdmin.Browser.Panel({
-              name: 'messages',
-              title: gettext('Messages'),
-              width: '100%',
-              height:'100%',
-              isCloseable: false,
-              isPrivate: true,
-              content: '<div id="messages" class="messages"></div>'
-            })
+          // Create the Local variables panel to display the local variables of the function.
+          var local_variables = new pgAdmin.Browser.Panel({
+            name: 'local_variables',
+            title: gettext('Local variables'),
+            width: '100%',
+            height: '100%',
+            isCloseable: false,
+            isPrivate: true,
+            content: '<div id ="local_variables" class="local_variables"></div>',
+          });
 
-            // Create the result panel to display the result after debugging the function
-            var results = new pgAdmin.Browser.Panel({
-              name: 'results',
-              title: gettext('Results'),
-              width: '100%',
-              height:'100%',
-              isCloseable: false,
-              isPrivate: true,
-              content: '<div id="debug_results" class="debug_results"></div>'
-            })
+          // Create the messages panel to display the message returned from the database server
+          var messages = new pgAdmin.Browser.Panel({
+            name: 'messages',
+            title: gettext('Messages'),
+            width: '100%',
+            height: '100%',
+            isCloseable: false,
+            isPrivate: true,
+            content: '<div id="messages" class="messages"></div>',
+          });
 
-            // Create the stack pane panel to display the debugging stack information.
-            var stack_pane = new pgAdmin.Browser.Panel({
-              name: 'stack_pane',
-              title: gettext('Stack'),
-              width: '100%',
-              height:'100%',
-              isCloseable: false,
-              isPrivate: true,
-              content: '<div id="stack_pane" class="stack_pane"></div>'
-            })
+          // Create the result panel to display the result after debugging the function
+          var results = new pgAdmin.Browser.Panel({
+            name: 'results',
+            title: gettext('Results'),
+            width: '100%',
+            height: '100%',
+            isCloseable: false,
+            isPrivate: true,
+            content: '<div id="debug_results" class="debug_results"></div>',
+          });
+
+          // Create the stack pane panel to display the debugging stack information.
+          var stack_pane = new pgAdmin.Browser.Panel({
+            name: 'stack_pane',
+            title: gettext('Stack'),
+            width: '100%',
+            height: '100%',
+            isCloseable: false,
+            isPrivate: true,
+            content: '<div id="stack_pane" class="stack_pane"></div>',
+          });
 
-            // Load all the created panels
-            parameters.load(self.docker);
-            local_variables.load(self.docker);
-            messages.load(self.docker);
-            results.load(self.docker);
-            stack_pane.load(self.docker);
+          // Load all the created panels
+          parameters.load(self.docker);
+          local_variables.load(self.docker);
+          messages.load(self.docker);
+          results.load(self.docker);
+          stack_pane.load(self.docker);
         });
 
-        self.code_editor_panel = self.docker.addPanel('code', wcDocker.DOCK.TOP );
+      self.code_editor_panel = self.docker.addPanel('code', wcDocker.DOCK.TOP);
 
-        self.parameters_panel = self.docker.addPanel(
-          'parameters', wcDocker.DOCK.BOTTOM, self.code_editor_panel);
-        self.local_variables_panel = self.docker.addPanel('local_variables', wcDocker.DOCK.STACKED, self.parameters_panel, {
-          tabOrientation: wcDocker.TAB.TOP
-        });
-        self.messages_panel = self.docker.addPanel('messages', wcDocker.DOCK.STACKED, self.parameters_panel);
-        self.results_panel = self.docker.addPanel(
-          'results', wcDocker.DOCK.STACKED, self.parameters_panel);
-        self.stack_pane_panel = self.docker.addPanel(
-          'stack_pane', wcDocker.DOCK.STACKED, self.parameters_panel);
-
-        var editor_pane = $('<div id="stack_editor_pane" class="full-container-pane info"></div>');
-        var code_editor_area = $('<textarea id="debugger-editor-textarea"></textarea>').append(editor_pane);
-        self.code_editor_panel.layout().addItem(code_editor_area);
-
-        // To show the line-number and set breakpoint marker details by user.
-        var editor = self.editor = CodeMirror.fromTextArea(
-          code_editor_area.get(0), {
+      self.parameters_panel = self.docker.addPanel(
+        'parameters', wcDocker.DOCK.BOTTOM, self.code_editor_panel);
+      self.local_variables_panel = self.docker.addPanel('local_variables', wcDocker.DOCK.STACKED, self.parameters_panel, {
+        tabOrientation: wcDocker.TAB.TOP,
+      });
+      self.messages_panel = self.docker.addPanel('messages', wcDocker.DOCK.STACKED, self.parameters_panel);
+      self.results_panel = self.docker.addPanel(
+        'results', wcDocker.DOCK.STACKED, self.parameters_panel);
+      self.stack_pane_panel = self.docker.addPanel(
+        'stack_pane', wcDocker.DOCK.STACKED, self.parameters_panel);
+
+      var editor_pane = $('<div id="stack_editor_pane" class="full-container-pane info"></div>');
+      var code_editor_area = $('<textarea id="debugger-editor-textarea"></textarea>').append(editor_pane);
+      self.code_editor_panel.layout().addItem(code_editor_area);
+
+      // To show the line-number and set breakpoint marker details by user.
+      self.editor = CodeMirror.fromTextArea(
+        code_editor_area.get(0), {
           lineNumbers: true,
           foldOptions: {
-            widget: "\u2026"
+            widget: '\u2026',
           },
           foldGutter: {
             rangeFinder: CodeMirror.fold.combine(CodeMirror.pgadminBeginRangeFinder, CodeMirror.pgadminIfRangeFinder,
-                                                 CodeMirror.pgadminLoopRangeFinder, CodeMirror.pgadminCaseRangeFinder)
+              CodeMirror.pgadminLoopRangeFinder, CodeMirror.pgadminCaseRangeFinder),
           },
-          gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "breakpoints"],
-          mode: "text/x-pgsql",
+          gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'breakpoints'],
+          mode: 'text/x-pgsql',
           readOnly: true,
           extraKeys: pgAdmin.Browser.editor_shortcut_keys,
           indentWithTabs: pgAdmin.Browser.editor_options.indent_with_tabs,
@@ -1647,22 +1707,22 @@ define([
           tabSize: pgAdmin.Browser.editor_options.tabSize,
           lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
           autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
-          matchBrackets: pgAdmin.Browser.editor_options.brace_matching
+          matchBrackets: pgAdmin.Browser.editor_options.brace_matching,
         });
 
-        // On loading the docker, register the callbacks
-        var onLoad = function() {
-          self.docker.finishLoading(100);
-          self.docker.off(wcDocker.EVENT.LOADED);
-          // Register the callback when user set/clear the breakpoint on gutter area.
-          self.editor.on("gutterClick", self.onBreakPoint.bind(self), self);
-        };
+      // On loading the docker, register the callbacks
+      var onLoad = function() {
+        self.docker.finishLoading(100);
+        self.docker.off(wcDocker.EVENT.LOADED);
+        // Register the callback when user set/clear the breakpoint on gutter area.
+        self.editor.on('gutterClick', self.onBreakPoint.bind(self), self);
+      };
 
-        self.docker.startLoading(gettext('Loading...'));
-        self.docker.on(wcDocker.EVENT.LOADED, onLoad);
+      self.docker.startLoading(gettext('Loading...'));
+      self.docker.on(wcDocker.EVENT.LOADED, onLoad);
 
-        // Create the toolbar view for debugging the function
-        this.toolbarView = new DebuggerToolbarView();
+      // Create the toolbar view for debugging the function
+      this.toolbarView = new DebuggerToolbarView();
     },
 
     // Register the panel with new debugger docker instance.
@@ -1681,14 +1741,16 @@ define([
             panel.title(title);
           panel.closeable(false);
           panel.layout().addItem(
-            $('<div>', {'class': 'pg-debugger-panel'})
+            $('<div>', {
+              'class': 'pg-debugger-panel',
+            })
           );
           if (onInit) {
             onInit.apply(self, [panel]);
           }
-        }
+        },
       });
-    }
+    },
   });
 
   pgTools.DirectDebug = new DirectDebug();
diff --git a/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js b/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js
index 4898f7fe..c0ca2a73 100644
--- a/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js
+++ b/web/pgadmin/tools/grant_wizard/static/js/grant_wizard.js
@@ -1,1129 +1,1172 @@
 // Grant Wizard
 define([
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
-  'underscore.string', 'alertify', 'pgadmin.browser', 'backbone', 'backgrid',
-  'pgadmin.browser.node', 'backgrid.select.all', 'backgrid.filter',
-  'pgadmin.browser.server.privilege', 'pgadmin.browser.wizard',
-], function(gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, pgNode) {
-
-    // if module is already initialized, refer to that.
-    if (pgBrowser.GrantWizard) {
-      return pgBrowser.GrantWizard;
-    }
-
-    /**
-      It is sub model for field "Objects". It has fields
-      for database object types such as Schemas, Views and
-      Sequence etc.
-    */
-    var DatabaseObjectModel = pgNode.Model.extend({
-      defaults: {
-        selected: false,
-        icon: 'icon-unknown',
-        name: undefined,
-        name_with_args: undefined,
-        nspname: undefined,
-        proargs: undefined,
-        object_type: undefined,
-        object_id: undefined
-      },
-      idAttribute: 'object_id', // to uniquely identify a model object
-      toJSON: function(obj) {
-        var d = pgNode.Model.prototype.toJSON.apply(this);
-        delete d.icon;
-        return d;
-      },
-      parse: function(res) {
-
-        // Create unique object id
-        res.object_id = res.name_with_args;
-
-        // create name with args if its object is function
-        if(!_.isUndefined(res.object_type) &&
-          (res.object_type == 'Function' ||
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
+  'pgadmin.alertifyjs', 'pgadmin.backgrid', 'pgadmin.backform',
+  'pgadmin.browser', 'pgadmin.browser.node', 'backgrid.select.all',
+  'backgrid.filter', 'pgadmin.browser.server.privilege',
+  'pgadmin.browser.wizard',
+], function(
+  gettext, url_for, $, _, Backbone, Alertify, Backgrid, Backform, pgBrowser,
+  pgNode
+) {
+
+  // if module is already initialized, refer to that.
+  if (pgBrowser.GrantWizard) {
+    return pgBrowser.GrantWizard;
+  }
+
+  /**
+    It is sub model for field "Objects". It has fields
+    for database object types such as Schemas, Views and
+    Sequence etc.
+  */
+  var DatabaseObjectModel = pgNode.Model.extend({
+    defaults: {
+      selected: false,
+      icon: 'icon-unknown',
+      name: undefined,
+      name_with_args: undefined,
+      nspname: undefined,
+      proargs: undefined,
+      object_type: undefined,
+      object_id: undefined,
+    },
+    idAttribute: 'object_id', // to uniquely identify a model object
+    toJSON: function() {
+      var d = pgNode.Model.prototype.toJSON.apply(this);
+      delete d.icon;
+      return d;
+    },
+    parse: function(res) {
+
+      // Create unique object id
+      res.object_id = res.name_with_args;
+
+      // create name with args if its object is function
+      if (!_.isUndefined(res.object_type) &&
+        (res.object_type == 'Function' ||
           res.object_type == 'Trigger Function' ||
           res.object_type == 'Procedure'
-          ))
-          res.name_with_args = res.name+'('+(typeof(res.proargs) != 'undefined' ? res.proargs : '')+')';
-        else
-          res.name_with_args = res.name;
+        ))
+        res.name_with_args = res.name + '(' + (typeof(res.proargs) != 'undefined' ? res.proargs : '') + ')';
+      else
+        res.name_with_args = res.name;
 
-        return res;
-      },
+      return res;
+    },
 
-      validate: function() {
-
-        /*
-        * Triggers error messages for object types "selected"
-        * if it is empty/undefined/null
-        */
-        var err = {},
-          errmsg,
-          node = this.get('objects').toJSON();
-        if (_.isEmpty(node)) {
-          err['selected'] = gettext('Please select any database object type.');
-          errmsg = errmsg || err['selected'];
-          this.errorModel.set('selected', errmsg);
-          return errmsg;
-        } else {
-          this.errorModel.unset('selected');
-        }
-        return null;
-      }
-    });
-
-    // Define columns for the Db Object Types grid
-    var columns = [{
-      name: "selected",
+    validate: function() {
 
       /*
-      Override render method of Backgrid.Extension.SelectRowCell
-      class. It has an issue: It doesn't mark rows checked if we move to next
-      page and then go back to previous page. but it must show.
-      so we handle this case by overriding the render method.
-      */
-      cell: Backgrid.Extension.SelectRowCell.extend({
-        render: function() {
-
-          // Use the Backform Control's render function
-          Backgrid.Extension.SelectRowCell.prototype.render.apply(this, arguments);
-
-          var col = this.column.get('name');
-          if (this.model && this.model.has(col)) {
-            if (this.model.get(col)) {
-              this.$el.parent().toggleClass("selected", true);
-              this.model.trigger("backgrid:selected", this.model, true);
-            }
-          }
-          return this;
-        }
-      }),
-
-      headerCell: "select-all",
+       * Triggers error messages for object types "selected"
+       * if it is empty/undefined/null
+       */
+      var err = {},
+        errmsg,
+        node = this.get('objects').toJSON();
+      if (_.isEmpty(node)) {
+        err['selected'] = gettext('Please select any database object type.');
+        errmsg = errmsg || err['selected'];
+        this.errorModel.set('selected', errmsg);
+        return errmsg;
+      } else {
+        this.errorModel.unset('selected');
+      }
+      return null;
+    },
+  });
 
-    },{
-      name: "object_type",
-      label: gettext("Object Type"),
-      editable: false,
-      cell: Backgrid.Cell.extend({
-        render: function() {
+  // Define columns for the Db Object Types grid
+  var columns = [{
+    name: 'selected',
 
-          // Override render to add icon to Db Object column
-          Backgrid.Cell.prototype.render.apply(this, arguments);
-          this.$el.addClass(this.model.get('icon')).css({"padding-left": "24px"});
+    /*
+    Override render method of Backgrid.Extension.SelectRowCell
+    class. It has an issue: It doesn't mark rows checked if we move to next
+    page and then go back to previous page. but it must show.
+    so we handle this case by overriding the render method.
+    */
+    cell: Backgrid.Extension.SelectRowCell.extend({
+      render: function() {
 
-          return this;
-        }
-      })
-    },{
-      name: "nspname",
-      label: gettext("Schema"),
-      cell: "string",
-      editable: false
-    },{
-      name: "name_with_args",
-      label: gettext("Name"),
-      cell: "string",
-      editable: false
-    }];
-
-    // Create an Object GrantWizard of pgBrowser class
-    pgBrowser.GrantWizard  = {
-      init: function() {
-        if (this.initialized)
-          return;
-
-        this.initialized = true;
-
-        // Define list of nodes on which grant wizard context menu option appears
-        var supported_nodes = [
-              'schema', 'coll-function', 'coll-sequence',
-              'coll-table', 'coll-view', 'coll-procedure',
-              'coll-mview', 'database', 'coll-trigger_function'
-            ],
+        // Use the Backform Control's render function
+        Backgrid.Extension.SelectRowCell.prototype.render.apply(this, arguments);
 
-            /**
-              Enable/disable grantwizard menu in tools based
-              on node selected
-              if selected node is present in supported_nodes,
-              menu will be enabled otherwise disabled.
-              Also, hide it for system view in catalogs
-            */
-            menu_enabled = function(itemData, item, data) {
-              var t = pgBrowser.tree, i = item, d = itemData;
-              var parent_item = t.hasParent(i) ? t.parent(i): null,
-                  parent_data = parent_item ? t.itemData(parent_item) : null;
-              if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
-                if (_.indexOf(supported_nodes, d._type) !== -1 &&
-                  parent_data._type != 'catalog') {
-                    if (d._type == 'database' && d.allowConn)
-                      return true;
-                    else if(d._type != 'database')
-                      return true;
-                    else
-                      return false;
-                }
-                else
-                  return false;
-              }
-              else
-                return false;
-            };
-
-        // Define the nodes on which the menus to be appear
-        var menus = [{
-          name: 'grant_wizard_schema', module: this,
-          applies: ['tools'], callback: 'start_grant_wizard',
-          priority: 14, label: gettext('Grant Wizard...'),
-          icon: 'fa fa-unlock-alt', enable: menu_enabled
-        }];
-
-        // Add supported menus into the menus list
-        for (var idx = 0; idx < supported_nodes.length; idx++) {
-          menus.push({
-            name: 'grant_wizard_schema_context_' + supported_nodes[idx],
-            node: supported_nodes[idx], module: this,
-            applies: ['context'], callback: 'start_grant_wizard',
-            priority: 14, label: gettext('Grant Wizard...'),
-            icon: 'fa fa-unlock-alt', enable: menu_enabled
-            });
+        var col = this.column.get('name');
+        if (this.model && this.model.has(col)) {
+          if (this.model.get(col)) {
+            this.$el.parent().toggleClass('selected', true);
+            this.model.trigger('backgrid:selected', this.model, true);
+          }
         }
-        pgAdmin.Browser.add_menus(menus);
-
         return this;
       },
+    }),
 
-      // Callback to draw Wizard Dialog
-      start_grant_wizard: function(action, item) {
+    headerCell: 'select-all',
 
-        // Declare Wizard dialog
-        if (!alertify.wizardDialog) {
-          alertify.dialog('wizardDialog', function factory() {
+  }, {
+    name: 'object_type',
+    label: gettext('Object Type'),
+    editable: false,
+    cell: Backgrid.Cell.extend({
+      render: function() {
 
-            // Generate wizard main container
-            var $container = $("<div class='wizard_dlg'></div>");
-
-            return {
-              main: function(title) {
-                this.set('title', title);
-              },
-              setup:function() {
-                return {
-                  // Set options for dialog
-                  options: {
-                    frameless: true,
-                    resizable: true,
-                    autoReset: false,
-                    maximizable: false,
-                    closable: false,
-                    closableByDimmer: false,
-                    modal: false,
-                    pinnable: false
-                  }
-                };
-              },
-              hooks:{
-                onshow: function() {
+        // Override render to add icon to Db Object column
+        Backgrid.Cell.prototype.render.apply(this, arguments);
+        this.$el.addClass(this.model.get('icon')).css({
+          'padding-left': '24px',
+        });
 
-                  // Add pgadmin_grant_wizard_body class to dialog
-                  $(this.elements.body).addClass('pgadmin_grant_wizard_body');
-                }
+        return this;
+      },
+    }),
+  }, {
+    name: 'nspname',
+    label: gettext('Schema'),
+    cell: 'string',
+    editable: false,
+  }, {
+    name: 'name_with_args',
+    label: gettext('Name'),
+    cell: 'string',
+    editable: false,
+  }];
+
+  // Create an Object GrantWizard of pgBrowser class
+  pgBrowser.GrantWizard = {
+    init: function() {
+      if (this.initialized)
+        return;
+
+      this.initialized = true;
+
+      // Define list of nodes on which grant wizard context menu option appears
+      var supported_nodes = [
+          'schema', 'coll-function', 'coll-sequence',
+          'coll-table', 'coll-view', 'coll-procedure',
+          'coll-mview', 'database', 'coll-trigger_function',
+        ],
+
+        /**
+          Enable/disable grantwizard menu in tools based
+          on node selected
+          if selected node is present in supported_nodes,
+          menu will be enabled otherwise disabled.
+          Also, hide it for system view in catalogs
+        */
+        menu_enabled = function(itemData, item) {
+          var t = pgBrowser.tree,
+            i = item,
+            d = itemData;
+          var parent_item = t.hasParent(i) ? t.parent(i) : null,
+            parent_data = parent_item ? t.itemData(parent_item) : null;
+          if (!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+            if (_.indexOf(supported_nodes, d._type) !== -1 &&
+              parent_data._type != 'catalog') {
+              if (d._type == 'database' && d.allowConn)
+                return true;
+              else if (d._type != 'database')
+                return true;
+              else
+                return false;
+            } else
+              return false;
+          } else
+            return false;
+        };
+
+      // Define the nodes on which the menus to be appear
+      var menus = [{
+        name: 'grant_wizard_schema',
+        module: this,
+        applies: ['tools'],
+        callback: 'start_grant_wizard',
+        priority: 14,
+        label: gettext('Grant Wizard...'),
+        icon: 'fa fa-unlock-alt',
+        enable: menu_enabled,
+      }];
+
+      // Add supported menus into the menus list
+      for (var idx = 0; idx < supported_nodes.length; idx++) {
+        menus.push({
+          name: 'grant_wizard_schema_context_' + supported_nodes[idx],
+          node: supported_nodes[idx],
+          module: this,
+          applies: ['context'],
+          callback: 'start_grant_wizard',
+          priority: 14,
+          label: gettext('Grant Wizard...'),
+          icon: 'fa fa-unlock-alt',
+          enable: menu_enabled,
+        });
+      }
+      pgBrowser.add_menus(menus);
+
+      return this;
+    },
+
+    // Callback to draw Wizard Dialog
+    start_grant_wizard: function() {
+
+      // Declare Wizard dialog
+      if (!Alertify.wizardDialog) {
+        Alertify.dialog('wizardDialog', function factory() {
+
+          // Generate wizard main container
+          var $container = $('<div class=\'wizard_dlg\'></div>');
+
+          return {
+            main: function(title) {
+              this.set('title', title);
+            },
+            setup: function() {
+              return {
+                // Set options for dialog
+                options: {
+                  frameless: true,
+                  resizable: true,
+                  autoReset: false,
+                  maximizable: false,
+                  closable: false,
+                  closableByDimmer: false,
+                  modal: false,
+                  pinnable: false,
+                },
+              };
+            },
+            hooks: {
+              onshow: function() {
+
+                // Add pgadmin_grant_wizard_body class to dialog
+                $(this.elements.body).addClass('pgadmin_grant_wizard_body');
               },
+            },
 
-              /**
-                Returns a Paginator Class Object which is again to be rendered
+            /**
+              Returns a Paginator Class Object which is again to be rendered
 
-                @class {Backgrid.Extension.Paginator}
-                @param {Backbone.Collection} coll - from which data is fetched
-                @return {Object} paginator
-              */
-              DbPaginator: function(coll){
-                var paginator = this.paginator = new Backgrid.Extension.Paginator({
-                  collection: coll,
-                  windowSize: 8
-                });
-                return paginator;
-              },
+              @class {Backgrid.Extension.Paginator}
+              @param {Backbone.Collection} coll - from which data is fetched
+              @return {Object} paginator
+            */
+            DbPaginator: function(coll) {
+              var paginator = this.paginator = new Backgrid.Extension.Paginator({
+                collection: coll,
+                windowSize: 8,
+              });
+              return paginator;
+            },
 
-              /**
-                Create new Filter which will filter the
-                rendered grid for Select Type Tabular Data
-                @param {Backbone.PageableCollection} coll
-              */
-              DbObjectFilter: function(coll){
-                var clientSideFilter = this.clientSideFilter = new Backgrid.Extension.ClientSideFilter({
-                  collection: coll,
-                  placeholder: _('Search by object type or name'),
+            /**
+              Create new Filter which will filter the
+              rendered grid for Select Type Tabular Data
+              @param {Backbone.PageableCollection} coll
+            */
+            DbObjectFilter: function(coll) {
+              var clientSideFilter = this.clientSideFilter = new Backgrid.Extension.ClientSideFilter({
+                collection: coll,
+                placeholder: _('Search by object type or name'),
+
+                // The model fields to search for matches
+                fields: ['object_type', 'name'],
+
+                // How long to wait after typing has stopped before searching can start
+                wait: 150,
+              });
+              return clientSideFilter;
+            },
+
+            //Enable Disable Next button of PrivilegePage
+            updateButtons: function(modified) {
+              if (!modified)
+                $('.wizard-next').prop('disabled', true);
+              else
+                $('.wizard-next').prop('disabled', false);
+            },
 
-                  // The model fields to search for matches
-                  fields: ['object_type', 'name'],
+            /**
+              Callback called when an errorModel is set
+              with invalid value and errormsg is set into
+              status bar element and next button is disabled
+            */
+            onSessionInvalid: function(msg) {
+              $('.pg-prop-status-bar .alert-text').html(msg);
+              $('.pg-prop-status-bar').css('visibility', 'visible');
 
-                  // How long to wait after typing has stopped before searching can start
-                  wait: 150
-                });
-                return clientSideFilter;
-              },
+              // Enable disable Next button
+              this.updateButtons(false);
+              return true;
+            },
 
-              //Enable Disable Next button of PrivilegePage
-              updateButtons: function(modified){
-                if(!modified)
-                  $('.wizard-next').prop('disabled', true);
-                else
-                  $('.wizard-next').prop('disabled', false);
-              },
+            /**
+              Callback called when anything is set into model
+              thus hide error msg element and enable next button
+              status bar element and next button is disabled
+            */
+            onSessionValidated: function(sessHasChanged) {
+              $('.pg-prop-status-bar .alert-text').empty();
+              $('.pg-prop-status-bar').css('visibility', 'hidden');
 
-              /**
-                Callback called when an errorModel is set
-                with invalid value and errormsg is set into
-                status bar element and next button is disabled
-              */
-              onSessionInvalid: function(msg) {
-                $('.pg-prop-status-bar .alert-text').html(msg);
-                $('.pg-prop-status-bar').css("visibility", "visible");
+              // Enable disable Next button
+              this.updateButtons(sessHasChanged);
+            },
 
-                // Enable disable Next button
-                this.updateButtons(false);
-                return true;
-              },
+            /**
+              Remove/Delete objects, attributes
+              in wizard on wizard close or finish
+              to reclaim memory
+            */
+            releaseObjects: function() {
+              var self = this;
 
-              /**
-                Callback called when anything is set into model
-                thus hide error msg element and enable next button
-                status bar element and next button is disabled
-              */
-              onSessionValidated: function(sessHasChanged) {
-                $('.pg-prop-status-bar .alert-text').empty();
-                $('.pg-prop-status-bar').css("visibility", "hidden");
+              if (!_.isUndefined(self.dbObjectFilter)) {
+                self.dbObjectFilter.remove();
+                self.dbObjectFilter = undefined;
+              }
 
-                // Enable disable Next button
-                this.updateButtons(sessHasChanged);
-              },
+              if (!_.isUndefined(self.clientSideFilter)) {
+                self.clientSideFilter.remove();
+                self.clientSideFilter = undefined;
+              }
 
-              /**
-                Remove/Delete objects, attributes
-                in wizard on wizard close or finish
-                to reclaim memory
-              */
-              releaseObjects: function(){
-                var self = this;
+              // clear object priv array
+              if (!_.isNull(self.obj_priv) &&
+                !_.isUndefined(self.obj_priv)) {
+                self.obj_priv = [];
+                delete self.obj_priv;
+              }
 
-                if(!_.isUndefined(self.dbObjectFilter)) {
-                  self.dbObjectFilter.remove();
-                  self.dbObjectFilter = undefined;
+              // Delete Wizard Pages, clear model and cleanup view
+              if (!_.isUndefined(self.dbObjectTypePage) &&
+                !_.isNull(self.dbObjectTypePage)) {
+                if (!_.isUndefined(self.dbObjectTypePage.get('model')) &&
+                  !_.isNull(self.dbObjectTypePage.get('model'))) {
+                  self.dbObjectTypePage.get('model').clear();
+                  self.dbObjectTypePage.get('view').cleanup();
+                  self.dbObjectTypePage = undefined;
                 }
+              }
 
-                if(!_.isUndefined(self.clientSideFilter)) {
-                  self.clientSideFilter.remove();
-                  self.clientSideFilter = undefined;
+              if (!_.isUndefined(self.privilegePage) &&
+                !_.isNull(self.privilegePage)) {
+                if (!_.isUndefined(self.privilegePage.get('model')) &&
+                  !_.isNull(self.privilegePage.get('model'))) {
+                  self.privilegePage.get('model').clear();
+                  self.privilegePage.get('view').cleanup();
+                  self.privilegePage = undefined;
                 }
+              }
 
-                // clear object priv array
-                if(!_.isNull(self.obj_priv) &&
-                  !_.isUndefined(self.obj_priv)) {
-                  self.obj_priv = [];
-                  delete self.obj_priv;
+              if (!_.isUndefined(self.reviewSQLPage) &&
+                !_.isNull(self.reviewSQLPage)) {
+                if (!_.isUndefined(self.reviewSQLPage.get('model')) &&
+                  !_.isNull(self.reviewSQLPage.get('model'))) {
+                  self.reviewSQLPage.get('model').clear();
+                  self.reviewSQLPage = undefined;
                 }
+              }
 
-                // Delete Wizard Pages, clear model and cleanup view
-                if(!_.isUndefined(self.dbObjectTypePage) &&
-                  !_.isNull(self.dbObjectTypePage)) {
-                  if(!_.isUndefined(self.dbObjectTypePage.get('model')) &&
-                    !_.isNull(self.dbObjectTypePage.get('model'))) {
-                    self.dbObjectTypePage.get('model').clear();
-                    self.dbObjectTypePage.get('view').cleanup();
-                    self.dbObjectTypePage = undefined;
-                  }
-                }
+              // Remove Sql control
+              if (!_.isUndefined(self.sqlControl)) {
+                self.sqlControl.remove();
+              }
 
-                if(!_.isUndefined(self.privilegePage) &&
-                  !_.isNull(self.privilegePage)) {
-                  if(!_.isUndefined(self.privilegePage.get('model')) &&
-                    !_.isNull(self.privilegePage.get('model'))) {
-                    self.privilegePage.get('model').clear();
-                    self.privilegePage.get('view').cleanup();
-                    self.privilegePage = undefined;
-                  }
-                }
+              // Clear privModel
+              if (!_.isNull(self.privModel) &&
+                !_.isUndefined(self.privModel)) {
+                self.privModel.clear();
+              }
 
-                if(!_.isUndefined(self.reviewSQLPage) &&
-                  !_.isNull(self.reviewSQLPage)) {
-                  if(!_.isUndefined(self.reviewSQLPage.get('model')) &&
-                    !_.isNull(self.reviewSQLPage.get('model'))) {
-                    self.reviewSQLPage.get('model').clear();
-                    self.reviewSQLPage = undefined;
-                  }
-                }
+              // Remove collection containing db object data
+              if (!_.isNull(self.coll) &&
+                !_.isUndefined(self.coll)) {
+                self.coll.reset();
+                self.coll = undefined;
+              }
+              // Delete Wizard
+              if (!_.isNull(self.wizard) &&
+                !_.isUndefined(self.wizard)) {
+                self.wizard.collection.reset();
+                self.wizard.curr_page = undefined;
+              }
 
-                // Remove Sql control
-                if (!_.isUndefined(self.sqlControl)) {
-                  self.sqlControl.remove();
-                }
+            },
 
-                // Clear privModel
-                if(!_.isNull(self.privModel) &&
-                  !_.isUndefined(self.privModel)) {
-                  self.privModel.clear();
-                }
+            /**
+              Every time a wizard is opened, this function
+              is called everytime. It has Wizard Pages which
+              are rendered by the Wizard Class:
+
+              @class {pgBrowser.WizardPage} dbObjectType1 - This page
+              @extends {Backbone.Model}
+              renders a grid of Database Object Types such as
+                Schemas, Views and Sequences etc.
+
+              @class {pgBrowser.WizardPage} WizardPage2 - This page
+              @extends {Backbone.Model}
+              adds Privilege Control which provides grant privileges
+              such as "Create, Insert, Delete, Update" so on the
+              database objects selected on Wizard Pages.
+
+              @class {pgBrowser.WizardPage} WizardPage3 - This page
+              displays the generated GRANT SQL query for the Db
+              objects selected with the specific privileges added to it.
+              @extends {Backbone.Model}
+
+              @class {Backbone.Collection} WizardCollection - It is the
+              collection of wizard pages
+
+              @class {pgBrowser.Wizard} wizard - Its task is:
+              - Create a Wizard
+              - Add Buttons, Callbacks to it.
+              - Render WizardPages
+              @extends {Backbone.View}
 
-                // Remove collection containing db object data
-                if(!_.isNull(self.coll) &&
-                  !_.isUndefined(self.coll)) {
-                  self.coll.reset();
-                  self.coll = undefined;
-                }
-                // Delete Wizard
-                if(!_.isNull(self.wizard) &&
-                  !_.isUndefined(self.wizard)) {
-                  self.wizard.collection.reset();
-                  self.wizard.curr_page = undefined;
-                }
+            */
+            build: function() {
+              this.elements.content.appendChild($container.get(0));
+              Alertify.pgDialogBuild.apply(this);
+            },
+
+            //Returns list of Acls defined for nodes
+            get_json_data: function(gid, sid, did) {
+              return $.ajax({
+                async: false,
+                url: url_for(
+                  'grant_wizard.acl', {
+                    'sid': encodeURI(sid),
+                    'did': encodeURI(did),
+                  }
+                ),
+                dataType: 'jsonp',
+              });
 
-              },
+            },
+            prepare: function() {
+              var that = this;
+              $container.empty().append('<div class=\'grant_wizard_container\'></div>');
 
-              /**
-                Every time a wizard is opened, this function
-                is called everytime. It has Wizard Pages which
-                are rendered by the Wizard Class:
-
-                @class {pgBrowser.WizardPage} dbObjectType1 - This page
-                @extends {Backbone.Model}
-                renders a grid of Database Object Types such as
-                  Schemas, Views and Sequences etc.
-
-                @class {pgBrowser.WizardPage} WizardPage2 - This page
-                @extends {Backbone.Model}
-                adds Privilege Control which provides grant privileges
-                such as "Create, Insert, Delete, Update" so on the
-                database objects selected on Wizard Pages.
-
-                @class {pgBrowser.WizardPage} WizardPage3 - This page
-                displays the generated GRANT SQL query for the Db
-                objects selected with the specific privileges added to it.
-                @extends {Backbone.Model}
-
-                @class {Backbone.Collection} WizardCollection - It is the
-                collection of wizard pages
-
-                @class {pgBrowser.Wizard} wizard - Its task is:
-                - Create a Wizard
-                - Add Buttons, Callbacks to it.
-                - Render WizardPages
-                @extends {Backbone.View}
+              // Define el for wizard view
+              var el = $('.grant_wizard_container');
 
+              // Extract the data from the selected tree node
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = this.d = i && i.length == 1 ? t.itemData(i) : undefined,
+                info = this.info = pgBrowser.Node.getTreeNodeHierarchy(i);
+
+              /**
+                Generate a URL using:
+                gid, did, sid(server id), node_id(node id),
+                node_(node name), node_type(node type)
+                and pass it to collection which will fetch Object Type properties.
               */
-              build: function() {
-                this.elements.content.appendChild($container.get(0));
-                alertify.pgDialogBuild.apply(this);
-              },
+              var gid = info['server_group']._id,
+                sid = info.server._id,
+                did = info.database._id,
+                node_id = d._id,
 
-              //Returns list of Acls defined for nodes
-              get_json_data: function(gid, sid, did) {
-                return $.ajax({
-                  async: false,
-                  url: url_for(
-                    'grant_wizard.acl',
-                    {'sid': encodeURI(sid), 'did': encodeURI(did)}
-                  ),
-                  dataType: 'jsonp'
+                /**
+                  get node name only. used in mapping with object types defined
+                  in allowed_acl.json
+                 */
+                node_type = d._type.replace('coll-', '').replace(
+                  'materialized_', ''
+                );
+
+              // Fetch privileges specific to nodes
+              var json_data = this.get_json_data(gid, sid, did);
+              var privDict = JSON.parse(json_data.responseText);
+
+              // Collection url to fetch database object types for objects field
+              var baseUrl = url_for(
+                  'grant_wizard.objects', {
+                    'sid': encodeURI(sid),
+                    'did': encodeURI(did),
+                    'node_id': encodeURI(node_id),
+                    'node_type': encodeURI(node_type),
+                  }),
+                // Model's save url
+                saveUrl = url_for(
+                  'grant_wizard.apply', {
+                    'sid': encodeURI(sid),
+                    'did': encodeURI(did),
+                  }),
+                Coll = Backbone.Collection.extend({
+                  model: DatabaseObjectModel,
+                  url: baseUrl,
+                }),
+                // Create instances of collection and filter
+                coll = this.coll = new Coll(),
+                self = this;
+
+              // Generate encoded url based on wizard type
+              this.msql_url = url_for(
+                'grant_wizard.modified_sql', {
+                  'sid': encodeURI(sid),
+                  'did': encodeURI(did),
                 });
 
-              },
-              prepare:function() {
-                var that = this;
-                $container.empty().append("<div class='grant_wizard_container'></div>");
+              coll.comparator = function(model) {
+                return model.get('object_type');
+              };
 
-                // Define el for wizard view
-                var el = $('.grant_wizard_container');
+              coll.sort();
+              this.dbObjectFilter = this.DbObjectFilter(coll);
 
-                // Extract the data from the selected tree node
-                var t = pgBrowser.tree,
-                    i = t.selected(),
-                    d = this.d = i && i.length == 1 ? t.itemData(i) : undefined,
-                    info = this.info = pgBrowser.Node.getTreeNodeHierarchy(i),
-                    icon = d.icon;
+              /**
+                privArray holds objects selected which further helps
+                in creating privileges Model
+              */
+              self.privArray = [];
 
-                /**
-                  Generate a URL using:
-                  gid, did, sid(server id), node_id(node id),
-                  node_(node name), node_type(node type)
-                  and pass it to collection which will fetch Object Type properties.
-                */
-                var gid = info['server_group']._id,
-                    sid = info.server._id,
-                    did = info.database._id,
-                    node_id = d._id,
-
-                    /**
-                      get node name only. used in mapping with object types defined
-                      in allowed_acl.json
-                     */
-                    node_type = d._type.replace('coll-', '').replace('materialized_', ''),
-                    node_label = d.label;
-
-                // Fetch privileges specific to nodes
-                var json_data = this.get_json_data(gid, sid, did);
-                var privDict = JSON.parse(json_data.responseText);
-
-                // Collection url to fetch database object types for objects field
-                var baseUrl = url_for(
-                      'grant_wizard.objects', {
-                        'sid': encodeURI(sid), 'did': encodeURI(did),
-                        'node_id': encodeURI(node_id),
-                        'node_type': encodeURI(node_type)
-                      }),
-                    // Model's save url
-                    saveUrl = url_for(
-                      'grant_wizard.apply', {
-                        'sid': encodeURI(sid), 'did': encodeURI(did)
-                      }),
-                    // generate encoded url based on wizard type
-                    msql_url = this.msql_url = url_for(
-                      'grant_wizard.modified_sql', {
-                        'sid': encodeURI(sid), 'did': encodeURI(did)
-                      }),
-                    Coll = Backbone.Collection.extend({
-                      model: DatabaseObjectModel,
-                      url: baseUrl
-                    }),
-
-                    // Create instances of collection and filter
-                    coll = this.coll = new Coll(),
-                    self = this;
-
-                coll.comparator = function(model) {
-                  return model.get('object_type');
+              /**
+                Override backgrid listener "backgrid:selected" to
+                Add/Remove model to/from objects collection
+              */
+              coll.on('backgrid:selected', function(model, selected) {
+                model.set('selected', selected);
+
+                var object_type = model.get('object_type');
+                switch (object_type) {
+                case 'Function':
+                  object_type = 'function';
+                  break;
+                case 'Trigger Function':
+                  object_type = 'function';
+                  break;
+                case 'Procedure':
+                  object_type = 'procedure';
+                  break;
+                case 'Table':
+                  object_type = 'table';
+                  break;
+                case 'Sequence':
+                  object_type = 'sequence';
+                  break;
+                case 'View':
+                  object_type = 'table';
+                  break;
+                case 'Materialized View':
+                  object_type = 'table';
+                  break;
+                default:
+                  break;
                 }
 
-                coll.sort();
-                var dbObjectFilter = this.dbObjectFilter = this.DbObjectFilter(coll);
-
                 /**
-                  privArray holds objects selected which further helps
-                  in creating privileges Model
-                */
-                self.privArray = [];
+                  if a row (checkbox) is checked, add that model
+                  into collection, when unchecked remove it from
+                  model.
 
-                /**
-                  Override backgrid listener "backgrid:selected" to
-                  Add/Remove model to/from objects collection
+                  Also push/pop object type in/from privArray
                 */
-                coll.on('backgrid:selected', function(model, selected) {
-                  model.set('selected', selected);
-
-                  var object_type = model.get('object_type');
-                  switch (object_type)
-                  {
-                    case 'Function':
-                      object_type = 'function';
-                      break;
-                    case 'Trigger Function':
-                      object_type = 'function';
-                      break;
-                    case 'Procedure':
-                      object_type = 'procedure';
-                      break;
-                    case 'Table':
-                      object_type = 'table';
-                      break;
-                    case 'Sequence':
-                      object_type = 'sequence';
-                      break;
-                    case 'View':
-                      object_type = 'table';
-                      break;
-                    case 'Materialized View':
-                      object_type = 'table';
-                      break;
-                    default:
-                      break;
-                  }
-
-                  /**
-                    if a row (checkbox) is checked, add that model
-                    into collection, when unchecked remove it from
-                    model.
-
-                    Also push/pop object type in/from privArray
-                  */
-                  if(selected) {
-                    if(_.indexOf(self.privArray, object_type) == -1)
-                      self.privArray.push(object_type);
-                    newModel.get('objects').add(model, { silent: true });
-                  }
-                  else {
-                    var idx = self.privArray.indexOf(object_type);
-                    if(idx !=-1)
-                      self.privArray.splice(idx, 1);
-                    newModel.get('objects').remove(model);
-                  }
-
-                  // validate model on checkbox check/uncheck
-                  var msg =  model.validate.call(newModel);
-
-                  /**
-                    If no object type is selected, set error msg
-                    and disable next button, else enable next button
-                  */
-                  if(msg)
-                    self.onSessionInvalid.call(self, msg);
-                  else
-                    self.onSessionValidated.call(self, true);
-                });
+                if (selected) {
+                  if (_.indexOf(self.privArray, object_type) == -1)
+                    self.privArray.push(object_type);
+                  newModel.get('objects').add(model, {
+                    silent: true,
+                  });
+                } else {
+                  var idx = self.privArray.indexOf(object_type);
+                  if (idx != -1)
+                    self.privArray.splice(idx, 1);
+                  newModel.get('objects').remove(model);
+                }
 
-                /**
-                  It is the main model with schema defined
-                  Every time a new wizard is opened,
-                  a new model should create.
-                */
-                var GrantWizardModel = pgNode.Model.extend({
-                  defaults: {
-                    objects: undefined,
-                    acl: undefined
-                  },
-                  schema: [
-                    {
-                      id: 'objects', label: gettext('Objects'), model: DatabaseObjectModel,
-                      type: 'collection', group: gettext('Objects')
-                    },
-                    {
-                      id: 'acl', label: gettext('Privileges'),
-                      model: pgAdmin.Browser.Node.PrivilegeRoleModel,
-                      type: 'collection', canAdd: true,
-                      canDelete: true, control: 'unique-col-collection'
-                    }
-                  ],
-                  urlRoot: saveUrl
-                });
+                // validate model on checkbox check/uncheck
+                var msg = model.validate.call(newModel);
 
                 /**
-                  Create instance of GrantWizard Model, provide urlRoot
-                  node_info object, Generate fields objects
+                  If no object type is selected, set error msg
+                  and disable next button, else enable next button
                 */
-                var newModel = new GrantWizardModel({}, { node_info: info });
-
-                /**
-                  Fetch data from server and set into grid
-                  and show/hide progress bar
-                */
-                $('.wizard-progress-bar p').show();
-
-                coll.fetch({
-                  success: function(collection, data) {
-                    $('.wizard-progress-bar p').html('');
-                    $('.wizard-progress-bar').hide();
-                  },
-                  reset: true
-                }, this);
-
-                //////////////////////////////////////////////////////////////////////
-                //                                                                  //
-                //            Wizard Page for Db Object Type                        //
-                //                                                                  //
-                //////////////////////////////////////////////////////////////////////
+                if (msg)
+                  self.onSessionInvalid.call(self, msg);
+                else
+                  self.onSessionValidated.call(self, true);
+              });
 
-                /**
-                  Create wizard page. It renders a grid of
-                  Database Object Types such as
-                  Schemas, Views and Sequences etc.
-                  Set default values
-                */
-                var dbObjectTypePage = self.dbObjectTypePage = new pgBrowser.WizardPage({
-                  id: 1,
-                  page_title: _('Object Selection (step 1 of 3)'),
-                  disable_prev: true,
-                  disable_next: true,
-                  show_description: _('Please select objects from the list below.'),
-                  show_progress_bar: _('Please wait while fetching records...'),
-                  model: newModel,
-                  view: new (function() {
+              /**
+                It is the main model with schema defined
+                Every time a new wizard is opened,
+                a new model should create.
+              */
+              var GrantWizardModel = pgNode.Model.extend({
+                defaults: {
+                  objects: undefined,
+                  acl: undefined,
+                },
+                schema: [{
+                  id: 'objects',
+                  label: gettext('Objects'),
+                  model: DatabaseObjectModel,
+                  type: 'collection',
+                  group: gettext('Objects'),
+                },
+                {
+                  id: 'acl',
+                  label: gettext('Privileges'),
+                  model: pgBrowser.Node.PrivilegeRoleModel,
+                  type: 'collection',
+                  canAdd: true,
+                  canDelete: true,
+                  control: 'unique-col-collection',
+                },
+                ],
+                urlRoot: saveUrl,
+              });
 
-                    // Set page Instance
-                    var pageView = this;
+              /**
+                Create instance of GrantWizard Model, provide urlRoot
+                node_info object, Generate fields objects
+              */
+              var newModel = new GrantWizardModel({}, {
+                node_info: info,
+              });
 
-                    _.extend(pageView, {
+              /**
+                Fetch data from server and set into grid
+                and show/hide progress bar
+              */
+              $('.wizard-progress-bar p').show();
+
+              coll.fetch({
+                success: function() {
+                  $('.wizard-progress-bar p').html('');
+                  $('.wizard-progress-bar').hide();
+                },
+                reset: true,
+              }, this);
+
+              //////////////////////////////////////////////////////////////////////
+              //                                                                  //
+              //            Wizard Page for Db Object Type                        //
+              //                                                                  //
+              //////////////////////////////////////////////////////////////////////
 
-                      // Remove grid if it is before render
-                      cleanup: function() {
-                        if (this.grid) {
-                          this.grid.remove();
-                          delete this.grid;
-                          this.grid = null;
-                        }
+              /**
+                Create wizard page. It renders a grid of
+                Database Object Types such as
+                Schemas, Views and Sequences etc.
+                Set default values
+              */
+              var dbObjectTypePage = self.dbObjectTypePage = new pgBrowser.WizardPage({
+                id: 1,
+                page_title: _('Object Selection (step 1 of 3)'),
+                disable_prev: true,
+                disable_next: true,
+                show_description: _('Please select objects from the list below.'),
+                show_progress_bar: _('Please wait while fetching records...'),
+                model: newModel,
+                view: new(function() {
+
+                  // Set page Instance
+                  var pageView = this;
+
+                  _.extend(pageView, {
+
+                    // Remove grid if it is before render
+                    cleanup: function() {
+                      if (this.grid) {
+                        this.grid.remove();
+                        delete this.grid;
+                        this.grid = null;
+                      }
 
-                        // Remove grid element if exists
-                        if (this.el) {
-                          $(this.el).remove();
-                          delete this.el;
-                        }
-                      },
+                      // Remove grid element if exists
+                      if (this.el) {
+                        $(this.el).remove();
+                        delete this.el;
+                      }
+                    },
 
-                      // Delete grid before render
-                      grid: null,
+                    // Delete grid before render
+                    grid: null,
 
-                      render: function() {
+                    render: function() {
 
-                        // Create a grid container
-                        var gridBody =
-                              $('<div class="db_objects_container pg-el-xs-12"></div>');
+                      // Create a grid container
+                      var gridBody =
+                        $('<div class="db_objects_container pg-el-xs-12"></div>');
 
-                        // Remove grid if exits before render
-                        if (this.grid) {
-                          this.cleanup();
-                        }
+                      // Remove grid if exits before render
+                      if (this.grid) {
+                        this.cleanup();
+                      }
 
-                        // Initialize a new Grid instance
-                        this.grid = new Backgrid.Grid({
-                          columns: _.clone(columns),
-                          collection: coll,
-                          className: "backgrid table-bordered object_type_table pg-el-xs-12"
-                          });
+                      // Initialize a new Grid instance
+                      this.grid = new Backgrid.Grid({
+                        columns: _.clone(columns),
+                        collection: coll,
+                        className: 'backgrid table-bordered object_type_table pg-el-xs-12',
+                      });
 
-                        // Render selection Type grid and paginator
-                        gridBody.append( this.grid.render().$el);
+                      // Render selection Type grid and paginator
+                      gridBody.append(this.grid.render().$el);
 
-                        // Render Search Filter
-                        gridBody.prepend(
-                          self.clientSideFilter.render().el);
+                      // Render Search Filter
+                      gridBody.prepend(
+                        self.clientSideFilter.render().el);
 
-                        // Assign gridBody content to page element
-                        this.el = gridBody;
+                      // Assign gridBody content to page element
+                      this.el = gridBody;
 
-                        /**
-                          Fetch selected models from collection and
-                          make rows checked in grid
-                        */
-                        newModel.get('objects').each(function(m) {
-                          var model = coll.get(m.get('object_id'));
-                          if (model) {
-                            coll.trigger('backgrid:selected', model, true);
-                          }
-                        });
+                      /**
+                        Fetch selected models from collection and
+                        make rows checked in grid
+                      */
+                      newModel.get('objects').each(function(m) {
+                        var model = coll.get(m.get('object_id'));
+                        if (model) {
+                          coll.trigger('backgrid:selected', model, true);
+                        }
+                      });
 
-                        // Refresh grid to re render rows.
-                        coll.trigger('backgrid:refresh');
+                      // Refresh grid to re render rows.
+                      coll.trigger('backgrid:refresh');
 
-                        return this;
-                      }
-                    });
-                  }),
+                      return this;
+                    },
+                  });
+                }),
 
-                  beforeNext: function(obj){
-                    var self = this;
-                    obj.options.disable_next = true;
-
-                    /**
-                      Enable/Disable next button of privilegePage if objects
-                      are present in model
-                    */
-                    if(!_.isNull(newModel.get('acl')) &&
-                      !_.isUndefined(newModel.get('acl'))) {
-                      if(newModel.get('acl').length > 0)
-                        obj.collection.at(1).set('disable_next', false);
-                      }
+                beforeNext: function(obj) {
+                  var self = this;
+                  obj.options.disable_next = true;
 
-                    // Clean the view
-                    if (self.view) {
-                      self.view.cleanup();
-                      delete self.view;
-                      self.view = null;
-                    }
-                    return true;
-                  },
+                  /**
+                    Enable/Disable next button of privilegePage if objects
+                    are present in model
+                  */
+                  if (!_.isNull(newModel.get('acl')) &&
+                    !_.isUndefined(newModel.get('acl'))) {
+                    if (newModel.get('acl').length > 0)
+                      obj.collection.at(1).set('disable_next', false);
+                  }
 
-                });
+                  // Clean the view
+                  if (self.view) {
+                    self.view.cleanup();
+                    delete self.view;
+                    self.view = null;
+                  }
+                  return true;
+                },
+
+              });
+
+              //////////////////////////////////////////////////////////////////////
+              //                                                                  //
+              //            Wizard Page for Privilege Control                     //
+              //                                                                  //
+              //////////////////////////////////////////////////////////////////////
+
+              // Wizard for Privelege control
+              var privilegePage = self.privilegePage = new pgBrowser.WizardPage({
+                id: 2,
+                page_title: _('Privileges Selection (step 2 of 3)'),
+                show_description: _('Please select privileges for the selected objects.'),
+                disable_next: true,
+                model: newModel,
+
+                // Create a view function object
+                view: new(function() {
+                  var pageView = this;
+                  _.extend(pageView, {
+
+                    // Render Privelege control to generate its html markup
+                    render: function() {
+
+                      var obj_priv = [];
+                      self.privArray = _.uniq(self.privArray);
+                      _.each(self.privArray, function(priv) {
+                        self.obj_priv = obj_priv = _.union(obj_priv, privDict[priv].acl);
+                      });
 
-                //////////////////////////////////////////////////////////////////////
-                //                                                                  //
-                //            Wizard Page for Privilege Control                     //
-                //                                                                  //
-                //////////////////////////////////////////////////////////////////////
-
-                // Wizard for Privelege control
-                var privilegePage = self.privilegePage = new pgBrowser.WizardPage({
-                  id: 2,
-                  page_title: _('Privileges Selection (step 2 of 3)'),
-                  show_description: _('Please select privileges for the selected objects.'),
-                  disable_next: true,
-                  model: newModel,
+                      /**
+                        Define PrivModel and its instance.
+                        Privileges array is generated based on
+                        the type of nodes selected.
+                       */
+                      var privModel = self.privModel;
+                      var PrivModel = pgNode.Model.extend({
+                        defaults: {
+                          acl: undefined,
+                        },
+                        schema: [{
+                          id: 'acl',
+                          label: gettext('Privileges'),
+                          model: pgBrowser.Node.PrivilegeRoleModel.extend({
+
+                            // privileges are selected based on node clicked
+                            privileges: obj_priv,
+                          }),
+                          uniqueCol: ['grantee', 'grantor'],
+                          editable: true,
+                          type: 'collection',
+                          canAdd: true,
+                          canDelete: true,
+                          control: 'unique-col-collection',
+                        } ],
+                      });
 
-                  // Create a view function object
-                  view: new (function() {
-                    var pageView = this;
-                      _.extend(pageView, {
-
-                        // Render Privelege control to generate its html markup
-                        render: function() {
-
-                          var obj_priv = [];
-                          self.privArray = _.uniq(self.privArray);
-                          _.each(self.privArray, function(priv){
-                            self.obj_priv = obj_priv = _.union(obj_priv , privDict[priv].acl);
-                          });
-
-                          /**
-                            Define PrivModel and its instance.
-                            Privileges array is generated based on
-                            the type of nodes selected.
-                           */
-                          var privModel = self.privModel;
-                          var PrivModel = pgNode.Model.extend({
-                            defaults: {
-                              acl: undefined
-                            },
-                            schema: [
-                              {
-                                id: 'acl', label: gettext('Privileges'),
-                                model: pgAdmin.Browser.Node.PrivilegeRoleModel.extend({
-
-                                  // privileges are selected based on node clicked
-                                  privileges: obj_priv
-                                }), uniqueCol : ['grantee', 'grantor'], editable: true,
-                                type: 'collection', canAdd: true,
-                                canDelete: true, control: 'unique-col-collection'
-                              }
-                            ]
-                          });
-
-                          /**
-                            When privelege control is re-rendered, in order to
-                            render privileges based on object type selected,
-                            delete privileges from privModel which are now not
-                            present in object privileges array(object_priv)
-                           */
-                          var data = {};
-                          if (privModel) {
-                            data = privModel.toJSON();
-                            var rolePrivs = data['acl'];
-                            if (!_.isUndefined(rolePrivs) && rolePrivs.length > 0) {
-                              for (var idx in rolePrivs) {
-                                var rolePriv = (rolePrivs[idx])['privileges'],
-                                    removeIdx = [], j;
-
-                                for (j in rolePriv) {
-                                  var p = rolePriv[j];
-                                  if (_.indexOf(obj_priv, p['privilege_type']) == -1) {
-                                    removeIdx.push(j);
-                                  }
-                                }
-
-                                for (j in removeIdx) {
-                                  rolePriv.splice(j, 1);
-                                }
+                      /**
+                        When privelege control is re-rendered, in order to
+                        render privileges based on object type selected,
+                        delete privileges from privModel which are now not
+                        present in object privileges array(object_priv)
+                       */
+                      var data = {};
+                      if (privModel) {
+                        data = privModel.toJSON();
+                        var rolePrivs = data['acl'];
+                        if (!_.isUndefined(rolePrivs) && rolePrivs.length > 0) {
+                          for (var idx in rolePrivs) {
+                            var rolePriv = (rolePrivs[idx])['privileges'],
+                              removeIdx = [],
+                              j;
+
+                            for (j in rolePriv) {
+                              var p = rolePriv[j];
+                              if (_.indexOf(obj_priv, p['privilege_type']) == -1) {
+                                removeIdx.push(j);
                               }
-                            } else {
-                              console.log('Acls are not defined');
                             }
-                          }
-
-                          // Instantiate privModel
-                          privModel = self.privModel = new PrivModel(data, { node_info: self.info });
-
-                          /*
-                          To track changes into model, start new session
-                          and Add event listener for privileges control
-                          */
-                          self.privModel.startNewSession();
-                          self.privModel.on('pgadmin-session:valid', self.onSessionValidated.bind(self));
-                          self.privModel.on('pgadmin-session:invalid', self.onSessionInvalid.bind(self));
-
-                        /**
-                          Create Field Object which has properties like
-                          node_data, node_info which is required for rendering
-                          Privilege control
-                          */
-                          var fields = Backform.generateViewSchema(
-                              self.info, self.privModel, 'create', self.d._type, self.d
-                              );
-                          var privilegesField = new Backform.Field(fields[0].fields[0]);
-
-                          this.privControl = new (privilegesField.get('control')) ({
-                            field: privilegesField,
-                            model: self.privModel
-                          });
-
-                          return {el: this.privControl.render().$el};
-                        },
 
-                        // Remove the privilege control
-                        cleanup: function() {
-                          if (this.privControl) {
-                            this.privControl.remove();
-                            delete this.privControl;
-                            this.privControl = null;
+                            for (j in removeIdx) {
+                              rolePriv.splice(j, 1);
+                            }
                           }
+                        } else {
+                          console.warn('Acls are not defined');
                         }
+                      }
+
+                      // Instantiate privModel
+                      privModel = self.privModel = new PrivModel(data, {
+                        node_info: self.info,
                       });
-                  }),
 
-                  beforePrev: function(wizardObj) {
+                      /*
+                      To track changes into model, start new session
+                      and Add event listener for privileges control
+                      */
+                      self.privModel.startNewSession();
+                      self.privModel.on('pgadmin-session:valid', self.onSessionValidated.bind(self));
+                      self.privModel.on('pgadmin-session:invalid', self.onSessionInvalid.bind(self));
+
+                      /**
+                        Create Field Object which has properties like
+                        node_data, node_info which is required for rendering
+                        Privilege control
+                        */
+                      var fields = Backform.generateViewSchema(
+                        self.info, self.privModel, 'create', self.d._type, self.d
+                      );
+                      var privilegesField = new Backform.Field(fields[0].fields[0]);
+
+                      this.privControl = new(privilegesField.get('control'))({
+                        field: privilegesField,
+                        model: self.privModel,
+                      });
+
+                      return {
+                        el: this.privControl.render().$el,
+                      };
+                    },
 
                     // Remove the privilege control
-                    if (this.view) {
-                      this.view.cleanup();
-                      delete this.view;
-                      this.view = null;
-                    }
+                    cleanup: function() {
+                      if (this.privControl) {
+                        this.privControl.remove();
+                        delete this.privControl;
+                        this.privControl = null;
+                      }
+                    },
+                  });
+                }),
 
-                    /**
-                      Enable/Disable next button of DbObjectType page if objects
-                      are present in model
-                     */
-                    var objectsModel = newModel.get('objects');
+                beforePrev: function(wizardObj) {
 
-                    if(!_.isUndefined(objectsModel) && !_.isEmpty(objectsModel) &&
-                        objectsModel.length > 0) {
-                      wizardObj.collection.at(0).set('disable_next', false);
+                  // Remove the privilege control
+                  if (this.view) {
+                    this.view.cleanup();
+                    delete this.view;
+                    this.view = null;
+                  }
 
-                      // Don't show progress bar
-                      wizardObj.collection.at(0).set('show_progress_bar', '');
-                    }
+                  /**
+                    Enable/Disable next button of DbObjectType page if objects
+                    are present in model
+                   */
+                  var objectsModel = newModel.get('objects');
 
-                    /**
-                      We're re-rendering the controls as they are deleted
-                      before heading to next page
-                      Refresh Backgrid to re-render the elements selected
-                      re-render Filter
-                    */
-                    newModel.trigger("backgrid:refresh", newModel, false);
-                    self.clientSideFilter.render();
-                    return true;
-                  },
+                  if (!_.isUndefined(objectsModel) && !_.isEmpty(objectsModel) &&
+                    objectsModel.length > 0) {
+                    wizardObj.collection.at(0).set('disable_next', false);
 
-                  beforeNext: function() { return true; },
+                    // Don't show progress bar
+                    wizardObj.collection.at(0).set('show_progress_bar', '');
+                  }
 
-                  onNext: function(obj){
+                  /**
+                    We're re-rendering the controls as they are deleted
+                    before heading to next page
+                    Refresh Backgrid to re-render the elements selected
+                    re-render Filter
+                  */
+                  newModel.trigger('backgrid:refresh', newModel, false);
+                  self.clientSideFilter.render();
+                  return true;
+                },
 
-                    // Assign acls of privModel to main model newModel
-                    if (!_.isUndefined(self.privModel)) {
-                      newModel.set({'acl': self.privModel.get('acl')});
-                    }
+                beforeNext: function() {
+                  return true;
+                },
 
-                    // Remove the privilege control
-                    if (this.view) {
-                      this.view.cleanup();
-                      delete this.view;
-                      this.view = null;
-                    }
+                onNext: function() {
 
-                    // Enable finish button
-                    self.wizard.options.disable_finish = false;
+                  // Assign acls of privModel to main model newModel
+                  if (!_.isUndefined(self.privModel)) {
+                    newModel.set({
+                      'acl': self.privModel.get('acl'),
+                    });
+                  }
 
-                    /**
-                      triggers to get SQL queries data to render
-                      into the reviewSQLPage
-                    */
-                    newModel.trigger('pgadmin-wizard:nextpage:sql', {'node_type': node_type });
+                  // Remove the privilege control
+                  if (this.view) {
+                    this.view.cleanup();
+                    delete this.view;
+                    this.view = null;
                   }
-                });
 
+                  // Enable finish button
+                  self.wizard.options.disable_finish = false;
+
+                  /**
+                    triggers to get SQL queries data to render
+                    into the reviewSQLPage
+                  */
+                  newModel.trigger('pgadmin-wizard:nextpage:sql', {
+                    'node_type': node_type,
+                  });
+                },
+              });
 
-                //////////////////////////////////////////////////////////////////////
-                //                                                                  //
-                //            Review SQL Query Page                                 //
-                //                                                                  //
-                //////////////////////////////////////////////////////////////////////
 
-                //Create SqlField Object
-                var sqlField = new Backform.Field(
-                    {
-                      id: 'sqltab',
-                      label: _('Sql Tab'),
+              //////////////////////////////////////////////////////////////////////
+              //                                                                  //
+              //            Review SQL Query Page                                 //
+              //                                                                  //
+              //////////////////////////////////////////////////////////////////////
 
-                      /**
-                        Extend 'SqlTabControl' to define new
-                        function 'onWizardNextPageChange'
-                        which gets triggered on next button
-                        click to fetch generated SQL query
-                        for the selected db objects.
-                      */
-                      control: Backform.SqlTabControl.extend({
-                        initialize: function() {
+              //Create SqlField Object
+              var sqlField = new Backform.Field({
+                  id: 'sqltab',
+                  label: _('Sql Tab'),
 
-                          // Initialize parent class
-                          Backform.SqlTabControl.prototype.initialize.apply(this, arguments);
+                  /**
+                    Extend 'SqlTabControl' to define new
+                    function 'onWizardNextPageChange'
+                    which gets triggered on next button
+                    click to fetch generated SQL query
+                    for the selected db objects.
+                  */
+                  control: Backform.SqlTabControl.extend({
+                    initialize: function() {
 
-                          this.msql_url = self.msql_url;
+                      // Initialize parent class
+                      Backform.SqlTabControl.prototype.initialize.apply(this, arguments);
 
-                          // define trigger events for prev and next page
-                          this.model.on('pgadmin-wizard:nextpage:sql', this.onWizardNextPageChange, this);
-                          this.model.on('pgadmin-wizard:prevpage:sql', this.onWizardPrevPageChange, this);
-                        },
+                      this.msql_url = self.msql_url;
 
-                        // This method fetches the modified SQL for the wizard
-                        onWizardNextPageChange: function(){
-
-                          var self = this;
-
-                          // Fetches modified SQL
-                          $.ajax({
-                            url: this.msql_url,
-                            type: 'GET',
-                            cache: false,
-                            data: self.model.toJSON(true, 'GET'),
-                            dataType: "json",
-                            contentType: "application/json"
-                          }).done(function(res) {
-                            self.sqlCtrl.clearHistory();
-                            self.sqlCtrl.setValue(res.data);
-                            self.sqlCtrl.refresh();
-                          }).fail(function() {
-                            self.model.trigger('pgadmin-view:msql:error');
-                          }).always(function() {
-                            self.model.trigger('pgadmin-view:msql:fetched');
-                          });
-                        },
+                      // define trigger events for prev and next page
+                      this.model.on('pgadmin-wizard:nextpage:sql', this.onWizardNextPageChange, this);
+                      this.model.on('pgadmin-wizard:prevpage:sql', this.onWizardPrevPageChange, this);
+                    },
 
-                        remove: function() {
+                    // This method fetches the modified SQL for the wizard
+                    onWizardNextPageChange: function() {
 
-                          // Clear html dom elements of CodeMirror sql tab
-                          self.sqlControl.unbind(); // Unbind all local event bindings
-                          var cmElem = self.sqlControl.sqlCtrl.getWrapperElement();
-                          $(cmElem).remove();
-                          self.sqlControl.sqlCtrl = undefined;
-                        }
+                      var self = this;
 
-                      })
-                    }),
+                      // Fetches modified SQL
+                      $.ajax({
+                        url: this.msql_url,
+                        type: 'GET',
+                        cache: false,
+                        data: self.model.toJSON(true, 'GET'),
+                        dataType: 'json',
+                        contentType: 'application/json',
+                      }).done(function(res) {
+                        self.sqlCtrl.clearHistory();
+                        self.sqlCtrl.setValue(res.data);
+                        self.sqlCtrl.refresh();
+                      }).fail(function() {
+                        self.model.trigger('pgadmin-view:msql:error');
+                      }).always(function() {
+                        self.model.trigger('pgadmin-view:msql:fetched');
+                      });
+                    },
 
-                  /**
-                    Create sqlField view instance
-                    to render it into wizard page
-                  */
-                  sqlControl = self.sqlControl = new (sqlField.get('control'))({
-                    field: sqlField,
-                    model: newModel
-                  });
+                    remove: function() {
 
-                // Wizard for SQL tab control
-                var reviewSQLPage = self.reviewSQLPage = new pgBrowser.WizardPage({
-                  id: 3,
-                  page_title: _('Final (Review Selection) (step 3 of 3)'),
-                  show_description: _('The SQL below will be executed on the ' +
-                                'database server to grant the selected privileges. ' +
-                                'Please click on <b>Finish</b> to complete the process.'),
-                  model: newModel,
-                  view: new(function() {
+                      // Clear html dom elements of CodeMirror sql tab
+                      self.sqlControl.unbind(); // Unbind all local event bindings
+                      var cmElem = self.sqlControl.sqlCtrl.getWrapperElement();
+                      $(cmElem).remove();
+                      self.sqlControl.sqlCtrl = undefined;
+                    },
 
-                    // Render SqlTab control to generate its html markup
-                    var sqlCtrlHtml = sqlControl.render().$el;
-                    this.render = function() {
-                        return { el: sqlCtrlHtml };
-                    };
                   }),
+                }),
 
-                  beforePrev: function(wizardObj) {
+                /**
+                  Create sqlField view instance
+                  to render it into wizard page
+                */
+                sqlControl = self.sqlControl = new(sqlField.get('control'))({
+                  field: sqlField,
+                  model: newModel,
+                });
 
-                    /**
-                      Enable next button if privilege
-                      model is not empty else disable
-                      next button
-                     */
-                    var aclModel = newModel.get('acl');
+              // Wizard for SQL tab control
+              var reviewSQLPage = self.reviewSQLPage = new pgBrowser.WizardPage({
+                id: 3,
+                page_title: _('Final (Review Selection) (step 3 of 3)'),
+                show_description: _('The SQL below will be executed on the ' +
+                  'database server to grant the selected privileges. ' +
+                  'Please click on <b>Finish</b> to complete the process.'),
+                model: newModel,
+                view: new(function() {
+
+                  // Render SqlTab control to generate its html markup
+                  var sqlCtrlHtml = sqlControl.render().$el;
+                  this.render = function() {
+                    return {
+                      el: sqlCtrlHtml,
+                    };
+                  };
+                }),
 
-                    if(!_.isUndefined(wizardObj.collection) &&
-                      wizardObj.collection.models.length > 0) {
-                      if(!_.isUndefined(aclModel) && !_.isEmpty(aclModel) &&
-                          aclModel.length > 0) {
-                        wizardObj.collection.at(1).set('disable_next', false);
-                      }
-                      else {
-                        wizardObj.collection.at(1).set('disable_next', true);
-                      }
+                beforePrev: function(wizardObj) {
 
-                      return true;
+                  /**
+                    Enable next button if privilege
+                    model is not empty else disable
+                    next button
+                   */
+                  var aclModel = newModel.get('acl');
+
+                  if (!_.isUndefined(wizardObj.collection) &&
+                    wizardObj.collection.models.length > 0) {
+                    if (!_.isUndefined(aclModel) && !_.isEmpty(aclModel) &&
+                      aclModel.length > 0) {
+                      wizardObj.collection.at(1).set('disable_next', false);
+                    } else {
+                      wizardObj.collection.at(1).set('disable_next', true);
                     }
-                  },
-                });
 
+                    return true;
+                  }
+                },
+              });
 
-                // Create Wizard Collection of Wizard Pages
-                var WizardCollection = Backbone.Collection.extend({
-                  model: pgBrowser.WizardPage
-                });
 
-                // It holds all the wizard pages to be rendered
-                this.wizardCollection = new WizardCollection(
-                  [dbObjectTypePage, privilegePage, reviewSQLPage]
-                );
+              // Create Wizard Collection of Wizard Pages
+              var WizardCollection = Backbone.Collection.extend({
+                model: pgBrowser.WizardPage,
+              });
 
-                /**
-                  Create wizard which has following operations:
-                  - renders wizard pages
-                  - defines the first page to render in wizard
-                  - Save the model on finishbutton
-                  - Remove wizard on cancel button
-                  */
-                self.wizard = new (pgBrowser.Wizard.extend({
-                  options: {
-                    title: _('Grant Wizard'), /* Main Wizard Title */
-                    width: '',
-                    height: '',
-                    curr_page: 0,
-                    show_left_panel: false,
-                    show_header_cancel_btn: true,
-                    show_header_maximize_btn: true,
-                    disable_finish: true,
-                    dialog_api: that,
-                    wizard_help: url_for(
-                      'help.static', {'filename': 'grant_wizard.html'}
-                    )
-                  },
-
-                  // Callback for finish button
-                  onFinish: function() {
-                    var m = newModel,
-                        d = m.toJSON('GET');
-
-                    // Save model
-                    if (d && !_.isEmpty(d) && !_.isUndefined(d.objects)) {
-                      m.save({}, {
-                        attrs: d,
-                        validate: false,
-                        cache: false,
-                        success: function(res) {
+              // It holds all the wizard pages to be rendered
+              this.wizardCollection = new WizardCollection(
+                [dbObjectTypePage, privilegePage, reviewSQLPage]
+              );
 
-                          // Release wizard objects
-                          self.releaseObjects();
-                          self.close();
-                        },
-                        error: function(m, jqxhr) {
-                          alertify.pgNotifier(
-                            "error", jqxhr,
-                            gettext("Error saving properties")
-                          );
-
-                            // Release wizard objects
-                            self.releaseObjects();
-                            self.close();
-                        }
-                      });
+              /**
+                Create wizard which has following operations:
+                - renders wizard pages
+                - defines the first page to render in wizard
+                - Save the model on finishbutton
+                - Remove wizard on cancel button
+                */
+              self.wizard = new(pgBrowser.Wizard.extend({
+                options: {
+                  title: _('Grant Wizard'),
+                  /* Main Wizard Title */
+                  width: '',
+                  height: '',
+                  curr_page: 0,
+                  show_left_panel: false,
+                  show_header_cancel_btn: true,
+                  show_header_maximize_btn: true,
+                  disable_finish: true,
+                  dialog_api: that,
+                  wizard_help: url_for(
+                    'help.static', {
+                      'filename': 'grant_wizard.html',
                     }
-                  },
-
-                  // Callback for cancel button
-                  onCancel: function() {
-
-                    // Release wizard objects
-                    self.releaseObjects();
-                    self.close();
+                  ),
+                },
+
+                // Callback for finish button
+                onFinish: function() {
+                  var m = newModel,
+                    d = m.toJSON('GET');
+
+                  // Save model
+                  if (d && !_.isEmpty(d) && !_.isUndefined(d.objects)) {
+                    m.save({}, {
+                      attrs: d,
+                      validate: false,
+                      cache: false,
+                      success: function() {
+
+                        // Release wizard objects
+                        self.releaseObjects();
+                        self.close();
+                      },
+                      error: function(m, jqxhr) {
+                        Alertify.pgNotifier(
+                          'error', jqxhr,
+                          gettext('Error saving properties')
+                        );
+
+                        // Release wizard objects
+                        self.releaseObjects();
+                        self.close();
+                      },
+                    });
                   }
-                })) ({
-                  collection: this.wizardCollection,
-                  el: el,
-                  model: newModel
-                });
-
-                // Render wizard
-                self.wizard.render();
-              }
-            };
-          });
-        }
-
-        // Call Grant Wizard Dialog and set dimensions for wizard
-        alertify.wizardDialog(true).resizeTo('55%', '75%');
+                },
+
+                // Callback for cancel button
+                onCancel: function() {
+
+                  // Release wizard objects
+                  self.releaseObjects();
+                  self.close();
+                },
+              }))({
+                collection: this.wizardCollection,
+                el: el,
+                model: newModel,
+              });
+
+              // Render wizard
+              self.wizard.render();
+            },
+          };
+        });
       }
-    };
 
-    return pgBrowser.GrantWizard;
-  });
+      // Call Grant Wizard Dialog and set dimensions for wizard
+      Alertify.wizardDialog(true).resizeTo('55%', '75%');
+    },
+  };
+
+  return pgBrowser.GrantWizard;
+});
diff --git a/web/pgadmin/tools/import_export/static/js/import_export.js b/web/pgadmin/tools/import_export/static/js/import_export.js
index 87973e42..070ba6c3 100644
--- a/web/pgadmin/tools/import_export/static/js/import_export.js
+++ b/web/pgadmin/tools/import_export/static/js/import_export.js
@@ -1,7 +1,7 @@
 define([
   'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
   'sources/pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'backform',
-  'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui'
+  'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui',
 ], function(
   gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, Backform
 ) {
@@ -17,7 +17,8 @@ define([
   // Main model for Import/Export functionality
   var ImportExportModel = Backbone.Model.extend({
     defaults: {
-      is_import: false, /* false for Export */
+      is_import: false,
+      /* false for Export */
       filename: undefined,
       format: 'csv',
       encoding: undefined,
@@ -31,227 +32,338 @@ define([
       icolumns: [],
       database: undefined,
       schema: undefined,
-      table: undefined
+      table: undefined,
     },
     schema: [{
-      id: 'is_import', label: gettext('Import/Export'), cell: 'switch',
-      type: 'switch', group: gettext('Options'),
+      id: 'is_import',
+      label: gettext('Import/Export'),
+      cell: 'switch',
+      type: 'switch',
+      group: gettext('Options'),
       options: {
-         'onText': gettext('Import'), 'offText': gettext('Export'),
-         'onColor': 'success', 'offColor': 'primary'
-      }
+        'onText': gettext('Import'),
+        'offText': gettext('Export'),
+        'onColor': 'success',
+        'offColor': 'primary',
+      },
     }, {
-      type: 'nested', control: 'fieldset', label: gettext('File Info'),
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('File Info'),
       group: gettext('Options'),
-      schema:[{ /* select file control for import */
-      id: 'filename', label: gettext('Filename'), deps: ['is_import'],
-      type: 'text', control: Backform.FileControl, group: gettext('File Info'),
-      dialog_type: 'select_file', supp_types: ['csv', 'txt', '*'],
-      visible: 'importing'
-    }, { /* create file control for export */
-        id: 'filename', label: gettext('Filename'), deps: ['is_import'],
-        type: 'text', control: Backform.FileControl, group: gettext('File Info'),
-        dialog_type: 'create_file', supp_types: ['csv', 'txt', '*'],
-        visible: 'exporting'
+      schema: [{ /* select file control for import */
+        id: 'filename',
+        label: gettext('Filename'),
+        deps: ['is_import'],
+        type: 'text',
+        control: Backform.FileControl,
+        group: gettext('File Info'),
+        dialog_type: 'select_file',
+        supp_types: ['csv', 'txt', '*'],
+        visible: 'importing',
+      }, { /* create file control for export */
+        id: 'filename',
+        label: gettext('Filename'),
+        deps: ['is_import'],
+        type: 'text',
+        control: Backform.FileControl,
+        group: gettext('File Info'),
+        dialog_type: 'create_file',
+        supp_types: ['csv', 'txt', '*'],
+        visible: 'exporting',
       }, {
-        id: 'format', label: gettext('Format'), cell: 'string',
-        control: 'select2', group: gettext('File Info'),
-        options:[
-            {'label': 'binary', 'value': 'binary'}, {'label': 'csv', 'value': 'csv'}, {'label': 'text', 'value': 'text'},
-          ],
-        disabled: 'isDisabled', select2: {allowClear: false, width: "100%" },
+        id: 'format',
+        label: gettext('Format'),
+        cell: 'string',
+        control: 'select2',
+        group: gettext('File Info'),
+        options: [{
+          'label': 'binary',
+          'value': 'binary',
+        }, {
+          'label': 'csv',
+          'value': 'csv',
+        }, {
+          'label': 'text',
+          'value': 'text',
+        } ],
+        disabled: 'isDisabled',
+        select2: {
+          allowClear: false,
+          width: '100%',
+        },
       }, {
-        id: 'encoding', label: gettext('Encoding'), cell: 'string',
-        control: 'node-ajax-options', node: 'database', url: 'get_encodings', first_empty: true,
-        group: gettext('File Info')
-      }]
-    },{
-        id: 'columns', label: gettext('Columns to import'), cell: 'string',
-        deps: ['is_import'], type: 'array', first_empty: false,
-        control: Backform.NodeListByNameControl.extend({
-          // By default, all the import columns should be selected
-          initialize: function() {
-            Backform.NodeListByNameControl.prototype.initialize.apply(this, arguments);
-            var self = this,
-                options = self.field.get('options'),
-                op_vals = [];
-
-            if (_.isFunction(options)) {
-              try {
-                var all_cols = options.apply(self);
-                for(var idx in all_cols) {
-                  op_vals.push((all_cols[idx])['value']);
-                }
-              } catch(e) {
-                // Do nothing
-                options = [];
-              }
-            } else {
-              for (idx in options) {
-                op_vals.push((options[idx])['value']);
+        id: 'encoding',
+        label: gettext('Encoding'),
+        cell: 'string',
+        control: 'node-ajax-options',
+        node: 'database',
+        url: 'get_encodings',
+        first_empty: true,
+        group: gettext('File Info'),
+      }],
+    }, {
+      id: 'columns',
+      label: gettext('Columns to import'),
+      cell: 'string',
+      deps: ['is_import'],
+      type: 'array',
+      first_empty: false,
+      control: Backform.NodeListByNameControl.extend({
+        // By default, all the import columns should be selected
+        initialize: function() {
+          Backform.NodeListByNameControl.prototype.initialize.apply(this, arguments);
+          var self = this,
+            options = self.field.get('options'),
+            op_vals = [];
+
+          if (_.isFunction(options)) {
+            try {
+              var all_cols = options.apply(self);
+              for (var idx in all_cols) {
+                op_vals.push((all_cols[idx])['value']);
               }
+            } catch (e) {
+              // Do nothing
+              options = [];
+              console.warn(e.stack || e);
+            }
+          } else {
+            for (idx in options) {
+              op_vals.push((options[idx])['value']);
             }
-
-            self.model.set('columns',op_vals);
           }
-        }),
-        transform: function(rows) {
-          var self = this,
-              node = self.field.get('schema_node'),
-              res = [];
-
-          _.each(rows, function(r) {
-              var l = (_.isFunction(node['node_label']) ?
-                    (node['node_label']).apply(node, [r, self.model, self]) :
-                    r.label),
-                  image = (_.isFunction(node['node_image']) ?
-                    (node['node_image']).apply(
-                      node, [r, self.model, self]
-                      ) :
-                    (node['node_image'] || ('icon-' + node.type)));
-              res.push({
-                'value': r.label,
-                'image': image,
-                'label': l
-              });
-          });
 
-          return res;
+          self.model.set('columns', op_vals);
         },
-        node: 'column', url: 'nodes', group: gettext('Columns'),
-        select2: {
-          multiple: true, allowClear: false,
-          placeholder: gettext('Columns for importing...'),
-          first_empty: false
-        }, visible: 'importing',
-        helpMessage:
-        gettext('An optional list of columns to be copied. If no column list is specified, all columns of the table will be copied.')
-      }, {
-        id: 'columns', label: gettext('Columns to export'), cell: 'string',
-        deps: ['is_import'], type: 'array',
-        control: 'node-list-by-name', first_empty: false,
-        node: 'column', url: 'nodes', group: gettext('Columns'),
-        select2: {
-          multiple: true, allowClear: true,
-          placeholder: gettext('Colums for exporting...')
-        }, visible: 'exporting',
-        transform: function(rows) {
-          var self = this,
-              node = self.field.get('schema_node'),
-              res = [];
-
-          _.each(rows, function(r) {
-              var l = (_.isFunction(node['node_label']) ?
-                    (node['node_label']).apply(node, [r, self.model, self]) :
-                    r.label),
-                  image = (_.isFunction(node['node_image']) ?
-                    (node['node_image']).apply(
-                      node, [r, self.model, self]
-                      ) :
-                    (node['node_image'] || ('icon-' + node.type)));
-              res.push({
-                'value': r.label,
-                'image': image,
-                'label': l
-              });
+      }),
+      transform: function(rows) {
+        var self = this,
+          node = self.field.get('schema_node'),
+          res = [];
+
+        _.each(rows, function(r) {
+          var l = (_.isFunction(node['node_label']) ?
+              (node['node_label']).apply(node, [r, self.model, self]) :
+              r.label),
+            image = (_.isFunction(node['node_image']) ?
+              (node['node_image']).apply(
+                node, [r, self.model, self]
+              ) :
+              (node['node_image'] || ('icon-' + node.type)));
+          res.push({
+            'value': r.label,
+            'image': image,
+            'label': l,
           });
+        });
 
-          return res;
-        },
-        helpMessage:
-          gettext('An optional list of columns to be copied. If no column list is specified, all columns of the table will be copied.')
+        return res;
+      },
+      node: 'column',
+      url: 'nodes',
+      group: gettext('Columns'),
+      select2: {
+        multiple: true,
+        allowClear: false,
+        placeholder: gettext('Columns for importing...'),
+        first_empty: false,
+      },
+      visible: 'importing',
+      helpMessage: gettext('An optional list of columns to be copied. If no column list is specified, all columns of the table will be copied.'),
+    }, {
+      id: 'columns',
+      label: gettext('Columns to export'),
+      cell: 'string',
+      deps: ['is_import'],
+      type: 'array',
+      control: 'node-list-by-name',
+      first_empty: false,
+      node: 'column',
+      url: 'nodes',
+      group: gettext('Columns'),
+      select2: {
+        multiple: true,
+        allowClear: true,
+        placeholder: gettext('Colums for exporting...'),
+      },
+      visible: 'exporting',
+      transform: function(rows) {
+        var self = this,
+          node = self.field.get('schema_node'),
+          res = [];
+
+        _.each(rows, function(r) {
+          var l = (_.isFunction(node['node_label']) ?
+              (node['node_label']).apply(node, [r, self.model, self]) :
+              r.label),
+            image = (_.isFunction(node['node_image']) ?
+              (node['node_image']).apply(
+                node, [r, self.model, self]
+              ) :
+              (node['node_image'] || ('icon-' + node.type)));
+          res.push({
+            'value': r.label,
+            'image': image,
+            'label': l,
+          });
+        });
+
+        return res;
+      },
+      helpMessage: gettext('An optional list of columns to be copied. If no column list is specified, all columns of the table will be copied.'),
+    }, {
+      id: 'null_string',
+      label: gettext('NULL Strings'),
+      cell: 'string',
+      type: 'text',
+      group: gettext('Columns'),
+      disabled: 'isDisabled',
+      deps: ['format'],
+      helpMessage: gettext('Specifies the string that represents a null value. The default is \\N (backslash-N) in text format, and an unquoted empty string in CSV format. You might prefer an empty string even in text format for cases where you don\'t want to distinguish nulls from empty strings. This option is not allowed when using binary format.'),
+    }, {
+      id: 'icolumns',
+      label: gettext('Not null columns'),
+      cell: 'string',
+      control: 'node-list-by-name',
+      node: 'column',
+      group: gettext('Columns'),
+      deps: ['format', 'is_import'],
+      disabled: 'isDisabled',
+      type: 'array',
+      first_empty: false,
+      select2: {
+        multiple: true,
+        allowClear: true,
+        first_empty: true,
+        placeholder: gettext('Not null columns...'),
+      },
+      helpMessage: gettext('Do not match the specified column values against the null string. In the default case where the null string is empty, this means that empty values will be read as zero-length strings rather than nulls, even when they are not quoted. This option is allowed only in import, and only when using CSV format.'),
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Miscellaneous'),
+      group: gettext('Options'),
+      schema: [{
+        id: 'oid',
+        label: gettext('OID'),
+        cell: 'string',
+        type: 'switch',
+        group: gettext('Miscellaneous'),
       }, {
-        id: 'null_string', label: gettext('NULL Strings'), cell: 'string',
-        type: 'text', group: gettext('Columns'), disabled: 'isDisabled',
+        id: 'header',
+        label: gettext('Header'),
+        cell: 'string',
+        type: 'switch',
+        group: gettext('Miscellaneous'),
         deps: ['format'],
-        helpMessage:
-          gettext("Specifies the string that represents a null value. The default is \\N (backslash-N) in text format, and an unquoted empty string in CSV format. You might prefer an empty string even in text format for cases where you don't want to distinguish nulls from empty strings. This option is not allowed when using binary format.")
+        disabled: 'isDisabled',
       }, {
-        id: 'icolumns', label: gettext('Not null columns'), cell: 'string',
-        control: 'node-list-by-name', node: 'column',
-        group: gettext('Columns'), deps: ['format', 'is_import'], disabled: 'isDisabled',
-        type: 'array', first_empty: false,
+        id: 'delimiter',
+        label: gettext('Delimiter'),
+        cell: 'string',
+        first_empty: true,
+        type: 'text',
+        control: 'node-ajax-options',
+        group: gettext('Miscellaneous'),
+        disabled: 'isDisabled',
+        deps: ['format'],
+        options: [{
+          'label': ';',
+          'value': ';',
+        },
+        {
+          'label': ',',
+          'value': ',',
+        },
+        {
+          'label': '|',
+          'value': '|',
+        },
+        {
+          'label': '[tab]',
+          'value': '[tab]',
+        },
+        ],
         select2: {
-          multiple: true, allowClear: true, first_empty: true,
-          placeholder: gettext('Not null columns...')
+          tags: true,
+          allowClear: false,
+          width: '100%',
+          placeholder: gettext('Select from list...'),
         },
-        helpMessage:
-          gettext('Do not match the specified column values against the null string. In the default case where the null string is empty, this means that empty values will be read as zero-length strings rather than nulls, even when they are not quoted. This option is allowed only in import, and only when using CSV format.')
-      }, {
-        type: 'nested', control: 'fieldset', label: gettext('Miscellaneous'),
-        group: gettext('Options'),
-        schema:[{
-          id: 'oid', label: gettext('OID'), cell: 'string',
-          type: 'switch', group: gettext('Miscellaneous')
-        },{
-          id: 'header', label: gettext('Header'), cell: 'string',
-          type: 'switch', group: gettext('Miscellaneous'), deps: ['format'], disabled: 'isDisabled'
-        },{
-          id: 'delimiter', label: gettext('Delimiter'), cell: 'string', first_empty: true,
-          type: 'text', control: 'node-ajax-options', group: gettext('Miscellaneous'), disabled: 'isDisabled',
-          deps: ['format'],
-          options:[
-            {'label': ';', 'value': ';'},
-            {'label': ',', 'value': ','},
-            {'label': '|', 'value': '|'},
-            {'label': '[tab]', 'value': '[tab]'}
-          ],
-          select2: {
-            tags: true,
-            allowClear: false,
-            width: "100%",
-            placeholder: gettext('Select from list...')
-          }, helpMessage:
-            gettext('Specifies the character that separates columns within each row (line) of the file. The default is a tab character in text format, a comma in CSV format. This must be a single one-byte character. This option is not allowed when using binary format.')
+        helpMessage: gettext('Specifies the character that separates columns within each row (line) of the file. The default is a tab character in text format, a comma in CSV format. This must be a single one-byte character. This option is not allowed when using binary format.'),
+      },
+      {
+        id: 'quote',
+        label: gettext('Quote'),
+        cell: 'string',
+        first_empty: true,
+        deps: ['format'],
+        type: 'text',
+        control: 'node-ajax-options',
+        group: gettext('Miscellaneous'),
+        disabled: 'isDisabled',
+        options: [{
+          'label': '\"',
+          'value': '\"',
         },
         {
-          id: 'quote', label: gettext('Quote'), cell: 'string', first_empty: true, deps: ['format'],
-          type: 'text', control: 'node-ajax-options', group: gettext('Miscellaneous'), disabled: 'isDisabled',
-          options:[
-            {'label': '\"', 'value': '\"'},
-            {'label': '\'', 'value': '\''},
-          ],
-          select2: {
-            tags: true,
-            allowClear: false,
-            width: "100%",
-            placeholder: gettext('Select from list...')
-          }, helpMessage:
-            gettext('Specifies the quoting character to be used when a data value is quoted. The default is double-quote. This must be a single one-byte character. This option is allowed only when using CSV format.')
+          'label': '\'',
+          'value': '\'',
+        },
+        ],
+        select2: {
+          tags: true,
+          allowClear: false,
+          width: '100%',
+          placeholder: gettext('Select from list...'),
+        },
+        helpMessage: gettext('Specifies the quoting character to be used when a data value is quoted. The default is double-quote. This must be a single one-byte character. This option is allowed only when using CSV format.'),
+      },
+      {
+        id: 'escape',
+        label: gettext('Escape'),
+        cell: 'string',
+        first_empty: true,
+        deps: ['format'],
+        type: 'text',
+        control: 'node-ajax-options',
+        group: gettext('Miscellaneous'),
+        disabled: 'isDisabled',
+        options: [{
+          'label': '\"',
+          'value': '\"',
         },
         {
-          id: 'escape', label: gettext('Escape'), cell: 'string', first_empty: true, deps: ['format'],
-          type: 'text', control: 'node-ajax-options', group: gettext('Miscellaneous'), disabled: 'isDisabled',
-          options:[
-            {'label': '\"', 'value': '\"'},
-            {'label': '\'', 'value': '\''},
-          ],
-          select2: {
-            tags: true,
-            allowClear: false,
-            width: "100%",
-            placeholder: gettext('Select from list...')
-          }, helpMessage:
-            gettext('Specifies the character that should appear before a data character that matches the QUOTE value. The default is the same as the QUOTE value (so that the quoting character is doubled if it appears in the data). This must be a single one-byte character. This option is allowed only when using CSV format.')
-        }]
-      }
-    ],
+          'label': '\'',
+          'value': '\'',
+        },
+        ],
+        select2: {
+          tags: true,
+          allowClear: false,
+          width: '100%',
+          placeholder: gettext('Select from list...'),
+        },
+        helpMessage: gettext('Specifies the character that should appear before a data character that matches the QUOTE value. The default is the same as the QUOTE value (so that the quoting character is doubled if it appears in the data). This must be a single one-byte character. This option is allowed only when using CSV format.'),
+      },
+      ],
+    } ],
 
     // Enable/Disable the items based on the user file format selection
     isDisabled: function(m) {
-      name = this.name;
-      switch(name) {
-        case 'quote':
-        case 'escape':
-        case 'header':
-          return (m.get('format') != 'csv')
-        case 'icolumns':
-          return (m.get('format') != 'csv' || !m.get('is_import'));
-        case 'null_string':
-        case 'delimiter':
-          return (m.get('format') == 'binary');
-        default:
-          return false;
+      switch (this.name) {
+      case 'quote':
+      case 'escape':
+      case 'header':
+        return (m.get('format') != 'csv');
+      case 'icolumns':
+        return (m.get('format') != 'csv' || !m.get('is_import'));
+      case 'null_string':
+      case 'delimiter':
+        return (m.get('format') == 'binary');
+      default:
+        return false;
       }
     },
     importing: function(m) {
@@ -259,281 +371,300 @@ define([
     },
     exporting: function(m) {
       return !(m.importing.apply(this, arguments));
-    }
+    },
   });
 
   pgTools.import_utility = {
-      init: function() {
-        // We do not want to initialize the module multiple times.
-        if (this.initialized)
-            return;
-
-        this.initialized = true;
-
-        /**
-         Enable/disable import menu in tools based on node selected
-         Import menu will be enabled only when user select table node.
-        */
-        var menu_enabled = function(itemData, item, data) {
-         var t = pgBrowser.tree, i = item, d = itemData;
-         var parent_item = t.hasParent(i) ? t.parent(i): null,
-             parent_data = parent_item ? t.itemData(parent_item) : null;
-           if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data))
-             return (
-               (_.indexOf(['table'], d._type) !== -1 &&
-               parent_data._type != 'catalog') ? true: false
-             );
-           else
-             return false;
-        };
-
-        // Initialize the context menu to display the import options when user open the context menu for table
-        pgBrowser.add_menus([{
-          name: 'import', node: 'table', module: this,
-          applies: ['tools', 'context'], callback: 'callback_import_export',
-          category: 'import', priority: 10, label: gettext('Import/Export...'),
-          icon: 'fa fa-shopping-cart', enable: menu_enabled
-        }]);
-      },
-
-      /*
-        Open the dialog for the import functionality
-      */
-      callback_import_export: function(args, item) {
-        var i = item || pgBrowser.tree.selected(),
-          server_data = null;
-
-        while (i) {
-          var node_data = pgBrowser.tree.itemData(i);
-          if (node_data._type == 'server') {
-            server_data = node_data;
-            break;
-          }
-
-          if (pgBrowser.tree.hasParent(i)) {
-            i = $(pgBrowser.tree.parent(i));
-          } else {
-            Alertify.alert(gettext("Please select server or child node from tree."));
-            break;
-          }
-        }
+    init: function() {
+      // We do not want to initialize the module multiple times.
+      if (this.initialized)
+        return;
 
-        if (!server_data) {
-          return;
-        }
+      this.initialized = true;
 
-        var module = 'paths',
-          preference_name = 'pg_bin_dir',
-          msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
+      /*
+       * Enable/disable import menu in tools based on node selected. Import
+       * menu will be enabled only when user select table node.
+       */
+      var menu_enabled = function(itemData, item) {
+        var t = pgBrowser.tree,
+          i = item,
+          d = itemData;
+        var parent_item = t.hasParent(i) ? t.parent(i) : null,
+          parent_data = parent_item ? t.itemData(parent_item) : null;
+        if (!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data))
+          return (
+            (_.indexOf(['table'], d._type) !== -1 &&
+              parent_data._type != 'catalog') ? true : false
+          );
+        else
+          return false;
+      };
+
+      // Initialize the context menu to display the import options when user open the context menu for table
+      pgBrowser.add_menus([{
+        name: 'import',
+        node: 'table',
+        module: this,
+        applies: ['tools', 'context'],
+        callback: 'callback_import_export',
+        category: 'import',
+        priority: 10,
+        label: gettext('Import/Export...'),
+        icon: 'fa fa-shopping-cart',
+        enable: menu_enabled,
+      }]);
+    },
 
-        if ((server_data.type && server_data.type == 'ppas') ||
-            server_data.server_type == 'ppas') {
-          preference_name = 'ppas_bin_dir';
-          msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+    /*
+      Open the dialog for the import functionality
+    */
+    callback_import_export: function(args, item) {
+      var i = item || pgBrowser.tree.selected(),
+        server_data = null;
+
+      while (i) {
+        var node_data = pgBrowser.tree.itemData(i);
+        if (node_data._type == 'server') {
+          server_data = node_data;
+          break;
         }
 
-        var preference = pgBrowser.get_preference(module, preference_name);
-
-        if(preference) {
-          if (!preference.value) {
-            Alertify.alert(gettext('Configuration required'), msg);
-            return;
-          }
+        if (pgBrowser.tree.hasParent(i)) {
+          i = $(pgBrowser.tree.parent(i));
         } else {
-          Alertify.alert(S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value());
-          return;
+          Alertify.alert(gettext('Please select server or child node from tree.'));
+          break;
         }
+      }
 
-        var self = this;
-        var input = args || {},
-            t = pgBrowser.tree,
-            i = item || t.selected(),
-            d = i && i.length == 1 ? t.itemData(i) : undefined,
-            node = d && pgBrowser.Nodes[d._type];
-
-        if (!d)
-          return;
-
-        var objName = d.label;
-        var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-
-        if (!Alertify.ImportDialog) {
-          Alertify.dialog('ImportDialog', function factory() {
-
-            return {
-              main: function(title, node, item, data) {
-                this.set('title', title);
-                this.setting('pg_node', node);
-                this.setting('pg_item', item);
-                this.setting('pg_item_data', data);
-              },
+      if (!server_data) {
+        return;
+      }
 
-              build: function() {
-                Alertify.pgDialogBuild.apply(this)
-              },
+      var module = 'paths',
+        preference_name = 'pg_bin_dir',
+        msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
 
-              setup: function() {
-                return {
-                  buttons:[{
-                    text: gettext("OK"), key: 13, disable: true,
-                    'data-btn-name': 'ok',
-                    className:
-                      "btn btn-primary fa fa-lg fa-save pg-alertify-button"
-                  }, {
-                    text: gettext("Cancel"), key: 27,
-                    'data-btn-name': 'cancel',
-                    className:
-                      "btn btn-danger fa fa-lg fa-times pg-alertify-button"
-                  }],
-                  options: {modal: true}
-                };
-              },
+      if ((server_data.type && server_data.type == 'ppas') ||
+        server_data.server_type == 'ppas') {
+        preference_name = 'ppas_bin_dir';
+        msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+      }
 
-              settings: {
-                pg_node: null,
-                pg_item: null,
-                pg_item_data: null
-              },
+      var preference = pgBrowser.get_preference(module, preference_name);
 
-              // Callback functions when click on the buttons of the Alertify dialogs
-              callback: function(e) {
-                if (e.button['data-btn-name'] === "ok") {
+      if (preference) {
+        if (!preference.value) {
+          Alertify.alert(gettext('Configuration required'), msg);
+          return;
+        }
+      } else {
+        Alertify.alert(S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value());
+        return;
+      }
 
-                  var n = this.settings['pg_node'],
-                    i = this.settings['pg_item'],
-                    treeInfo = n.getTreeNodeHierarchy.apply(n, [i])
+      var t = pgBrowser.tree;
+      i = item || t.selected();
+      var d = i && i.length == 1 ? t.itemData(i) : undefined,
+        node = d && pgBrowser.Nodes[d._type];
+
+      if (!d)
+        return;
+
+      var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+
+      if (!Alertify.ImportDialog) {
+        Alertify.dialog('ImportDialog', function factory() {
+
+          return {
+            main: function(title, node, item, data) {
+              this.set('title', title);
+              this.setting('pg_node', node);
+              this.setting('pg_item', item);
+              this.setting('pg_item_data', data);
+            },
+
+            build: function() {
+              Alertify.pgDialogBuild.apply(this);
+            },
+
+            setup: function() {
+              return {
+                buttons: [{
+                  text: gettext('OK'),
+                  key: 13,
+                  disable: true,
+                  'data-btn-name': 'ok',
+                  className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
+                }, {
+                  text: gettext('Cancel'),
+                  key: 27,
+                  'data-btn-name': 'cancel',
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+                }],
+                options: {
+                  modal: true,
+                },
+              };
+            },
+
+            settings: {
+              pg_node: null,
+              pg_item: null,
+              pg_item_data: null,
+            },
+
+            // Callback functions when click on the buttons of the Alertify dialogs
+            callback: function(e) {
+              if (e.button['data-btn-name'] === 'ok') {
+
+                var n = this.settings['pg_node'],
+                  i = this.settings['pg_item'],
+                  treeInfo = n.getTreeNodeHierarchy.apply(n, [i]);
+
+                this.view.model.set({
+                  'database': treeInfo.database._label,
+                  'schema': treeInfo.schema._label,
+                  'table': treeInfo.table._label,
+                });
+                var self = this;
 
-                  this.view.model.set({
-                    'database': treeInfo.database._label,
-                    'schema': treeInfo.schema._label,
-                    'table': treeInfo.table._label
-                  });
-                  var self = this;
-
-                  $.ajax({
-                    url: url_for(
-                      'import_export.create_job', {'sid': treeInfo.server._id}
-                    ),
-                    method: 'POST',
-                    data:{ 'data': JSON.stringify(this.view.model.toJSON()) },
-                    success: function(res) {
-                      if (res.success) {
-                        Alertify.success(gettext('Import/export job created.'), 5);
-                        pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
-                      }
-                    },
-                    error: function(xhr, status, error) {
-                      try {
-                        var err = $.parseJSON(xhr.responseText);
-                        Alertify.alert(
- gettext('Import/export job failed.'),
-                          err.errormsg
-                        );
-                      } catch (e) {}
+                $.ajax({
+                  url: url_for(
+                    'import_export.create_job', {
+                      'sid': treeInfo.server._id,
+                    }
+                  ),
+                  method: 'POST',
+                  data: {
+                    'data': JSON.stringify(this.view.model.toJSON()),
+                  },
+                  success: function(res) {
+                    if (res.success) {
+                      Alertify.success(gettext('Import/export job created.'), 5);
+                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
                     }
+                  },
+                  error: function(xhr) {
+                    try {
+                      var err = $.parseJSON(xhr.responseText);
+                      Alertify.alert(
+                        gettext('Import/export job failed.'),
+                        err.errormsg
+                      );
+                    } catch (e) {
+                      console.warn(e.stack || e);
+                    }
+                  },
+                });
+              }
+            },
+
+            hooks: {
+              onclose: function() {
+                if (this.view) {
+                  this.view.remove({
+                    data: true,
+                    internal: true,
+                    silent: true,
                   });
                 }
               },
 
-              hooks: {
-                onclose: function() {
-                  if (this.view) {
-                    this.view.remove({data: true, internal: true, silent: true});
-                  }
-                },
-
-                // triggered when a dialog option gets update.
-                onupdate: function(option,oldValue, newValue) {
+              // triggered when a dialog option gets update.
+              onupdate: function(option, oldValue, newValue) {
 
-                  switch(option){
-                    case 'resizable':
-                      if(newValue){
-                        this.elements.content.removeAttribute('style');
-                      } else {
-                        this.elements.content.style.minHeight = 'inherit';
-                      }
-                      break;
+                switch (option) {
+                case 'resizable':
+                  if (newValue) {
+                    this.elements.content.removeAttribute('style');
+                  } else {
+                    this.elements.content.style.minHeight = 'inherit';
                   }
+                  break;
                 }
               },
+            },
+
+            prepare: function() {
+              // Main import module container
+              var self = this;
+
+              // Disable OK button until user provides valid Filename
+              this.__internal.buttons[0].element.disabled = true;
+
+              var $container = $('<div class=\'import_dlg\'></div>'),
+                n = this.settings.pg_node,
+                i = this.settings.pg_item,
+                treeInfo = n.getTreeNodeHierarchy.apply(n, [i]),
+                newModel = new ImportExportModel({}, {
+                  node_info: treeInfo,
+                }),
+                fields = Backform.generateViewSchema(
+                  treeInfo, newModel, 'create', node, treeInfo.server, true
+                ),
+                view = this.view = new Backform.Dialog({
+                  el: $container,
+                  model: newModel,
+                  schema: fields,
+                });
 
-              prepare: function() {
-                // Main import module container
-                var self = this;
-
-                // Disable OK button until user provides valid Filename
-                this.__internal.buttons[0].element.disabled = true;
-
-                var $container = $("<div class='import_dlg'></div>"),
-                    n = this.settings.pg_node,
-                    i = this.settings.pg_item,
-                    treeInfo = n.getTreeNodeHierarchy.apply(n, [i]),
-                    newModel = new ImportExportModel ({}, {
-                      node_info: treeInfo
-                    }),
-                    fields = Backform.generateViewSchema(
-                        treeInfo, newModel, 'create', node, treeInfo.server, true
-                    ),
-                    view = this.view = new Backform.Dialog({
-                      el: $container, model: newModel, schema: fields
-                    });
-
-                $(this.elements.body.childNodes[0]).addClass(
-                  'alertify_tools_dialog_properties obj_properties'
-                );
-                view.render();
-
-                this.elements.content.appendChild($container.get(0));
-
-                // Listen to model & if filename is provided then enable OK button
-                // For the 'Quote', 'escape' and 'delimiter' only one character is allowed to enter
-                this.view.model.on('change', function() {
-                    if (!_.isUndefined(this.get('filename')) && this.get('filename') !== '') {
+              $(this.elements.body.childNodes[0]).addClass(
+                'alertify_tools_dialog_properties obj_properties'
+              );
+              view.render();
+
+              this.elements.content.appendChild($container.get(0));
+
+              // Listen to model & if filename is provided then enable OK button
+              // For the 'Quote', 'escape' and 'delimiter' only one character is allowed to enter
+              this.view.model.on('change', function() {
+                if (!_.isUndefined(this.get('filename')) && this.get('filename') !== '') {
+                  this.errorModel.clear();
+                  if (!_.isUndefined(this.get('delimiter')) && !_.isNull(this.get('delimiter'))) {
+                    this.errorModel.clear();
+                    if (!_.isUndefined(this.get('quote')) && this.get('quote') !== '' &&
+                      this.get('quote').length == 1) {
                       this.errorModel.clear();
-                      if (!_.isUndefined(this.get('delimiter')) && !_.isNull(this.get('delimiter'))
-                      ) {
+                      if (!_.isUndefined(this.get('escape')) && this.get('escape') !== '' &&
+                        this.get('escape').length == 1) {
                         this.errorModel.clear();
-                        if (!_.isUndefined(this.get('quote')) && this.get('quote') !== '' &&
-                            this.get('quote').length == 1) {
-                          this.errorModel.clear();
-                          if (!_.isUndefined(this.get('escape')) && this.get('escape') !== '' &&
-                              this.get('escape').length == 1) {
-                            this.errorModel.clear();
-                            self.__internal.buttons[0].element.disabled = false;
-                          } else {
-                            self.__internal.buttons[0].element.disabled = true;
-                            this.errorModel.set('escape', gettext('Escape should contain only one character'))
-                          }
-                        } else {
-                          self.__internal.buttons[0].element.disabled = true;
-                          this.errorModel.set('quote', gettext('Quote should contain only one character'))
-                        }
+                        self.__internal.buttons[0].element.disabled = false;
                       } else {
                         self.__internal.buttons[0].element.disabled = true;
-                        this.errorModel.set('delimiter', gettext('Delimiter should contain only one character'))
+                        this.errorModel.set('escape', gettext('Escape should contain only one character'));
                       }
                     } else {
                       self.__internal.buttons[0].element.disabled = true;
-                      this.errorModel.set('filename', gettext('Please provide filename'))
+                      this.errorModel.set('quote', gettext('Quote should contain only one character'));
                     }
-                });
-
-                // Give the dialog initial height & width
-                this.elements.dialog.style.minHeight = '80%';
-                this.elements.dialog.style.minWidth = '70%';
-              }
-            };
-          });
-        }
+                  } else {
+                    self.__internal.buttons[0].element.disabled = true;
+                    this.errorModel.set('delimiter', gettext('Delimiter should contain only one character'));
+                  }
+                } else {
+                  self.__internal.buttons[0].element.disabled = true;
+                  this.errorModel.set('filename', gettext('Please provide filename'));
+                }
+              });
 
-        // Open the Alertify dialog for the import/export module
-        Alertify.ImportDialog(
-            S(
- gettext("Import/Export data - table '%s'")
-            ).sprintf(treeInfo.table.label).value(), node, i, d
-         ).set('resizable',true).resizeTo('70%','80%');
+              // Give the dialog initial height & width
+              this.elements.dialog.style.minHeight = '80%';
+              this.elements.dialog.style.minWidth = '70%';
+            },
+          };
+        });
       }
-    };
 
-    return pgAdmin.Tools.import_utility;
-  });
+      // Open the Alertify dialog for the import/export module
+      Alertify.ImportDialog(
+        S(
+          gettext('Import/Export data - table \'%s\'')
+        ).sprintf(treeInfo.table.label).value(), node, i, d
+      ).set('resizable', true).resizeTo('70%', '80%');
+    },
+  };
+
+  return pgAdmin.Tools.import_utility;
+});
diff --git a/web/pgadmin/tools/maintenance/static/js/maintenance.js b/web/pgadmin/tools/maintenance/static/js/maintenance.js
index 982c595a..7f67dbfd 100644
--- a/web/pgadmin/tools/maintenance/static/js/maintenance.js
+++ b/web/pgadmin/tools/maintenance/static/js/maintenance.js
@@ -3,7 +3,7 @@ define([
   'underscore.string', 'pgadmin.alertifyjs', 'sources/pgadmin', 'pgadmin.browser', 'backbone',
   'backgrid', 'backform',
   'pgadmin.backform', 'pgadmin.backgrid',
-  'pgadmin.browser.node.ui'
+  'pgadmin.browser.node.ui',
 ], function(
   gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
   Backform
@@ -17,22 +17,22 @@ define([
   if (pgAdmin.Tools.maintenance)
     return pgAdmin.Tools.maintenance;
 
-  var CustomSwitchControl = Backform.CustomSwitchControl = Backform.SwitchControl.extend({
-      template: _.template([
-        '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
-        '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
-        '  <div class="checkbox">',
-        '    <label>',
-        '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
-        '    </label>',
-        '  </div>',
-        '</div>',
-        '<% if (helpMessage && helpMessage.length) { %>',
-        '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
-        '<% } %>'
-      ].join("\n")),
-      className: 'pgadmin-control-group form-group col-xs-6'
-    });
+  Backform.CustomSwitchControl = Backform.SwitchControl.extend({
+    template: _.template([
+      '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
+      '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
+      '  <div class="checkbox">',
+      '    <label>',
+      '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
+      '    </label>',
+      '  </div>',
+      '</div>',
+      '<% if (helpMessage && helpMessage.length) { %>',
+      '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
+      '<% } %>',
+    ].join('\n')),
+    className: 'pgadmin-control-group form-group col-xs-6',
+  });
 
   // Main model for Maintenance functionality
   var MaintenanceModel = Backbone.Model.extend({
@@ -41,390 +41,443 @@ define([
       vacuum_full: false,
       vacuum_freeze: false,
       vacuum_analyze: false,
-      verbose: true
+      verbose: true,
     },
     initialize: function() {
-        var node_info = arguments[1]['node_info'];
-        // If node is Unique or Primary key then set op to reindex
-        if ('primary_key' in node_info || 'unique_constraint' in node_info
-                                       || 'index' in node_info) {
-          this.set('op', 'REINDEX');
-          this.set('verbose', false);
-        }
+      var node_info = arguments[1]['node_info'];
+      // If node is Unique or Primary key then set op to reindex
+      if ('primary_key' in node_info || 'unique_constraint' in node_info ||
+        'index' in node_info) {
+        this.set('op', 'REINDEX');
+        this.set('verbose', false);
+      }
     },
-    schema: [
+    schema: [{
+      id: 'op',
+      label: gettext('Maintenance operation'),
+      cell: 'string',
+      type: 'text',
+      group: gettext('Options'),
+      options: [{
+        'label': 'VACUUM',
+        'value': 'VACUUM',
+      },
       {
-        id: 'op', label: gettext('Maintenance operation'), cell: 'string',
-        type: 'text', group: gettext('Options'),
-        options:[
-          {'label': "VACUUM", 'value': "VACUUM"},
-          {'label': "ANALYZE", 'value': "ANALYZE"},
-          {'label': "REINDEX", 'value': "REINDEX"},
-          {'label': "CLUSTER", 'value': "CLUSTER"},
-        ],
-        control: Backform.RadioControl.extend({
-          template: _.template([
-            '<label class="control-label col-sm-4 col-xs-12"><%=label%></label>',
-            '<div class="pgadmin-controls col-xs-12 col-sm-8 btn-group pg-maintenance-op" data-toggle="buttons">',
-            ' <% for (var i=0; i < options.length; i++) { %>',
-            ' <% var option = options[i]; %>',
-            ' <label class="btn btn-primary<% if (i == 0) { %> active<%}%>">',
-            '  <input type="radio" name="op" id="op" autocomplete="off" value=<%-formatter.fromRaw(option.value)%><% if (i == 0) { %> selected<%}%> > <%-option.label%>',
-            ' </label>',
-            ' <% } %>',
-            '</div>'
-          ].join("\n"))
-        }),
-        select2: {
-          allowClear: false,
-          width: "100%",
-          placeholder: gettext('Select from list...')
-        },
+        'label': 'ANALYZE',
+        'value': 'ANALYZE',
       },
       {
-        type: 'nested', control: 'fieldset', label: gettext('Vacuum'), group: gettext('Options'),
-        schema:[{
-          id: 'vacuum_full', group: gettext('Vacuum'), disabled: 'isDisabled',
-          control: Backform.CustomSwitchControl, label: gettext('FULL'), deps: ['op']
-        },{
-          id: 'vacuum_freeze', deps: ['op'], disabled: 'isDisabled',
-          control: Backform.CustomSwitchControl, label: gettext('FREEZE'), group: gettext('Vacuum')
-        },{
-          id: 'vacuum_analyze', deps: ['op'], disabled: 'isDisabled',
-          control: Backform.CustomSwitchControl, label: gettext('ANALYZE'), group: gettext('Vacuum')
-        }]
+        'label': 'REINDEX',
+        'value': 'REINDEX',
       },
       {
-        id: 'verbose', group: gettext('Options'), deps: ['op'],
-        control: Backform.CustomSwitchControl, label: gettext('Verbose Messages'), disabled: 'isDisabled'
-      }
+        'label': 'CLUSTER',
+        'value': 'CLUSTER',
+      },
+      ],
+      control: Backform.RadioControl.extend({
+        template: _.template([
+          '<label class="control-label col-sm-4 col-xs-12"><%=label%></label>',
+          '<div class="pgadmin-controls col-xs-12 col-sm-8 btn-group pg-maintenance-op" data-toggle="buttons">',
+          ' <% for (var i=0; i < options.length; i++) { %>',
+          ' <% var option = options[i]; %>',
+          ' <label class="btn btn-primary<% if (i == 0) { %> active<%}%>">',
+          '  <input type="radio" name="op" id="op" autocomplete="off" value=<%-formatter.fromRaw(option.value)%><% if (i == 0) { %> selected<%}%> > <%-option.label%>',
+          ' </label>',
+          ' <% } %>',
+          '</div>',
+        ].join('\n')),
+      }),
+      select2: {
+        allowClear: false,
+        width: '100%',
+        placeholder: gettext('Select from list...'),
+      },
+    },
+    {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Vacuum'),
+      group: gettext('Options'),
+      schema: [{
+        id: 'vacuum_full',
+        group: gettext('Vacuum'),
+        disabled: 'isDisabled',
+        control: Backform.CustomSwitchControl,
+        label: gettext('FULL'),
+        deps: ['op'],
+      }, {
+        id: 'vacuum_freeze',
+        deps: ['op'],
+        disabled: 'isDisabled',
+        control: Backform.CustomSwitchControl,
+        label: gettext('FREEZE'),
+        group: gettext('Vacuum'),
+      }, {
+        id: 'vacuum_analyze',
+        deps: ['op'],
+        disabled: 'isDisabled',
+        control: Backform.CustomSwitchControl,
+        label: gettext('ANALYZE'),
+        group: gettext('Vacuum'),
+      }],
+    },
+    {
+      id: 'verbose',
+      group: gettext('Options'),
+      deps: ['op'],
+      control: Backform.CustomSwitchControl,
+      label: gettext('Verbose Messages'),
+      disabled: 'isDisabled',
+    },
     ],
 
-    // Enable/Disable the items based on the user maintenance operation selection
+    // Enable/Disable the items based on the user maintenance operation
+    // selection.
     isDisabled: function(m) {
-      var name = this.name,
-        node_info = this.node_info;
-      switch(name) {
-        case 'vacuum_full':
-        case 'vacuum_freeze':
-        case 'vacuum_analyze':
-          if (m.get('op') != 'VACUUM') {
-            return true;
-          }
-          else {
-            return false;
-          }
-          break;
-        case 'verbose':
-          if ('primary_key' in node_info || 'unique_constraint' in node_info ||
-                'index' in node_info ) {
-            if (m.get('op') == 'REINDEX') {
-              setTimeout(function() { m.set('verbose', false); }, 10);
-              return true;
-            }
-          }
+      var node_info = this.node_info;
+
+      switch (this.name) {
+      case 'vacuum_full':
+      case 'vacuum_freeze':
+      case 'vacuum_analyze':
+        return (m.get('op') != 'VACUUM');
+      case 'verbose':
+        if ('primary_key' in node_info || 'unique_constraint' in node_info ||
+            'index' in node_info) {
           if (m.get('op') == 'REINDEX') {
+            setTimeout(function() {
+              m.set('verbose', false);
+            }, 10);
             return true;
           }
-          else {
-            return false;
-          }
-          break;
-        default:
-          return false;
+        }
+        return m.get('op') == 'REINDEX';
+      default:
+        return false;
       }
-      return false;
-    }
+    },
   });
 
   pgTools.maintenance = {
-      init: function() {
-
-        // We do not want to initialize the module multiple times.
-        if (this.initialized)
-            return;
-
-        this.initialized = true;
-
-        var maintenance_supported_nodes = [
-              'database', 'table', 'primary_key',
-              'unique_constraint', 'index', 'partition'
-            ];
-
-        /**
-         Enable/disable Maintenance menu in tools based on node selected.
-         Maintenance menu will be enabled only when user select table and database node.
-        */
-        var menu_enabled = function(itemData, item, data) {
-         var t = pgBrowser.tree, i = item, d = itemData;
-         var parent_item = t.hasParent(i) ? t.parent(i): null,
-             parent_data = parent_item ? t.itemData(parent_item) : null;
-           if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
-             if (_.indexOf(maintenance_supported_nodes, d._type) !== -1 &&
-               parent_data._type != 'catalog') {
-               if (d._type == 'database' && d.allowConn)
-                 return true;
-               else if(d._type != 'database')
-                 return true;
-               else
-                 return false;
-              }
-              else
-                return false;
-           }
-           else
-             return false;
-        };
-
-        var menus = [{
-          name: 'maintenance', module: this,
-          applies: ['tools'], callback: 'callback_maintenance',
-          priority: 10, label: gettext('Maintenance...'),
-          icon: 'fa fa-wrench', enable: menu_enabled
-        }];
-
-        // Add supported menus into the menus list
-        for (var idx = 0; idx < maintenance_supported_nodes.length; idx++) {
-          menus.push({
-            name: 'maintenance_context_' + maintenance_supported_nodes[idx],
-            node: maintenance_supported_nodes[idx], module: this,
-            applies: ['context'], callback: 'callback_maintenance',
-            priority: 10, label: gettext('Maintenance...'),
-            icon: 'fa fa-wrench', enable: menu_enabled
-          });
-        }
-        pgBrowser.add_menus(menus);
-      },
+    init: function() {
 
-      /*
-        Open the dialog for the maintenance functionality
-      */
-      callback_maintenance: function(args, item) {
-        var i = item || pgBrowser.tree.selected(),
-          server_data = null;
-
-        while (i) {
-          var node_data = pgBrowser.tree.itemData(i);
-          if (node_data._type == 'server') {
-            server_data = node_data;
-            break;
-          }
+      // We do not want to initialize the module multiple times.
+      if (this.initialized)
+        return;
 
-          if (pgBrowser.tree.hasParent(i)) {
-            i = $(pgBrowser.tree.parent(i));
-          } else {
-            Alertify.alert(gettext("Please select server or child node from tree."));
-            break;
-          }
-        }
+      this.initialized = true;
 
-        if (!server_data) {
-          return;
-        }
+      var maintenance_supported_nodes = [
+        'database', 'table', 'primary_key',
+        'unique_constraint', 'index', 'partition',
+      ];
 
-        var module = 'paths',
-          preference_name = 'pg_bin_dir',
-          msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
+      /**
+       Enable/disable Maintenance menu in tools based on node selected.
+       Maintenance menu will be enabled only when user select table and database node.
+      */
+      var menu_enabled = function(itemData, item) {
+        var t = pgBrowser.tree,
+          i = item,
+          d = itemData;
+        var parent_item = t.hasParent(i) ? t.parent(i) : null,
+          parent_data = parent_item ? t.itemData(parent_item) : null;
+        if (!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+          if (_.indexOf(maintenance_supported_nodes, d._type) !== -1 &&
+            parent_data._type != 'catalog') {
+            if (d._type == 'database' && d.allowConn)
+              return true;
+            else if (d._type != 'database')
+              return true;
+            else
+              return false;
+          } else
+            return false;
+        } else
+          return false;
+      };
+
+      var menus = [{
+        name: 'maintenance',
+        module: this,
+        applies: ['tools'],
+        callback: 'callback_maintenance',
+        priority: 10,
+        label: gettext('Maintenance...'),
+        icon: 'fa fa-wrench',
+        enable: menu_enabled,
+      }];
+
+      // Add supported menus into the menus list
+      for (var idx = 0; idx < maintenance_supported_nodes.length; idx++) {
+        menus.push({
+          name: 'maintenance_context_' + maintenance_supported_nodes[idx],
+          node: maintenance_supported_nodes[idx],
+          module: this,
+          applies: ['context'],
+          callback: 'callback_maintenance',
+          priority: 10,
+          label: gettext('Maintenance...'),
+          icon: 'fa fa-wrench',
+          enable: menu_enabled,
+        });
+      }
+      pgBrowser.add_menus(menus);
+    },
 
-        if ((server_data.type && server_data.type == 'ppas') ||
-            server_data.server_type == 'ppas') {
-          preference_name = 'ppas_bin_dir';
-          msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+    /*
+      Open the dialog for the maintenance functionality
+    */
+    callback_maintenance: function(args, item) {
+      var i = item || pgBrowser.tree.selected(),
+        server_data = null;
+
+      while (i) {
+        var node_data = pgBrowser.tree.itemData(i);
+        if (node_data._type == 'server') {
+          server_data = node_data;
+          break;
         }
 
-        var preference = pgBrowser.get_preference(module, preference_name);
-
-        if(preference) {
-          if (!preference.value) {
-            Alertify.alert(gettext('Configuration required'), msg);
-            return;
-          }
+        if (pgBrowser.tree.hasParent(i)) {
+          i = $(pgBrowser.tree.parent(i));
         } else {
-          Alertify.alert(S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value());
-          return;
+          Alertify.alert(gettext('Please select server or child node from tree.'));
+          break;
         }
+      }
 
-        var self = this,
-          input = args || {},
-          t = pgBrowser.tree,
-          i = item || t.selected(),
-          d = i && i.length == 1 ? t.itemData(i) : undefined,
-          node = d && pgBrowser.Nodes[d._type];
+      if (!server_data) {
+        return;
+      }
 
-        if (!d)
-          return;
+      var module = 'paths',
+        preference_name = 'pg_bin_dir',
+        msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
 
-        var objName = d.label;
-        var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+      if ((server_data.type && server_data.type == 'ppas') ||
+        server_data.server_type == 'ppas') {
+        preference_name = 'ppas_bin_dir';
+        msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+      }
 
-        if (!Alertify.MaintenanceDialog) {
-          Alertify.dialog('MaintenanceDialog', function factory() {
+      var preference = pgBrowser.get_preference(module, preference_name);
 
-            return {
-              main: function(title) {
-                this.set('title', title);
-              },
-              setup: function() {
-                return {
-                  buttons:[{
-                    text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
-                    attrs:{name:'object_help', type:'button', url: 'maintenance.html', label: gettext('Maintenance')}
-                  },{
-                    text: '', key: 112,
-                    className: 'btn btn-default pull-left fa fa-lg fa-question',
-                    attrs:{
-                      name:'dialog_help', type:'button',
-                      label: gettext('Maintenance'),
-                      url: url_for(
-                        'help.static', {'filename': 'maintenance_dialog.html'}
-                      )
-                    }
-                  },{
-                    text: gettext("OK"), key: 13, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button",
-                    'data-btn-name': 'ok',
-                  },{
-                    text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-lg fa-times pg-alertify-button",
-                    'data-btn-name': 'cancel',
-                  }],
-                  options: { modal: 0, pinnable: false}
-                };
-              },
-              // Callback functions when click on the buttons of the Alertify dialogs
-              callback: function(e) {
-                var i = pgBrowser.tree.selected(),
-                  d = i && i.length == 1 ? pgBrowser.tree.itemData(i) : undefined,
-                  node = d && pgBrowser.Nodes[d._type];
-
-                if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
-                  e.cancel = true;
-                  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
-                    node, i, e.button.element.getAttribute('label'));
-                  return;
-                }
+      if (preference) {
+        if (!preference.value) {
+          Alertify.alert(gettext('Configuration required'), msg);
+          return;
+        }
+      } else {
+        Alertify.alert(S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value());
+        return;
+      }
 
-                if (e.button['data-btn-name'] === "ok") {
-
-                  var schema = undefined,
-                    table = undefined,
-                    primary_key = undefined,
-                    unique_constraint = undefined,
-                    index = undefined;
-
-                  if (!d)
-                    return;
-
-                  var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
-
-                  if (treeInfo.schema != undefined) {
-                    schema = treeInfo.schema._label;
-                  }
-
-                  if (treeInfo.partition != undefined) {
-                    table = treeInfo.partition._label;
-                  } else if  (treeInfo.table != undefined) {
-                    table = treeInfo.table._label;
-                  }
-
-                  if (treeInfo.primary_key != undefined) {
-                    primary_key = treeInfo.primary_key._label;
-                  } else if (treeInfo.unique_constraint != undefined) {
-                    unique_constraint = treeInfo.unique_constraint._label;
-                  } else if (treeInfo.index != undefined) {
-                    index = treeInfo.index._label;
-                  }
-
-                  this.view.model.set({'database': treeInfo.database._label,
-                                      'schema': schema,
-                                      'table': table,
-                                      'primary_key': primary_key,
-                                      'unique_constraint': unique_constraint,
-                                      'index': index})
-
-                  $.ajax({
+      var self = this,
+        t = pgBrowser.tree;
+
+      i = item || t.selected();
+
+      var d = i && i.length == 1 ? t.itemData(i) : undefined;
+
+      if (!d)
+        return;
+
+      if (!Alertify.MaintenanceDialog) {
+        Alertify.dialog('MaintenanceDialog', function factory() {
+
+          return {
+            main: function(title) {
+              this.set('title', title);
+            },
+            setup: function() {
+              return {
+                buttons: [{
+                  text: '',
+                  className: 'btn btn-default pull-left fa fa-lg fa-info',
+                  attrs: {
+                    name: 'object_help',
+                    type: 'button',
+                    url: 'maintenance.html',
+                    label: gettext('Maintenance'),
+                  },
+                }, {
+                  text: '',
+                  key: 112,
+                  className: 'btn btn-default pull-left fa fa-lg fa-question',
+                  attrs: {
+                    name: 'dialog_help',
+                    type: 'button',
+                    label: gettext('Maintenance'),
                     url: url_for(
-                      'maintenance.create_job', {
-                        'sid': treeInfo.server._id,
-                        'did': treeInfo.database._id
-                      }),
-                    method: 'POST',
-                    data:{'data': JSON.stringify(this.view.model.toJSON())},
-                    success: function(res) {
-                      if (res.data && res.data.status) {
-                        //Do nothing as we are creating the job and exiting from the main dialog
-                        Alertify.success(res.data.info);
-                        pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
+                      'help.static', {
+                        'filename': 'maintenance_dialog.html',
                       }
-                      else {
-                        Alertify.error(res.data.errmsg);
-                      }
-                    },
-                    error: function(e) {
-                      Alertify.alert(
-                        gettext("Maintenance job creation failed.")
-                      );
-                    }
-                  });
-                }
-              },
-              build: function() {
-                Alertify.pgDialogBuild.apply(this)
-              },
-              hooks: {
-                onclose: function() {
-                  if (this.view) {
-                    this.view.remove({data: true, internal: true, silent: true});
-                  }
-                }
-              },
-              prepare: function() {
-                // Main maintenance tool dialog container
-                var $container = $("<div class='maintenance_dlg'></div>");
+                    ),
+                  },
+                }, {
+                  text: gettext('OK'),
+                  key: 13,
+                  className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
+                  'data-btn-name': 'ok',
+                }, {
+                  text: gettext('Cancel'),
+                  key: 27,
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+                  'data-btn-name': 'cancel',
+                }],
+                options: {
+                  modal: 0,
+                  pinnable: false,
+                },
+              };
+            },
+            // Callback functions when click on the buttons of the Alertify dialogs
+            callback: function(e) {
+              var i = pgBrowser.tree.selected(),
+                d = i && i.length == 1 ? pgBrowser.tree.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (e.button.element.name == 'dialog_help' || e.button.element.name == 'object_help') {
+                e.cancel = true;
+                pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+                  node, i, e.button.element.getAttribute('label'));
+                return;
+              }
+
+              if (e.button['data-btn-name'] === 'ok') {
 
-                var t = pgBrowser.tree,
-                  i = t.selected(),
-                  d = i && i.length == 1 ? t.itemData(i) : undefined,
-                  node = d && pgBrowser.Nodes[d._type];
+                var schema = undefined,
+                  table = undefined,
+                  primary_key = undefined,
+                  unique_constraint = undefined,
+                  index = undefined;
 
                 if (!d)
                   return;
 
                 var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
 
-                var newModel = new MaintenanceModel (
-                  {}, {node_info: treeInfo}
-                  ),
-                  fields = Backform.generateViewSchema(
-                    treeInfo, newModel, 'create', node, treeInfo.server, true
-                  );
+                if (treeInfo.schema != undefined) {
+                  schema = treeInfo.schema._label;
+                }
 
-                  var view = this.view = new Backform.Dialog({
-                    el: $container, model: newModel, schema: fields
-                  });
+                if (treeInfo.partition != undefined) {
+                  table = treeInfo.partition._label;
+                } else if (treeInfo.table != undefined) {
+                  table = treeInfo.table._label;
+                }
+
+                if (treeInfo.primary_key != undefined) {
+                  primary_key = treeInfo.primary_key._label;
+                } else if (treeInfo.unique_constraint != undefined) {
+                  unique_constraint = treeInfo.unique_constraint._label;
+                } else if (treeInfo.index != undefined) {
+                  index = treeInfo.index._label;
+                }
 
-                  $(this.elements.body.childNodes[0]).addClass('alertify_tools_dialog_properties obj_properties');
-                  view.render();
-
-                 // If node is Index, Unique or Primary key then disable vacuum & analyze button
-                  if (d._type == 'primary_key' || d._type == 'unique_constraint'
-                                               || d._type == 'index') {
-                    var vacuum_analyze_btns = $container.find(
-                                                '.pgadmin-controls label:lt(2)'
-                                                ).removeClass('active').addClass('disabled');
-                    // Find reindex button element & add active class to it
-                    var reindex_btn = vacuum_analyze_btns[1].nextElementSibling;
-                    $(reindex_btn).addClass('active');
-                  }
-
-                  this.elements.content.appendChild($container.get(0));
+                this.view.model.set({
+                  'database': treeInfo.database._label,
+                  'schema': schema,
+                  'table': table,
+                  'primary_key': primary_key,
+                  'unique_constraint': unique_constraint,
+                  'index': index,
+                });
+
+                $.ajax({
+                  url: url_for(
+                    'maintenance.create_job', {
+                      'sid': treeInfo.server._id,
+                      'did': treeInfo.database._id,
+                    }),
+                  method: 'POST',
+                  data: {
+                    'data': JSON.stringify(this.view.model.toJSON()),
+                  },
+                  success: function(res) {
+                    if (res.data && res.data.status) {
+                      //Do nothing as we are creating the job and exiting from the main dialog
+                      Alertify.success(res.data.info);
+                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
+                    } else {
+                      Alertify.error(res.data.errmsg);
+                    }
+                  },
+                  error: function() {
+                    Alertify.alert(
+                      gettext('Maintenance job creation failed.')
+                    );
+                  },
+                });
+              }
+            },
+            build: function() {
+              Alertify.pgDialogBuild.apply(this);
+            },
+            hooks: {
+              onclose: function() {
+                if (this.view) {
+                  this.view.remove({
+                    data: true,
+                    internal: true,
+                    silent: true,
+                  });
+                }
+              },
+            },
+            prepare: function() {
+              // Main maintenance tool dialog container
+              var $container = $('<div class=\'maintenance_dlg\'></div>');
+
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = i && i.length == 1 ? t.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (!d)
+                return;
+
+              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+
+              var newModel = new MaintenanceModel({}, {
+                  node_info: treeInfo,
+                }),
+                fields = Backform.generateViewSchema(
+                  treeInfo, newModel, 'create', node, treeInfo.server, true
+                );
+
+              var view = this.view = new Backform.Dialog({
+                el: $container,
+                model: newModel,
+                schema: fields,
+              });
+
+              $(this.elements.body.childNodes[0]).addClass('alertify_tools_dialog_properties obj_properties');
+              view.render();
+
+              // If node is Index, Unique or Primary key then disable vacuum & analyze button
+              if (d._type == 'primary_key' || d._type == 'unique_constraint' ||
+                d._type == 'index') {
+                var vacuum_analyze_btns = $container.find(
+                  '.pgadmin-controls label:lt(2)'
+                ).removeClass('active').addClass('disabled');
+                // Find reindex button element & add active class to it
+                var reindex_btn = vacuum_analyze_btns[1].nextElementSibling;
+                $(reindex_btn).addClass('active');
               }
-            };
-          });
-        }
 
-        // Open the Alertify dialog
-        Alertify.MaintenanceDialog('Maintenance...').set('resizable',true).resizeTo('60%','80%');
-      },
-    };
+              this.elements.content.appendChild($container.get(0));
+            },
+          };
+        });
+      }
 
-    return pgAdmin.Tools.maintenance;
-  });
+      // Open the Alertify dialog
+      Alertify.MaintenanceDialog('Maintenance...').set('resizable', true).resizeTo('60%', '80%');
+    },
+  };
+
+  return pgAdmin.Tools.maintenance;
+});
diff --git a/web/pgadmin/tools/restore/static/js/restore.js b/web/pgadmin/tools/restore/static/js/restore.js
index 7160f51c..2b44cf09 100644
--- a/web/pgadmin/tools/restore/static/js/restore.js
+++ b/web/pgadmin/tools/restore/static/js/restore.js
@@ -1,567 +1,691 @@
 // Restore dialog
 define('tools.restore', [
-  'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
-  'underscore.string', 'pgadmin.alertifyjs', 'pgadmin.browser', 'backbone', 'backgrid',
-  'backform', 'pgadmin.browser.node'
+  'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'backbone',
+  'underscore.string', 'pgadmin.alertifyjs', 'pgadmin.browser',
+  'pgadmin.backgrid', 'pgadmin.backform',
 ], function(
-  gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform,
-  pgNode
+  gettext, url_for, $, _, Backbone, S, alertify, pgBrowser, Backgrid, Backform
 ) {
 
-    // if module is already initialized, refer to that.
-    if (pgBrowser.Restore) {
-      return pgBrowser.Restore;
-    }
-
-    var CustomSwitchControl = Backform.CustomSwitchControl = Backform.SwitchControl.extend({
-        template: _.template([
-          '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
-          '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
-          '  <div class="checkbox">',
-          '    <label>',
-          '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
-          '    </label>',
-          '  </div>',
-          '</div>',
-          '<% if (helpMessage && helpMessage.length) { %>',
-          '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
-          '<% } %>'
-        ].join("\n")),
-        className: 'pgadmin-control-group form-group pg-el-xs-4'
-    });
-
-    //Restore Model (Objects like Database/Schema/Table)
-    var RestoreObjectModel = Backbone.Model.extend({
-      idAttribute: 'id',
-      defaults: {
-        custom: false,
-        file: undefined,
-        role: undefined,
-        format: 'custom',
-        verbose: true,
-        blobs: true,
-        encoding: undefined,
-        database: undefined,
-        schemas: undefined,
-        tables: undefined,
-        functions: undefined,
-        triggers: undefined,
-        trigger_funcs: undefined,
-        indexes: undefined
-      },
+  // if module is already initialized, refer to that.
+  if (pgBrowser.Restore) {
+    return pgBrowser.Restore;
+  }
+
+  Backform.CustomSwitchControl = Backform.SwitchControl.extend({
+    template: _.template([
+      '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
+      '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
+      '  <div class="checkbox">',
+      '    <label>',
+      '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>" name="<%=name%>" <%=value ? "checked=\'checked\'" : ""%> <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> />',
+      '    </label>',
+      '  </div>',
+      '</div>',
+      '<% if (helpMessage && helpMessage.length) { %>',
+      '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
+      '<% } %>',
+    ].join('\n')),
+    className: 'pgadmin-control-group form-group pg-el-xs-4',
+  });
+
+  //Restore Model (Objects like Database/Schema/Table)
+  var RestoreObjectModel = Backbone.Model.extend({
+    idAttribute: 'id',
+    defaults: {
+      custom: false,
+      file: undefined,
+      role: undefined,
+      format: 'custom',
+      verbose: true,
+      blobs: true,
+      encoding: undefined,
+      database: undefined,
+      schemas: undefined,
+      tables: undefined,
+      functions: undefined,
+      triggers: undefined,
+      trigger_funcs: undefined,
+      indexes: undefined,
+    },
+
+    // Default values!
+    initialize: function(attrs) {
+      // Set default options according to node type selection by user
+      var node_type = attrs.node_data.type;
+
+      if (node_type) {
+        // Only_Schema option
+        if (node_type === 'function' || node_type === 'index' ||
+          node_type === 'trigger') {
+          this.set({
+            'only_schema': true,
+          }, {
+            silent: true,
+          });
+        }
+
+        // Only_Data option
+        if (node_type === 'table') {
+          this.set({
+            'only_data': true,
+          }, {
+            silent: true,
+          });
+        }
 
-      // Default values!
-      initialize: function(attrs, args) {
-        // Set default options according to node type selection by user
-        var node_type = attrs.node_data.type;
-
-        if (node_type) {
-          // Only_Schema option
-          if (node_type === 'function' || node_type === 'index'
-          || node_type === 'trigger') {
-            this.set({'only_schema': true}, {silent: true});
-          }
-
-          // Only_Data option
-          if (node_type === 'table') {
-            this.set({'only_data': true}, {silent: true});
-          }
-
-          // Clean option
-          if (node_type === 'function' || node_type === 'trigger_function') {
-            this.set({'clean': true}, {silent: true});
-          }
+        // Clean option
+        if (node_type === 'function' || node_type === 'trigger_function') {
+          this.set({
+            'clean': true,
+          }, {
+            silent: true,
+          });
         }
-        Backbone.Model.prototype.initialize.apply(this, arguments);
+      }
+      Backbone.Model.prototype.initialize.apply(this, arguments);
+    },
+    schema: [{
+      id: 'format',
+      label: gettext('Format'),
+      type: 'text',
+      disabled: false,
+      control: 'select2',
+      select2: {
+        allowClear: false,
+        width: '100%',
+      },
+      options: [{
+        label: gettext('Custom or tar'),
+        value: 'custom',
       },
+      {
+        label: gettext('Directory'),
+        value: 'directory',
+      },
+      ],
+    }, {
+      id: 'file',
+      label: gettext('Filename'),
+      type: 'text',
+      disabled: false,
+      control: Backform.FileControl,
+      dialog_type: 'select_file',
+      supp_types: ['*', 'backup', 'sql', 'patch'],
+    }, {
+      id: 'no_of_jobs',
+      label: gettext('Number of jobs'),
+      type: 'int',
+    }, {
+      id: 'role',
+      label: gettext('Role name'),
+      control: 'node-list-by-name',
+      node: 'role',
+      select2: {
+        allowClear: false,
+      },
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Sections'),
+      group: gettext('Restore options'),
       schema: [{
-        id: 'format', label: gettext('Format'),
-        type: 'text', disabled: false,
-        control: 'select2', select2: {
-            allowClear: false,
-            width: "100%"
+        id: 'pre_data',
+        label: gettext('Pre-data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Sections'),
+        deps: ['only_data', 'only_schema'],
+        disabled: function(m) {
+          return this.node.type !== 'function' && this.node.type !== 'table' &&
+            this.node.type !== 'trigger' &&
+            this.node.type !== 'trigger_function' &&
+            (m.get('only_data') || m.get('only_schema'));
+        },
+      }, {
+        id: 'data',
+        label: gettext('Data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Sections'),
+        deps: ['only_data', 'only_schema'],
+        disabled: function(m) {
+          return this.node.type !== 'function' && this.node.type !== 'table' &&
+            this.node.type !== 'trigger' &&
+            this.node.type !== 'trigger_function' &&
+            (m.get('only_data') || m.get('only_schema'));
+        },
+      }, {
+        id: 'post_data',
+        label: gettext('Post-data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Sections'),
+        deps: ['only_data', 'only_schema'],
+        disabled: function(m) {
+          return this.node.type !== 'function' && this.node.type !== 'table' &&
+            this.node.type !== 'trigger' &&
+            this.node.type !== 'trigger_function' &&
+            (m.get('only_data') || m.get('only_schema'));
         },
-        options: [
-          {label: gettext('Custom or tar'), value: "custom"},
-          {label: gettext('Directory'), value: "directory"}
-        ]
-      },{
-        id: 'file', label: gettext('Filename'),
-        type: 'text', disabled: false, control: Backform.FileControl,
-        dialog_type: 'select_file', supp_types: ['*', 'backup','sql', 'patch']
-      },{
-        id: 'no_of_jobs', label: gettext('Number of jobs'),
-        type: 'int'
-      },{
-        id: 'role', label: gettext('Role name'),
-        control: 'node-list-by-name', node: 'role',
-        select2: { allowClear: false }
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Sections'),
-        group: gettext('Restore options'),
-        schema:[{
-          id: 'pre_data', label: gettext('Pre-data'),
-          control: Backform.CustomSwitchControl, group: gettext('Sections'),
-          deps: ['only_data', 'only_schema'], disabled: function(m) {
-            return this.node.type !== 'function' && this.node.type !== 'table'
-                   && this.node.type !== 'trigger'
-                   && this.node.type !== 'trigger_function'
-                   && (m.get('only_data') || m.get('only_schema'));
-          }
-        },{
-          id: 'data', label: gettext('Data'),
-          control: Backform.CustomSwitchControl, group: gettext('Sections'),
-          deps: ['only_data', 'only_schema'], disabled: function(m) {
-            return this.node.type !== 'function' && this.node.type !== 'table'
-                   && this.node.type !== 'trigger'
-                   && this.node.type !== 'trigger_function'
-                   && (m.get('only_data') || m.get('only_schema'));
-          }
-        },{
-          id: 'post_data', label: gettext('Post-data'),
-          control: Backform.CustomSwitchControl, group: gettext('Sections'),
-          deps: ['only_data', 'only_schema'], disabled: function(m) {
-            return this.node.type !== 'function' && this.node.type !== 'table'
-                   && this.node.type !== 'trigger'
-                   && this.node.type !== 'trigger_function'
-                   && (m.get('only_data') || m.get('only_schema'));
-          }
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Type of objects'),
-        group: gettext('Restore options'),
-        schema:[{
-          id: 'only_data', label: gettext('Only data'),
-          control: Backform.CustomSwitchControl, group: gettext('Type of objects'),
-          deps: ['pre_data', 'data', 'post_data','only_schema'], disabled: function(m) {
-            return (this.node.type !== 'database' && this.node.type !== 'schema')
-                   || ( m.get('pre_data')
-                        ||m.get('data')
-                        || m.get('post_data')
-                        || m.get('only_schema')
-                      );
-          }
-        },{
-          id: 'only_schema', label: gettext('Only schema'),
-          control: Backform.CustomSwitchControl, group: gettext('Type of objects'),
-          deps: ['pre_data', 'data', 'post_data', 'only_data'], disabled: function(m) {
-            return (this.node.type !== 'database' && this.node.type !== 'schema')
-                   || ( m.get('pre_data')
-                        || m.get('data')
-                        || m.get('post_data')
-                        || m.get('only_data')
-                      );
-          }
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Do not save'),
-        group: gettext('Restore options'),
-        schema:[{
-          id: 'dns_owner', label: gettext('Owner'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        },{
-          id: 'dns_privilege', label: gettext('Privilege'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        },{
-          id: 'dns_tablespace', label: gettext('Tablespace'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Do not save')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Queries'),
-        group: gettext('Restore options'),
-        schema:[{
-          id: 'include_create_database', label: gettext('Include CREATE DATABASE statement'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Queries')
-        },{
-          id: 'clean', label: gettext('Clean before restore'),
-          control: Backform.CustomSwitchControl, group: gettext('Queries'),
-          disabled: function(m) {
-            return this.node.type === 'function' ||
-                     this.node.type === 'trigger_function';
-          }
-        },{
-          id: 'single_transaction', label: gettext('Single transaction'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Queries')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Disable'),
-        group: gettext('Restore options'),
-        schema:[{
-          id: 'disable_trigger', label: gettext('Trigger'),
-          control: Backform.CustomSwitchControl, group: gettext('Disable')
-        },{
-          id: 'no_data_fail_table', label: gettext('No data for Failed Tables'),
-          control: Backform.CustomSwitchControl, disabled: false, group: gettext('Disable')
-        }]
-      },{
-        type: 'nested', control: 'fieldset', label: gettext('Miscellaneous / Behavior'),
-        group: gettext('Restore options'),
-        schema:[{
-          id: 'verbose', label: gettext('Verbose messages'),
-          control: Backform.CustomSwitchControl, disabled: false,
-          group: gettext('Miscellaneous / Behavior')
-        },{
-          id: 'use_set_session_auth', label: gettext('Use SET SESSION AUTHORIZATION'),
-          control: Backform.CustomSwitchControl, disabled: false,
-          group: gettext('Miscellaneous / Behavior')
-        },{
-          id: 'exit_on_error', label: gettext('Exit on error'),
-          control: Backform.CustomSwitchControl, disabled: false,
-          group: gettext('Miscellaneous / Behavior')
-        }]
       }],
-      validate: function() {
-        return null;
-      }
-    });
-
-    // Create an Object Restore of pgBrowser class
-    pgBrowser.Restore  = {
-      init: function() {
-        if (this.initialized)
-          return;
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Type of objects'),
+      group: gettext('Restore options'),
+      schema: [{
+        id: 'only_data',
+        label: gettext('Only data'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Type of objects'),
+        deps: ['pre_data', 'data', 'post_data', 'only_schema'],
+        disabled: function(m) {
+          return (this.node.type !== 'database' && this.node.type !== 'schema') ||
+            (m.get('pre_data') ||
+              m.get('data') ||
+              m.get('post_data') ||
+              m.get('only_schema')
+            );
+        },
+      }, {
+        id: 'only_schema',
+        label: gettext('Only schema'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Type of objects'),
+        deps: ['pre_data', 'data', 'post_data', 'only_data'],
+        disabled: function(m) {
+          return (this.node.type !== 'database' && this.node.type !== 'schema') ||
+            (m.get('pre_data') ||
+              m.get('data') ||
+              m.get('post_data') ||
+              m.get('only_data')
+            );
+        },
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Do not save'),
+      group: gettext('Restore options'),
+      schema: [{
+        id: 'dns_owner',
+        label: gettext('Owner'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }, {
+        id: 'dns_privilege',
+        label: gettext('Privilege'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }, {
+        id: 'dns_tablespace',
+        label: gettext('Tablespace'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Do not save'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Queries'),
+      group: gettext('Restore options'),
+      schema: [{
+        id: 'include_create_database',
+        label: gettext('Include CREATE DATABASE statement'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Queries'),
+      }, {
+        id: 'clean',
+        label: gettext('Clean before restore'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Queries'),
+        disabled: function() {
+          return this.node.type === 'function' ||
+            this.node.type === 'trigger_function';
+        },
+      }, {
+        id: 'single_transaction',
+        label: gettext('Single transaction'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Queries'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Disable'),
+      group: gettext('Restore options'),
+      schema: [{
+        id: 'disable_trigger',
+        label: gettext('Trigger'),
+        control: Backform.CustomSwitchControl,
+        group: gettext('Disable'),
+      }, {
+        id: 'no_data_fail_table',
+        label: gettext('No data for Failed Tables'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Disable'),
+      }],
+    }, {
+      type: 'nested',
+      control: 'fieldset',
+      label: gettext('Miscellaneous / Behavior'),
+      group: gettext('Restore options'),
+      schema: [{
+        id: 'verbose',
+        label: gettext('Verbose messages'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous / Behavior'),
+      }, {
+        id: 'use_set_session_auth',
+        label: gettext('Use SET SESSION AUTHORIZATION'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous / Behavior'),
+      }, {
+        id: 'exit_on_error',
+        label: gettext('Exit on error'),
+        control: Backform.CustomSwitchControl,
+        disabled: false,
+        group: gettext('Miscellaneous / Behavior'),
+      }],
+    }],
+    validate: function() {
+      return null;
+    },
+  });
 
-        this.initialized = true;
-
-        // Define list of nodes on which restore context menu option appears
-        var restore_supported_nodes = [
-              'database', 'schema',
-              'table', 'function',
-              'trigger', 'index',
-              'partition'
-            ];
-
-        /**
-          Enable/disable restore menu in tools based
-          on node selected
-          if selected node is present in supported_nodes,
-          menu will be enabled otherwise disabled.
-          Also, hide it for system view in catalogs
-        */
-        var menu_enabled = function(itemData, item, data) {
-          var t = pgBrowser.tree, i = item, d = itemData;
-          var parent_item = t.hasParent(i) ? t.parent(i): null,
-              parent_data = parent_item ? t.itemData(parent_item) : null;
-            if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
-              if (_.indexOf(restore_supported_nodes, d._type) !== -1 &&
-                is_parent_catalog(itemData, item, data) ) {
-                  if (d._type == 'database' && d.allowConn)
-                    return true;
-                  else if(d._type != 'database')
-                    return true;
-                  else
-                    return false;
-              }
-              else
-                return false;
-            }
+  // Create an Object Restore of pgBrowser class
+  pgBrowser.Restore = {
+    init: function() {
+      if (this.initialized)
+        return;
+
+      this.initialized = true;
+
+      // Define list of nodes on which restore context menu option appears
+      var restore_supported_nodes = [
+        'database', 'schema',
+        'table', 'function',
+        'trigger', 'index',
+        'partition',
+      ];
+
+      /**
+        Enable/disable restore menu in tools based
+        on node selected
+        if selected node is present in supported_nodes,
+        menu will be enabled otherwise disabled.
+        Also, hide it for system view in catalogs
+      */
+      var menu_enabled = function(itemData, item, data) {
+        var t = pgBrowser.tree,
+          i = item,
+          d = itemData;
+        var parent_item = t.hasParent(i) ? t.parent(i) : null,
+          parent_data = parent_item ? t.itemData(parent_item) : null;
+        if (!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+          if (_.indexOf(restore_supported_nodes, d._type) !== -1 &&
+            is_parent_catalog(itemData, item, data)) {
+            if (d._type == 'database' && d.allowConn)
+              return true;
+            else if (d._type != 'database')
+              return true;
             else
               return false;
-        };
-
-        var is_parent_catalog = function(itemData, item, data) {
-          var t = pgBrowser.tree, i = item, d = itemData;
-          // To iterate over tree to check parent node
-          while (i) {
-            // If it is schema then allow user to restore
-            if (_.indexOf(['catalog'], d._type) > -1)
-              return false;
-            i = t.hasParent(i) ? t.parent(i) : null;
-            d = i ? t.itemData(i) : null;
-          }
-          // by default we do not want to allow create menu
-          return true;
-        }
-
-        // Define the nodes on which the menus to be appear
-        var menus = [{
-          name: 'restore_object', module: this,
-          applies: ['tools'], callback: 'restore_objects',
-          priority: 13, label: gettext('Restore...'),
-          icon: 'fa fa-upload', enable: menu_enabled
-        }];
-
-        for (var idx = 0; idx < restore_supported_nodes.length; idx++) {
-          menus.push({
-            name: 'restore_' + restore_supported_nodes[idx],
-            node: restore_supported_nodes[idx], module: this,
-            applies: ['context'], callback: 'restore_objects',
-            priority: 13, label: gettext('Restore...'),
-            icon: 'fa fa-upload', enable: menu_enabled
-            });
-        }
-
-        pgAdmin.Browser.add_menus(menus);
-        return this;
-      },
-      // Callback to draw Backup Dialog for objects
-      restore_objects: function(action, treeItem) {
-
-        var i = treeItem || pgBrowser.tree.selected(),
-          server_data = null;
-
+          } else
+            return false;
+        } else
+          return false;
+      };
+
+      var is_parent_catalog = function(itemData, item) {
+        var t = pgBrowser.tree,
+          i = item,
+          d = itemData;
+
+        // To iterate over tree to check parent node
         while (i) {
-          var node_data = pgBrowser.tree.itemData(i);
-          if (node_data._type == 'server') {
-            server_data = node_data;
-            break;
-          }
-
-          if (pgBrowser.tree.hasParent(i)) {
-            i = $(pgBrowser.tree.parent(i));
-          } else {
-            alertify.alert(
-              gettext("Restore Error"),
-              gettext("Please select server or child node from tree.")
-            );
-            break;
-          }
+          // If it is schema then allow user to restore
+          if (_.indexOf(['catalog'], d._type) > -1)
+            return false;
+          i = t.hasParent(i) ? t.parent(i) : null;
+          d = i ? t.itemData(i) : null;
         }
+        // by default we do not want to allow create menu
+        return true;
+      };
+
+      // Define the nodes on which the menus to be appear
+      var menus = [{
+        name: 'restore_object',
+        module: this,
+        applies: ['tools'],
+        callback: 'restore_objects',
+        priority: 13,
+        label: gettext('Restore...'),
+        icon: 'fa fa-upload',
+        enable: menu_enabled,
+      }];
+
+      for (var idx = 0; idx < restore_supported_nodes.length; idx++) {
+        menus.push({
+          name: 'restore_' + restore_supported_nodes[idx],
+          node: restore_supported_nodes[idx],
+          module: this,
+          applies: ['context'],
+          callback: 'restore_objects',
+          priority: 13,
+          label: gettext('Restore...'),
+          icon: 'fa fa-upload',
+          enable: menu_enabled,
+        });
+      }
 
-        if (!server_data) {
-          return;
-        }
+      pgBrowser.add_menus(menus);
+      return this;
+    },
+    // Callback to draw Backup Dialog for objects
+    restore_objects: function(action, treeItem) {
 
-        var module = 'paths',
-          preference_name = 'pg_bin_dir',
-          msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
+      var i = treeItem || pgBrowser.tree.selected(),
+        server_data = null;
 
-        if ((server_data.type && server_data.type == 'ppas') ||
-            server_data.server_type == 'ppas') {
-          preference_name = 'ppas_bin_dir';
-          msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+      while (i) {
+        var node_data = pgBrowser.tree.itemData(i);
+        if (node_data._type == 'server') {
+          server_data = node_data;
+          break;
         }
 
-        var preference = pgBrowser.get_preference(module, preference_name);
-
-        if(preference) {
-          if (!preference.value) {
-            alertify.alert(gettext('Configuration required'), msg);
-            return;
-          }
+        if (pgBrowser.tree.hasParent(i)) {
+          i = $(pgBrowser.tree.parent(i));
         } else {
           alertify.alert(
-            gettext("Restore Error"),
-            S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value()
+            gettext('Restore Error'),
+            gettext('Please select server or child node from tree.')
           );
-          return;
+          break;
         }
+      }
+
+      if (!server_data) {
+        return;
+      }
+
+      var module = 'paths',
+        preference_name = 'pg_bin_dir',
+        msg = gettext('Please configure the PostgreSQL Binary Path in the Preferences dialog.');
+
+      if ((server_data.type && server_data.type == 'ppas') ||
+        server_data.server_type == 'ppas') {
+        preference_name = 'ppas_bin_dir';
+        msg = gettext('Please configure the EDB Advanced Server Binary Path in the Preferences dialog.');
+      }
 
-        var title = S(gettext('Restore (%s: %s)')),
-            tree = pgBrowser.tree,
-            item = treeItem || tree.selected(),
-            data = item && item.length == 1 && tree.itemData(item),
-            node = data && data._type && pgBrowser.Nodes[data._type];
+      var preference = pgBrowser.get_preference(module, preference_name);
 
-        if (!node)
+      if (preference) {
+        if (!preference.value) {
+          alertify.alert(gettext('Configuration required'), msg);
           return;
+        }
+      } else {
+        alertify.alert(
+          gettext('Restore Error'),
+          S(gettext('Failed to load preference %s of module %s')).sprintf(preference_name, module).value()
+        );
+        return;
+      }
 
-        title = title.sprintf(node.label, data.label).value();
-
-        if(!alertify.pg_restore) {
-          // Create Dialog title on the fly with node details
-          alertify.dialog('pg_restore' ,function factory() {
-            return {
-               main: function(title, item, data, node) {
-                this.set('title', title);
-                this.setting('pg_node', node);
-                this.setting('pg_item', item);
-                this.setting('pg_item_data', data);
-               },
-               build: function() {
-                alertify.pgDialogBuild.apply(this)
-               },
-               setup:function() {
-                return {
-                  buttons: [{
-                    text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
-                    attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Restore')}
-                  },{
-                    text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
-                    attrs:{
-                      name:'dialog_help', type:'button', label: gettext('Restore'),
-                      url: url_for('help.static', {'filename': 'restore_dialog.html'})
-                    }
-                  },{
-                    text: gettext('Restore'), key: 13,
-                    className: 'btn btn-primary fa fa-upload pg-alertify-button', restore: true,
-                    'data-btn-name': 'restore'
-                  },{
-                    text: gettext('Cancel'), key: 27,
-                    className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button', restore: false,
-                    'data-btn-name': 'cancel'
-                  }],
-                  // Set options for dialog
-                  options: {
-                    title: title,
-                    //disable both padding and overflow control.
-                    padding : !1,
-                    overflow: !1,
-                    model: 0,
-                    resizable: true,
-                    maximizable: true,
-                    pinnable: false,
-                    closableByDimmer: false,
-                    modal: false
-                  }
-                };
-              },
-              hooks: {
-                // triggered when the dialog is closed
-                onclose: function() {
-                  if (this.view) {
-                    this.view.remove({data: true, internal: true, silent: true});
-                  }
+      var title = S(gettext('Restore (%s: %s)')),
+        tree = pgBrowser.tree,
+        item = treeItem || tree.selected(),
+        data = item && item.length == 1 && tree.itemData(item),
+        node = data && data._type && pgBrowser.Nodes[data._type];
+
+      if (!node)
+        return;
+
+      title = title.sprintf(node.label, data.label).value();
+
+      if (!alertify.pg_restore) {
+        // Create Dialog title on the fly with node details
+        alertify.dialog('pg_restore', function factory() {
+          return {
+            main: function(title, item, data, node) {
+              this.set('title', title);
+              this.setting('pg_node', node);
+              this.setting('pg_item', item);
+              this.setting('pg_item_data', data);
+            },
+            build: function() {
+              alertify.pgDialogBuild.apply(this);
+            },
+            setup: function() {
+              return {
+                buttons: [{
+                  text: '',
+                  className: 'btn btn-default pull-left fa fa-lg fa-info',
+                  attrs: {
+                    name: 'object_help',
+                    type: 'button',
+                    url: 'backup.html',
+                    label: gettext('Restore'),
+                  },
+                }, {
+                  text: '',
+                  key: 112,
+                  className: 'btn btn-default pull-left fa fa-lg fa-question',
+                  attrs: {
+                    name: 'dialog_help',
+                    type: 'button',
+                    label: gettext('Restore'),
+                    url: url_for('help.static', {
+                      'filename': 'restore_dialog.html',
+                    }),
+                  },
+                }, {
+                  text: gettext('Restore'),
+                  key: 13,
+                  className: 'btn btn-primary fa fa-upload pg-alertify-button',
+                  restore: true,
+                  'data-btn-name': 'restore',
+                }, {
+                  text: gettext('Cancel'),
+                  key: 27,
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+                  restore: false,
+                  'data-btn-name': 'cancel',
+                }],
+                // Set options for dialog
+                options: {
+                  title: title,
+                  //disable both padding and overflow control.
+                  padding: !1,
+                  overflow: !1,
+                  model: 0,
+                  resizable: true,
+                  maximizable: true,
+                  pinnable: false,
+                  closableByDimmer: false,
+                  modal: false,
+                },
+              };
+            },
+            hooks: {
+              // triggered when the dialog is closed
+              onclose: function() {
+                if (this.view) {
+                  this.view.remove({
+                    data: true,
+                    internal: true,
+                    silent: true,
+                  });
                 }
               },
-              settings:{
-                pg_node: null,
-                pg_item: null,
-                pg_item_data: null
-              },
-              prepare: function() {
+            },
+            settings: {
+              pg_node: null,
+              pg_item: null,
+              pg_item_data: null,
+            },
+            prepare: function() {
+
+              var self = this;
+              // Disable Backup button until user provides Filename
+              this.__internal.buttons[2].element.disabled = true;
+              var $container = $('<div class=\'restore_dialog\'></div>');
+              var t = pgBrowser.tree,
+                i = t.selected(),
+                d = i && i.length == 1 ? t.itemData(i) : undefined,
+                node = d && pgBrowser.Nodes[d._type];
+
+              if (!d)
+                return;
+
+              var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+
+              var newModel = new RestoreObjectModel({
+                  node_data: node,
+                }, {
+                  node_info: treeInfo,
+                }),
+                fields = Backform.generateViewSchema(
+                  treeInfo, newModel, 'create', node, treeInfo.server, true
+                );
 
-                var self = this;
-                // Disable Backup button until user provides Filename
-                this.__internal.buttons[2].element.disabled = true;
-                var $container = $("<div class='restore_dialog'></div>");
-                var t = pgBrowser.tree,
-                  i = t.selected(),
-                  d = i && i.length == 1 ? t.itemData(i) : undefined,
-                  node = d && pgBrowser.Nodes[d._type];
+              var view = this.view = new Backform.Dialog({
+                el: $container,
+                model: newModel,
+                schema: fields,
+              });
 
-                if (!d)
-                  return;
+              $(this.elements.body.childNodes[0]).addClass(
+                'alertify_tools_dialog_properties obj_properties'
+              );
 
-                var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]);
+              view.render();
 
-                var newModel = new RestoreObjectModel(
-                  {node_data: node}, {node_info: treeInfo}
-                  ),
-                  fields = Backform.generateViewSchema(
-                    treeInfo, newModel, 'create', node, treeInfo.server, true
-                  );
-
-                var view = this.view = new Backform.Dialog({
-                  el: $container, model: newModel, schema: fields
-                });
+              this.elements.content.appendChild($container.get(0));
 
-                $(this.elements.body.childNodes[0]).addClass(
-                  'alertify_tools_dialog_properties obj_properties'
+              // Listen to model & if filename is provided then enable Backup button
+              this.view.model.on('change', function() {
+                if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
+                  this.errorModel.clear();
+                  self.__internal.buttons[2].element.disabled = false;
+                } else {
+                  self.__internal.buttons[2].element.disabled = true;
+                  this.errorModel.set('file', gettext('Please provide filename'));
+                }
+              });
+
+            },
+            // Callback functions when click on the buttons of the Alertify dialogs
+            callback: function(e) {
+              // Fetch current server id
+              var t = pgBrowser.tree,
+                i = this.settings['pg_item'] || t.selected(),
+                d = this.settings['pg_item_data'] || (
+                  i && i.length == 1 ? t.itemData(i) : undefined
+                ),
+                node = this.settings['pg_node'] || (
+                  d && pgBrowser.Nodes[d._type]
                 );
 
-                view.render();
-
-                this.elements.content.appendChild($container.get(0));
-
-                 // Listen to model & if filename is provided then enable Backup button
-                this.view.model.on('change', function() {
-                    if (!_.isUndefined(this.get('file')) && this.get('file') !== '') {
-                      this.errorModel.clear();
-                      self.__internal.buttons[2].element.disabled = false;
-                    } else {
-                      self.__internal.buttons[2].element.disabled = true;
-                      this.errorModel.set('file', gettext('Please provide filename'))
-                    }
-                });
+              if (e.button.element.name == 'dialog_help' || e.button.element.name == 'object_help') {
+                e.cancel = true;
+                pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+                  node, i, e.button.element.getAttribute('label'));
+                return;
+              }
 
-              },
-              // Callback functions when click on the buttons of the Alertify dialogs
-              callback: function(e) {
-                // Fetch current server id
-                var t = pgBrowser.tree,
-                  i = this.settings['pg_item'] || t.selected(),
-                  d = this.settings['pg_item_data'] || (
-                    i && i.length == 1 ? t.itemData(i) : undefined
-                  ),
-                  node = this.settings['pg_node'] || (
-                    d && pgBrowser.Nodes[d._type]
-                  );
-
-                if (e.button.element.name == "dialog_help" || e.button.element.name == "object_help") {
-                  e.cancel = true;
-                  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
-                    node, i, e.button.element.getAttribute('label'));
+              if (e.button['data-btn-name'] === 'restore') {
+                if (!d)
                   return;
-                }
 
-                if (e.button['data-btn-name'] === "restore") {
-                  if (!d)
-                    return;
-
-                  var info = node.getTreeNodeHierarchy.apply(node, [i]),
-                      m = this.view.model;
-                  // Set current node info into model
-                  m.set('database', info.database._label);
-                  if (!m.get('custom')) {
-                    switch (d._type) {
-                      case 'schema':
-                        m.set('schemas', [d._label]);
-                        break;
-                      case 'table':
-                        m.set('schemas', [info.schema._label]);
-                        m.set('tables', [d._label]);
-                        break;
-                      case 'function':
-                        m.set('schemas', [info.schema._label]);
-                        m.set('functions', [d._label]);
-                        break;
-                      case 'index':
-                        m.set('schemas', [info.schema._label]);
-                        m.set('indexes', [d._label]);
-                        break;
-                      case 'trigger':
-                        m.set('schemas', [info.schema._label]);
-                        m.set('triggers', [d._label]);
-                        break;
-                      case 'trigger_func':
-                        m.set('schemas', [info.schema._label]);
-                        m.set('trigger_funcs', [d._label]);
-                        break;
-                    }
-                  } else {
-                    // TODO::
-                    // When we will implement the object selection in the
-                    // import dialog, we will need to select the objects from
-                    // the tree selection tab.
+                var info = node.getTreeNodeHierarchy.apply(node, [i]),
+                  m = this.view.model;
+                // Set current node info into model
+                m.set('database', info.database._label);
+                if (!m.get('custom')) {
+                  switch (d._type) {
+                  case 'schema':
+                    m.set('schemas', [d._label]);
+                    break;
+                  case 'table':
+                    m.set('schemas', [info.schema._label]);
+                    m.set('tables', [d._label]);
+                    break;
+                  case 'function':
+                    m.set('schemas', [info.schema._label]);
+                    m.set('functions', [d._label]);
+                    break;
+                  case 'index':
+                    m.set('schemas', [info.schema._label]);
+                    m.set('indexes', [d._label]);
+                    break;
+                  case 'trigger':
+                    m.set('schemas', [info.schema._label]);
+                    m.set('triggers', [d._label]);
+                    break;
+                  case 'trigger_func':
+                    m.set('schemas', [info.schema._label]);
+                    m.set('trigger_funcs', [d._label]);
+                    break;
                   }
+                } else {
+                  // TODO::
+                  // When we will implement the object selection in the
+                  // import dialog, we will need to select the objects from
+                  // the tree selection tab.
+                }
 
-                  var self = this,
-                      baseUrl = url_for('restore.create_job', {'sid': info.server._id}),
-                      args =  this.view.model.toJSON();
-
-                  $.ajax({
-                    url: baseUrl,
-                    method: 'POST',
-                    data:{ 'data': JSON.stringify(args) },
-                    success: function(res) {
-                      if (res.success) {
-                        alertify.success(
-                          gettext('Restore job created.'), 5
-                        );
-                        pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
-                      } else {
-                        console.log(res);
-                      }
-                    },
-                    error: function(xhr, status, error) {
-                      try {
-                        var err = $.parseJSON(xhr.responseText);
-                        alertify.alert(
-                          gettext('Restore failed.'),
-                          err.errormsg
-                        );
-                      } catch (e) {}
+                var self = this,
+                  baseUrl = url_for('restore.create_job', {
+                    'sid': info.server._id,
+                  }),
+                  args = this.view.model.toJSON();
+
+                $.ajax({
+                  url: baseUrl,
+                  method: 'POST',
+                  data: {
+                    'data': JSON.stringify(args),
+                  },
+                  success: function(res) {
+                    if (res.success) {
+                      alertify.success(
+                        gettext('Restore job created.'), 5
+                      );
+                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
+                    } else {
+                      console.warn(res);
                     }
-                  });
-                }
-             }
+                  },
+                  error: function(xhr) {
+                    try {
+                      var err = $.parseJSON(xhr.responseText);
+                      alertify.alert(
+                        gettext('Restore failed.'),
+                        err.errormsg
+                      );
+                    } catch (e) {
+                      console.warn(e.stack || e);
+                    }
+                  },
+                });
+              }
+            },
           };
         });
       }
 
-      alertify.pg_restore(title, item, data, node).resizeTo('65%','60%');
-      }
-    };
-    return pgBrowser.Restore;
-  });
+      alertify.pg_restore(title, item, data, node).resizeTo('65%', '60%');
+    },
+  };
+  return pgBrowser.Restore;
+});
diff --git a/web/pgadmin/tools/user_management/static/js/user_management.js b/web/pgadmin/tools/user_management/static/js/user_management.js
index d51d6b48..8e2f801b 100644
--- a/web/pgadmin/tools/user_management/static/js/user_management.js
+++ b/web/pgadmin/tools/user_management/static/js/user_management.js
@@ -2,744 +2,799 @@ define([
   'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
   'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node',
   'pgadmin.user_management.current_user',
-  'backgrid.select.all', 'backgrid.filter'
+  'backgrid.select.all', 'backgrid.filter',
 ], function(
   gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform,
   pgNode, userInfo
 ) {
 
-    // if module is already initialized, refer to that.
-    if (pgBrowser.UserManagement) {
-      return pgBrowser.UserManagement;
-    }
-
-    var USERURL = url_for('user_management.users'),
-        ROLEURL = url_for('user_management.roles'),
-        userFilter = function(collection) {
-          return (new Backgrid.Extension.ClientSideFilter({
-            collection: collection,
-            placeholder: _('Filter by email'),
-
-            // The model fields to search for matches
-            fields: ['email'],
-
-            // How long to wait after typing has stopped before searching can start
-            wait: 150
-          }));
-        }
-
-    pgBrowser.UserManagement  = {
-      init: function() {
-        if (this.initialized)
-          return;
-
-        this.initialized = true;
-
-        return this;
-      },
-
-      // Callback to draw change password Dialog.
-      change_password: function(url) {
-        var title = gettext('Change Password');
-
-        if(!alertify.ChangePassword) {
-          alertify.dialog('ChangePassword' ,function factory() {
-            return {
-              main: function(title, url) {
-                this.set({
-                  'title': title,
-                  'url': url
-                });
-              },
-              build: function() {
-                alertify.pgDialogBuild.apply(this)
-              },
-              settings:{
-                  url: undefined
-              },
-              setup:function() {
-                return {
-                  buttons: [{
-                    text: '', key: 112,
-                    className: 'btn btn-default pull-left fa fa-lg fa-question',
-                    attrs:{
-                      name:'dialog_help', type:'button', label: gettext('Change Password'),
-                      url: url_for(
-                        'help.static', {
-                          'filename': 'change_user_password.html'
-                        })
-                    }
-                  },{
-                    text: gettext('Close'), key: 27,
-                    className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
-                    attrs:{name:'close', type:'button'}
-                  }],
-                  // Set options for dialog
-                  options: {
-                    //disable both padding and overflow control.
-                    padding : !1,
-                    overflow: !1,
-                    modal: false,
-                    resizable: true,
-                    maximizable: true,
-                    pinnable: false,
-                    closableByDimmer: false,
-                    closable: false
-                  }
-                };
-              },
-              hooks: {
-                // Triggered when the dialog is closed
-                onclose: function() {
-                  // Clear the view
-                  return setTimeout((function() {
-                    return alertify.ChangePassword().destroy();
-                  }), 500);
-                }
-              },
-              prepare: function() {
-                // create the iframe element
-                var iframe = document.createElement('iframe');
-                iframe.frameBorder = "no";
-                iframe.width = "100%";
-                iframe.height = "100%";
-                iframe.src = this.setting('url');
-                // add it to the dialog
-                this.elements.content.appendChild(iframe);
+  // if module is already initialized, refer to that.
+  if (pgBrowser.UserManagement) {
+    return pgBrowser.UserManagement;
+  }
+
+  var USERURL = url_for('user_management.users'),
+    ROLEURL = url_for('user_management.roles'),
+    userFilter = function(collection) {
+      return (new Backgrid.Extension.ClientSideFilter({
+        collection: collection,
+        placeholder: _('Filter by email'),
+
+        // The model fields to search for matches
+        fields: ['email'],
+
+        // How long to wait after typing has stopped before searching can start
+        wait: 150,
+      }));
+    };
+
+  pgBrowser.UserManagement = {
+    init: function() {
+      if (this.initialized)
+        return;
+
+      this.initialized = true;
+
+      return this;
+    },
+
+    // Callback to draw change password Dialog.
+    change_password: function(url) {
+      var title = gettext('Change Password');
+
+      if (!alertify.ChangePassword) {
+        alertify.dialog('ChangePassword', function factory() {
+          return {
+            main: function(title, url) {
+              this.set({
+                'title': title,
+                'url': url,
+              });
+            },
+            build: function() {
+              alertify.pgDialogBuild.apply(this);
+            },
+            settings: {
+              url: undefined,
+            },
+            setup: function() {
+              return {
+                buttons: [{
+                  text: '',
+                  key: 112,
+                  className: 'btn btn-default pull-left fa fa-lg fa-question',
+                  attrs: {
+                    name: 'dialog_help',
+                    type: 'button',
+                    label: gettext('Change Password'),
+                    url: url_for(
+                      'help.static', {
+                        'filename': 'change_user_password.html',
+                      }),
+                  },
+                }, {
+                  text: gettext('Close'),
+                  key: 27,
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
+                  attrs: {
+                    name: 'close',
+                    type: 'button',
+                  },
+                }],
+                // Set options for dialog
+                options: {
+                  //disable both padding and overflow control.
+                  padding: !1,
+                  overflow: !1,
+                  modal: false,
+                  resizable: true,
+                  maximizable: true,
+                  pinnable: false,
+                  closableByDimmer: false,
+                  closable: false,
+                },
+              };
+            },
+            hooks: {
+              // Triggered when the dialog is closed
+              onclose: function() {
+                // Clear the view
+                return setTimeout((function() {
+                  return alertify.ChangePassword().destroy();
+                }), 500);
               },
-              callback: function(e) {
-                if (e.button.element.name == "dialog_help") {
-                  e.cancel = true;
-                  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
-                    null, null, e.button.element.getAttribute('label'));
-                  return;
-                }
+            },
+            prepare: function() {
+              // create the iframe element
+              var iframe = document.createElement('iframe');
+              iframe.frameBorder = 'no';
+              iframe.width = '100%';
+              iframe.height = '100%';
+              iframe.src = this.setting('url');
+              // add it to the dialog
+              this.elements.content.appendChild(iframe);
+            },
+            callback: function(e) {
+              if (e.button.element.name == 'dialog_help') {
+                e.cancel = true;
+                pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+                  null, null, e.button.element.getAttribute('label'));
+                return;
               }
-            };
-          });
-        }
-
-        alertify.ChangePassword(title, url).resizeTo('75%','70%');
-      },
-
-      // Callback to draw User Management Dialog.
-      show_users: function(action, item, params) {
-        if (!userInfo['is_admin']) return;
-        var Roles = [];
-
-        var UserModel = pgAdmin.Browser.Node.Model.extend({
-            idAttribute: 'id',
-            urlRoot: USERURL,
-            defaults: {
-              id: undefined,
-              email: undefined,
-              active: true,
-              role: undefined,
-              newPassword: undefined,
-              confirmPassword: undefined
             },
-            schema: [
-            {
-              id: 'email', label: gettext('Email'), type: 'text',
-              cell: Backgrid.Extension.StringDepCell, cellHeaderClasses: 'width_percent_30',
-              deps: ['id'],
-              editable: function(m) {
-                if(m instanceof Backbone.Collection) {
-                  return false;
-                }
-                // Disable email edit for existing user.
-                if (m.isNew()){
-                    return true;
-                }
+          };
+        });
+      }
+
+      alertify.ChangePassword(title, url).resizeTo('75%', '70%');
+    },
+
+    // Callback to draw User Management Dialog.
+    show_users: function() {
+      if (!userInfo['is_admin']) return;
+      var Roles = [];
+
+      var UserModel = pgBrowser.Node.Model.extend({
+          idAttribute: 'id',
+          urlRoot: USERURL,
+          defaults: {
+            id: undefined,
+            email: undefined,
+            active: true,
+            role: undefined,
+            newPassword: undefined,
+            confirmPassword: undefined,
+          },
+          schema: [{
+            id: 'email',
+            label: gettext('Email'),
+            type: 'text',
+            cell: Backgrid.Extension.StringDepCell,
+            cellHeaderClasses: 'width_percent_30',
+            deps: ['id'],
+            editable: function(m) {
+              if (m instanceof Backbone.Collection) {
                 return false;
               }
-            },{
-              id: 'role', label: gettext('Role'),
-              type: 'text', control: "Select2", cellHeaderClasses:'width_percent_20',
-              cell: 'select2', select2: {allowClear: false, openOnEnter: false},
-              options: function (controlOrCell) {
-                var options = [];
-
-                if( controlOrCell instanceof Backform.Control){
-                  // This is be backform select2 control
-                  _.each(Roles, function(role) {
-                    options.push({
-                      label: role.name,
-                      value: role.id.toString()}
-                    );
-                  });
-                } else {
-                  // This must be backgrid select2 cell
-                  _.each(Roles, function(role) {
-                    options.push([role.name, role.id.toString()]);
+              // Disable email edit for existing user.
+              if (m.isNew()) {
+                return true;
+              }
+              return false;
+            },
+          }, {
+            id: 'role',
+            label: gettext('Role'),
+            type: 'text',
+            control: 'Select2',
+            cellHeaderClasses: 'width_percent_20',
+            cell: 'select2',
+            select2: {
+              allowClear: false,
+              openOnEnter: false,
+            },
+            options: function(controlOrCell) {
+              var options = [];
+
+              if (controlOrCell instanceof Backform.Control) {
+                // This is be backform select2 control
+                _.each(Roles, function(role) {
+                  options.push({
+                    label: role.name,
+                    value: role.id.toString(),
                   });
-                }
+                });
+              } else {
+                // This must be backgrid select2 cell
+                _.each(Roles, function(role) {
+                  options.push([role.name, role.id.toString()]);
+                });
+              }
 
-                return options;
-              },
-              editable: function(m) {
-                if(m instanceof Backbone.Collection) {
-                  return true;
-                }
-                if (m.get("id") == userInfo['id']){
-                    return false;
-                } else {
-                    return true;
-                }
+              return options;
+            },
+            editable: function(m) {
+              if (m instanceof Backbone.Collection) {
+                return true;
               }
-            },{
-              id: 'active', label: gettext('Active'),
-              type: 'switch', cell: 'switch', cellHeaderClasses:'width_percent_10',
-              options: { 'onText': gettext('Yes'), 'offText': gettext('No')},
-              editable: function(m) {
-                if(m instanceof Backbone.Collection) {
-                  return true;
-                }
-                if (m.get("id") == userInfo['id']){
-                    return false;
-                } else {
-                    return true;
-                }
+              if (m.get('id') == userInfo['id']) {
+                return false;
+              } else {
+                return true;
+              }
+            },
+          }, {
+            id: 'active',
+            label: gettext('Active'),
+            type: 'switch',
+            cell: 'switch',
+            cellHeaderClasses: 'width_percent_10',
+            options: {
+              'onText': gettext('Yes'),
+              'offText': gettext('No'),
+            },
+            editable: function(m) {
+              if (m instanceof Backbone.Collection) {
+                return true;
+              }
+              if (m.get('id') == userInfo['id']) {
+                return false;
+              } else {
+                return true;
               }
-            },{
-              id: 'newPassword', label: gettext('New password'),
-              type: 'password', disabled: false, control: 'input',
-              cell: 'password', cellHeaderClasses:'width_percent_20'
-            },{
-              id: 'confirmPassword', label: gettext('Confirm password'),
-              type: 'password', disabled: false, control: 'input',
-              cell: 'password', cellHeaderClasses:'width_percent_20'
-            }],
-            validate: function() {
-              var err = {},
-                  errmsg = null,
-                  changedAttrs = this.changed || {},
-                  email_filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
-
-              if (('email' in changedAttrs || !this.isNew()) && (_.isUndefined(this.get('email')) ||
-                    _.isNull(this.get('email')) ||
-                    String(this.get('email')).replace(/^\s+|\s+$/g, '') == '')) {
-                errmsg = gettext('Email address cannot be empty.');
-                this.errorModel.set('email', errmsg);
+            },
+          }, {
+            id: 'newPassword',
+            label: gettext('New password'),
+            type: 'password',
+            disabled: false,
+            control: 'input',
+            cell: 'password',
+            cellHeaderClasses: 'width_percent_20',
+          }, {
+            id: 'confirmPassword',
+            label: gettext('Confirm password'),
+            type: 'password',
+            disabled: false,
+            control: 'input',
+            cell: 'password',
+            cellHeaderClasses: 'width_percent_20',
+          }],
+          validate: function() {
+            var errmsg = null,
+              changedAttrs = this.changed || {},
+              email_filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
+
+            if (('email' in changedAttrs || !this.isNew()) && (_.isUndefined(this.get('email')) ||
+                _.isNull(this.get('email')) ||
+                String(this.get('email')).replace(/^\s+|\s+$/g, '') == '')) {
+              errmsg = gettext('Email address cannot be empty.');
+              this.errorModel.set('email', errmsg);
+              return errmsg;
+            } else if (!!this.get('email') && !email_filter.test(this.get('email'))) {
+
+              errmsg = S(gettext('Invalid email address: %s.')).sprintf(
+                this.get('email')
+              ).value();
+              this.errorModel.set('email', errmsg);
+              return errmsg;
+            } else if (!!this.get('email') && this.collection.where({
+              'email': this.get('email'),
+            }).length > 1) {
+
+              errmsg = S(gettext('The email address %s already exists.')).sprintf(
+                this.get('email')
+              ).value();
+
+              this.errorModel.set('email', errmsg);
+              return errmsg;
+            } else {
+              this.errorModel.unset('email');
+            }
+
+            if ('role' in changedAttrs && (_.isUndefined(this.get('role')) ||
+                _.isNull(this.get('role')) ||
+                String(this.get('role')).replace(/^\s+|\s+$/g, '') == '')) {
+
+              errmsg = S(gettext('Role cannot be empty for user %s.')).sprintf(
+                (this.get('email') || '')
+              ).value();
+
+              this.errorModel.set('role', errmsg);
+              return errmsg;
+            } else {
+              this.errorModel.unset('role');
+            }
+
+            if (this.isNew()) {
+              // Password is compulsory for new user.
+              if ('newPassword' in changedAttrs && (_.isUndefined(this.get('newPassword')) ||
+                  _.isNull(this.get('newPassword')) ||
+                  this.get('newPassword') == '')) {
+
+                errmsg = S(gettext('Password cannot be empty for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
+
+                this.errorModel.set('newPassword', errmsg);
                 return errmsg;
-              } else if (!!this.get('email') && !email_filter.test(this.get('email'))) {
+              } else if (!_.isUndefined(this.get('newPassword')) &&
+                !_.isNull(this.get('newPassword')) &&
+                this.get('newPassword').length < 6) {
 
-                errmsg =  S(gettext("Invalid email address: %s.")).sprintf(
-                            this.get('email')
-                          ).value();
-                this.errorModel.set('email', errmsg);
+                errmsg = S(gettext('Password must be at least 6 characters for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
+
+                this.errorModel.set('newPassword', errmsg);
                 return errmsg;
-              } else if (!!this.get('email') && this.collection.where({"email":this.get('email')}).length > 1) {
+              } else {
+                this.errorModel.unset('newPassword');
+              }
 
-                errmsg =  S(gettext("The email address %s already exists.")).sprintf(
-                            this.get('email')
-                          ).value();
+              if ('confirmPassword' in changedAttrs && (_.isUndefined(this.get('confirmPassword')) ||
+                  _.isNull(this.get('confirmPassword')) ||
+                  this.get('confirmPassword') == '')) {
 
-                this.errorModel.set('email', errmsg);
+                errmsg = S(gettext('Confirm Password cannot be empty for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
+
+                this.errorModel.set('confirmPassword', errmsg);
                 return errmsg;
               } else {
-                this.errorModel.unset('email');
+                this.errorModel.unset('confirmPassword');
               }
 
-              if ('role' in changedAttrs && (_.isUndefined(this.get('role')) ||
-                    _.isNull(this.get('role')) ||
-                    String(this.get('role')).replace(/^\s+|\s+$/g, '') == '')) {
+              if (!!this.get('newPassword') && !!this.get('confirmPassword') &&
+                this.get('newPassword') != this.get('confirmPassword')) {
 
-                errmsg =  S(gettext("Role cannot be empty for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
+                errmsg = S(gettext('Passwords do not match for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
 
-                this.errorModel.set('role', errmsg);
+                this.errorModel.set('confirmPassword', errmsg);
                 return errmsg;
               } else {
-                this.errorModel.unset('role');
+                this.errorModel.unset('confirmPassword');
               }
 
-              if(this.isNew()){
-                // Password is compulsory for new user.
-                if ('newPassword' in changedAttrs && (_.isUndefined(this.get('newPassword')) ||
-                      _.isNull(this.get('newPassword')) ||
-                      this.get('newPassword') == '')) {
-
-                  errmsg =  S(gettext("Password cannot be empty for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
-
-                  this.errorModel.set('newPassword', errmsg);
-                  return errmsg;
-                } else if (!_.isUndefined(this.get('newPassword')) &&
-                  !_.isNull(this.get('newPassword')) &&
-                  this.get('newPassword').length < 6) {
-
-                  errmsg =  S(gettext("Password must be at least 6 characters for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
-
-                  this.errorModel.set('newPassword', errmsg);
-                  return errmsg;
-                } else {
-                  this.errorModel.unset('newPassword');
+            } else {
+              if ((_.isUndefined(this.get('newPassword')) || _.isNull(this.get('newPassword')) ||
+                  this.get('newPassword') == '') &&
+                ((_.isUndefined(this.get('confirmPassword')) || _.isNull(this.get('confirmPassword')) ||
+                  this.get('confirmPassword') == ''))) {
+
+                this.errorModel.unset('newPassword');
+                if (this.get('newPassword') == '') {
+                  this.set({
+                    'newPassword': undefined,
+                  });
                 }
 
-                if ('confirmPassword' in changedAttrs && (_.isUndefined(this.get('confirmPassword')) ||
-                      _.isNull(this.get('confirmPassword')) ||
-                      this.get('confirmPassword') == '')) {
+                this.errorModel.unset('confirmPassword');
+                if (this.get('confirmPassword') == '') {
+                  this.set({
+                    'confirmPassword': undefined,
+                  });
+                }
+              } else if (!_.isUndefined(this.get('newPassword')) &&
+                !_.isNull(this.get('newPassword')) &&
+                !this.get('newPassword') == '' &&
+                this.get('newPassword').length < 6) {
 
-                  errmsg =  S(gettext("Confirm Password cannot be empty for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
+                errmsg = S(gettext('Password must be at least 6 characters for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
 
-                  this.errorModel.set('confirmPassword', errmsg);
-                  return errmsg;
-                } else {
-                  this.errorModel.unset('confirmPassword');
-                }
+                this.errorModel.set('newPassword', errmsg);
+                return errmsg;
+              } else if (_.isUndefined(this.get('confirmPassword')) ||
+                _.isNull(this.get('confirmPassword')) ||
+                this.get('confirmPassword') == '') {
 
-                if(!!this.get('newPassword') && !!this.get('confirmPassword') &&
-                    this.get('newPassword') != this.get('confirmPassword')) {
+                errmsg = S(gettext('Confirm Password cannot be empty for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
 
-                  errmsg =  S(gettext("Passwords do not match for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
+                this.errorModel.set('confirmPassword', errmsg);
+                return errmsg;
+              } else if (!!this.get('newPassword') && !!this.get('confirmPassword') &&
+                this.get('newPassword') != this.get('confirmPassword')) {
 
-                  this.errorModel.set('confirmPassword', errmsg);
-                  return errmsg;
-                } else {
-                  this.errorModel.unset('confirmPassword');
-                }
+                errmsg = S(gettext('Passwords do not match for user %s.')).sprintf(
+                  (this.get('email') || '')
+                ).value();
 
+                this.errorModel.set('confirmPassword', errmsg);
+                return errmsg;
               } else {
-                if ((_.isUndefined(this.get('newPassword')) || _.isNull(this.get('newPassword')) ||
-                      this.get('newPassword') == '') &&
-                      ((_.isUndefined(this.get('confirmPassword')) || _.isNull(this.get('confirmPassword')) ||
-                      this.get('confirmPassword') == ''))) {
-
-                   this.errorModel.unset('newPassword');
-                   if(this.get('newPassword') == ''){
-                    this.set({'newPassword': undefined})
-                   }
-
-                   this.errorModel.unset('confirmPassword');
-                   if(this.get('confirmPassword') == ''){
-                    this.set({'confirmPassword': undefined})
-                   }
-                } else if (!_.isUndefined(this.get('newPassword')) &&
-                    !_.isNull(this.get('newPassword')) &&
-                    !this.get('newPassword') == '' &&
-                    this.get('newPassword').length < 6) {
-
-                  errmsg =  S(gettext("Password must be at least 6 characters for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
-
-                  this.errorModel.set('newPassword', errmsg);
-                  return errmsg;
-                } else if (_.isUndefined(this.get('confirmPassword')) ||
-                      _.isNull(this.get('confirmPassword')) ||
-                      this.get('confirmPassword') == '') {
-
-                  errmsg =  S(gettext("Confirm Password cannot be empty for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
-
-                  this.errorModel.set('confirmPassword', errmsg);
-                  return errmsg;
-                } else if (!!this.get('newPassword') && !!this.get('confirmPassword') &&
-                          this.get('newPassword') != this.get('confirmPassword')) {
-
-                  errmsg =  S(gettext("Passwords do not match for user %s.")).sprintf(
-                            (this.get('email') || '')
-                          ).value();
-
-                  this.errorModel.set('confirmPassword', errmsg);
-                  return errmsg;
-                } else {
-                  this.errorModel.unset('newPassword');
-                  this.errorModel.unset('confirmPassword');
-                }
+                this.errorModel.unset('newPassword');
+                this.errorModel.unset('confirmPassword');
               }
-              return null;
             }
-          }),
-          gridSchema = Backform.generateGridColumnsFromModel(
-              null, UserModel, 'edit'),
-          deleteUserCell = Backgrid.Extension.DeleteCell.extend({
-            deleteRow: function(e) {
-              self = this;
-              e.preventDefault();
-
-              if (self.model.get("id") == userInfo['id']) {
-                alertify.alert(
-                  gettext('Cannot delete user.'),
-                  gettext('Cannot delete currently logged in user.'),
-                  function(){
-                    return true;
-                  }
-                );
-                return true;
-              }
-
-              // We will check if row is deletable or not
-              var canDeleteRow = (!_.isUndefined(this.column.get('canDeleteRow')) &&
-                                  _.isFunction(this.column.get('canDeleteRow')) ) ?
-                                   Backgrid.callByNeed(this.column.get('canDeleteRow'),
-                                    this.column, this.model) : true;
-              if (canDeleteRow) {
-                if(self.model.isNew()){
-                  self.model.destroy();
-                } else {
-                  alertify.confirm(
-                    gettext('Delete user?'),
-                    gettext('Are you sure you wish to delete this user?'),
-                    function(evt) {
-                      self.model.destroy({
-                        wait: true,
-                        success: function(res) {
-                          alertify.success(gettext('User deleted.'));
-                        },
-                        error: function(m, jqxhr) {
-                          alertify.error(gettext('Error during deleting user.'));
-                        }
-                      });
-                    },
-                    function(evt) {
-                      return true;
-                    }
-                  );
+            return null;
+          },
+        }),
+        gridSchema = Backform.generateGridColumnsFromModel(
+          null, UserModel, 'edit'),
+        deleteUserCell = Backgrid.Extension.DeleteCell.extend({
+          deleteRow: function(e) {
+            var self = this;
+            e.preventDefault();
+
+            if (self.model.get('id') == userInfo['id']) {
+              alertify.alert(
+                gettext('Cannot delete user.'),
+                gettext('Cannot delete currently logged in user.'),
+                function() {
+                  return true;
                 }
+              );
+              return true;
+            }
+
+            // We will check if row is deletable or not
+            var canDeleteRow = (!_.isUndefined(this.column.get('canDeleteRow')) &&
+                _.isFunction(this.column.get('canDeleteRow'))) ?
+              Backgrid.callByNeed(this.column.get('canDeleteRow'),
+                this.column, this.model) : true;
+            if (canDeleteRow) {
+              if (self.model.isNew()) {
+                self.model.destroy();
               } else {
-                alertify.alert(
-                  gettext("Error"),
-                  gettext("This user cannot be deleted."),
-                  function(){
+                alertify.confirm(
+                  gettext('Delete user?'),
+                  gettext('Are you sure you wish to delete this user?'),
+                  function() {
+                    self.model.destroy({
+                      wait: true,
+                      success: function() {
+                        alertify.success(gettext('User deleted.'));
+                      },
+                      error: function() {
+                        alertify.error(
+                          gettext('Error during deleting user.')
+                        );
+                      },
+                    });
+                  },
+                  function() {
                     return true;
                   }
                 );
               }
+            } else {
+              alertify.alert(
+                gettext('Error'),
+                gettext('This user cannot be deleted.'),
+                function() {
+                  return true;
+                }
+              );
             }
-          });
-
-          gridSchema.columns.unshift({
-            name: "pg-backform-delete", label: "",
-            cell: deleteUserCell,
-            editable: false, cell_priority: -1,
-            canDeleteRow: true
-          });
-
-        // Users Management dialog code here
-        if(!alertify.UserManagement) {
-          alertify.dialog('UserManagement' ,function factory() {
-            return {
-              main: function(title) {
-                this.set('title', title);
-              },
-              build: function() {
-                alertify.pgDialogBuild.apply(this)
-              },
-              setup:function() {
-                return {
-                  buttons: [{
-                    text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
-                    attrs:{
-                      name:'dialog_help', type:'button', label: gettext('Users'),
-                      url: url_for(
-                        'help.static', {
-                          'filename': 'pgadmin_user.html'
-                        })
-                    }
-                  },{
-                    text: gettext('Close'), key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button user_management_pg-alertify-button',
-                    attrs:{name:'close', type:'button'}
-                  }],
-                  // Set options for dialog
-                  options: {
-                    title: gettext('User Management'),
-                    //disable both padding and overflow control.
-                    padding : !1,
-                    overflow: !1,
-                    modal: false,
-                    resizable: true,
-                    maximizable: true,
-                    pinnable: false,
-                    closableByDimmer: false,
-                    closable: false
-                  }
-                };
-              },
-              hooks: {
-                // Triggered when the dialog is closed
-                onclose: function() {
-                  if (this.view) {
-                    // clear our backform model/view
-                    this.view.remove({data: true, internal: true, silent: true});
-                    this.$content.remove();
-                  }
+          },
+        });
+
+      gridSchema.columns.unshift({
+        name: 'pg-backform-delete',
+        label: '',
+        cell: deleteUserCell,
+        editable: false,
+        cell_priority: -1,
+        canDeleteRow: true,
+      });
+
+      // Users Management dialog code here
+      if (!alertify.UserManagement) {
+        alertify.dialog('UserManagement', function factory() {
+          return {
+            main: function(title) {
+              this.set('title', title);
+            },
+            build: function() {
+              alertify.pgDialogBuild.apply(this);
+            },
+            setup: function() {
+              return {
+                buttons: [{
+                  text: '',
+                  key: 112,
+                  className: 'btn btn-default pull-left fa fa-lg fa-question',
+                  attrs: {
+                    name: 'dialog_help',
+                    type: 'button',
+                    label: gettext('Users'),
+                    url: url_for(
+                      'help.static', {
+                        'filename': 'pgadmin_user.html',
+                      }),
+                  },
+                }, {
+                  text: gettext('Close'),
+                  key: 27,
+                  className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button user_management_pg-alertify-button',
+                  attrs: {
+                    name: 'close',
+                    type: 'button',
+                  },
+                }],
+                // Set options for dialog
+                options: {
+                  title: gettext('User Management'),
+                  //disable both padding and overflow control.
+                  padding: !1,
+                  overflow: !1,
+                  modal: false,
+                  resizable: true,
+                  maximizable: true,
+                  pinnable: false,
+                  closableByDimmer: false,
+                  closable: false,
+                },
+              };
+            },
+            hooks: {
+              // Triggered when the dialog is closed
+              onclose: function() {
+                if (this.view) {
+                  // clear our backform model/view
+                  this.view.remove({
+                    data: true,
+                    internal: true,
+                    silent: true,
+                  });
+                  this.$content.remove();
                 }
               },
-              prepare: function() {
-                var self = this,
-                  footerTpl = _.template([
-                    '<div class="pg-prop-footer" style="visibility:hidden;">',
-                      '<div class="pg-prop-status-bar">',
-                        '<div class="media error-in-footer bg-red-1 border-red-2 font-red-3 text-14">',
-                          '<div class="media-body media-middle">',
-                            '<div class="alert-icon error-icon">',
-                              '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>',
-                            '</div>',
-                            '<div class="alert-text">',
-                            '</div>',
-                            '<div class="close-error-bar"><a class="close-error">x</a></div>',
-                          '</div>',
-                        '</div>',
-                      '</div>',
-                    '</div>'].join("\n")),
-                  $statusBar = $(footerTpl()),
-                  UserRow = Backgrid.Row.extend({
-                    userInvalidColor: "lightYellow",
-
-                    userValidColor: "#fff",
-
-                    initialize: function() {
-                      Backgrid.Row.prototype.initialize.apply(this, arguments);
-                      this.listenTo(this.model, 'pgadmin:user:invalid', this.userInvalid);
-                      this.listenTo(this.model, 'pgadmin:user:valid', this.userValid);
-                    },
-                    userInvalid: function() {
-                      $(this.el).removeClass("new");
-                      this.el.style.backgroundColor = this.userInvalidColor;
-                    },
-                    userValid: function() {
-                      this.el.style.backgroundColor = this.userValidColor;
-                    }
-                  }),
-                  UserCollection = Backbone.Collection.extend({
-                    model: UserModel,
-                    url: USERURL,
-                    initialize: function() {
-                      Backbone.Collection.prototype.initialize.apply(this, arguments);
-                      var self = this;
-                      self.changedUser = null;
-                      self.invalidUsers = {};
-
-                      self.on('add', self.onModelAdd);
-                      self.on('remove', self.onModelRemove);
-                      self.on('pgadmin-session:model:invalid', function(msg, m, c) {
-                        self.invalidUsers[m.cid] = msg;
-                        m.trigger('pgadmin:user:invalid', m);
-                        $statusBar.find('.alert-text').html(msg);
-                        $statusBar.css("visibility", "visible");
-                      });
-                      self.on('pgadmin-session:model:valid', function(m, c) {
-                        delete self.invalidUsers[m.cid];
-                        m.trigger('pgadmin:user:valid', m);
-                        this.updateErrorMsg();
-                        this.saveUser(m);
-                      });
-                    },
-                    onModelAdd: function(m) {
-                      // Start tracking changes.
-                      m.startNewSession();
-                    },
-                    onModelRemove: function(m) {
-                      delete this.invalidUsers[m.cid];
+            },
+            prepare: function() {
+              var footerTpl = _.template([
+                  '<div class="pg-prop-footer" style="visibility:hidden;">',
+                  '<div class="pg-prop-status-bar">',
+                  '<div class="media error-in-footer bg-red-1 border-red-2 font-red-3 text-14">',
+                  '<div class="media-body media-middle">',
+                  '<div class="alert-icon error-icon">',
+                  '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>',
+                  '</div>',
+                  '<div class="alert-text">',
+                  '</div>',
+                  '<div class="close-error-bar"><a class="close-error">x</a></div>',
+                  '</div>',
+                  '</div>',
+                  '</div>',
+                  '</div>',
+                ].join('\n')),
+                $statusBar = $(footerTpl()),
+                UserRow = Backgrid.Row.extend({
+                  userInvalidColor: 'lightYellow',
+
+                  userValidColor: '#fff',
+
+                  initialize: function() {
+                    Backgrid.Row.prototype.initialize.apply(this, arguments);
+                    this.listenTo(this.model, 'pgadmin:user:invalid', this.userInvalid);
+                    this.listenTo(this.model, 'pgadmin:user:valid', this.userValid);
+                  },
+                  userInvalid: function() {
+                    $(this.el).removeClass('new');
+                    this.el.style.backgroundColor = this.userInvalidColor;
+                  },
+                  userValid: function() {
+                    this.el.style.backgroundColor = this.userValidColor;
+                  },
+                }),
+                UserCollection = Backbone.Collection.extend({
+                  model: UserModel,
+                  url: USERURL,
+                  initialize: function() {
+                    Backbone.Collection.prototype.initialize.apply(this, arguments);
+                    var self = this;
+                    self.changedUser = null;
+                    self.invalidUsers = {};
+
+                    self.on('add', self.onModelAdd);
+                    self.on('remove', self.onModelRemove);
+                    self.on('pgadmin-session:model:invalid', function(msg, m) {
+                      self.invalidUsers[m.cid] = msg;
+                      m.trigger('pgadmin:user:invalid', m);
+                      $statusBar.find('.alert-text').html(msg);
+                      $statusBar.css('visibility', 'visible');
+                    });
+                    self.on('pgadmin-session:model:valid', function(m) {
+                      delete self.invalidUsers[m.cid];
+                      m.trigger('pgadmin:user:valid', m);
                       this.updateErrorMsg();
-                    },
-                    updateErrorMsg: function() {
-                      var self = this,
-                        msg = null;
-
-                      for (var key in self.invalidUsers) {
-                        msg = self.invalidUsers [key];
-                        if (msg) {
-                          break;
-                        }
+                      this.saveUser(m);
+                    });
+                  },
+                  onModelAdd: function(m) {
+                    // Start tracking changes.
+                    m.startNewSession();
+                  },
+                  onModelRemove: function(m) {
+                    delete this.invalidUsers[m.cid];
+                    this.updateErrorMsg();
+                  },
+                  updateErrorMsg: function() {
+                    var self = this,
+                      msg = null;
+
+                    for (var key in self.invalidUsers) {
+                      msg = self.invalidUsers[key];
+                      if (msg) {
+                        break;
                       }
+                    }
 
-                      if(msg){
-                        $statusBar.find('.alert-text').html(msg);
-                        $statusBar.css("visibility", "visible");
-                      } else {
-                        $statusBar.find('.alert-text').empty();
-                        $statusBar.css("visibility", "hidden");
-                      }
-                    },
-                    saveUser: function(m) {
-                      var d = m.toJSON(true);
+                    if (msg) {
+                      $statusBar.find('.alert-text').html(msg);
+                      $statusBar.css('visibility', 'visible');
+                    } else {
+                      $statusBar.find('.alert-text').empty();
+                      $statusBar.css('visibility', 'hidden');
+                    }
+                  },
+                  saveUser: function(m) {
+                    var d = m.toJSON(true);
 
-                      if(m.isNew() && (!m.get('email') || !m.get('role') ||
-                          !m.get('newPassword') || !m.get('confirmPassword') ||
-                          m.get('newPassword') != m.get('confirmPassword'))
-                      ) {
+                    if (m.isNew() && (!m.get('email') || !m.get('role') ||
+                        !m.get('newPassword') || !m.get('confirmPassword') ||
+                        m.get('newPassword') != m.get('confirmPassword'))) {
                       // New user model is valid but partially filled so return without saving.
-                        return false;
-                      } else if (!m.isNew() && m.get('newPassword') != m.get('confirmPassword')) {
+                      return false;
+                    } else if (!m.isNew() && m.get('newPassword') != m.get('confirmPassword')) {
                       // For old user password change is in progress and user model is valid but admin has not added
                       // both the passwords so return without saving.
-                        return false;
-                      }
-
-                      if (m.sessChanged() && d && !_.isEmpty(d)) {
-                        m.stopSession();
-                        m.save({}, {
-                          attrs: d,
-                          wait: true,
-                          success: function(res) {
-                            // User created/updated on server now start new session for this user.
-                            m.set({'newPassword':undefined,
-                                   'confirmPassword':undefined});
-
-                            m.startNewSession();
-                            alertify.success(S(gettext("User '%s' saved.")).sprintf(
-                              m.get('email')
-                            ).value());
-                          },
-                          error: function(res, jqxhr) {
-                            m.startNewSession();
-                            alertify.error(
-                              S(gettext("Error saving user: '%s'")).sprintf(
-                                jqxhr.responseJSON.errormsg
-                              ).value()
-                            );
-                          }
-                        });
-                      }
+                      return false;
                     }
-                  }),
-                  userCollection = this.userCollection = new UserCollection(),
-                  header = [
-                    '<div class="subnode-header">',
-                    '  <button class="btn-sm btn-default add fa fa-plus" title="<%-add_title%>" <%=canAdd ? "" : "disabled=\'disabled\'"%> ></button>',
-                    '  <div class="control-label search_users"></div>',
-                    '</div>',].join("\n"),
-                  headerTpl = _.template(header),
-                  data = {
-                    canAdd: true,
-                    add_title: gettext('Add new user')
-                  },
-                  $gridBody = $("<div></div>", {
-                    class: "user_container"
-                  });
 
-                $.ajax({
-                  url: ROLEURL,
-                  method: 'GET',
-                  async: false,
-                  success: function(res) {
-                    Roles = res
+                    if (m.sessChanged() && d && !_.isEmpty(d)) {
+                      m.stopSession();
+                      m.save({}, {
+                        attrs: d,
+                        wait: true,
+                        success: function() {
+                          // User created/updated on server now start new session for this user.
+                          m.set({
+                            'newPassword': undefined,
+                            'confirmPassword': undefined,
+                          });
+
+                          m.startNewSession();
+                          alertify.success(S(gettext('User \'%s\' saved.')).sprintf(
+                            m.get('email')
+                          ).value());
+                        },
+                        error: function(res, jqxhr) {
+                          m.startNewSession();
+                          alertify.error(
+                            S(gettext('Error saving user: \'%s\'')).sprintf(
+                              jqxhr.responseJSON.errormsg
+                            ).value()
+                          );
+                        },
+                      });
+                    }
                   },
-                  error: function(e) {
-                    setTimeout(function() {
-                      alertify.alert(
-                        gettext('Error'),
-                        gettext('Cannot load user roles.')
-                      );
-                    },100);
-                  }
-                });
-
-                var view = this.view = new Backgrid.Grid({
-                  row: UserRow,
-                  columns: gridSchema.columns,
-                  collection: userCollection,
-                  className: "backgrid table-bordered"
+                }),
+                userCollection = this.userCollection = new UserCollection(),
+                header = [
+                  '<div class="subnode-header">',
+                  '  <button class="btn-sm btn-default add fa fa-plus" title="<%-add_title%>" <%=canAdd ? "" : "disabled=\'disabled\'"%> ></button>',
+                  '  <div class="control-label search_users"></div>',
+                  '</div>',
+                ].join('\n'),
+                headerTpl = _.template(header),
+                data = {
+                  canAdd: true,
+                  add_title: gettext('Add new user'),
+                },
+                $gridBody = $('<div></div>', {
+                  class: 'user_container',
                 });
 
-                $gridBody.append(view.render().$el[0]);
+              $.ajax({
+                url: ROLEURL,
+                method: 'GET',
+                async: false,
+                success: function(res) {
+                  Roles = res;
+                },
+                error: function() {
+                  setTimeout(function() {
+                    alertify.alert(
+                      gettext('Error'),
+                      gettext('Cannot load user roles.')
+                    );
+                  }, 100);
+                },
+              });
 
-                this.$content = $("<div class='user_management object subnode'></div>").append(
-                    headerTpl(data)).append($gridBody
-                    ).append($statusBar);
+              var view = this.view = new Backgrid.Grid({
+                row: UserRow,
+                columns: gridSchema.columns,
+                collection: userCollection,
+                className: 'backgrid table-bordered',
+              });
 
-                $(this.elements.body.childNodes[0]).addClass(
-                  'alertify_tools_dialog_backgrid_properties');
+              $gridBody.append(view.render().$el[0]);
 
-                this.elements.content.appendChild(this.$content[0]);
+              this.$content = $('<div class=\'user_management object subnode\'></div>').append(
+                headerTpl(data)).append($gridBody).append($statusBar);
 
-                // Render Search Filter
-                $('.search_users').append(
-                  userFilter(userCollection).render().el);
+              $(this.elements.body.childNodes[0]).addClass(
+                'alertify_tools_dialog_backgrid_properties');
 
-                userCollection.fetch();
+              this.elements.content.appendChild(this.$content[0]);
 
-                this.$content.find('a.close-error').click(function(e) {
-                  $statusBar.find('.alert-text').empty();
-                  $statusBar.css("visibility", "hidden");
-                });
+              // Render Search Filter
+              $('.search_users').append(
+                userFilter(userCollection).render().el);
 
-                this.$content.find('button.add').first().click(function(e) {
-                  e.preventDefault();
-                  var canAddRow = true;
+              userCollection.fetch();
 
-                  if (canAddRow) {
-                      // There should be only one empty row.
+              this.$content.find('a.close-error').click(function() {
+                $statusBar.find('.alert-text').empty();
+                $statusBar.css('visibility', 'hidden');
+              });
 
-                      var isEmpty = false,
-                        unsavedModel = null;
+              this.$content.find('button.add').first().click(function(e) {
+                e.preventDefault();
+                var canAddRow = true;
 
-                      userCollection.each(function(model) {
-                        if(!isEmpty) {
-                          isEmpty = model.isNew();
-                          unsavedModel = model;
-                        }
-                      });
-                      if(isEmpty) {
-                        var idx = userCollection.indexOf(unsavedModel),
-                          row = view.body.rows[idx].$el;
+                if (canAddRow) {
+                  // There should be only one empty row.
 
-                        row.addClass("new");
-                        $(row).pgMakeVisible('backform-tab');
-                        return false;
-                      }
+                  var isEmpty = false,
+                    unsavedModel = null;
 
-                      $(view.body.$el.find($("tr.new"))).removeClass("new")
-                      var m = new (UserModel) (null, {
-                        handler: userCollection,
-                        top: userCollection,
-                        collection: userCollection
-                      });
-                      userCollection.add(m);
+                  userCollection.each(function(model) {
+                    if (!isEmpty) {
+                      isEmpty = model.isNew();
+                      unsavedModel = model;
+                    }
+                  });
+                  var idx;
 
-                      var idx = userCollection.indexOf(m),
-                          newRow = view.body.rows[idx].$el;
+                  if (isEmpty) {
+                    idx = userCollection.indexOf(unsavedModel);
+                    var row = view.body.rows[idx].$el;
 
-                      newRow.addClass("new");
-                      $(newRow).pgMakeVisible('backform-tab');
-                      return false;
+                    row.addClass('new');
+                    $(row).pgMakeVisible('backform-tab');
+                    return false;
                   }
-                });
-              },
-              callback: function(e) {
-                if (e.button.element.name == "dialog_help") {
-                  e.cancel = true;
-                  pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
-                    null, null, e.button.element.getAttribute('label'));
-                  return;
+
+                  $(view.body.$el.find($('tr.new'))).removeClass('new');
+                  var m = new(UserModel)(null, {
+                    handler: userCollection,
+                    top: userCollection,
+                    collection: userCollection,
+                  });
+                  userCollection.add(m);
+
+                  idx = userCollection.indexOf(m);
+                  var newRow = view.body.rows[idx].$el;
+
+                  newRow.addClass('new');
+                  $(newRow).pgMakeVisible('backform-tab');
+                  return false;
                 }
-                if (e.button.element.name == "close") {
-                  var self = this;
-                  if (!_.all(this.userCollection.pluck('id')) || !_.isEmpty(this.userCollection.invalidUsers)) {
-                    e.cancel = true;
-                    alertify.confirm(
-                      gettext('Discard unsaved changes?'),
-                      gettext('Are you sure you want to close the dialog? Any unsaved changes will be lost.'),
-                      function(e) {
-                        self.close();
-                        return true;
-                      },
-                      function(e) {
-                        // Do nothing.
-                        return true;
-                      }
-                    );
-                  }
+              });
+            },
+            callback: function(e) {
+              if (e.button.element.name == 'dialog_help') {
+                e.cancel = true;
+                pgBrowser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
+                  null, null, e.button.element.getAttribute('label'));
+                return;
+              }
+              if (e.button.element.name == 'close') {
+                var self = this;
+                if (!_.all(this.userCollection.pluck('id')) || !_.isEmpty(this.userCollection.invalidUsers)) {
+                  e.cancel = true;
+                  alertify.confirm(
+                    gettext('Discard unsaved changes?'),
+                    gettext('Are you sure you want to close the dialog? Any unsaved changes will be lost.'),
+                    function() {
+                      self.close();
+                      return true;
+                    },
+                    function() {
+                      // Do nothing.
+                      return true;
+                    }
+                  );
                 }
               }
+            },
           };
-       });
+        });
       }
-        alertify.UserManagement(true).resizeTo('680px','400px');
-     }
+      alertify.UserManagement(true).resizeTo('680px', '400px');
+    },
 
-    };
-    return pgBrowser.UserManagement;
-  });
+  };
+  return pgBrowser.UserManagement;
+});
