diff --git a/.dockerignore b/.dockerignore
index 6806de8..402c792 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -37,4 +37,5 @@ state.db
 build/
 __pycache__/
 sist2-vue/dist
-sist2-admin/frontend/dist
\ No newline at end of file
+sist2-admin/frontend/dist
+*.fts
\ No newline at end of file
diff --git a/scripts/test_in_docker.sh b/scripts/test_in_docker.sh
new file mode 100644
index 0000000..e6d0633
--- /dev/null
+++ b/scripts/test_in_docker.sh
@@ -0,0 +1,7 @@
+docker build . -t tmp
+
+docker run --rm -it\
+  -v $(pwd):/host \
+  tmp \
+  scan --ocr-lang eng --ocr-ebooks -t6 --incremental --very-verbose \
+  -o /host/docker.sist2 /host/third-party/libscan/libscan-test-files/test_files/
\ No newline at end of file
diff --git a/src/cli.c b/src/cli.c
index f40ad16..b62d441 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -93,9 +93,12 @@ int scan_args_validate(scan_args_t *args, int argc, const char **argv) {
     if (abs_path == NULL) {
         LOG_FATALF("cli.c", "Invalid PATH argument. File not found: %s", argv[1]);
     } else {
-        abs_path = realloc(abs_path, strlen(abs_path) + 2);
-        strcat(abs_path, "/");
-        args->path = abs_path;
+        char *new_abs_path = realloc(abs_path, strlen(abs_path) + 2);
+        if (new_abs_path == NULL) {
+            LOG_FATALF("cli.c", "FIXME: realloc() failed for argv[1]=%s, abs_path=%s", argv[1], abs_path);
+        }
+        strcat(new_abs_path, "/");
+        args->path = new_abs_path;
     }
 
     if (args->tn_quality == OPTION_VALUE_UNSPECIFIED) {
@@ -142,10 +145,14 @@ int scan_args_validate(scan_args_t *args, int argc, const char **argv) {
 
     char *abs_output = abspath(args->output);
     if (args->incremental && abs_output == NULL) {
-        LOG_WARNINGF("main.c", "Could not open original index for incremental scan: %s. Will not perform incremental scan.", args->output);
+        LOG_WARNINGF("main.c",
+                     "Could not open original index for incremental scan: %s. Will not perform incremental scan.",
+                     args->output);
         args->incremental = FALSE;
     } else if (!args->incremental && abs_output != NULL) {
-        LOG_FATALF("main.c", "Index already exists: %s. If you wish to perform incremental scan, you must specify --incremental", abs_output);
+        LOG_FATALF("main.c",
+                   "Index already exists: %s. If you wish to perform incremental scan, you must specify --incremental",
+                   abs_output);
     }
     free(abs_output);
 
diff --git a/src/database/database_fts.c b/src/database/database_fts.c
index f77d03b..2ef886a 100644
--- a/src/database/database_fts.c
+++ b/src/database/database_fts.c
@@ -466,8 +466,8 @@ cJSON *database_fts_search(database_t *db, const char *query, const char *path,
     const char *path_where = path_where_clause(path);
     const char *size_where = size_where_clause(size_min, size_max);
     const char *date_where = date_where_clause(date_min, date_max);
-    const char *index_id_where = index_ids_where_clause(index_ids);
-    const char *mime_where = mime_types_where_clause(mime_types);
+    char *index_id_where = index_ids_where_clause(index_ids);
+    char *mime_where = mime_types_where_clause(mime_types);
     const char *query_where = match_where(query);
     const char *after_where = get_after_where(after, sort);
     const char *tags_where = tags_where_clause(tags);
diff --git a/src/log.h b/src/log.h
index 2426be3..59598be 100644
--- a/src/log.h
+++ b/src/log.h
@@ -3,6 +3,7 @@
 
 
 #include <signal.h>
+
 #define LOG_MAX_LENGTH 8192
 
 #define LOG_SIST_DEBUG 0
@@ -33,11 +34,12 @@
 
 #define LOG_FATALF(filepath, fmt, ...)\
     sist_logf(filepath, LOG_SIST_FATAL, fmt, __VA_ARGS__);\
-    raise(SIGUSR1)
+    raise(SIGUSR1);                   \
+    exit(-1)
 #define LOG_FATAL(filepath, str) \
     sist_log(filepath, LOG_SIST_FATAL, str);\
-    exit(SIGUSR1)
-
+    raise(SIGUSR1);                   \
+    exit(-1)
 #define LOG_FATALF_NO_EXIT(filepath, fmt, ...) \
     sist_logf(filepath, LOG_SIST_FATAL, fmt, __VA_ARGS__)
 #define LOG_FATAL_NO_EXIT(filepath, str) \
@@ -46,6 +48,7 @@
 #include "sist.h"
 
 void sist_logf(const char *filepath, int level, char *format, ...);
+
 void vsist_logf(const char *filepath, int level, char *format, va_list ap);
 
 void sist_log(const char *filepath, int level, char *str);
diff --git a/src/sist.h b/src/sist.h
index 5657c85..ca3414c 100644
--- a/src/sist.h
+++ b/src/sist.h
@@ -51,11 +51,11 @@
 #include <ctype.h>
 #include "git_hash.h"
 
-#define VERSION "3.1.0"
+#define VERSION "3.1.1"
 static const char *const Version = VERSION;
 static const int VersionMajor = 3;
 static const int VersionMinor = 1;
-static const int VersionPatch = 0;
+static const int VersionPatch = 1;
 
 #ifndef SIST_PLATFORM
 #define SIST_PLATFORM unknown
diff --git a/src/web/web_fts.c b/src/web/web_fts.c
index d25cefb..7ff3199 100644
--- a/src/web/web_fts.c
+++ b/src/web/web_fts.c
@@ -170,7 +170,7 @@ fts_search_req_t *get_search_req(struct mg_http_message *hm) {
         cJSON_Delete(json);
         return NULL;
     }
-    if (req_path.val && (strstr(req_path.val->valuestring, "*") || strlen(req_path.val) >= PATH_MAX)) {
+    if (req_path.val && (strstr(req_path.val->valuestring, "*") || strlen(req_path.val->valuestring) >= PATH_MAX)) {
         cJSON_Delete(json);
         return NULL;
     }