diff --git a/inc/lektor/common.h b/inc/lektor/common.h
index c65f732a5fc441a5d90858350852c337ef4af2ad..d12ca94e317146c74cec2303f800e9eeecd45d23 100644
--- a/inc/lektor/common.h
+++ b/inc/lektor/common.h
@@ -51,13 +51,13 @@ extern void (*__lkt_assert)(const char *file, int line, const char *func, const
 #endif
 
 /* Custom log functions. */
-extern int log_level;
 enum log_level {
     ERROR   = 1,
     WARN    = 2,
     INFO    = 3,
     DEBUG   = 4,
 };
+extern enum log_level __log_level;
 void __lkt_log(enum log_level, const char *section, const char *func, const char *format, ...);
 #define LOG_INFO( section, ...) __lkt_log(INFO,  section, __func__, __VA_ARGS__)
 #define LOG_WARN( section, ...) __lkt_log(WARN,  section, __func__, __VA_ARGS__)
diff --git a/src/base/commands.c b/src/base/commands.c
index cb0808dd0b67d09af388c956ef0ac8244835875b..65db132a891a3a924f74915d26fca1bdeaf91ee9 100644
--- a/src/base/commands.c
+++ b/src/base/commands.c
@@ -62,7 +62,8 @@ command_update(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX]
 }
 
 bool
-command_rescan(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX], int forced)
+command_rescan(struct lkt_state *srv, size_t c, char *argv[LKT_MESSAGE_ARGS_MAX],
+               int __attribute__((unused)) forced)
 {
     UNUSED(argv);
     RETURN_UNLESS(lkt_client_auth(srv, c, false), "Failed to authentificate user", false);
diff --git a/src/base/common.c b/src/base/common.c
index 093e5ff3fe816a7b1bba9e9a04a02031d2fec86a..d1de4234264da5d1b3034f80e30923272313172b 100644
--- a/src/base/common.c
+++ b/src/base/common.c
@@ -36,7 +36,7 @@ __set_assert(void)
 
 /* Log functions */
 
-int log_level = 0; /* None by default */
+enum log_level __log_level = 0; /* None by default */
 
 void
 __lkt_log(enum log_level level, const char *section, const char *func, const char *format, ...)
@@ -44,7 +44,7 @@ __lkt_log(enum log_level level, const char *section, const char *func, const cha
     char line[LKT_MESSAGE_MAX];
     va_list ap;
 
-    if (level <= log_level) {
+    if (level <= __log_level) {
         safe_snprintf(line, LKT_MESSAGE_MAX, " %c [%s] %s: %s\n",
                       level == ERROR ? '!' : level == WARN ? '*' : level == INFO ? '.' : ' ',
                       section, func, format);
diff --git a/src/base/config.c b/src/base/config.c
index 6ec549ae16bb368977914111c8c8d268922a5179..e5efa35383951be06952aa8e4f0978bf71461fca 100644
--- a/src/base/config.c
+++ b/src/base/config.c
@@ -62,17 +62,17 @@ __set_log_level(const char *name, const char *level)
     }
 
     if (STR_MATCH(level, "error"))
-        log_level = ERROR;
+        __log_level = ERROR;
     else if (STR_MATCH(level, "warn") || STR_MATCH(level, "warning"))
-        log_level = WARN;
+        __log_level = WARN;
     else if (STR_MATCH(level, "info"))
-        log_level = INFO;
+        __log_level = INFO;
     else if (STR_MATCH(level, "debug"))
-        log_level = DEBUG;
+        __log_level = DEBUG;
     else
-        log_level = strtol(level, NULL, 0);
+        __log_level = strtol(level, NULL, 0);
 
-    LOG_INFO("CONFIG", "Log level set to %d", log_level);
+    LOG_INFO("CONFIG", "Log level set to %d", __log_level);
 }
 
 static inline int
diff --git a/src/database/disk.sql b/src/database/disk.sql
index 691a028ac17d7ee836c196089c249f5c8f711484..d1e356f6bb2ac14244e3931dcbd3e0510d65aed9 100644
--- a/src/database/disk.sql
+++ b/src/database/disk.sql
@@ -77,13 +77,6 @@ CREATE TABLE IF NOT EXISTS queue
   , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)
   );
 
--- Temporary queue table used when reordering the queue (for inserts)
-CREATE TABLE IF NOT EXISTS queue_tmp
-   ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0)
-   , kara_id INTEGER
-   , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)
-   );
-
 
 -- The user table
 -- Used for the [password {passwd}] MPD command. The documentation can be found
