diff --git a/src/load_templates.py b/src/load_templates.py
index e3ee406b645ffb1491e168541e604e06e596fa1e..17e132b9bec5e697732118fb5aa3f742efe09608 100644
--- a/src/load_templates.py
+++ b/src/load_templates.py
@@ -64,7 +64,7 @@ def load_templates(wiktlang: str):
         is_done, msg=f"Loading templates for {wiktlang}..."
     )
 
-    wxr = get_wiktextract_context(wiktlang)
+    wxr = get_wiktextract_context(wiktlang, mock_get_page=False)
 
     wxr.wtp.db_conn.execute("DELETE FROM pages")
     wxr.wtp.db_conn.commit()
@@ -81,6 +81,7 @@ def load_templates(wiktlang: str):
         out_f=None,  # type: ignore
     )
     wxr.wtp.db_conn.commit()
+    wxr.wtp.close_db_conn()
 
     stop_progress_indicator(indicator_thread, is_done)
 
diff --git a/src/wiktextract_context.py b/src/wiktextract_context.py
index e1abb42a70df4eaa23ff72b66c42557d2e29c0f2..79d08e0a0c8f2f56eb80e9ac5bfec60d07f7bfff 100644
--- a/src/wiktextract_context.py
+++ b/src/wiktextract_context.py
@@ -31,7 +31,7 @@ class CustomWtp(Wtp):
         return original_result
 
 
-def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None):
+def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None, mock_get_page: bool = True):
     db_path = f"./sqlite-{wiktlang}.db"
     config = WiktionaryConfig(
         dump_file_lang_code=wiktlang,
@@ -46,6 +46,8 @@ def get_wiktextract_context(wiktlang: str, wordlang: Optional[str] = None):
         capture_descendants=True,
         capture_inflections=True,
     )
-    wxr = WiktextractContext(CustomWtp(db_path=db_path), config)
+    config.load_edition_settings()
+    wtp = CustomWtp(db_path=db_path, lang_code=wiktlang) if mock_get_page else Wtp(db_path=db_path, lang_code=wiktlang)
+    wxr = WiktextractContext(wtp, config)
 
     return wxr