Make sure the script exits in a clean way when no output file was specified. Also some more random cleaning in SqliteDB here...