diff --git a/src/Lib/Script/CRTPLuaScriptObject.hh b/src/Lib/Script/CRTPLuaScriptObject.hh
index 480c569595e985fd42dc1137c2f9d678c34e3582..311acb65c66067ed04d6e64411440208b3ed17cb 100644
--- a/src/Lib/Script/CRTPLuaScriptObject.hh
+++ b/src/Lib/Script/CRTPLuaScriptObject.hh
@@ -22,19 +22,24 @@ namespace Vivy::Script
 
 #define method_list static constexpr inline auto
 
-#define LUA_SCRIPTABLE_CLASS(theClassName)                                                  \
-    VIVY_UNMOVABLE_OBJECT(theClassName)                                                     \
-    static constexpr char className[] = #theClassName;                                      \
-    friend CRTPLuaScriptObject<theClassName>;                                               \
-    theClassName(lua_State *L) noexcept                                                     \
-    {                                                                                       \
-        out(LuaContext::getContext(L)) << "Create instance of " << theClassName::className; \
-    }                                                                                       \
+#define LUA_SCRIPTABLE_CLASS_MANUAL_CTOR(theClassName) \
+    VIVY_UNMOVABLE_OBJECT(theClassName)                \
+    static constexpr char className[] = #theClassName; \
+    friend CRTPLuaScriptObject<theClassName>;          \
     ~theClassName() noexcept {}
 
+#define LUA_SCRIPTABLE_CLASS(theClassName)                               \
+    LUA_SCRIPTABLE_CLASS_MANUAL_CTOR(theClassName)                       \
+    theClassName(lua_State *L) noexcept                                  \
+    {                                                                    \
+        err(LuaContext::getContext(L))                                   \
+            << "Create instance of " << theClassName::className << "\n"; \
+    }
+
 // The type of the thing that a job iterate over
 enum class JobIteratorType { Line = 1, Syllabe = 2 };
