diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 3b7c57b..355651b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -24,7 +24,7 @@ from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
 from pgadmin.browser.utils import PGChildNodeView
 from pgadmin.utils.ajax import make_json_response, \
     make_response as ajax_response, internal_server_error, unauthorized
-from pgadmin.utils.ajax import precondition_required, gone
+from pgadmin.utils.ajax import gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -132,11 +132,6 @@ class DatabaseView(PGChildNodeView):
                     self.conn = self.manager.connection(did=kwargs['did'])
                 else:
                     self.conn = self.manager.connection()
-                # If DB not connected then return error to browser
-                if not self.conn.connected():
-                    return precondition_required(
-                        _("Connection to the server has been lost!")
-                    )
 
                 ver = self.manager.version
                 # we will set template path for sql scripts
@@ -146,6 +141,7 @@ class DatabaseView(PGChildNodeView):
                     self.template_path = 'databases/sql/9.2_plus'
                 else:
                     self.template_path = 'databases/sql/9.1_plus'
+
                 return f(self, *args, **kwargs)
 
             return wrapped
@@ -155,7 +151,9 @@ class DatabaseView(PGChildNodeView):
     @check_precondition(action="list")
     def list(self, gid, sid):
         last_system_oid = 0 if self.blueprint.show_system_objects else \
