diff --git a/config.js b/config.js
index 5b89a0bc9ae3df506e5d4b69d7cfd5788e6344f7..1a7584accb991eae8a0d2531e4dc24136235cfe8 100644
--- a/config.js
+++ b/config.js
@@ -9,8 +9,8 @@ export const COLOR_PALETTE = [
 ];
 
 // Just renaming a variable which is given by the PHP script. This avoids errors in all other files.
-export const PLUGIN_PATH = plugin.path;
-export var SPACE = space.id;
+export const PLUGIN_PATH = ks_global.plugin_path;
+export var SPACE = ks_global.space_id;
 
 export function setSpace(space) {
     SPACE = space;
diff --git a/datasets/datasets.js b/datasets/datasets.js
index 92cf8d9957489318eeb6c0d9205b9b9245a81fd3..3ce3208d13ac9030aa5e908534dba4ffdcc0b4be 100644
--- a/datasets/datasets.js
+++ b/datasets/datasets.js
@@ -17,7 +17,7 @@ export function loadGraphJson(spaceId) {
     return jQuery
         .ajax({
             type: "POST",
-            url: ajax_object.ajax_url,
+            url: ks_global.ajax_url,
             data: payload,
         })
         .then((data) => JSON.parse(data));
@@ -40,7 +40,7 @@ export function saveGraphJson(spaceId, json) {
 
     return jQuery.ajax({
         type: "POST",
-        url: ajax_object.ajax_url,
+        url: ks_global.ajax_url,
         data: payload,
     });
 }
@@ -57,7 +57,7 @@ export function listAllSpaces() {
 
     return jQuery.ajax({
         type: "POST",
-        url: ajax_object.ajax_url,
+        url: ks_global.ajax_url,
         data: payload,
     }).then((data) => JSON.parse(data)["spaces"]);
 }
diff --git a/knowledge-space.php b/knowledge-space.php
index e1777374745c6d07d15f10142a3cfc538714be02..b54200d3ad761f15f34a5163f7b5e8c48a404b4f 100644
--- a/knowledge-space.php
+++ b/knowledge-space.php
@@ -11,38 +11,42 @@ $GLOBALS['build'] = 'debug';
 
 function ks_add_graph($atts = []): string
 {
-    $space_id = kg_get_space_id_from_atts($atts);
     $div = '<div id="3d-graph"></div>'; // The id "3d-graph" indicates, that the javascript associated with this should automatically be executed
-    $plugin_dir = plugin_dir_url(__FILE__);
 
     $script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.js';
     // $script = "<script src='$script_path'></script>";
     //wp_enqueue_script('kg-script', $script_path);
     wp_enqueue_script("ks-display-js", plugins_url($script_path, __FILE__), array('jquery'), false);
-    wp_localize_script(
-        'ks-display-js',
-        'ajax_object',
-        array('ajax_url' => admin_url('admin-ajax.php'))
-    );
-    wp_localize_script("ks-display-js", "space", array('id' => $space_id));
-    wp_localize_script("ks-display-js", "plugin", array('path' => $plugin_dir));
+    ks_localize();
 
-    return $div . $variables;
+    return $div;
     // return $div . $variables . $script;
 }
 
-function ks_echo_graph ($atts = []): void {
+function ks_echo_graph($atts = []): void
+{
     echo ks_add_graph($atts);
 }
 
-function ks_add_editor($atts = [])
+function ks_localize()
 {
-    ks_add_editor_dependencies();
-
     $space_id = kg_get_space_id_from_atts($atts);
     $plugin_dir = plugin_dir_url(__FILE__);
-    wp_localize_script("ks-editor-js", "space", array('id' => $space_id));
-    wp_localize_script("ks-editor-js", "plugin", array('path' => $plugin_dir));
+    wp_localize_script(
+        'ks-editor-js',
+        'ks_global',
+        array(
+            'ajax_url' => admin_url('admin-ajax.php'),
+            'space_id' => $space_id,
+            'plugin_path' => $plugin_dir
+        )
+    );
+}
+
+function ks_add_editor($atts = [])
+{
+    ks_add_editor_dependencies();
+    ks_localize();
 
     require_once(__DIR__ . '/editor/editor.php');
 }
@@ -55,11 +59,6 @@ function ks_add_editor_dependencies()
     wp_enqueue_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
     //wp_register_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
 
-    wp_localize_script(
-        'ks-editor-js',
-        'ajax_object',
-        array('ajax_url' => admin_url('admin-ajax.php'))
-    );
     //wp_enqueue_script("ks-editor-js");
 
     $style_file_version = date("ymd-Gis", filemtime(plugin_dir_path(__FILE__) . "editor/css/editor.css"));