-static inline JobIteratorType
+
+[[maybe_unused]] static inline JobIteratorType
 getJobIteratorTypeFromString(const std::string_view it) noexcept
 {
     if (it == "LINE")
@@ -324,7 +329,9 @@ public:
 
 // Holds all the free functions (well, not really free functions here...)
 script_class (FreeFunctions) {
-    LUA_SCRIPTABLE_CLASS(FreeFunctions)
+    LUA_SCRIPTABLE_CLASS_MANUAL_CTOR(FreeFunctions)
+
+    FreeFunctions(lua_State *const) noexcept;
 
     static int print(lua_State *const) noexcept;
     static int getModule(lua_State *const) noexcept;
diff --git a/src/Lib/Script/CRTPLuaScriptObject/FreeFunctions.cc b/src/Lib/Script/CRTPLuaScriptObject/FreeFunctions.cc
index 3b49778e26aa4accd499e8dd03deaf4054face67..9192f1d1f73cc355505ee4f479a565b8b955107a 100644
--- a/src/Lib/Script/CRTPLuaScriptObject/FreeFunctions.cc
+++ b/src/Lib/Script/CRTPLuaScriptObject/FreeFunctions.cc
@@ -1,7 +1,23 @@
 #include "../CRTPLuaScriptObject.hh"
+#include "../LuaContext.hh"
+#include "../../../VivyApplication.hh"
 
 using namespace Vivy::Script;
 
+FreeFunctions::FreeFunctions(lua_State *const L) noexcept
+{
+    const auto *const context = LuaContext::getContext(L);
+    out(context) << "Creating the FreeFunctions lua object!";
+
+    std::shared_ptr<VivyDocument> vivyDoc = context->getAttachedVivyDocument();
+    if (vivyDoc) {
+    }
+
+    else {
+        out(context) << "No attached Vivy document in the Lua context";
+    }
+}
+
 int
 FreeFunctions::print(lua_State *const L) noexcept
 {
diff --git a/src/Lib/Script/LuaContext.cc b/src/Lib/Script/LuaContext.cc
index 48ac5354729be15bbe4e597dc78e7d5a4924e7b9..2998a1eb3f197a23e9e669a7a42389127515da18 100644
--- a/src/Lib/Script/LuaContext.cc
+++ b/src/Lib/Script/LuaContext.cc
@@ -1,6 +1,7 @@
 #include "CRTPLuaScriptObject.hh"
 #include "ScriptDocument.hh"
 #include "LuaContext.hh"
+#include "../Document/VivyDocument.hh"
 
 // LuaContext implementation
 using namespace Vivy::Script;
@@ -158,6 +159,12 @@ LuaContext::getState() noexcept
     return L;
 }
 
+std::shared_ptr<Vivy::VivyDocument>
+LuaContext::getAttachedVivyDocument() const noexcept
+{
+    return attachedVivyDocument;
+}
+
 bool
 LuaContext::moduleExists(const std::string_view mod) const noexcept
 {
diff --git a/src/Lib/Script/LuaContext.hh b/src/Lib/Script/LuaContext.hh
index 06da7b4318d42a683802bfbdc7f4fa577160649d..318751abaeb7ad0e7cbf53616a20b7aad56a8a0b 100644
--- a/src/Lib/Script/LuaContext.hh
+++ b/src/Lib/Script/LuaContext.hh
@@ -9,6 +9,7 @@ struct lua_State;
 namespace Vivy
 {
 class ScriptDocument;
+class VivyDocument;
 }
 
 namespace Vivy::Script
@@ -27,6 +28,7 @@ class LuaContext final {
     VIVY_APP_LOGGABLE_OBJECT(LuaContext, logger)
 
     lua_State *L{ nullptr };
+    std::shared_ptr<Vivy::VivyDocument> attachedVivyDocument{ nullptr };
 
     std::string failureString{};
     std::string currentFile{};
@@ -47,6 +49,7 @@ public:
     ~LuaContext() noexcept;
 
     Code loadDocument(std::shared_ptr<ScriptDocument>) noexcept;
+    Code loadDocument(std::shared_ptr<Vivy::VivyDocument>) noexcept;
 
     QString getLastLuaError() noexcept;
 
@@ -59,9 +62,10 @@ public:
     void setFailedWith(const std::string &) noexcept;
 
     lua_State *getState() noexcept;
+    std::shared_ptr<Vivy::VivyDocument> getAttachedVivyDocument() const noexcept;
 
-    decltype(auto) getOutputStream() noexcept { return logInfo(); }
-    decltype(auto) getErrorStream() noexcept { return logError(); }
+    decltype(auto) getOutputStream() const noexcept { return logInfo(); }
+    decltype(auto) getErrorStream() const noexcept { return logError(); }
 
     operator lua_State *() noexcept { return L; }
     static LuaContext *getContext(const lua_State *const) noexcept;
@@ -99,14 +103,14 @@ private:
     void swapEnv() noexcept;
 };
 
-static inline decltype(auto)
-out(LuaContext *const context) noexcept
+[[maybe_unused]] static inline decltype(auto)
+out(const LuaContext *const context) noexcept
 {
     return context->getOutputStream();
 }
 
-static inline decltype(auto)
-err(LuaContext *const context) noexcept
+[[maybe_unused]] static inline decltype(auto)
+err(const LuaContext *const context) noexcept
 {
     return context->getErrorStream();
 }
diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh
index 7317c7ea752bfea182e02d36a48bcf82281dd74a..71c8344bf90801e35252e329cd8b6e6f833aa717 100644
--- a/src/VivyApplication.hh
+++ b/src/VivyApplication.hh
@@ -16,8 +16,8 @@
 #define VIVY_APP_LOGGABLE_OBJECT_BY_STORED_NAME(name, logger) \
     VIVY_LOGGABLE_OBJECT_BY_STORED_NAME(vivyApp->getLogSink(), name, logger)
 
-#define currentVivyDocument() dynamic_cast<::Vivy::VivyDocument *>(vivyApp->getCurrentDocument())
-#define currentScriptDocument dynamic_cast<::Vivy::ScriptDocument *>(vivyApp->getCurrentDocument())
+#define currentVivyDocument   dynamic_cast<VivyDocument *>(vivyApp->getCurrentDocument())
+#define currentScriptDocument dynamic_cast<ScriptDocument *>(vivyApp->getCurrentDocument())
 
 // Only support dark theme for now
 #define VIVY_ICON_APP     ":icons/vivy.png"