--- old-pie/rhythmdb/rhythmdb-tree.c	2006-05-22 18:18:19.000000000 +1000
+++ new-pie/rhythmdb/rhythmdb-tree.c	2006-05-22 18:18:19.000000000 +1000
@@ -1046,6 +1046,7 @@
 	artist = get_or_create_artist (db, genre, entry->artist);
 	set_entry_album (db, entry, artist, entry->album);
 
+	/* this accounts for the initial reference on the entry */
 	g_hash_table_insert (db->priv->entries, entry->location, entry);
 }
 
@@ -1332,6 +1333,7 @@
 	g_assert (g_hash_table_lookup (db->priv->entries, entry->location) != NULL);
 
 	g_hash_table_remove (db->priv->entries, entry->location);
+	rhythmdb_entry_unref (adb, entry);
 }
 
 typedef struct {
@@ -1348,6 +1350,7 @@
 	if (entry->type == ctxt->type) {
 		rhythmdb_emit_entry_deleted (ctxt->db, entry);
 		remove_entry_from_album (RHYTHMDB_TREE (ctxt->db), entry); 
+		rhythmdb_entry_unref (ctxt->db, entry);
 		return TRUE;
 	}
 	return FALSE;

--- old-pie/rhythmdb/rhythmdb.c	2006-05-22 18:18:19.000000000 +1000
+++ new-pie/rhythmdb/rhythmdb.c	2006-05-22 18:18:19.000000000 +1000
@@ -807,8 +807,8 @@
 {
 	if (thread != g_thread_self ())
 		return FALSE;
-	
-	rhythmdb_entry_ref (db, entry);
+
+	/* carry reference over from deleted_entries hash table */
 	db->priv->deleted_entries_to_emit = g_list_prepend (db->priv->deleted_entries_to_emit, entry);
 	return TRUE;
 }
