diff --git a/sbroad/sbroad-core/src/executor/engine.rs b/sbroad/sbroad-core/src/executor/engine.rs
index e1faafc98fc8718e4c5f7c7b745e1a7184ae33cf..2f091007e1ca5f1f0830759b353b64d539a95183 100644
--- a/sbroad/sbroad-core/src/executor/engine.rs
+++ b/sbroad/sbroad-core/src/executor/engine.rs
@@ -73,20 +73,18 @@ pub trait Metadata: Sized {
 
 pub fn get_builtin_functions() -> &'static [Function] {
     // Once lock is used because of concurrent access in tests.
-    static mut BUILTINS: OnceLock<Vec<Function>> = OnceLock::new();
-
-    unsafe {
-        BUILTINS.get_or_init(|| {
-            vec![
-                Function::new_stable("to_date".into(), DerivedType::new(Type::Datetime), false),
-                Function::new_stable("to_char".into(), DerivedType::new(Type::String), false),
-                Function::new_stable("substr".into(), DerivedType::new(Type::String), true),
-                Function::new_stable("lower".into(), DerivedType::new(Type::String), true),
-                Function::new_stable("upper".into(), DerivedType::new(Type::String), true),
-                Function::new_stable("coalesce".into(), DerivedType::new(Type::Any), true),
-            ]
-        })
-    }
+    static BUILTINS: OnceLock<Vec<Function>> = OnceLock::new();
+
+    BUILTINS.get_or_init(|| {
+        vec![
+            Function::new_stable("to_date".into(), DerivedType::new(Type::Datetime), false),
+            Function::new_stable("to_char".into(), DerivedType::new(Type::String), false),
+            Function::new_stable("substr".into(), DerivedType::new(Type::String), true),
+            Function::new_stable("lower".into(), DerivedType::new(Type::String), true),
+            Function::new_stable("upper".into(), DerivedType::new(Type::String), true),
+            Function::new_stable("coalesce".into(), DerivedType::new(Type::Any), true),
+        ]
+    })
 }
 
 pub trait StorageCache {
diff --git a/sbroad/sbroad-core/src/executor/engine/helpers.rs b/sbroad/sbroad-core/src/executor/engine/helpers.rs
index 4d14546a6d5dd1e9cb0c492510d5d1d02b84109c..2953f6ef92857c8ec0ad35b6328be11cbf62945d 100644
--- a/sbroad/sbroad-core/src/executor/engine/helpers.rs
+++ b/sbroad/sbroad-core/src/executor/engine/helpers.rs
@@ -1760,9 +1760,9 @@ pub struct UpdateArgs<'vtable_tuple> {
 
 pub fn eq_op() -> &'static Value {
     // Once lock is used because of concurrent access in tests.
-    static mut EQ: OnceLock<Value> = OnceLock::new();
+    static EQ: OnceLock<Value> = OnceLock::new();
 
-    unsafe { EQ.get_or_init(|| Value::String("=".into())) }
+    EQ.get_or_init(|| Value::String("=".into()))
 }
 
 /// Convert vtable tuple to tuple
diff --git a/sbroad/sbroad-core/src/executor/engine/helpers/proxy.rs b/sbroad/sbroad-core/src/executor/engine/helpers/proxy.rs
index 5a47a63919bcdda4b54eb030c49b30b3401059a5..4d7f6ebc5f908298ca88ec0b0ecfefed1151c526 100644
--- a/sbroad/sbroad-core/src/executor/engine/helpers/proxy.rs
+++ b/sbroad/sbroad-core/src/executor/engine/helpers/proxy.rs
@@ -1,4 +1,3 @@
-use std::cell::OnceCell;
 use std::rc::Rc;
 use std::time::Duration;
 
@@ -36,6 +35,10 @@ pub(crate) struct SqlCacheProxy {
     response: Rc<Channel<CacheResponse>>,
 }
 
