diff --git a/src/main/server.c b/src/main/server.c
index 02c87f1a913938672ffa0282359aa81487744359..02583051665001c324dd78eba77cd5e2a6848070 100644
--- a/src/main/server.c
+++ b/src/main/server.c
@@ -110,6 +110,10 @@ main(int argc, char *argv[])
 
     {   /* Module initialization */
         char *module = safe_malloc(sizeof(char) * PATH_MAX);
+        if (!module) {
+            LOG_ERROR("GENERAL", "Out of memory");
+            return 1;
+        }
         database_config_get_text(srv.db, "player", "module", module, PATH_MAX);
         reg_import(module, &srv.window_mod.reg, &srv.window_mod.handle);
         database_config_get_text(srv.db, "repo", "module", module, PATH_MAX);
diff --git a/src/module/module_repo.c b/src/module/module_repo.c
index 54c0c6fc5ad19810dfb669b46698cf2eddeb7d60..c301be3711aba08f87ee38c5bce8c1dc712fd900 100644
--- a/src/module/module_repo.c
+++ b/src/module/module_repo.c
@@ -431,7 +431,7 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil
                         10 /* Initial number of elements in the call queue */,
                         workers_count /* Number of worker threads */)) {
         LOG_ERROR("REPO", "Out of memory");
-        return 1;
+        return false;
     }
 
     /* Copies */
@@ -441,9 +441,9 @@ module_repo_new(struct module_repo_internal *repo_, struct queue *queue, volatil
         !database_config_get_text(db, "repo",     "id_json",  repo.get_id_json,  LKT_LINE_MAX) ||
         !database_config_get_text(db, "repo",     "id_kara",  repo.get_id_file,  LKT_LINE_MAX) ||
         !database_config_get_text(db, "repo",     "json",     repo.get_all_json, LKT_LINE_MAX) )
-        return 1;
+        return false;
     memcpy(repo_, &repo, sizeof(struct module_repo_internal));
-    return 0;
+    return true;
 }
 
 /********************
@@ -460,8 +460,11 @@ mod_new(va_list *va)
     struct queue *queue  = va_arg(copy, struct queue *);
     volatile sqlite3 *db = va_arg(copy, volatile sqlite3 *);
 
-    if (NULL == *repo)
-        *repo = malloc(sizeof(struct module_repo_internal));
+    if (NULL != *repo) {
+        LOG_ERROR("REPO", "Can't init two times the module");
+        return 1;
+    }
+    *repo = malloc(sizeof(struct module_repo_internal));
     if (NULL == *repo) {
         LOG_ERROR("REPO", "Out of memory");
         return 1;
@@ -470,6 +473,8 @@ mod_new(va_list *va)
     bool ret = module_repo_new(*repo, queue, db);
     lkt_queue_make_available(queue, lkt_event_db_updating);
     va_end(copy);
+    if (!ret)
+        LOG_ERROR("REPO", "Failed to create the module");
     return ! ret;
 }
 
diff --git a/src/module/worker.c b/src/module/worker.c
index be196bd7c4ae2f7e0e86df8c24ff5190d46e0af6..220de13d84c1598ec444973ce56172010442b995 100644
--- a/src/module/worker.c
+++ b/src/module/worker.c
@@ -8,15 +8,21 @@
 #include <assert.h>
 #include <sys/sysinfo.h>
 #include <sched.h>
+#include <errno.h>
+#include <string.h>
 
-static inline void *
+static void *
 __worker_thread(void *__pool)
 {
     struct worker_pool *pool = (struct worker_pool *) __pool;
     volatile void *volatile arg;
     worker_function func;
     for (;;) {
-        assert(!pthread_mutex_lock(&pool->lock));
+        errno = 0;
+        if (pthread_mutex_lock(&pool->lock)) {
+            LOG_ERROR("WORKER", "Failed to lock mutex: %s", strerror(errno));
+            abort();
+        }
         if (pool->len) {
             --(pool->len);
             ++(pool->thread_working);
@@ -47,7 +53,6 @@ __worker_thread(void *__pool)
 int
 worker_pool_new(struct worker_pool *ret, size_t init_size, size_t thread_count)
 {
-    pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
     if (!thread_count)
         thread_count = get_nprocs_conf();
     struct worker_pool __ret = {
@@ -57,7 +62,6 @@ worker_pool_new(struct worker_pool *ret, size_t init_size, size_t thread_count)
         .size        = init_size,
         .thread_size = thread_count,
         .len         = 0u,
-        .lock        = mtx,
         .exit        = 0,
     };
     if (!__ret.functions || !__ret.args || !__ret.threads) {
@@ -66,8 +70,12 @@ worker_pool_new(struct worker_pool *ret, size_t init_size, size_t thread_count)
         worker_pool_free(&__ret);
         return 1;
     }
-    size_t i;
     *ret = __ret;
+    if (pthread_mutex_init(&ret->lock, NULL)) {
+        LOG_ERROR("WORKER", "Failed to init mutex: %s", strerror(errno));
+        abort();
+    }
+    size_t i;
     for (i = 0; i < ret->thread_size; ++i)
         assert(!pthread_create(&ret->threads[i], NULL, __worker_thread, ret));
     return 0;
@@ -76,6 +84,7 @@ worker_pool_new(struct worker_pool *ret, size_t init_size, size_t thread_count)
 void
 worker_pool_free(struct worker_pool *pool)
 {
+    LOG_DEBUG("WORKER", "Freeing worker pool %p", pool);
     size_t i;
     pool->exit = 1;
     for (i = 0; i < pool->thread_size; ++i)