-            (self.manager.db_info[self.manager.did])['datlastsysoid']
+            (self.manager.db_info[self.manager.did])['datlastsysoid'] \
+            if self.manager.db_info is not None and \
+            self.manager.did in self.manager.db_info else 0
         SQL = render_template(
             "/".join([self.template_path, 'properties.sql']),
             conn=self.conn, last_system_oid=last_system_oid
@@ -174,7 +172,9 @@ class DatabaseView(PGChildNodeView):
     def nodes(self, gid, sid):
         res = []
         last_system_oid = 0 if self.blueprint.show_system_objects else \
-            (self.manager.db_info[self.manager.did])['datlastsysoid']
+            (self.manager.db_info[self.manager.did])['datlastsysoid'] \
+            if self.manager.db_info is not None and \
+            self.manager.did in self.manager.db_info else 0
 
         SQL = render_template(
             "/".join([self.template_path, 'nodes.sql']),
@@ -804,7 +804,10 @@ class DatabaseView(PGChildNodeView):
         server.
         """
         last_system_oid = 0 if self.blueprint.show_system_objects else \
-            (self.manager.db_info[self.manager.did])['datlastsysoid']
+            (self.manager.db_info[self.manager.did])['datlastsysoid'] \
+            if self.manager.db_info is not None and \
+            self.manager.did in self.manager.db_info else 0
+
         status, res = self.conn.execute_dict(
             render_template(
                 "/".join([self.template_path, 'stats.sql']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
index 86a7eca..6be5d63 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
@@ -17,9 +17,8 @@ from flask import render_template, make_response, request, jsonify
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -201,17 +200,8 @@ class CastView(PGChildNodeView):
             self = args[0]
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-            ver = self.manager.version
-            # we will set template path for sql scripts
-            if ver >= 90100:
-                self.template_path = 'cast/sql/9.1_plus'
+            # Set template path for the SQL scripts
+            self.template_path = 'cast/sql/9.1_plus'
 
             return f(*args, **kwargs)
 
@@ -226,9 +216,13 @@ class CastView(PGChildNodeView):
         :param did: database id
         :return:
         """
+        last_system_oid = 0 if self.blueprint.show_system_objects else \
+            (self.manager.db_info[did])['datlastsysoid'] \
+            if self.manager.db_info is not None and \
+            did in self.manager.db_info else 0
         sql = render_template(
             "/".join([self.template_path, 'properties.sql']),
-            datlastsysoid=self.manager.db_info[did]['datlastsysoid'],
+            datlastsysoid=last_system_oid,
             showsysobj=self.blueprint.show_system_objects
         )
         status, res = self.conn.execute_dict(sql)
@@ -255,9 +249,13 @@ class CastView(PGChildNodeView):
         :return:
         """
         res = []
+        last_system_oid = 0 if self.blueprint.show_system_objects else \
+            (self.manager.db_info[did])['datlastsysoid'] \
+            if self.manager.db_info is not None and \
+            did in self.manager.db_info else 0
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            datlastsysoid=self.manager.db_info[did]['datlastsysoid'],
+            datlastsysoid=last_system_oid,
             showsysobj=self.blueprint.show_system_objects
         )
         status, rset = self.conn.execute_2darray(sql)
@@ -313,17 +311,19 @@ class CastView(PGChildNodeView):
         :param cid: cast id
         :return:
         """
+        last_system_oid = (self.manager.db_info[did])['datlastsysoid'] if \
+            self.manager.db_info is not None and \
+            did in self.manager.db_info else 0
         sql = render_template(
             "/".join([self.template_path, 'properties.sql']),
             cid=cid,
-            datlastsysoid=self.manager.db_info[did]['datlastsysoid'],
+            datlastsysoid=last_system_oid,
             showsysobj=self.blueprint.show_system_objects
         )
         status, res = self.conn.execute_dict(sql)
 
         if not status:
             return internal_server_error(errormsg=res)
-        result = res['rows'][0]
 
         return ajax_response(
             response=res['rows'][0],
@@ -367,10 +367,14 @@ class CastView(PGChildNodeView):
                 return internal_server_error(errormsg=res)
 
             # we need oid to to add object in tree at browser, below sql will gives the same
+            last_system_oid = 0 if self.blueprint.show_system_objects else \
+                (self.manager.db_info[did])['datlastsysoid'] \
+                if self.manager.db_info is not None and \
+                did in self.manager.db_info else 0
             sql = render_template("/".join([self.template_path, 'properties.sql']),
                                   srctyp=data['srctyp'],
                                   trgtyp=data['trgtyp'],
-                                  datlastsysoid=self.manager.db_info[did]['datlastsysoid'],
+                                  datlastsysoid=last_system_oid,
                                   showsysobj=self.blueprint.show_system_objects
                                   )
             status, cid = self.conn.execute_scalar(sql)
@@ -529,9 +533,13 @@ class CastView(PGChildNodeView):
         """
         try:
             if cid is not None:
+                last_system_oid = 0 if self.blueprint.show_system_objects else \
+                    (self.manager.db_info[did])['datlastsysoid'] \
+                    if self.manager.db_info is not none and \
+                    did in self.manager.db_info else 0
                 sql = render_template("/".join([self.template_path, 'properties.sql']),
                                       cid=cid,
-                                      datlastsysoid=self.manager.db_info[did]['datlastsysoid'],
+                                      datlastsysoid=last_system_oid,
                                       showsysobj=self.blueprint.show_system_objects)
                 status, res = self.conn.execute_dict(sql)
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
index 9f434e1..aae333d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
@@ -16,9 +16,8 @@ from flask import render_template, make_response, request, jsonify
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -188,22 +187,12 @@ class EventTriggerView(PGChildNodeView):
 
         @wraps(f)
         def wrap(*args, **kwargs):
-            # Here args[0] will hold self & kwargs will hold gid,sid,did
+
+            # Here - args[0] will always hold self & kwargs will hold gid, sid, did
             self = args[0]
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
-            ver = self.manager.version
-            if ver >= 90300:
-                self.template_path = 'event_triggers/sql/9.3_plus'
+            self.template_path = 'event_triggers/sql/9.3_plus'
 
             return f(*args, **kwargs)
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
index d4494a1..3e1b47d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
@@ -19,9 +19,8 @@ from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -211,17 +210,8 @@ class ForeignDataWrapperView(PGChildNodeView):
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
 
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
-            ver = self.manager.version
-            # we will set template path for sql scripts
-            if ver >= 90300:
+            # Set the template path for the SQL scripts
+            if self.manager.version >= 90300:
                 self.template_path = 'foreign_data_wrappers/sql/9.3_plus'
             else:
                 self.template_path = 'foreign_data_wrappers/sql/9.1_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
index f51975f..55e9659 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
@@ -19,9 +19,8 @@ from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -204,18 +203,8 @@ class ForeignServerView(PGChildNodeView):
             self = args[0]
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
-            ver = self.manager.version
-            # we will set template path for sql scripts
-            if ver >= 90300:
+            # Set the template path for the SQL scripts
+            if self.manager.version >= 90300:
                 self.template_path = 'foreign_servers/sql/9.3_plus'
             else:
                 self.template_path = 'foreign_servers/sql/9.1_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
index c0e3f58..2ab692b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
@@ -17,9 +17,8 @@ from flask import render_template, make_response, request, jsonify
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -219,21 +218,9 @@ class UserMappingView(PGChildNodeView):
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
 
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
+            # Set the template path for the SQL scripts
             self.template_path = 'user_mappings/sql/9.1_plus'
 
-            ver = self.manager.version
-            # we will set template path for sql scripts
-            if ver >= 90100:
-                self.template_path = 'user_mappings/sql/9.1_plus'
-
             return f(*args, **kwargs)
 
         return wrap
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py
index 07c04e9..e455d98 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py
@@ -19,9 +19,8 @@ from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -218,18 +217,8 @@ class LanguageView(PGChildNodeView):
             self.driver = get_driver(PG_DEFAULT_DRIVER)
             self.manager = self.driver.connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
-            ver = self.manager.version
-            # we will set template path for sql scripts
-            if ver >= 90300:
+            # Set the template path for the SQL scripts
+            if self.manager.version >= 90300:
                 self.template_path = 'languages/sql/9.3_plus'
             else:
                 self.template_path = 'languages/sql/9.1_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
index 4671897..dcf23d5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
@@ -18,10 +18,8 @@ from pgadmin.browser.collection import CollectionNodeModule, PGChildModule
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, gone, \
-    bad_request
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone, bad_request
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -129,13 +127,7 @@ def check_precondition(f):
             kwargs['sid']
         )
         self.conn = self.manager.connection(did=kwargs['did'])
-        # If DB not connected then return error to browser
-        if not self.conn.connected():
-            return precondition_required(
-                gettext("Connection to the server has been lost!")
-            )
-
-        # Set template path for sql scripts
+        # Set the template path for the SQL scripts
         self.template_path = self.template_initial + '/' + (
             self.ppas_template_path(self.manager.version)
             if self.manager.server_type == 'ppas' else
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py
index e55afdf..a77c0c2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/__init__.py
@@ -17,9 +17,8 @@ from flask_babel import gettext
 from pgadmin.browser.server_groups.servers.databases.schemas.utils \
     import SchemaChildModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -146,14 +145,6 @@ class CatalogObjectView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             self.template_path = 'catalog_object/sql/{0}/9.1_plus'.format(
                 'ppas' if self.manager.server_type == 'ppas' else 'pg'
             )
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py
index b0e784f..758d9b0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/__init__.py
@@ -16,9 +16,8 @@ from flask import render_template
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 from pgadmin.utils.preferences import Preferences
 
@@ -166,14 +165,6 @@ class CatalogObjectColumnsView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             self.template_path = 'catalog_object_column/sql/9.1_plus'
 
             return f(*args, **kwargs)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
index c4e7bc3..68d38e8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
@@ -18,9 +18,8 @@ from flask_babel import gettext
 from pgadmin.browser.server_groups.servers.databases.schemas.utils \
     import SchemaChildModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -185,18 +184,10 @@ class CollationView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
-            # we will set template path for sql scripts
+            # Set the template path for the SQL scripts
             self.template_path = 'collation/sql/9.1_plus'
-            return f(*args, **kwargs)
 
+            return f(*args, **kwargs)
         return wrap
 
     @check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
index c94525a..73c43ce 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
@@ -20,9 +20,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
 from pgadmin.browser.server_groups.servers.databases.utils import \
     parse_sec_labels_from_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, gone
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -263,18 +262,10 @@ class DomainView(PGChildNodeView, DataTypeReader):
             self.conn = self.manager.connection(did=kwargs['did'])
             self.qtIdent = driver.qtIdent
 
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext("Connection to the server has been lost!")
-                )
-
-            ver = self.manager.version
-            server_type = self.manager.server_type
-
             # we will set template path for sql scripts
-            if ver >= 90200:
+            if self.manager.version >= 90200:
                 self.template_path = 'domains/sql/9.2_plus'
-            elif ver >= 90100:
+            else:
                 self.template_path = 'domains/sql/9.1_plus'
 
             return f(*args, **kwargs)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
index 8eef4d1..db375f5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
@@ -18,9 +18,8 @@ from flask import render_template, make_response, request, jsonify
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -256,22 +255,13 @@ class DomainConstraintView(PGChildNodeView):
             self.conn = self.manager.connection(did=kwargs['did'])
             self.qtIdent = driver.qtIdent
 
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext("Connection to the server has been lost!")
-                )
-
-            ver = self.manager.version
-
-            # we will set template path for sql scripts
-            if ver >= 90200:
+            # Set the template path for the SQL scripts
+            if self.manager.version >= 90200:
                 self.template_path = 'domain_constraints/sql/9.2_plus'
-            elif ver >= 90100:
+            else:
                 self.template_path = 'domain_constraints/sql/9.1_plus'
 
             return f(*args, **kwargs)
-
         return wrap
 
     @check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
index c171d01..e7239f5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
@@ -25,9 +25,8 @@ from pgadmin.browser.server_groups.servers.databases.utils import \
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, gone
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -338,16 +337,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
 
             # Get database connection
             self.conn = self.manager.connection(did=kwargs['did'])
-
             self.qtIdent = driver.qtIdent
 
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             ver = self.manager.version
             # Set template path for sql scripts depending
             # on the server version.
@@ -360,7 +351,6 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
                 self.template_path = 'foreign_tables/sql/9.1_plus'
 
             return f(*args, **kwargs)
-
         return wrap
 
     @check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
index 8c32025..122f459 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
@@ -18,9 +18,8 @@ from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases.schemas.utils \
     import SchemaChildModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, gone
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -230,17 +229,10 @@ class FtsConfigurationView(PGChildNodeView):
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
                 kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _("Connection to the server has been lost!")
-                )
-            # we will set template path for sql scripts depending upon server version
-            ver = self.manager.version
-            if ver >= 90100:
-                self.template_path = 'fts_configuration/sql/9.1_plus'
-            return f(*args, **kwargs)
+            # Set the template path for the SQL scripts
+            self.template_path = 'fts_configuration/sql/9.1_plus'
 
+            return f(*args, **kwargs)
         return wrap
 
     @check_precondition
@@ -741,7 +733,6 @@ class FtsConfigurationView(PGChildNodeView):
         :param scid: schema id
         """
         # Fetch last system oid
-        datlastsysoid = self.manager.db_info[did]['datlastsysoid']
 
         sql = render_template(
             "/".join([self.template_path, 'parser.sql']),
@@ -752,6 +743,8 @@ class FtsConfigurationView(PGChildNodeView):
         if not status:
             return internal_server_error(errormsg=rset)
 
+        datlastsysoid = self.manager.db_info[did]['datlastsysoid']
+
         # Empty set is added before actual list as initially it will be visible
         # at parser control while creating a new FTS Configuration
         res = [{'label': '', 'value': ''}]
@@ -776,8 +769,6 @@ class FtsConfigurationView(PGChildNodeView):
         :param scid: schema id
         """
         # Fetch last system oid
-        datlastsysoid = self.manager.db_info[did]['datlastsysoid']
-
         sql = render_template(
             "/".join([self.template_path, 'copy_config.sql']),
             copy_config=True
@@ -787,6 +778,8 @@ class FtsConfigurationView(PGChildNodeView):
         if not status:
             return internal_server_error(errormsg=rset)
 
+        datlastsysoid = self.manager.db_info[did]['datlastsysoid']
+
         # Empty set is added before actual list as initially it will be visible
         # at copy_config control while creating a new FTS Configuration
         res = [{'label': '', 'value': ''}]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
index b7dea08..24b9d2d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
@@ -18,9 +18,8 @@ from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases.schemas.utils \
     import SchemaChildModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, gone
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -222,17 +221,10 @@ class FtsDictionaryView(PGChildNodeView):
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
                 kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _("Connection to the server has been lost!")
-                )
-            # we will set template path for sql scripts depending upon server version
-            ver = self.manager.version
-            if ver >= 90100:
-                self.template_path = 'fts_dictionary/sql/9.1_plus'
-            return f(*args, **kwargs)
+            # Set the template path for the SQL scripts
+            self.template_path = 'fts_dictionary/sql/9.1_plus'
 
+            return f(*args, **kwargs)
         return wrap
 
     def tokenize_options(self, option_value):
@@ -725,8 +717,6 @@ class FtsDictionaryView(PGChildNodeView):
         :param scid: schema id
         """
         # Fetch last system oid
-        datlastsysoid = self.manager.db_info[did]['datlastsysoid']
-
         sql = render_template("/".join([self.template_path, 'templates.sql']),
                               template=True)
         status, rset = self.conn.execute_dict(sql)
@@ -734,6 +724,7 @@ class FtsDictionaryView(PGChildNodeView):
         if not status:
             return internal_server_error(errormsg=rset)
 
+        datlastsysoid = self.manager.db_info[did]['datlastsysoid']
         # Empty set is added before actual list as initially it will be visible
         # at template control while creating a new FTS Dictionary
         res = [{'label': '', 'value': ''}]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py
index cd31922..b821fbe 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py
@@ -17,9 +17,8 @@ from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases import DatabaseModule
 from pgadmin.browser.server_groups.servers.databases.schemas.utils import SchemaChildModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -220,19 +219,10 @@ class FtsParserView(PGChildNodeView):
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
                 kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _(
-                        "Connection to the server has been lost!"
-                    )
-                )
-            # we will set template path for sql scripts depending upon server version
-            ver = self.manager.version
-            if ver >= 90100:
-                self.template_path = 'fts_parser/sql/9.1_plus'
-            return f(*args, **kwargs)
+            # Set the template path for the SQL scripts
+            self.template_path = 'fts_parser/sql/9.1_plus'
 
+            return f(*args, **kwargs)
         return wrap
 
     @check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
index a349197..85a8ca5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
@@ -17,9 +17,8 @@ from flask_babel import gettext
 from pgadmin.browser.server_groups.servers.databases import DatabaseModule
 from pgadmin.browser.server_groups.servers.databases.schemas.utils import SchemaChildModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -209,19 +208,9 @@ class FtsTemplateView(PGChildNodeView):
             self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
                 kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-            # we will set template path for sql scripts depending upon server version
-            ver = self.manager.version
-            if ver >= 90100:
-                self.template_path = 'fts_template/sql/9.1_plus'
-            return f(*args, **kwargs)
+            self.template_path = 'fts_template/sql/9.1_plus'
 
+            return f(*args, **kwargs)
         return wrap
 
     @check_precondition
@@ -267,7 +256,6 @@ class FtsTemplateView(PGChildNodeView):
 
     @check_precondition
     def node(self, gid, sid, did, scid, tid):
-        res = []
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
             tid=tid
@@ -286,6 +274,9 @@ class FtsTemplateView(PGChildNodeView):
                 ),
                 status=200
             )
+        return gone(
+            _("Could not the requested FTS template.")
+        )
 
     @check_precondition
     def properties(self, gid, sid, did, scid, tid):
@@ -609,9 +600,9 @@ class FtsTemplateView(PGChildNodeView):
         :param scid: schema id
         :param tid: fts tempate id
         """
-        data = request.args
-        sql = render_template("/".join([self.template_path, 'functions.sql']),
-                              lexize=True)
+        sql = render_template(
+            "/".join([self.template_path, 'functions.sql']), lexize=True
+        )
         status, rset = self.conn.execute_dict(sql)
 
         if not status:
@@ -638,9 +629,9 @@ class FtsTemplateView(PGChildNodeView):
         :param scid: schema id
         :param tid: fts tempate id
         """
-        data = request.args
-        sql = render_template("/".join([self.template_path, 'functions.sql']),
-                              init=True)
+        sql = render_template(
+            "/".join([self.template_path, 'functions.sql']), init=True
+        )
         status, rset = self.conn.execute_dict(sql)
 
         if not status:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index ca69cac..105038a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -27,9 +27,8 @@ from pgadmin.browser.server_groups.servers.databases.utils import \
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, gone
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, gone
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -329,21 +328,12 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 
             # Get database connection
             self.conn = self.manager.connection(did=kwargs['did'])
-
             self.qtIdent = driver.qtIdent
             self.qtLiteral = driver.qtLiteral
 
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             ver = self.manager.version
 
-            # Set template path for sql scripts depending
-            # on the server version.
+            # Set the template path for the SQL scripts
             self.template_path = "/".join([
                 self.node_type
             ])
@@ -469,10 +459,9 @@ class FunctionView(PGChildNodeView, DataTypeReader):
         proallargtypes = data['proallargtypes'] \
             if data['proallargtypes'] else []
 
-        proargout = []
-        proargid = []
-        proargmodenames = {'i': 'IN', 'o': 'OUT', 'b': 'INOUT',
-                           'v': 'VARIADIC', 't': 'TABLE'}
+        proargmodenames = {
+            'i': 'IN', 'o': 'OUT', 'b': 'INOUT', 'v': 'VARIADIC', 't': 'TABLE'
+        }
 
         # The proargtypes doesn't give OUT params, so we need to fetch
         # those from database explicitly, below code is written for this
@@ -1325,7 +1314,6 @@ It may have been removed by another user or moved to another schema.
         if not status:
             return internal_server_error(errormsg=res)
 
-        func_def = res['rows'][0]['func_def']
         name = res['rows'][0]['name']
 
         # Fetch only arguments
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
index 29be4fd..fed62f8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -20,9 +20,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -145,20 +144,11 @@ class SequenceView(PGChildNodeView):
                     self.conn = self.manager.connection(did=kwargs['did'])
                 else:
                     self.conn = self.manager.connection()
-                # If DB not connected then return error to browser
-                if not self.conn.connected():
-                    return precondition_required(
-                        _(
-                            "Connection to the server has been lost!"
-                        )
-                    )
-
                 self.template_path = 'sequence/sql/9.1_plus'
                 self.acl = ['r', 'w', 'U']
-                return f(self, *args, **kwargs)
 
+                return f(self, *args, **kwargs)
             return wrapped
-
         return wrap
 
     @check_precondition(action='list')
@@ -336,10 +326,10 @@ class SequenceView(PGChildNodeView):
             # We need oid of newly created sequence.
             SQL = render_template("/".join([self.template_path, 'get_oid.sql']), name=data['name'], scid=scid)
             SQL = SQL.strip('\n').strip(' ')
-            if SQL and SQL != "":
-                status, seid = self.conn.execute_scalar(SQL)
-                if not status:
-                    return internal_server_error(errormsg=res)
+
+            status, seid = self.conn.execute_scalar(SQL)
+            if not status:
+                return internal_server_error(errormsg=seid)
 
             return jsonify(
                 node=self.blueprint.generate_browser_node(
@@ -504,18 +494,13 @@ class SequenceView(PGChildNodeView):
                             "Could not find the required parameter (%s)." % arg
                         )
                     )
-        try:
-            SQL = self.getSQL(gid, sid, did, data, scid, seid)
-            SQL = SQL.strip('\n').strip(' ')
-            return make_json_response(
-                data=SQL,
-                status=200
-            )
-        except Exception as e:
-            return make_json_response(
-                data="-- modified SQL",
-                status=200
-            )
+        SQL = self.getSQL(gid, sid, did, data, scid, seid)
+        SQL = SQL.strip('\n').strip(' ')
+
+        return make_json_response(
+            data=SQL,
+            status=200
+        )
 
     def getSQL(self, gid, sid, did, data, scid, seid=None):
         """
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 0d29ab3..d913b19 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -22,9 +22,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -272,22 +271,18 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
             # Here args[0] will hold self & kwargs will hold gid,sid,did
             self = args[0]
             driver = get_driver(PG_DEFAULT_DRIVER)
+            did = kwargs['did']
             self.manager = driver.connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
             self.qtIdent = driver.qtIdent
             # We need datlastsysoid to check if current table is system table
-            self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
-            self.server_type = self.manager.server_type
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-            # we will set template path for sql scripts
+            self.datlastsysoid = self.manager.db_info[
+                did
+            ]['datlastsysoid'] if self.manager.db_info is not None and \
+                did in self.manager.db_info else 0
+
             ver = self.manager.version
-            # Template for Column node
+            # Set the template path for the SQL scripts
             if ver >= 90500:
                 self.template_path = 'table/sql/9.5_plus'
             else:
@@ -1193,7 +1188,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         try:
             SQL = render_template("/".join([self.template_path,
                                             'get_oftype.sql']), scid=scid,
-                                  server_type=self.server_type,
+                                  server_type=self.manager.server_type,
                                   show_sys_objects=self.blueprint.show_system_objects)
             status, rset = self.conn.execute_2darray(SQL)
             if not status:
@@ -1224,7 +1219,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
             SQL = render_template("/".join([self.template_path, 'get_inherits.sql']),
                                   show_system_objects=self.blueprint.show_system_objects,
                                   tid=tid,
-                                  server_type=self.server_type)
+                                  server_type=self.manager.server_type)
             status, rset = self.conn.execute_2darray(SQL)
             if not status:
                 return internal_server_error(errormsg=res)
@@ -1253,7 +1248,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         try:
             SQL = render_template("/".join([self.template_path, 'get_relations.sql']),
                                   show_sys_objects=self.blueprint.show_system_objects,
-                                  server_type=self.server_type)
+                                  server_type=self.manager.server_type)
             status, rset = self.conn.execute_2darray(SQL)
             if not status:
                 return internal_server_error(errormsg=res)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
index ef5cbe4..fe88123 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
@@ -21,9 +21,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -199,17 +198,9 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
             )
             self.conn = self.manager.connection(did=kwargs['did'])
             self.qtIdent = driver.qtIdent
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
 
-            ver = self.manager.version
-            # we will set template path for sql scripts
-            if ver >= 90200:
+            # Set the template path for the SQL scripts
+            if self.manager.version >= 90200:
                 self.template_path = 'column/sql/9.2_plus'
             else:
                 self.template_path = 'column/sql/9.1_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
index 3405ded..a6ccec3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
@@ -19,9 +19,8 @@ from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
     import ConstraintRegistry
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -208,15 +207,8 @@ class CheckConstraintView(PGChildNodeView):
             self.conn = self.manager.connection(did=kwargs['did'])
             self.qtIdent = driver.qtIdent
 
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _("Connection to the server has been lost!")
-                )
-
             ver = self.manager.version
-
-            # we will set template path for sql scripts
+            # Set the template path for the SQL scripts
             if ver >= 90200:
                 self.template_path = 'check_constraint/sql/9.2_plus'
             elif ver >= 90100:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index 26115f7..1c1834a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -18,9 +18,8 @@ from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
     import ConstraintRegistry, ConstraintTypeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -216,16 +215,7 @@ class ExclusionConstraintView(PGChildNodeView):
             )
             self.conn = self.manager.connection(did=kwargs['did'])
 
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             ver = self.manager.version
-
             if ver >= 90200:
                 self.template_path = 'exclusion_constraint/sql/9.2_plus'
             elif ver >= 90100:
@@ -242,8 +232,8 @@ class ExclusionConstraintView(PGChildNodeView):
             for row in rset['rows']:
                 self.schema = row['schema']
                 self.table = row['table']
-            return f(*args, **kwargs)
 
+            return f(*args, **kwargs)
         return wrap
 
     def end_transaction(self):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
index 9a2ee06..43e270e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
@@ -18,9 +18,8 @@ from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
     import ConstraintRegistry, ConstraintTypeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -194,7 +193,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
         ],
         'delete': [{'delete': 'delete'}],
         'children': [{'get': 'children'}],
-        'nodes': [{'get': 'node'}, {'get': 'nodes'}],
+        'nodes': [{'get': 'nodes'}, {'get': 'nodes'}],
         'sql': [{'get': 'sql'}],
         'msql': [{'get': 'msql'}, {'get': 'msql'}],
         'stats': [{'get': 'statistics'}],
@@ -234,16 +233,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             self.template_path = 'foreign_key/sql'
+
             # We need parent's name eg table name and schema name
             SQL = render_template("/".join([self.template_path,
                                             'get_parent.sql']),
@@ -255,8 +246,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
             for row in rset['rows']:
                 self.schema = row['schema']
                 self.table = row['table']
-            return f(*args, **kwargs)
 
+            return f(*args, **kwargs)
         return wrap
 
     def end_transaction(self):
@@ -398,31 +389,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
         Returns:
 
         """
-        try:
-            res = self.get_nodes(gid, sid, did, scid, tid, fkid)
-            return make_json_response(
-                data=res,
-                status=200
-            )
-        except Exception as e:
-            return internal_server_error(errormsg=str(e))
-
-    @check_precondition
-    def get_nodes(self, gid, sid, did, scid, tid, fkid=None):
-        """
-        This function returns all event trigger nodes as a list.
+        res = self.get_nodes(gid, sid, did, scid, tid, fkid)
 
-        Args:
-          gid: Server Group ID
-          sid: Server ID
-          did: Database ID
-          scid: Schema ID
-          tid: Table ID
-          fkid: Foreign key constraint ID
-
-        Returns:
-
-        """
         res = []
         SQL = render_template("/".join([self.template_path,
                                         'nodes.sql']),
@@ -444,7 +412,11 @@ class ForeignKeyConstraintView(PGChildNodeView):
                     icon=icon,
                     valid=valid
                 ))
