diff --git a/exec/dorkit/graphic.js b/exec/dorkit/graphic.js
index ac40459dab2c7127c40c40a452a3a7d6988ee3c1..063671da140254a9f4f65183ef89aaebb2dd9d20 100644
--- a/exec/dorkit/graphic.js
+++ b/exec/dorkit/graphic.js
@@ -16,7 +16,7 @@
  *
  */
 
-if (js.global.Attribute === undefined)
+if (typeof(Attribute) === 'undefined')
 	load("attribute.js");
 
 function Graphic(w,h,attr,ch)
diff --git a/exec/dorkit/jsexec_input.js b/exec/dorkit/jsexec_input.js
index 4c872abbd389091a97af39b22332577d1b2deeb9..793c8e5844ee721f51c9aeef2edb24073faaa0f0 100644
--- a/exec/dorkit/jsexec_input.js
+++ b/exec/dorkit/jsexec_input.js
@@ -1,5 +1,5 @@
 js.load_path_list.unshift(js.exec_dir+"dorkit/");
-if (js.global.system !== undefined)
+if (typeof(system) !== 'undefined')
 	js.load_path_list.unshift(system.exec_dir+"dorkit/");
 load('ansi_input.js');
 var k;
diff --git a/exec/dorkit/local_console.js b/exec/dorkit/local_console.js
index a8ce26afd7bfdb7cea2ed929a9078e21bf20b5fe..e425f480c038ce3d3a249acc68587ccabf1c6e8b 100644
--- a/exec/dorkit/local_console.js
+++ b/exec/dorkit/local_console.js
@@ -2,7 +2,7 @@
  * Implements the local console using conio
  */
 
-if (js.global.Graphic === undefined)
+if (typeof(Graphic) === 'undefined')
 	load("graphic.js");
 
 dk.console.local_io = {
diff --git a/exec/dorkit/sbbs_console.js b/exec/dorkit/sbbs_console.js
index 6aa55a89c220481239404317591b4bad32d34225..eeecfb9b0625941bcaaad9cf22cf3a67012273d6 100644
--- a/exec/dorkit/sbbs_console.js
+++ b/exec/dorkit/sbbs_console.js
@@ -1,7 +1,7 @@
 load("sbbsdefs.js");
-js.global.dk_old_ctrlkey_passthru = console.ctrlkey_passthru;
-js.global.dk_old_pauseoff = bbs.sys_status & SS_PAUSEOFF;
-js.on_exit("console.ctrlkey_passthru=js.global.dk_old_ctrlkey_passthru;bbs.sys_status=(bbs.sys_status &~ SS_PAUSEOFF)|js.global.dk_old_pauseoff");
+dk_old_ctrlkey_passthru = console.ctrlkey_passthru;
+dk_old_pauseoff = bbs.sys_status & SS_PAUSEOFF;
+js.on_exit("console.ctrlkey_passthru=dk_old_ctrlkey_passthru;bbs.sys_status=(bbs.sys_status &~ SS_PAUSEOFF)|dk_old_pauseoff");
 console.ctrlkey_passthru=0x7fffffff;	// Disable all parsing.
 
 /*
diff --git a/exec/dorkit/sbbs_input.js b/exec/dorkit/sbbs_input.js
index 8ebe15e7d949bcf69630290df5dbce209d36aa9c..9816bd2724913605712327356c3b50b5e13b73f9 100644
--- a/exec/dorkit/sbbs_input.js
+++ b/exec/dorkit/sbbs_input.js
@@ -1,5 +1,5 @@
 js.load_path_list.unshift(js.exec_dir+"dorkit/");
-if (js.global.system !== undefined)
+if (typeof(system) !== 'undefined')
 	js.load_path_list.unshift(system.exec_dir+"dorkit/");
 load('ansi_input.js');
 var q = new Queue("dorkit_input");
diff --git a/exec/dorkit/screen.js b/exec/dorkit/screen.js
index 3beeb3dc800953094bcc6343a66b015588e29456..b4f452603df638316e3e3bfdd23b8e15aa088f79 100644
--- a/exec/dorkit/screen.js
+++ b/exec/dorkit/screen.js
@@ -7,9 +7,9 @@
  * all data should be provided using the print() method.
  */
 
-if (js.global.Graphic === undefined)
+if (typeof(Graphic) === 'undefined')
 	load("graphic.js");
-if (js.global.Attribute === undefined)
+if (typeof(Attribute) === 'undefined')
 	load("attribute.js");
 
 function Screen(w, h, attr, fill)
diff --git a/exec/dorkit/socket_input.js b/exec/dorkit/socket_input.js
index b616a0231a1b5c4d5a56ccc76810124d62d423e0..25acc0143bf3209ecbf28d802551ebf153ea1b32 100644
--- a/exec/dorkit/socket_input.js
+++ b/exec/dorkit/socket_input.js
@@ -1,5 +1,5 @@
 js.load_path_list.unshift(js.exec_dir+"dorkit/");
-if (js.global.system !== undefined)
+if (typeof(system) !== 'undefined')
 	js.load_path_list.unshift(system.exec_dir+"dorkit/");
 load('ansi_input.js');
 var i;
diff --git a/exec/load/dorkit.js b/exec/load/dorkit.js
index 4c3a999329d288fcd87ed02401e102e6bf8cd88f..feec34a9c228ff1a2e36334beee93612f51edc69 100644
--- a/exec/load/dorkit.js
+++ b/exec/load/dorkit.js
@@ -1,6 +1,9 @@
 js.load_path_list.unshift(js.exec_dir+"dorkit/");
-if (js.global.system !== undefined)
+js.on_exit("js.load_path_list.shift()");
+if (typeof(system) !== 'undefined') {
 	js.load_path_list.unshift(system.exec_dir+"dorkit/");
+	js.on_exit("js.load_path_list.shift()");
+}
 load("screen.js");
 
 // polyfill the String object with repeat method.
@@ -716,13 +719,13 @@ var dk = {
 		gen_dir:undefined,
 		sysop_name:undefined,
 		default_attr:new Attribute(7),
-		mode:(js.global.bbs !== undefined
-				&& js.global.server !== undefined
-				&& js.global.client !== undefined
-				&& js.global.user !== undefined
-				&& js.global.console !== undefined) ? 'sbbs'
-				: (js.global.jsexec_revision !== undefined ? 'jsexec'
-					: (js.global.jsdoor_revision !== undefined ? 'jsdoor' : undefined))
+		mode:(typeof(bbs) !== 'undefined'
+				&& typeof(server) !== 'undefined'
+				&& typeof(client) !== 'undefined'
+				&& typeof(user) !== 'undefined'
+				&& typeof(console) !== 'undefined') ? 'sbbs'
+				: (typeof(jsexec_revision) !== 'undefined' ? 'jsexec'
+					: (typeof(jsdoor_revision) !== 'undefined' ? 'jsdoor' : undefined))
 	},
 	misc:{
 		event_time:undefined,