diff --git a/src/collection/sqlcollection/ScanResultProcessor.cpp b/src/collection/sqlcollection/ScanResultProcessor.cpp
index aa0d51f..e6968cc 100644
--- a/src/collection/sqlcollection/ScanResultProcessor.cpp
+++ b/src/collection/sqlcollection/ScanResultProcessor.cpp
@@ -477,9 +477,10 @@ ScanResultProcessor::addTrack( const QVariantMap &trackData, int albumArtistId )
         m_nextTrackNum--;
     }
     else
+    {
         m_tracksHashByUrl.insert( url, trackList );
-
-    m_tracksHashById.insert( id, trackList );
+        m_tracksHashById.insert( id, trackList );
+    }
 
     if( m_tracksHashByAlbum.contains( album ) && m_tracksHashByAlbum[album] != 0 )
         m_tracksHashByAlbum[album]->append( trackList );
@@ -696,12 +697,13 @@ ScanResultProcessor::urlId( const QString &url, const QString &uid )
     if( currUrlIdValues[1] == QString::number( deviceId ) && currUrlIdValues[2] == rpath )
     {
         //We found an existing path; give it the most recent UID value
+        debug() << "In urlId, found deviceid " << QString::number( deviceId ) << " and rpath " << rpath;
         int urlId = currUrlIdValues[0].toInt();
         if( m_urlsHashById.contains( urlId ) && m_urlsHashById[urlId] != 0 )
         {
             QStringList *list = m_urlsHashById[urlId];
+            debug() << "Replacing hash " << list->at( 4 ) << " with " << uid;
             list->replace( 4, uid );
-            //debug() << "Hash updated path-based values for uid " << uid;
         }
 
         m_permanentTablesUidUpdates.insert( url, uid );
@@ -898,12 +900,13 @@ ScanResultProcessor::setupDatabase()
         populateCacheHashes();
         // /*
         debug() << "Next URL num: " << m_nextUrlNum;
-        //foreach( QString key, m_urlsHashByUid.keys() )
-        //    debug() << "Key: " << key << ", list: " << *m_urlsHashByUid[key];
-        //foreach( int key, m_urlsHashById.keys() )
-        //    debug() << "Key: " << key << ", list: " << *m_urlsHashById[key];
-        //foreach( QPair<int, QString> key, m_urlsHashByLocation.keys() )
-        //    debug() << "Key: " << key << ", list: " << *m_urlsHashByLocation[key];
+        foreach( QString key, m_urlsHashByUid.keys() )
+            debug() << "Key: " << key << ", list: " << *m_urlsHashByUid[key];
+        foreach( int key, m_urlsHashById.keys() )
+            debug() << "Key: " << key << ", list: " << *m_urlsHashById[key];
+        typedef QPair<int, QString> blahType; //QFOREACH is stupid when it comes to QPairs
+        foreach( blahType key, m_urlsHashByLocation.keys() )
+            debug() << "Key: " << key << ", list: " << *m_urlsHashByLocation[key];
         debug() << "Next album num: " << m_nextAlbumNum;
         //foreach( int key, m_albumsHashById.keys() )
         //    debug() << "Key: " << key << ", list: " << *m_albumsHashById[key];
@@ -1113,6 +1116,7 @@ ScanResultProcessor::copyHashesToTempTables()
     foreach( int key, keys )
     {
         currList = m_urlsHashById[key];
+        debug() << "inserting following list: " << currList;
         currQuery =   "(" + currList->at( 0 ) + ","
                           + ( currList->at( 1 ).isEmpty() ? "NULL" : currList->at( 1 ) ) + ","
                           + "'" + m_collection->escape( currList->at( 2 ) ) + "',"
@@ -1121,7 +1125,7 @@ ScanResultProcessor::copyHashesToTempTables()
         if( query.size() + currQuery.size() + 1 >= maxSize - 3 ) // ";"
         {
             query += ";";
-            //debug() << "inserting " << query << ", size " << query.size();
+            debug() << "inserting " << query << ", size " << query.size();
             m_collection->insert( query );
             query = queryStart;
             valueReady = false;
@@ -1130,15 +1134,19 @@ ScanResultProcessor::copyHashesToTempTables()
         if( !valueReady )
         {
             query += currQuery;
+            debug() << "appending " << currQuery;
             valueReady = true;
         }
         else
+        {
+            debug() << "appending , + " << currQuery;
             query += "," + currQuery;
+        }
     }
     if( query != queryStart )
     {
         query += ";";
-        //debug() << "inserting " << query << ", size " << query.size();
+        debug() << "inserting " << query << ", size " << query.size();
         m_collection->insert( query );
     }
     keys.clear();
