diff --git a/agkyra/cli.py b/agkyra/cli.py
index 593a1d6f72fec928dc444b3e983a68681993ed79..bf1dbe2dc0775886f451cfc8a2ec273d3f96807a 100644
--- a/agkyra/cli.py
+++ b/agkyra/cli.py
@@ -449,4 +449,23 @@ class AgkyraCLI(cmd.Cmd):
         """
         if self.must_help('gui'):
             return
-        gui.run(callback=self.callback, debug=self.args.debug)
+        session = self.helper.load_active_session()
+        if not session:
+            self._start('')
+            session = self.helper.wait_session_to_load()
+        if session:
+            LOGGER.info('Start new GUI')
+            new_gui = gui.GUI(session, debug=self.args.debug)
+            try:
+                new_gui.start()
+            except KeyboardInterrupt:
+                LOGGER.info('GUI interrupted by user')
+                sys.stderr.write('GUI interrupted by user, exiting\n')
+                sys.stderr.flush()
+                new_gui.clean_exit()
+            LOGGER.info('GUI is shutdown')
+            if self.client:
+                self._shutdown('')
+        else:
+            sys.stderr.write('Session failed to load\n')
+            sys.stderr.flush()
diff --git a/agkyra/gui.py b/agkyra/gui.py
index c2d5eaf5aecffb08fabaa629ac72f7631ba90b21..982041a12a5412808aa3e5495c3a8f15d08f8390 100644
--- a/agkyra/gui.py
+++ b/agkyra/gui.py
@@ -101,24 +101,3 @@ class GUI(WebSocketBaseClient):
         finally:
             self.clean_exit()
         LOG.debug('GUI finished, close GUI wrapper connection')
-
-
-def run(callback, debug):
-    """Prepare SessionHelper and GUI and run them in the proper order"""
-    launch_server(callback, debug)
-    LOG.info('Client blocks until session is ready')
-    session = SessionHelper().wait_session_to_load()
-    assert session, 'UI server failed to load...'
-    LOG.info('Server session is ready, setup the GUI session')
-    gui = GUI(session, debug=debug)
-
-    try:
-        LOG.info('Start GUI')
-        gui.start()
-    except KeyboardInterrupt:
-        LOG.info('Shutdown GUI')
-        gui.clean_exit()
-
-if __name__ == '__main__':
-    logging.basicConfig(filename='agkyra.log', level=logging.DEBUG)
-    run(os.path.abspath('gui/app'))