diff --git a/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua b/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua
index 2afceb31e63d60eb3feced442b9282362fa3db93..d328f438c059cf0d9b862b6ccf0e1326db534a87 100644
--- a/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua
+++ b/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua
@@ -1,4 +1,3 @@
-local disp = require 'gluon.web.dispatcher'
 local fs = require "nixio.fs"
 local util = require "gluon.web.util"
 local nixio_util = require "nixio.util"
diff --git a/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua b/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua
index 985620059bb1ef05a9f7ca4ddce3470314c4cb04..dc6dbea208a3cac62e14a2766aa0e30aabeb50ef 100644
--- a/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua
+++ b/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua
@@ -30,7 +30,6 @@ local function filehandler(meta, chunk, eof)
 end
 
 local function action_upgrade(http, renderer)
-	local disp = require 'gluon.web.dispatcher'
 	local nixio = require 'nixio'
 
 	local function fork_exec(...)
diff --git a/package/gluon-web-theme/files/lib/gluon/web/view/themes/gluon/layout.html b/package/gluon-web-theme/files/lib/gluon/web/view/themes/gluon/layout.html
index b7f60d09f2162a551b5ed91a2054084b810f509a..febe91b525524b75305466b5742d6f2733961844 100644
--- a/package/gluon-web-theme/files/lib/gluon/web/view/themes/gluon/layout.html
+++ b/package/gluon-web-theme/files/lib/gluon/web/view/themes/gluon/layout.html
@@ -10,7 +10,6 @@ You may obtain a copy of the License at
 -%>
 <%
 	local uci  = require("simple-uci").cursor()
-	local disp = require "gluon.web.dispatcher"
 	local fs   = require "nixio.fs"
 	local pretty_hostname = require "pretty_hostname"
 
@@ -23,9 +22,34 @@ You may obtain a copy of the License at
 	local category = request[1]
 	local cattree  = category and node(category)
 
-	local categories = disp.node_children(root)
+	local function node_visible(node)
+		return (
+			node.title and
+			node.target and
+			(not node.hidden)
+		)
+	end
 
-	http:prepare_content("application/xhtml+xml")
+	local function node_children(node)
+		if not node then return {} end
+
+		local ret = {}
+		for k, v in pairs(node.nodes) do
+			if node_visible(v) then
+				table.insert(ret, k)
+			end
+		end
+
+		table.sort(ret,
+			function(a, b)
+				return (node.nodes[a].order or 100)
+				     < (node.nodes[b].order or 100)
+			end
+		)
+		return ret
+	end
+
+	local categories = node_children(root)
 
 	local function append(xs, x)
 		local r = {unpack(xs)}
@@ -40,7 +64,7 @@ You may obtain a copy of the License at
 	local function subtree(prefix, node, name, ...)
 		if not node then return end
 
-		local children = disp.node_children(node)
+		local children = node_children(node)
 		if #children == 0 then return end
 
 	%>
@@ -69,6 +93,8 @@ You may obtain a copy of the License at
 	local function menutree(path, ...)
 		subtree({path}, root.nodes[category], ...)
 	end
+
+	http:prepare_content("application/xhtml+xml")
 -%>
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
diff --git a/package/gluon-web/luasrc/usr/lib/lua/gluon/web/dispatcher.lua b/package/gluon-web/luasrc/usr/lib/lua/gluon/web/dispatcher.lua
index 25404fa4588dc692ee7f7796674873678206c669..2612af99403d6cf4ae8d209ac7a7c4a066ac2d48 100644
--- a/package/gluon-web/luasrc/usr/lib/lua/gluon/web/dispatcher.lua
+++ b/package/gluon-web/luasrc/usr/lib/lua/gluon/web/dispatcher.lua
@@ -20,33 +20,6 @@ function redirect(http, ...)
 	http:redirect(build_url(http, {...}))
 end
 
-function node_visible(node)
-	return (
-		node.title and
-		node.target and
-		(not node.hidden)
-	)
-end
-
-function node_children(node)
-	if not node then return {} end
-
-	local ret = {}
-	for k, v in pairs(node.nodes) do
-		if node_visible(v) then
-			table.insert(ret, k)
-		end
-	end
-
-	table.sort(ret,
-		function(a, b)
-			return (node.nodes[a].order or 100)
-			     < (node.nodes[b].order or 100)
-		end
-	)
-	return ret
-end
-
 
 function httpdispatch(http)
 	local request = {}