diff --git a/config.defaults b/config.defaults
index bd669cb2cc724a74e3dd81fc708a96dfdd6a4ebe..79e84f48a6a60f45de027a5df278ac51bfe55804 100644
--- a/config.defaults
+++ b/config.defaults
@@ -23,13 +23,14 @@
 
 # # Commands
 # The MySQL client program.
-MYSQL_CMD=$(command -v mysql)
+MYSQL_CMD=$(command -v mysql || echo "mysql not found!" >&2)
 # The mysqladmin program which comes with the MySQL client.
-MYSQLADMIN_CMD=$(command -v mysqladmin)
+MYSQLADMIN_CMD=$(command -v mysqladmin || echo "mysqladmin not found!" >&2)
 # The mysqldump program which comes with the MySQL client.
-MYSQLDUMP_CMD=$(command -v mysqldump)
+MYSQLDUMP_CMD=$(command -v mysqldump || echo "mysqldump not found!" >&2)
 # The mysql_config_editor program which is used to store the credentials.
-MYSQL_CONFIG_EDITOR_CMD=$(command -v mysql_config_editor)
+MYSQL_CONFIG_EDITOR_CMD=$(command -v mysql_config_editor \
+                              || echo "mysql_config_editor not found!" >&2)
 
 # # MySQL Connection
 # The host of the MySQL server.
diff --git a/patches/applyPatches.sh b/patches/applyPatches.sh
index 56cbac7e05a1528ee041540ed84cc7faf7b3a5d6..a0c8e045e8cb31bff64cb458a091e89a59be80cc 100755
--- a/patches/applyPatches.sh
+++ b/patches/applyPatches.sh
@@ -24,12 +24,29 @@
 # ** end header
 #
 
-#apply all available patches.
+###############################################################################
+#                         Apply all available patches                         #
+###############################################################################
+
 set -e
+
+if [ -z "$UTILSPATH" ]; then
+    UTILSPATH=$(realpath "$(dirname $0)/../utils")
+    export UTILSPATH
+	MAINPATH="$(dirname $UTILSPATH)"
+	export MAINPATH
+fi
+
+source $UTILSPATH/load_settings.sh
+source $UTILSPATH/helpers.sh
+
 PATCHES="./patch*/patch.sh"
 
 for p in $PATCHES
 do
+    echo "$p"
+    env | grep MYSQL | sort
+    export | grep MYSQL | sort
     $p "$@" --patch=$p
 done
 
diff --git a/utils/backup.sh b/utils/backup.sh
index 92a20c816832873e4634ddf97d9cc1b17a85e495..aab15415b1490c53cef7809cdb7366fa871b62b3 100755
--- a/utils/backup.sh
+++ b/utils/backup.sh
@@ -24,10 +24,11 @@
 
 # Dump a database with all procedures, permissions, structure and data
 
-
 if [ -z "$UTILSPATH" ]; then
 	UTILSPATH="$(realpath $(dirname $0))"
 	export UTILSPATH
+	MAINPATH="$(dirname $UTILSPATH)"
+	export MAINPATH
 fi
 
 # The directory which the dump is to be stored to. Do not change it here. Use
diff --git a/utils/helpers.sh b/utils/helpers.sh
index b1f6d19c2270f8b3207a88f36151f6633318cfc5..4ecf8789b650d9463639b119dcda1bfe2bce2bcd 100644
--- a/utils/helpers.sh
+++ b/utils/helpers.sh
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2018 Research Group Biomedical Physics,
 # Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-# Copyright 2019 Daniel Hornung
+# Copyright 2019, 2020 Daniel Hornung
 # Copyright 2020 Henrik tom Wörden, IndiScale GmbH
 #
 # This program is free software: you can redistribute it and/or modify
@@ -19,15 +19,27 @@
 # along with this program. If not, see <https://www.gnu.org/licenses/>.
 
 
