diff -ru digikam-2.1.0-orig/core/libs/database//databaseparameters.cpp digikam-software-compilation/core/libs/database//databaseparameters.cpp
--- digikam-2.1.0-orig/core/libs/database//databaseparameters.cpp	2011-09-07 11:44:12.000000000 +0200
+++ digikam-software-compilation/core/libs/database//databaseparameters.cpp	2011-09-11 16:09:12.201787142 +0200
@@ -412,13 +412,20 @@
     if (imgDatabaseType == "QMYSQL" && internalServer)
     {
         const QString miscDir = KStandardDirs::locateLocal("data", "digikam/db_misc");
-        tmbDatabaseType=    imgDatabaseType= "QMYSQL";
-        tmbDatabaseName =   imgDatabaseName = "digikam";
-        tmbHostName =       imgHostName = QString();
-        tmbPort =           imgPort = -1;
-        tmbUserName =       imgUserName = "root";
-        tmbPassword =       imgPassword = QString();
-        tmbConnectOptions = imgConnectOptions = QString::fromLatin1("UNIX_SOCKET=%1/mysql.socket").arg(miscDir);
+        imgDatabaseType= "QMYSQL";
+        imgDatabaseName = "digikam";
+        imgHostName = QString();
+        imgPort = -1;
+        imgUserName = "root";
+        imgPassword = QString();
+        imgConnectOptions = QString::fromLatin1("UNIX_SOCKET=%1/mysql.socket").arg(miscDir);
+        tmbDatabaseType=    "QMYSQL";
+        tmbDatabaseName =   "digikam";
+        tmbHostName =       QString();
+        tmbPort =           -1;
+        tmbUserName =       "root";
+        tmbPassword =       QString();
+        tmbConnectOptions = QString::fromLatin1("UNIX_SOCKET=%1/mysql.socket").arg(miscDir);
     }
 
     if (imgDatabaseType.isEmpty())
@@ -433,6 +440,9 @@
             kDebug(50003) << configDatabaseType << " Found.";
             imgDatabaseType         = group.readEntry(configDatabaseType, QString());
             imgDatabaseName         = group.readEntry(configDatabaseName, QString());
+            if (imgDatabaseType == QString::fromLatin1("QSQLITE")) {
+                imgDatabaseName = databaseFileSQLite(imgDatabaseName, QString::fromLatin1(DIGIKAM4DB));
+            }
             imgHostName             = group.readEntry(configDatabaseHostName, QString());
             imgPort                 = group.readEntry(configDatabasePort, -1);
             imgUserName             = group.readEntry(configDatabaseUsername, QString());
@@ -441,6 +451,9 @@
 
             tmbDatabaseType         = group.readEntry(configDatabaseType, QString());
             tmbDatabaseName         = group.readEntry(configDatabaseNameThumbnails, QString());
+            if (tmbDatabaseType == QString::fromLatin1("QSQLITE")) {
+                tmbDatabaseName = databaseFileSQLite(tmbDatabaseName, QString::fromLatin1(THUMBNAILS_DIGIKAMDB));
+            }
             tmbHostName             = group.readEntry(configDatabaseHostName, QString());
             tmbPort                 = group.readEntry(configDatabasePort, -1);
             tmbUserName             = group.readEntry(configDatabaseUsername, QString());
@@ -602,12 +615,19 @@
     return parameters;
 }
 
-//FIXME:
 DatabaseParameters DatabaseParameters::thumbnailParameters() const
 {
-    DatabaseParameters params = *this;
-    params.tmbDatabaseName = tmbDatabaseName;
-    return params;
+    DatabaseParameters parameters = *this;
+
+    parameters.imgDatabaseType = tmbDatabaseType;
+    parameters.imgDatabaseName = tmbDatabaseName;
+    parameters.imgHostName     = tmbHostName;
+    parameters.imgUserName     = tmbUserName;
+    parameters.imgPassword     = tmbPassword;
+    parameters.imgPort         = tmbPort;
+    parameters.imgConnectOptions = tmbConnectOptions;
+
+    return parameters;
 }
 
 DatabaseParameters DatabaseParameters::parametersForSQLite(const QString& databaseFile)