+thread_local! {
+    pub(crate) static SQL_CACHE_PROXY: SqlCacheProxy = SqlCacheProxy::new();
+}
+
 fn proxy_start(rq: Rc<Channel<CacheRequest>>, rsp: Rc<Channel<CacheResponse>>) -> fiber::FiberId {
     fiber::Builder::new()
         .name("sql_cache")
@@ -98,7 +101,8 @@ impl SqlCacheProxy {
     }
 
     fn send(&self, request: CacheRequest) -> Result<(), Error> {
-        fiber::wakeup(sql_cache_proxy().id);
+        let id = SQL_CACHE_PROXY.with(|proxy| proxy.id);
+        fiber::wakeup(id);
         if self.request.send(request).is_err() {
             if fiber::is_cancelled() {
                 return Err(Error::Other("current fiber is cancelled".into()));
@@ -138,8 +142,3 @@ impl SqlCacheProxy {
         }
     }
 }
-
-pub(crate) fn sql_cache_proxy() -> &'static SqlCacheProxy {
-    static mut PROXY: OnceCell<SqlCacheProxy> = OnceCell::new();
-    unsafe { PROXY.get_or_init(SqlCacheProxy::new) }
-}
diff --git a/sbroad/sbroad-core/src/executor/engine/helpers/storage.rs b/sbroad/sbroad-core/src/executor/engine/helpers/storage.rs
index 478393b5b6f6a0c1cf9ae3bc0fc7c434937562c8..84d90a65711e4cfc1a7cbac5e6c7ec4380a778a4 100644
--- a/sbroad/sbroad-core/src/executor/engine/helpers/storage.rs
+++ b/sbroad/sbroad-core/src/executor/engine/helpers/storage.rs
@@ -12,7 +12,7 @@ use tarantool::tuple::{Tuple, TupleBuffer};
 use crate::backend::sql::space::ADMIN_ID;
 use crate::error;
 use crate::errors::SbroadError;
-use crate::executor::engine::helpers::proxy::sql_cache_proxy;
+use crate::executor::engine::helpers::proxy::SQL_CACHE_PROXY;
 use crate::executor::engine::helpers::table_name;
 use crate::executor::lru::DEFAULT_CAPACITY;
 use crate::ir::node::NodeId;
@@ -84,11 +84,12 @@ impl StorageMetadata {
 }
 
 pub fn prepare(pattern: String) -> Result<Statement, SbroadError> {
-    let proxy = sql_cache_proxy();
-    let stmt = proxy.prepare(pattern).map_err(|e| {
-        error!(Option::from("prepare"), &format!("{e:?}"));
-        SbroadError::from(e)
-    })?;
+    let stmt = SQL_CACHE_PROXY
+        .with(|proxy| proxy.prepare(pattern))
+        .map_err(|e| {
+            error!(Option::from("prepare"), &format!("{e:?}"));
+            SbroadError::from(e)
+        })?;
     Ok(stmt)
 }
 
@@ -99,11 +100,12 @@ pub fn unprepare(
     let (stmt, table_ids) = std::mem::take(entry);
 
     // Remove the statement from the instance cache.
-    let proxy = sql_cache_proxy();
-    proxy.unprepare(stmt).map_err(|e| {
-        error!(Option::from("unprepare"), &format!("{e:?}"));
-        SbroadError::from(e)
-    })?;
+    SQL_CACHE_PROXY
+        .with(|proxy| proxy.unprepare(stmt))
+        .map_err(|e| {
+            error!(Option::from("unprepare"), &format!("{e:?}"));
+            SbroadError::from(e)
+        })?;
 
     // Remove temporary tables from the instance.
     for node_id in table_ids {
diff --git a/sbroad/sbroad-core/src/ir/expression.rs b/sbroad/sbroad-core/src/ir/expression.rs
index 358f2f97fd4b6b69aeff631fddac2284945adc7b..1e59d05f815a968de45c8e89dd7f30dd3eae9015 100644
--- a/sbroad/sbroad-core/src/ir/expression.rs
+++ b/sbroad/sbroad-core/src/ir/expression.rs
@@ -945,7 +945,7 @@ impl<'source> NewColumnsSource<'source> {
         }
     }
 
-    fn iter(&'source self) -> NewColumnSourceIterator {
+    fn iter(&'source self) -> NewColumnSourceIterator<'source> {
         <&Self as IntoIterator>::into_iter(self)
     }
 }