diff --git a/src/database/macro.h b/src/database/macro.h
index 76f449021bf6966c1d7e31f0f3e39e311f7cf9f2..da23e82ca954a90e253ddd7b47f914dbdb417ccd 100644
--- a/src/database/macro.h
+++ b/src/database/macro.h
@@ -3,21 +3,21 @@
 
 #define SQLITE_PREPARE(db, stmt, SQL, goto_label)                               \
     if (sqlite3_prepare_v2((sqlite3 *) db, SQL, -1, &(stmt), 0) != SQLITE_OK) { \
-        LOG_ERROR("DB", "Failed to prepare statement: %s",                      \
+        LOG_DEBUG("DB", "Failed to prepare statement: %s",                      \
                   sqlite3_errmsg((sqlite3 *) db));                              \
         goto goto_label;                                                        \
     }
 
 #define SQLITE_EXEC(db, SQL, goto_label)                                        \
     if (sqlite3_exec((sqlite3 *) db, SQL, NULL, NULL, NULL) != SQLITE_OK) {     \
-        LOG_ERROR("DB", "Failed to exec statement: %s",                         \
+        LOG_DEBUG("DB", "Failed to exec statement: %s",                         \
                   sqlite3_errmsg((sqlite3 *) db));                              \
         goto goto_label;                                                        \
     }
 
 #define SQLITE_BIND_TEXT(db, stmt, pos, text, error) {                          \
     if (sqlite3_bind_text(stmt, pos, text, -1, 0) != SQLITE_OK) {               \
-        LOG_ERROR("DB", "Failed to bind text %s at pos %d: %s",                 \
+        LOG_DEBUG("DB", "Failed to bind text %s at pos %d: %s",                 \
                   (const char *) text, pos,                                     \
                   sqlite3_errmsg((sqlite3 *) db));                              \
         goto error;                                                             \
@@ -25,14 +25,14 @@
 
 #define SQLITE_BIND_INT(db, stmt, pos, integer, error) {                        \
     if (sqlite3_bind_int(stmt, pos, integer) != SQLITE_OK) {                    \
-        LOG_ERROR("DB", "Failed to bind int %d at pos %d: %s",                  \
+        LOG_DEBUG("DB", "Failed to bind int %d at pos %d: %s",                  \
                   integer, pos, sqlite3_errmsg((sqlite3 *) db));                \
         goto error;                                                             \
     }}
 
 #define SQLITE_STEP(db, stmt, code, error)                                      \
     if (sqlite3_step(stmt) != code) {                                           \
-        LOG_ERROR("DB", "Failed to step: %s",                                   \
+        LOG_DEBUG("DB", "Failed to step: %s",                                   \
                   sqlite3_errmsg((sqlite3 *) db));                              \
         goto error;                                                             \
     }
diff --git a/src/database/memory.sql b/src/database/memory.sql
index 5a36f3a9b1392b00d3ad6fe26525b5281602f96d..83d8bfe73223f74dbb4be0dd71224aad6681eb6e 100644
--- a/src/database/memory.sql
+++ b/src/database/memory.sql
@@ -26,6 +26,14 @@ CREATE TABLE IF NOT EXISTS queue_state
 INSERT INTO queue_state (id) VALUES (42);
 
 
+-- Temporary queue table used when reordering the queue (for inserts)
+CREATE TABLE IF NOT EXISTS queue_tmp
+   ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0)
+   , kara_id INTEGER
+   , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)
+   );
+
+
 -- Used to store the content of the ini configuration file.
 
 CREATE TABLE IF NOT EXISTS config
diff --git a/src/database/queue.c b/src/database/queue.c
index ac5d1181731da4fc42923e8e85aceec6648b0c7d..959d416ed7e5a38bc842007f5270ecb7c1321bc8 100644
--- a/src/database/queue.c
+++ b/src/database/queue.c
@@ -253,12 +253,13 @@ database_queue_add_id(volatile sqlite3 *db, int id, int priority)
     sqlite3_finalize(stmt);
 
     /* Do the move shit only if the priority > 1 */
-    reorder(db, priority, error);
+    reorder(db, priority, error_no_stmt);
 
     SQLITE_EXEC(db, "COMMIT;", error);
     return true;
 error:
     sqlite3_finalize(stmt);
+error_no_stmt:
     SQLITE_DO_ROLLBACK(db);
     return false;
 }
@@ -293,8 +294,8 @@ database_queue_del_id(volatile sqlite3 *db, int id)
 {
     static const char *SQL_TEMPLATE =
         "BEGIN TRANSACTION;"
-        "CREATE TEMPORARY TABLE IF NOT EXISTS queue_tmp (position INTEGER, kara_id INTEGER, priority INTEGER);"
         "DELETE FROM queue_tmp;"
+        "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"
         /* Move the current 'pointer' */
         "UPDATE queue_state SET current = (SELECT NULLIF(COUNT(position), 0) FROM queue JOIN queue_state ON position <= current AND kara_id != %d);"
         "DELETE FROM queue WHERE kara_id = %d;"                                                 /* Delete any kara with the specified id */
@@ -570,13 +571,8 @@ database_queue_shuffle(volatile sqlite3 *db)
     const char *SQL =
         "BEGIN TRANSACTION;"
         /* Create temporary queue */
-        "CREATE TEMPORARY TABLE IF NOT EXISTS queue_tmp"
-        "  ( position INTEGER PRIMARY KEY AUTOINCREMENT CHECK(position > 0)"
-        "  , kara_id INTEGER"
-        "  , priority INTEGER NOT NULL DEFAULT 1 CHECK(priority > 0 AND priority < 6)"
-        "  );"
-        "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"
         "DELETE FROM queue_tmp;"
+        "DELETE FROM sqlite_sequence WHERE name = 'queue_tmp';"
         /* When current is NULL, that thing is also NULL, so no insertion is done */
         "INSERT INTO queue_tmp (kara_id, priority)"
         "  SELECT kara_id, 5"
diff --git a/src/main/lkt.c b/src/main/lkt.c
index 042d346729fd039594a4a981a13398d0fc70082a..079a34e1a1f200fc9f8ffd114fe46e15ea8d7581 100644
--- a/src/main/lkt.c
+++ b/src/main/lkt.c
@@ -1101,7 +1101,7 @@ parse_args(args_t *args, int argc, const char **argv)
 int
 main(int argc, const char **argv)
 {
-    log_level = ERROR;
+    __log_level = ERROR;
     executable_name = "lkt";
     assert(NULL != setlocale(LC_ALL, "en_US.UTF-8"));   /* BECAUSE! */
     if (signal(SIGPIPE, sigpipe__)) {