diff -ru digikam-2.1.0-orig/core/libs/database//imagehistory/imagehistorygraph.cpp digikam-software-compilation/core/libs/database//imagehistory/imagehistorygraph.cpp
--- digikam-2.1.0-orig/core/libs/database//imagehistory/imagehistorygraph.cpp	2011-09-07 11:44:12.000000000 +0200
+++ digikam-software-compilation/core/libs/database//imagehistory/imagehistorygraph.cpp	2011-09-11 16:09:12.201787142 +0200
@@ -296,10 +296,16 @@
         //kDebug() << "Find by uuid" << uuid << ": found" << v.isNull();
         if (v.isNull())
         {
-            HistoryImageId id = info.historyImageId();
-            v = findVertexByProperties(id);
+            id = info.historyImageId();
+            v  = findVertexByProperties(id);
             //kDebug() << "Find by h-i-m" << ": found" << v.isNull();
         }
+
+        // Need to add new vertex. Do this through the method which will resolve the history id
+        if (v.isNull())
+        {
+            v = addVertex(id);
+        }
     }
 
     applyProperties(v, QList<ImageInfo>() << info, QList<HistoryImageId>() << id);
diff -ru digikam-2.1.0-orig/core/libs/database//imagescanner.cpp digikam-software-compilation/core/libs/database//imagescanner.cpp
--- digikam-2.1.0-orig/core/libs/database//imagescanner.cpp	2011-09-07 11:44:12.000000000 +0200
+++ digikam-software-compilation/core/libs/database//imagescanner.cpp	2011-09-11 16:09:12.201787142 +0200
@@ -869,17 +869,60 @@
     return false;
 }
 
+// Returns true if both have the same UUID, or at least one of the two has no UUID
+// Returns false iff both have a UUID and the UUIDs differ
+static bool uuidDoesNotDiffer(const HistoryImageId& referenceId, qlonglong id)
+{
+    if (referenceId.hasUuid())
+    {
+        QString uuid = DatabaseAccess().db()->getImageUuid(id);
+        if (!uuid.isEmpty())
+        {
+            return referenceId.m_uuid == uuid;
+        }
+    }
+    return true;
+}
+
+static QList<qlonglong> mergedIdLists(const HistoryImageId& referenceId,
+                         const QList<qlonglong>& uuidList, const QList<qlonglong>& candidates)
+{
+    QList<qlonglong> results;
+    // uuidList are definite results
+    results = uuidList;
+
+    // Add a candidate if it has the same UUID, or either reference or candidate  have a UUID
+    // (other way round: do not add a candidate which positively has a different UUID)
+    foreach (qlonglong candidate, candidates)
+    {
+        if (results.contains(candidate))
+        {
+            continue; // already in list, skip
+        }
+
+        if (uuidDoesNotDiffer(referenceId, candidate))
+        {
+            results << candidate;
+        }
+    }
+
+    return results;
+}
+
 QList<qlonglong> ImageScanner::resolveHistoryImageId(const HistoryImageId& historyId)
 {
     // first and foremost: UUID
+    QList<qlonglong> uuidList;
     if (historyId.hasUuid())
     {
-        QList<qlonglong> uuidList = DatabaseAccess().db()->getItemsForUuid(historyId.m_uuid);
+        uuidList = DatabaseAccess().db()->getItemsForUuid(historyId.m_uuid);
 
-        if (!uuidList.isEmpty())
+        // If all images had a UUID, we would be finished and could return here with a result:
+        /*if (!uuidList.isEmpty())
         {
             return uuidList;
-        }
+        }*/
+        // But as identical images may have no UUID yet, we need to continue
     }
 
     // Second: uniqueHash + fileSize. Sufficient to assume that a file is identical, but subject to frequent change.
@@ -897,7 +940,7 @@
                     ids << info.id;
                 }
             }
-            return ids;
+            return mergedIdLists(historyId, uuidList, ids);
         }
     }
 
@@ -909,7 +952,7 @@
 
         if (!ids.isEmpty())
         {
-            return ids;
+            return mergedIdLists(historyId, uuidList, ids);
         }
     }
 
@@ -933,7 +976,7 @@
 
                 if (info.id)
                 {
-                    return QList<qlonglong>() << info.id;
+                    return mergedIdLists(historyId, uuidList, QList<qlonglong>() << info.id);
                 }
             }
         }