+
+###############################################################################
+#                         Helper function definitions                         #
+###############################################################################
+
+# When sourcing this file, the following variables must be set:
+#
+# MYSQL_CMD : source $UTILSPATH/load_settings.sh
+
+
+
 function mysql_execute {
-	#TODO is it meaningful that here always the database user is used???
-	set +e
-	$MYSQL_CMD $(get_db_args) -e "$1"
-	ret=${PIPESTATUS[0]}
-	if [ "$ret" -ne 0 ]; then
-		failure "MYSQL ERROR"
-	fi
-	set -e
+	  #TODO is it meaningful that here always the database user is used???
+	  set +e
+    # env | sort
+	  $MYSQL_CMD $(get_db_args) -e "$1"
+	  ret=${PIPESTATUS[0]}
+	  if [ "$ret" -ne 0 ]; then
+		    failure "MYSQL ERROR"
+	  fi
+	  set -e
 }
 
 function get_mysql_args {
diff --git a/utils/load_settings.sh b/utils/load_settings.sh
index a001b98b4e9188ac89f8200069dad3a34e2ea354..a46db58d2c4c3d1e4a87d1f2b831f77bc6163b1b 100644
--- a/utils/load_settings.sh
+++ b/utils/load_settings.sh
@@ -18,9 +18,34 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program. If not, see <https://www.gnu.org/licenses/>.
 
-[[ -n "config.defaults" ]] && source "config.defaults"
-[[ -n ".config" ]] && source ".config"
-[[ -n "$ENV_FILE" ]] && source "$ENV_FILE"
+# Load setting from different files, in this order:
+# - config.defaults (in the current directory)
+# - .config (in the current directory)
+# - The file given in ENV_FILE.
+
+if [ "$MAINPATH" ]; then
+    pushd "$MAINPATH" > /dev/null
+    pushed=1
+fi
+
+if [[ -r "config.defaults" ]] ; then
+    source "config.defaults"
+fi
+if [[ -r ".config" ]] ; then
+    source ".config"
+fi
+if [[ -n "$ENV_FILE" ]] ; then
+    source "$ENV_FILE"
+fi
+
+if [[ -z "$MYSQL_CMD" ]] ; then
+    echo "mysql not defined!"
+    exit 1
+fi
+
+if [ $pushed ]; then
+    popd > /dev/null
+fi
 
 export MYSQL_CMD
 export MYSQLDUMP_CMD
diff --git a/utils/make_db b/utils/make_db
index bd175b6565e5eda26ff68f591ab2b85855b849b2..92a8541c73d55b9a2c5d779926afb27b2ed2415d 100755
--- a/utils/make_db
+++ b/utils/make_db
@@ -22,18 +22,20 @@
 #
 # ** end header
 
+set -e
+
 INSTALL_SQL_FILE="db_2_0.sql"
 
 if [ -z "$UTILSPATH" ]; then
 	UTILSPATH="$(realpath $(dirname $0))"
 	export UTILSPATH
+	MAINPATH="$(dirname $UTILSPATH)"
+	export MAINPATH
 fi
 
 source $UTILSPATH/load_settings.sh
 source $UTILSPATH/helpers.sh
 
-set -e
-
 function fail() {
   echo "Some error occured, exiting."
   exit 1
@@ -131,6 +133,7 @@ function restore_db() {
 }
 
 function test-connection() {
+    echo $MYSQL_CMD $(get_mysql_args_nodb) -e "select 0;"
     $MYSQL_CMD $(get_mysql_args_nodb) -e "select 0;"
 }
 
diff --git a/utils/patch_header.sh b/utils/patch_header.sh
index 7f85505234b2b5dd1232d2f7614b73908e70efc2..f53266aabd96b316ecf2c17948384c505e5a9d87 100644
--- a/utils/patch_header.sh
+++ b/utils/patch_header.sh
@@ -24,7 +24,8 @@
 #header for patch scripts
 
 # load useful functions #######################################################
-. $UTILSPATH/helpers.sh
+source $UTILSPATH/load_settings.sh
+source $UTILSPATH/helpers.sh
 
 USAGE="$1 [ --env=ENV_FILE ] [ --patch=PATCH ] [ --backupdir=BACKUPDIR ]\n\n"
 CMD_OPTIONS=$(cat <<EOF
diff --git a/utils/update_sql_procedures.sh b/utils/update_sql_procedures.sh
index 73f6bacc86c80bc5b1be83e2c9c762777f99e878..2b78ab8cca5b1d337fa03d9ab3bb2e2e120a3be0 100755
--- a/utils/update_sql_procedures.sh
+++ b/utils/update_sql_procedures.sh
@@ -24,7 +24,15 @@
 
 # Updates all SQL procedures
 
+if [ -z "$UTILSPATH" ]; then
+    UTILSPATH=$(realpath "$(dirname $0)")
+    export UTILSPATH
+	MAINPATH="$(dirname $UTILSPATH)"
+	export MAINPATH
+fi
+
 source $UTILSPATH/helpers.sh
+source $UTILSPATH/load_settings.sh
 
 echo -n "updating rules ... "
 set -e