Clean out warnings from using shellcheck on the code
There were a big bunch of unquoted variables in the code. Also found the use of legacy cmd instead of $(cmd). Adjusted all of these.
No changes on the lftp lines as I do not really know the lftp syntax that well.