-        return res
+
+        return make_json_response(
+            data=res,
+            status=200
+        )
 
     @check_precondition
     def create(self, gid, sid, did, scid, tid, fkid=None):
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
index ecdbd8b..349b5e3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
@@ -18,9 +18,8 @@ from flask_babel import gettext as _
 from pgadmin.browser.server_groups.servers.databases.schemas.tables.constraints.type \
     import ConstraintRegistry, ConstraintTypeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -237,16 +236,8 @@ class IndexConstraintView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    _(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             self.template_path = 'index_constraint/sql'
+
             # We need parent's name eg table name and schema name
             SQL = render_template("/".join([self.template_path,
                                             'get_parent.sql']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
index d79c946..94ffbf1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
@@ -17,9 +17,8 @@ from flask import render_template, request, jsonify
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -69,13 +68,6 @@ class IndexesModule(CollectionNodeModule):
         """
         if super(IndexesModule, self).BackendSupported(manager, **kwargs):
             conn = manager.connection(did=kwargs['did'])
-            # If DB is not connected then return error to browser
-            if not conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
 
             if 'vid' not in kwargs:
                 return True
@@ -228,16 +220,11 @@ class IndexesView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             # We need datlastsysoid to check if current index is system index
-            self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
+            self.datlastsysoid = self.manager.db_info[
+                kwargs['did']
+            ]['datlastsysoid'] if self.manager.db_info is not None and \
+                kwargs['did'] in self.manager.db_info else 0
 
             # we will set template path for sql scripts
             self.template_path = 'index/sql/9.1_plus'
@@ -440,7 +427,6 @@ class IndexesView(PGChildNodeView):
         # 'options' we need true/false to render switch ASC(false)/DESC(true)
         columns = []
         cols = []
-        cnt = 1
         for row in rset['rows']:
             # We need all data as collection for ColumnsModel
             cols_data = {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
index d462454..79d6398 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
@@ -19,9 +19,8 @@ from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
     parse_rule_definition
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -53,13 +52,6 @@ class RuleModule(CollectionNodeModule):
         """
         if super(RuleModule, self).BackendSupported(manager, **kwargs):
             conn = manager.connection(did=kwargs['did'])
-            # If DB is not connected then return error to browser
-            if not conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
 
             if 'vid' not in kwargs:
                 return True
@@ -202,16 +194,10 @@ class RuleView(PGChildNodeView):
             self.manager = get_driver(
                 PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
             self.conn = self.manager.connection(did=kwargs['did'])
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
-            self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
+            self.datlastsysoid = self.manager.db_info[
+                kwargs['did']
+            ]['datlastsysoid'] if self.manager.db_info is not None and \
+                kwargs['did'] in self.manager.db_info else 0
             self.template_path = 'rules/sql'
             return f(*args, **kwargs)
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/nodes.sql
index 9667588..be54e8c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/nodes.sql
@@ -4,4 +4,4 @@ SELECT ct.oid,
 FROM pg_constraint ct
 WHERE contype='f' AND
     conrelid = {{tid}}::oid
-ORDER BY conname
\ No newline at end of file
+ORDER BY conname
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
index b3e4eec..6002bc3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
@@ -17,9 +17,8 @@ from flask import render_template, request, jsonify
 from flask_babel import gettext
 from pgadmin.browser.collection import CollectionNodeModule
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -69,24 +68,21 @@ class TriggerModule(CollectionNodeModule):
         """
         if super(TriggerModule, self).BackendSupported(manager, **kwargs):
             conn = manager.connection(did=kwargs['did'])
-            # If DB is not connected then return error to browser
-            if not conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
 
             if 'vid' not in kwargs:
                 return True
 
             template_path = 'trigger/sql/9.1_plus'
             SQL = render_template("/".join(
-                [template_path, 'backend_support.sql']), vid=kwargs['vid'])
+                [template_path, 'backend_support.sql']), vid=kwargs['vid']
+            )
+
             status, res = conn.execute_scalar(SQL)
+
             # check if any errors
             if not status:
                 return internal_server_error(errormsg=res)
+
             # Check vid is view not material view
             # then true, othewise false
             return res
@@ -255,16 +251,11 @@ class TriggerView(PGChildNodeView):
                 kwargs['sid']
             )
             self.conn = self.manager.connection(did=kwargs['did'])
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
-
             # We need datlastsysoid to check if current trigger is system trigger
-            self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
+            self.datlastsysoid = self.manager.db_info[
+                kwargs['did']
+            ]['datlastsysoid'] if self.manager.db_info is not None and \
+                kwargs['did'] in self.manager.db_info else 0
 
             # we will set template path for sql scripts
             self.template_path = 'trigger/sql/9.1_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
index 8ea7aa9..9c8b30f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
@@ -20,9 +20,8 @@ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
 from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -223,15 +222,10 @@ class TypeView(PGChildNodeView, DataTypeReader):
             self.conn = self.manager.connection(did=kwargs['did'])
 
             # We need datlastsysoid to check if current type is system type
-            self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
-
-            # If DB not connected then return error to browser
-            if not self.conn.connected():
-                return precondition_required(
-                    gettext(
-                        "Connection to the server has been lost!"
-                    )
-                )
+            self.datlastsysoid = self.manager.db_info[
+                kwargs['did']
+            ]['datlastsysoid'] if self.manager.db_info is not None and \
+                kwargs['did'] in self.manager.db_info else 0
 
             # Declare allows acl on type
             self.acl = ['U']
@@ -240,7 +234,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
             self.template_path = 'type/sql/9.1_plus'
 
             return f(*args, **kwargs)
-
         return wrap
 
     @check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index 317a488..9034f43 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -18,10 +18,8 @@ from flask_babel import gettext
 from pgadmin.browser.server_groups.servers.databases.schemas.utils import \
     SchemaChildModule, parse_rule_definition, VacuumSettings
 from pgadmin.browser.utils import PGChildNodeView
-from pgadmin.utils.ajax import make_json_response, \
-    make_response as ajax_response, internal_server_error, \
-    bad_request
-from pgadmin.utils.ajax import precondition_required
+from pgadmin.utils.ajax import make_json_response, internal_server_error, \
+    make_response as ajax_response, bad_request
 from pgadmin.utils.driver import get_driver
 
 from config import PG_DEFAULT_DRIVER
@@ -171,13 +169,10 @@ def check_precondition(f):
             kwargs['sid']
         )
         self.conn = self.manager.connection(did=kwargs['did'])
-        # If DB not connected then return error to browser
-        if not self.conn.connected():
-            return precondition_required(
-                gettext("Connection to the server has been lost!")
-            )
         self.datlastsysoid = self.manager.db_info[
-            kwargs['did']]['datlastsysoid']
+            kwargs['did']
+        ]['datlastsysoid'] if self.manager.db_info is not None and \
+            kwargs['did'] in self.manager.db_info else 0
 
         # Set template path for sql scripts
         self.template_path = self.template_initial + '/' + (
