diff -u -p -r1.33 rb-daap-connection.c
--- daapsharing/rb-daap-connection.c	14 Jul 2006 12:25:03 -0000	1.33
+++ daapsharing/rb-daap-connection.c	17 Jul 2006 10:54:24 -0000
@@ -1763,6 +1763,9 @@ rb_daap_connection_set_property (GObject
 		priv->name = g_value_dup_string (value);
 		break;
 	case PROP_DB:
+		if (priv->db != NULL) {
+			g_object_unref (priv->db);
+		}
 		priv->db = RHYTHMDB (g_value_dup_object (value));
 		break;
 	case PROP_PASSWORD_PROTECTED:
diff -u -p -r1.23 rb-daap-share.c
--- daapsharing/rb-daap-share.c	14 Jul 2006 12:25:03 -0000	1.23
+++ daapsharing/rb-daap-share.c	17 Jul 2006 10:54:26 -0000
@@ -271,6 +271,21 @@ rb_daap_share_set_password (RBDAAPShare 
 }
 
 static void
+rb_daap_share_set_db (RBDAAPShare *share,
+		      RhythmDB    *db)
+{
+	if (share->priv->db != NULL) {
+		g_object_unref (share->priv->db);
+	}
+
+	share->priv->db = db;
+
+	if (share->priv->db != NULL) {
+		g_object_ref (share->priv->db);
+	}
+}
+
+static void
 rb_daap_share_set_playlist_manager (RBDAAPShare       *share,
 				    RBPlaylistManager *playlist_manager)
 {
@@ -278,19 +293,30 @@ rb_daap_share_set_playlist_manager (RBDA
 
 	g_return_if_fail (share != NULL);
 
+	if (share->priv->playlist_manager != NULL) {
+		g_object_unref (share->priv->playlist_manager);
+		g_signal_handlers_disconnect_by_func (share->priv->playlist_manager,
+						      G_CALLBACK (rb_daap_share_playlist_created),
+						      share);
+	}
+
 	share->priv->playlist_manager = playlist_manager;
 
-	g_signal_connect_object (G_OBJECT (share->priv->playlist_manager),
-				 "playlist_added",
-				 G_CALLBACK (rb_daap_share_playlist_created),
-				 share, 0);
+	if (share->priv->playlist_manager != NULL) {
+		g_object_ref (share->priv->playlist_manager);
 
-	/* Currently, there are no playlists when this object is created, but in
-	 * case it changes..
-	 */
-	playlists = rb_playlist_manager_get_playlists (share->priv->playlist_manager);
-	g_list_foreach (playlists, (GFunc) rb_daap_share_process_playlist, share);
-	g_list_free (playlists);
+		g_signal_connect_object (G_OBJECT (share->priv->playlist_manager),
+					 "playlist_added",
+					 G_CALLBACK (rb_daap_share_playlist_created),
+					 share, 0);
+
+		/* Currently, there are no playlists when this object is created, but in
+		 * case it changes..
+		 */
+		playlists = rb_playlist_manager_get_playlists (share->priv->playlist_manager);
+		g_list_foreach (playlists, (GFunc) rb_daap_share_process_playlist, share);
+		g_list_free (playlists);
+	}
 }
 
 static void
@@ -309,7 +335,7 @@ rb_daap_share_set_property (GObject *obj
 		rb_daap_share_set_password (share, g_value_get_string (value));
 		break;
 	case PROP_DB:
-		share->priv->db = g_value_get_object (value);
+		rb_daap_share_set_db (share, g_value_get_object (value));
 		break;
 	case PROP_PLAYLIST_MANAGER:
 		rb_daap_share_set_playlist_manager (share, g_value_get_object (value));
@@ -1064,11 +1090,13 @@ add_playlist_to_mlcl (RBPlaylistID *play
 	guint num_songs;
 	RhythmDBQueryModel *model;
 
-	g_object_get (G_OBJECT (playlist_id->source), "name", &name, NULL);
-	g_object_get (G_OBJECT (playlist_id->source), "query-model", &model, NULL);
+	g_object_get (playlist_id->source,
+		      "name", &name,
+		      "query-model", &model,
+		      NULL);
 
 	num_songs = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
-	g_object_unref (G_OBJECT (model));
+	g_object_unref (model);
 
 	mlit = rb_daap_structure_add (mlcl, RB_DAAP_CC_MLIT);
 	rb_daap_structure_add (mlit, RB_DAAP_CC_MIID, playlist_id->id);
@@ -1343,7 +1371,7 @@ databases_cb (RBDAAPShare *share,
 
 			mb.pointer = share->priv->entry_to_id;
 
-			g_object_get (G_OBJECT (id->source), "query-model", &model, NULL);
+			g_object_get (id->source, "query-model", &model, NULL);
 			num_songs = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
 
 			rb_daap_structure_add (apso, RB_DAAP_CC_MTCO, (gint32) num_songs);
diff -u -p -r1.6 rb-daap-sharing.c
--- daapsharing/rb-daap-sharing.c	14 Jul 2006 12:25:03 -0000	1.6
+++ daapsharing/rb-daap-sharing.c	17 Jul 2006 10:54:26 -0000
@@ -69,7 +69,9 @@ create_share (RBShell *shell)
 		eel_gconf_set_string (CONF_DAAP_SHARE_NAME, name);
 	}
 
-	g_object_get (G_OBJECT (shell), "db", &db, "playlist-manager", &playlist_manager, NULL);
+	g_object_get (shell,
+		      "db", &db,
+		      "playlist-manager", &playlist_manager, NULL);
 
 	require_password = eel_gconf_get_boolean (CONF_DAAP_REQUIRE_PASSWORD);
 	if (require_password) {
@@ -79,6 +81,9 @@ create_share (RBShell *shell)
 	}
 
 	share = rb_daap_share_new (name, password, db, playlist_manager);
+
+	g_object_unref (db);
+	g_object_unref (playlist_manager);
 
 	g_free (name);
 	g_free (password);
diff -u -p -r1.24 rb-new-station-dialog.c
--- iradio/rb-new-station-dialog.c	14 Jul 2006 12:26:10 -0000	1.24
+++ iradio/rb-new-station-dialog.c	17 Jul 2006 10:56:28 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <time.h>
@@ -39,14 +39,6 @@
 static void rb_new_station_dialog_class_init (RBNewStationDialogClass *klass);
 static void rb_new_station_dialog_init (RBNewStationDialog *dialog);
 static void rb_new_station_dialog_finalize (GObject *object);
-static void rb_new_station_dialog_set_property (GObject *object,
-						guint prop_id,
-						const GValue *value,
-						GParamSpec *pspec);
-static void rb_new_station_dialog_get_property (GObject *object,
-						guint prop_id,
-						GValue *value,
-						GParamSpec *pspec);
 static void rb_new_station_dialog_response_cb (GtkDialog *gtkdialog,
 					       int response_id,
 					       RBNewStationDialog *dialog);
@@ -55,9 +47,6 @@ static void rb_new_station_dialog_text_c
 
 struct RBNewStationDialogPrivate
 {
-	RBEntryView *entry_view;
-	RhythmDB    *db;
-
 	GtkWidget   *url;
 	GtkWidget   *okbutton;
 	GtkWidget   *cancelbutton;
@@ -67,12 +56,6 @@ struct RBNewStationDialogPrivate
 
 enum
 {
-	PROP_0,
-	PROP_ENTRY_VIEW
-};
-
-enum
-{
 	LOCATION_ADDED,
 	LAST_SIGNAL
 };
@@ -86,18 +69,8 @@ rb_new_station_dialog_class_init (RBNewS
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	object_class->set_property = rb_new_station_dialog_set_property;
-	object_class->get_property = rb_new_station_dialog_get_property;
 	object_class->finalize = rb_new_station_dialog_finalize;
 
-	g_object_class_install_property (object_class,
-					 PROP_ENTRY_VIEW,
-					 g_param_spec_object ("entry-view",
-					                      "RBEntryView",
-					                      "RBEntryView object",
-					                      RB_TYPE_ENTRY_VIEW,
-					                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
 	rb_new_station_dialog_signals [LOCATION_ADDED] =
 		g_signal_new ("location-added",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -179,55 +152,12 @@ rb_new_station_dialog_finalize (GObject 
 	G_OBJECT_CLASS (rb_new_station_dialog_parent_class)->finalize (object);
 }
 
-static void
-rb_new_station_dialog_set_property (GObject *object,
-				    guint prop_id,
-				    const GValue *value,
-				    GParamSpec *pspec)
-{
-	RBNewStationDialog *dialog = RB_NEW_STATION_DIALOG (object);
-
-	switch (prop_id) {
-	case PROP_ENTRY_VIEW:
-		dialog->priv->entry_view = g_value_get_object (value);
-		g_object_get (G_OBJECT (dialog->priv->entry_view), "db",
-			      &dialog->priv->db, NULL);
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-		break;
-	}
-}
-
-static void
-rb_new_station_dialog_get_property (GObject *object,
-				    guint prop_id,
-				    GValue *value,
-				    GParamSpec *pspec)
-{
-	RBNewStationDialog *dialog = RB_NEW_STATION_DIALOG (object);
-
-	switch (prop_id) {
-	case PROP_ENTRY_VIEW:
-		g_value_set_object (value, dialog->priv->entry_view);
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-		break;
-	}
-}
-
 GtkWidget *
 rb_new_station_dialog_new (RBEntryView *view)
 {
 	RBNewStationDialog *dialog;
 
-	g_return_val_if_fail (RB_ENTRY_VIEW (view), NULL);
-
-	dialog = g_object_new (RB_TYPE_NEW_STATION_DIALOG,
-			       "entry-view", view, NULL);
-
-	g_return_val_if_fail (dialog->priv != NULL, NULL);
+	dialog = g_object_new (RB_TYPE_NEW_STATION_DIALOG, NULL);
 
 	return GTK_WIDGET (dialog);
 }
diff -u -p -r1.34 rb-station-properties-dialog.c
--- iradio/rb-station-properties-dialog.c	14 Jul 2006 12:26:10 -0000	1.34
+++ iradio/rb-station-properties-dialog.c	17 Jul 2006 10:56:28 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <time.h>
@@ -73,7 +73,7 @@ static void rb_station_properties_dialog
 struct RBStationPropertiesDialogPrivate
 {
 	RBEntryView *entry_view;
-	RhythmDB *db;
+	RhythmDB    *db;
 	RhythmDBEntry *current_entry;
 
 	GtkWidget   *title;
@@ -200,6 +200,10 @@ rb_station_properties_dialog_finalize (G
 
 	g_return_if_fail (dialog->priv != NULL);
 
+	if (dialog->priv->db != NULL) {
+		g_object_unref (dialog->priv->db);
+	}
+
 	G_OBJECT_CLASS (rb_station_properties_dialog_parent_class)->finalize (object);
 }
 
@@ -213,9 +217,14 @@ rb_station_properties_dialog_set_propert
 
 	switch (prop_id) {
 	case PROP_ENTRY_VIEW:
+		if (dialog->priv->db != NULL) {
+			g_object_unref (dialog->priv->db);
+		}
+
 		dialog->priv->entry_view = g_value_get_object (value);
-		g_object_get (G_OBJECT (dialog->priv->entry_view), "db",
-			      &dialog->priv->db, NULL);
+
+		g_object_get (G_OBJECT (dialog->priv->entry_view),
+			      "db", &dialog->priv->db, NULL);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -287,7 +296,15 @@ rb_station_properties_dialog_get_current
 		return FALSE;
 	}
 
-	dialog->priv->current_entry = selected_entries->data;
+	if (dialog->priv->current_entry != NULL) {
+		rhythmdb_entry_unref (dialog->priv->current_entry);
+	}
+
+	dialog->priv->current_entry = rhythmdb_entry_ref (selected_entries->data);
+
+	g_list_foreach (selected_entries, (GFunc)rhythmdb_entry_unref, NULL);
+	g_list_free (selected_entries);
+
 	return TRUE;
 }
 
diff -u -p -r1.52 rb-file-helpers.c
--- lib/rb-file-helpers.c	4 Jul 2006 22:54:46 -0000	1.52
+++ lib/rb-file-helpers.c	17 Jul 2006 10:56:29 -0000
@@ -642,8 +642,6 @@ rb_uri_handle_recursively_cb (const gcha
 			      RBUriHandleRecursivelyData *data,
 			      gboolean *recurse)
 {
-	char *path;
-
 	if (data->cancel_flag && *data->cancel_flag)
 		return TRUE;
 
@@ -656,7 +654,9 @@ rb_uri_handle_recursively_cb (const gcha
 	}
 
 	if (info->type == GNOME_VFS_FILE_TYPE_REGULAR) {
-		char *escaped_rel_path = gnome_vfs_escape_path_string (rel_path);
+		char *path, *escaped_rel_path;
+
+		escaped_rel_path = gnome_vfs_escape_path_string (rel_path);
 		escaped_rel_path = escape_extra_gnome_vfs_chars (escaped_rel_path);
 		path = g_build_filename (data->uri, escaped_rel_path, NULL);
 		(data->func) (path, data->user_data);
diff -u -p -r1.12 rb-tree-dnd.c
--- lib/rb-tree-dnd.c	8 Jun 2006 07:19:42 -0000	1.12
+++ lib/rb-tree-dnd.c	17 Jul 2006 10:56:30 -0000
@@ -270,7 +270,7 @@ init_rb_tree_dnd_data (GtkWidget *widget
 	{
 		priv_data = g_new0 (RbTreeDndData, 1);
 		priv_data->pending_event = FALSE;
-		g_object_set_data (G_OBJECT (widget), RB_TREE_DND_STRING, priv_data);
+		g_object_set_data_full (G_OBJECT (widget), RB_TREE_DND_STRING, priv_data, g_free);
 		priv_data->drag_motion_handler = 0;
 		priv_data->drag_leave_handler = 0;
 		priv_data->button_press_event_handler = 0;
diff -u -p -r1.6 CoverArtDatabase.py
--- plugins/artdisplay/artdisplay/CoverArtDatabase.py	12 Jul 2006 02:44:28 -0000	1.6
+++ plugins/artdisplay/artdisplay/CoverArtDatabase.py	17 Jul 2006 10:56:36 -0000
@@ -110,7 +110,7 @@ class CoverArtDatabase (object):
 	def write_blist (self, blist_location, blist):
 		if blist:
 			blist_file = file (blist_location, 'w')
-			blist_file.writelines ("%s\n" % b for b in blist)
+			blist_file.writelines (blist)
 			blist_file.close ()
 		elif os.path.exists (blist_location):
 			os.unlink (blist_location)
diff -u -p -r1.16 rb-generic-player-source.c
--- plugins/generic-player/rb-generic-player-source.c	11 Jul 2006 11:29:21 -0000	1.16
+++ plugins/generic-player/rb-generic-player-source.c	17 Jul 2006 10:56:38 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  *  arch-tag: Implementation of generic audio player source object
  *
  *  Copyright (C) 2004 James Livingston  <jrl@ids.org.au>
@@ -21,12 +22,13 @@
 
 #define __EXTENSIONS__
 
-#include <config.h>
+#include "config.h"
 
-#include <gtk/gtktreeview.h>
 #include <string.h>
-#include "rhythmdb.h"
-#include <libgnome/gnome-i18n.h>
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
 #ifdef HAVE_HAL_0_5
 #include <libhal.h>
 #include <dbus/dbus.h>
@@ -81,7 +83,7 @@ typedef struct
 	/* information derived from gnome-vfs volume */
 	gboolean read_only;
 	gboolean handles_trash;
-	
+
 	/* information derived from HAL */
 	char **audio_folders;
 	gboolean playlist_format_unknown;
@@ -250,7 +252,7 @@ rb_generic_player_source_get_device_info
 #endif
 }
 
-static void 
+static void
 rb_generic_player_source_dispose (GObject *object)
 {
 	RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (object);
@@ -259,7 +261,7 @@ rb_generic_player_source_dispose (GObjec
 		g_object_unref (G_OBJECT (priv->db));
 		priv->db = NULL;
 	}
-	
+
 	G_OBJECT_CLASS (rb_generic_player_source_parent_class)->dispose (object);
 }
 
@@ -290,11 +292,11 @@ rb_generic_player_source_new (RBShell *s
 	g_object_unref (G_OBJECT (db));
 
 	source = RB_GENERIC_PLAYER_SOURCE (g_object_new (RB_TYPE_GENERIC_PLAYER_SOURCE,
-					  "entry-type", entry_type,
-					  "volume", volume,
-					  "shell", shell,
-					  "sourcelist-group", RB_SOURCELIST_GROUP_REMOVABLE,
-					  NULL));
+							 "entry-type", entry_type,
+							 "volume", volume,
+							 "shell", shell,
+							 "sourcelist-group", RB_SOURCELIST_GROUP_REMOVABLE,
+							 NULL));
 
 	rb_generic_player_source_get_device_info (source);
 	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);
@@ -473,19 +475,20 @@ handle_playlist_entry_cb (TotemPlParser 
 			  const char *genre, HandlePlaylistEntryData *data)
 {
 	char *local_uri;
-	const char *name;
+	char *name;
 
 	local_uri = rb_generic_player_source_transform_playlist_uri (data->player_source, uri);
 	if (local_uri == NULL)
 		return;
-	
+
 	g_object_get (G_OBJECT (data->source), "name", &name, NULL);
 	rb_debug ("adding '%s' as '%s' to playlist '%s'", uri, local_uri, name);
 	rb_static_playlist_source_add_location (data->source, local_uri, -1);
 	g_free (local_uri);
+	g_free (name);
 }
 
-static void 
+static void
 load_playlist_file (RBGenericPlayerSource *source,
 		    const char *playlist_path,
 		    const char *rel_path)
@@ -713,4 +716,3 @@ free_dbus_error (const char *what, DBusE
 
 
 #endif
-
diff -u -p -r1.10 rb-nokia770-source.c
--- plugins/generic-player/rb-nokia770-source.c	11 Jul 2006 11:29:21 -0000	1.10
+++ plugins/generic-player/rb-nokia770-source.c	17 Jul 2006 10:56:38 -0000
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  *  arch-tag: Implementation of Nokia 770 source object
  *
  *  Copyright (C) 2006 James Livingston  <jrl@ids.org.au>
@@ -21,16 +22,16 @@
 
 #define __EXTENSIONS__
 
-#include <config.h>
+#include "config.h"
 
-#include <gtk/gtktreeview.h>
 #include <string.h>
-#include "rhythmdb.h"
-#include <libgnome/gnome-i18n.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <dbus/dbus.h>
+#include <libhal.h>
 #include <libgnomevfs/gnome-vfs-volume.h>
 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libhal.h>
-#include <dbus/dbus.h>
 
 #include "eel-gconf-extensions.h"
 #include "rb-nokia770-source.h"
@@ -81,16 +82,16 @@ rb_nokia770_source_new (RBShell *shell, 
 
 	g_assert (rb_nokia770_is_volume_player (volume));
 
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-	entry_type =  rhythmdb_entry_register_type (db, NULL);
-	g_object_unref (G_OBJECT (db));
+	g_object_get (shell, "db", &db, NULL);
+	entry_type = rhythmdb_entry_register_type (db, NULL);
+	g_object_unref (db);
 
 	source = RB_NOKIA770_SOURCE (g_object_new (RB_TYPE_NOKIA770_SOURCE,
-					  "entry-type", entry_type,
-					  "volume", volume,
-					  "shell", shell,
-					  "sourcelist-group", RB_SOURCELIST_GROUP_REMOVABLE,
-					  NULL));
+						   "entry-type", entry_type,
+						   "volume", volume,
+						   "shell", shell,
+						   "sourcelist-group", RB_SOURCELIST_GROUP_REMOVABLE,
+						   NULL));
 
 	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);
 
@@ -130,7 +131,7 @@ hal_udi_is_nokia770 (const char *udi)
 
 	result = FALSE;
 	dbus_error_init (&error);
-	
+
 	conn = NULL;
 	ctx = libhal_ctx_new ();
 	if (ctx == NULL) {
@@ -172,10 +173,10 @@ hal_udi_is_nokia770 (const char *udi)
 		}
 	}
 	
+end:
 	g_free (parent_name);
-		
 	g_free (parent_udi);
-end:
+
 	if (dbus_error_is_set (&error)) {
 		rb_debug ("Error: %s\n", error.message);
 		dbus_error_free (&error);
diff -u -p -r1.10 rb-psp-source.c
--- plugins/generic-player/rb-psp-source.c	11 Jul 2006 11:29:21 -0000	1.10
+++ plugins/generic-player/rb-psp-source.c	17 Jul 2006 10:56:38 -0000
@@ -218,7 +218,6 @@ hal_udi_is_psp (const char *udi)
 		
 	parent_name = libhal_device_get_property_string (ctx, parent_udi,
 			"storage.model", &error);
-	g_free (parent_udi);
 	if (parent_name == NULL || dbus_error_is_set (&error))
 		goto end;
 
@@ -226,8 +225,10 @@ hal_udi_is_psp (const char *udi)
 		result = TRUE;
 	}
 
-	g_free (parent_name);
 end:
+	g_free (parent_udi);
+	g_free (parent_name);
+
 	if (dbus_error_is_set (&error)) {
 		rb_debug ("Error: %s\n", error.message);
 		dbus_error_free (&error);
diff -u -p -r1.51 rb-podcast-manager.c
--- podcast/rb-podcast-manager.c	14 Jul 2006 12:28:24 -0000	1.51
+++ podcast/rb-podcast-manager.c	17 Jul 2006 10:57:55 -0000
@@ -20,6 +20,8 @@
  *
  */
 
+#include "config.h"
+
 #include <string.h>
 #define __USE_XOPEN
 #include <time.h>
diff -u -p -r1.11 rb-podcast-properties-dialog.c
--- podcast/rb-podcast-properties-dialog.c	14 Jul 2006 12:28:24 -0000	1.11
+++ podcast/rb-podcast-properties-dialog.c	17 Jul 2006 10:57:56 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <time.h>
@@ -202,10 +202,30 @@ rb_podcast_properties_dialog_finalize (G
 
 	g_return_if_fail (dialog->priv != NULL);
 
+	if (dialog->priv->db != NULL) {
+		g_object_unref (dialog->priv->db);
+	}
+
 	G_OBJECT_CLASS (rb_podcast_properties_dialog_parent_class)->finalize (object);
 }
 
 static void
+rb_podcast_properties_dialog_set_entry_view (RBPodcastPropertiesDialog *dialog,
+					     RBEntryView               *view)
+{
+	if (dialog->priv->db != NULL) {
+		g_object_unref (dialog->priv->db);
+	}
+
+	dialog->priv->entry_view = view;
+
+	if (dialog->priv->entry_view != NULL) {
+		g_object_get (dialog->priv->entry_view,
+			      "db", &dialog->priv->db, NULL);
+	}
+}
+
+static void
 rb_podcast_properties_dialog_set_property (GObject *object,
 					   guint prop_id,
 					   const GValue *value,
@@ -215,9 +235,7 @@ rb_podcast_properties_dialog_set_propert
 
 	switch (prop_id) {
 	case PROP_ENTRY_VIEW:
-		dialog->priv->entry_view = g_value_get_object (value);
-		g_object_get (G_OBJECT (dialog->priv->entry_view), "db",
-			      &dialog->priv->db, NULL);
+		rb_podcast_properties_dialog_set_entry_view (dialog, g_value_get_object (value));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff -u -p -r1.48 rhythmdb-property-model.c
--- rhythmdb/rhythmdb-property-model.c	14 Jul 2006 12:29:27 -0000	1.48
+++ rhythmdb/rhythmdb-property-model.c	17 Jul 2006 10:57:58 -0000
@@ -20,7 +20,8 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
diff -u -p -r1.136 rhythmdb-query-model.c
--- rhythmdb/rhythmdb-query-model.c	14 Jul 2006 12:53:44 -0000	1.136
+++ rhythmdb/rhythmdb-query-model.c	17 Jul 2006 10:57:59 -0000
@@ -20,7 +20,8 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -438,6 +439,8 @@ rhythmdb_query_model_set_property (GObje
 		break;
 	case PROP_QUERY:
 		rhythmdb_query_free (model->priv->query);
+		rhythmdb_query_free (model->priv->original_query);
+
 		model->priv->query = rhythmdb_query_copy (g_value_get_pointer (value));
 		model->priv->original_query = rhythmdb_query_copy (model->priv->query);
 		rhythmdb_query_preprocess (model->priv->db, model->priv->query);
@@ -2583,6 +2586,6 @@ rhythmdb_query_model_reapply_query_cb (R
 	rhythmdb_query_model_reapply_query (model, FALSE);
 	rhythmdb_do_full_query_async_parsed (model->priv->db,
 					     RHYTHMDB_QUERY_RESULTS (model),
-					     model->priv->original_query);
+					     model->priv->query);
 	return TRUE;
 }
diff -u -p -r1.4 rhythmdb-query.c
--- rhythmdb/rhythmdb-query.c	14 Jul 2006 12:29:29 -0000	1.4
+++ rhythmdb/rhythmdb-query.c	17 Jul 2006 10:57:59 -0000
@@ -499,23 +499,32 @@ rhythmdb_query_deserialize (RhythmDB *db
 		} else if (!xmlStrcmp (child->name, RB_PARSE_SUFFIX)) {
 			data->type = RHYTHMDB_QUERY_PROP_SUFFIX;
 		} else if (!xmlStrcmp (child->name, RB_PARSE_EQUALS)) {
-			if (!xmlStrcmp(xmlGetProp(child, RB_PARSE_PROP),
-				       (xmlChar *)"date"))
+			xmlChar* prop;
+
+			prop = xmlGetProp(child, RB_PARSE_PROP);
+			if (!xmlStrcmp(prop, (xmlChar *)"date"))
 				data->type = RHYTHMDB_QUERY_PROP_YEAR_EQUALS;
 			else
 				data->type = RHYTHMDB_QUERY_PROP_EQUALS;
+			xmlFree (prop);
 		} else if (!xmlStrcmp (child->name, RB_PARSE_GREATER)) {
-			if (!xmlStrcmp(xmlGetProp(child, RB_PARSE_PROP),
-				       (xmlChar *)"date"))
+			xmlChar* prop;
+
+			prop = xmlGetProp(child, RB_PARSE_PROP);
+			if (!xmlStrcmp(prop, (xmlChar *)"date"))
 				data->type = RHYTHMDB_QUERY_PROP_YEAR_GREATER;
 			else
 				data->type = RHYTHMDB_QUERY_PROP_GREATER;
+			xmlFree (prop);
 		} else if (!xmlStrcmp (child->name, RB_PARSE_LESS)) {
-			if (!xmlStrcmp(xmlGetProp(child, RB_PARSE_PROP),
-				       (xmlChar *)"date"))
+			xmlChar* prop;
+
+			prop = xmlGetProp(child, RB_PARSE_PROP);
+			if (!xmlStrcmp(prop, (xmlChar *)"date"))
 				data->type = RHYTHMDB_QUERY_PROP_YEAR_LESS;
 			else
 				data->type = RHYTHMDB_QUERY_PROP_LESS;
+			xmlFree (prop);
 		} else if (!xmlStrcmp (child->name, RB_PARSE_CURRENT_TIME_WITHIN)) {
 			data->type = RHYTHMDB_QUERY_PROP_CURRENT_TIME_WITHIN;
 		} else if (!xmlStrcmp (child->name, RB_PARSE_CURRENT_TIME_NOT_WITHIN)) {
diff -u -p -r1.113 rhythmdb-tree.c
--- rhythmdb/rhythmdb-tree.c	14 Jul 2006 12:29:29 -0000	1.113
+++ rhythmdb/rhythmdb-tree.c	17 Jul 2006 10:58:00 -0000
@@ -1883,6 +1883,8 @@ split_query_by_disjunctions (RhythmDBTre
 
 	if (subquery->len > 0)
 		conjunctions = g_list_prepend (conjunctions, subquery);
+	else
+		g_ptr_array_free (subquery, TRUE);
 
 	return conjunctions;
 }
diff -u -p -r1.238 rhythmdb.c
--- rhythmdb/rhythmdb.c	14 Jul 2006 12:29:32 -0000	1.238
+++ rhythmdb/rhythmdb.c	17 Jul 2006 10:58:02 -0000
@@ -20,23 +20,22 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #define	G_IMPLEMENT_INLINES 1
 #define	__RHYTHMDB_C__
 #include "rhythmdb.h"
 #undef G_IMPLEMENT_INLINES
 
-#include "rhythmdb-private.h"
-#include "rhythmdb-property-model.h"
 #include <string.h>
-#include <gobject/gvaluecollector.h>
+#include <libxml/tree.h>
 #include <glib.h>
 #include <glib-object.h>
-#include <gconf/gconf-client.h>
-#include <gdk/gdk.h>
-#include <libxml/tree.h>
 #include <glib/gi18n.h>
+#include <gobject/gvaluecollector.h>
+#include <gdk/gdk.h>
+#include <gconf/gconf-client.h>
+
 #include "rb-marshal.h"
 #include "rb-file-helpers.h"
 #include "rb-debug.h"
@@ -44,6 +43,8 @@
 #include "rb-cut-and-paste-code.h"
 #include "rb-preferences.h"
 #include "eel-gconf-extensions.h"
+#include "rhythmdb-private.h"
+#include "rhythmdb-property-model.h"
 
 #define RB_PARSE_NICK_START (xmlChar *) "["
 #define RB_PARSE_NICK_END (xmlChar *) "]"
@@ -472,13 +473,7 @@ rhythmdb_start_action_thread (RhythmDB *
 static void
 rhythmdb_action_free (RhythmDB *db, RhythmDBAction *action)
 {
-	switch (action->type) {
-	case RHYTHMDB_ACTION_STAT:
-	case RHYTHMDB_ACTION_LOAD:
-	case RHYTHMDB_ACTION_SYNC:
-		g_free (action->uri);
-		break;
-	}
+	g_free (action->uri);
 	g_free (action);
 }
 
@@ -486,42 +481,34 @@ static void
 rhythmdb_event_free (RhythmDB *db, RhythmDBEvent *result)
 {
 	switch (result->type) {
-	case RHYTHMDB_EVENT_STAT:
-		g_free (result->uri);
-		g_free (result->real_uri);
-		if (result->vfsinfo)
-			gnome_vfs_file_info_unref (result->vfsinfo);
-		break;
-	case RHYTHMDB_EVENT_METADATA_LOAD:
-		g_free (result->uri);
-		g_free (result->real_uri);
-		if (result->vfsinfo)
-			gnome_vfs_file_info_unref (result->vfsinfo);
-		if (result->metadata)
-			g_object_unref (result->metadata);
-		g_clear_error (&result->error);
-		break;
-	case RHYTHMDB_EVENT_DB_LOAD:
-		break;
 	case RHYTHMDB_EVENT_THREAD_EXITED:
 		g_object_unref (db);
 		g_assert (g_atomic_int_dec_and_test (&db->priv->outstanding_threads) >= 0);
 		g_async_queue_unref (db->priv->action_queue);
 		g_async_queue_unref (db->priv->event_queue);
 		break;
+	case RHYTHMDB_EVENT_STAT:
+	case RHYTHMDB_EVENT_METADATA_LOAD:
+	case RHYTHMDB_EVENT_DB_LOAD:
 	case RHYTHMDB_EVENT_DB_SAVED:
-		break;
 	case RHYTHMDB_EVENT_QUERY_COMPLETE:
-		g_object_unref (result->results);
-		break;
 	case RHYTHMDB_EVENT_FILE_CREATED_OR_MODIFIED:
-		break;
 	case RHYTHMDB_EVENT_FILE_DELETED:
 		break;
 	case RHYTHMDB_EVENT_ENTRY_SET:
 		g_value_unset (&result->change.new);
 		break;
 	}
+	if (result->error)
+		g_error_free (result->error);
+	g_free (result->uri);
+	g_free (result->real_uri);
+	if (result->vfsinfo)
+		gnome_vfs_file_info_unref (result->vfsinfo);
+	if (result->metadata)
+		g_object_unref (result->metadata);
+	if (result->results)
+		g_object_unref (result->results);
 	g_free (result);
 }
 
@@ -556,7 +543,7 @@ rhythmdb_shutdown (RhythmDB *db)
 		rhythmdb_event_free (db, result);
 	}
 
-	//FIXME
+	/* FIXME */
 	while ((result = g_async_queue_try_pop (db->priv->event_queue)) != NULL)
 		rhythmdb_event_free (db, result);
 }
@@ -655,7 +642,7 @@ rhythmdb_get_property (GObject *object,
 static void
 rhythmdb_thread_create (RhythmDB *db, GThreadFunc func, gpointer data)
 {
-	g_object_ref (G_OBJECT (db));
+	g_object_ref (db);
 	g_atomic_int_inc (&db->priv->outstanding_threads);
 	g_async_queue_ref (db->priv->action_queue);
 	g_async_queue_ref (db->priv->event_queue);
@@ -2099,7 +2086,7 @@ action_thread_main (RhythmDB *db)
 				RhythmDBSaveErrorData *data;
 
 				data = g_new0 (RhythmDBSaveErrorData, 1);
-				g_object_ref (G_OBJECT (db));
+				g_object_ref (db);
 				data->db = db;
 				data->uri = g_strdup (action->uri);
 				data->error = error;
@@ -2972,8 +2959,8 @@ rhythmdb_do_full_query_async_parsed (Rhy
 
 	rhythmdb_query_results_set_query (results, query);
 
-	g_object_ref (G_OBJECT (results));
-	g_object_ref (G_OBJECT (db));
+	g_object_ref (results);
+	g_object_ref (db);
 	g_atomic_int_inc (&db->priv->outstanding_threads);
 	g_async_queue_ref (db->priv->action_queue);
 	g_async_queue_ref (db->priv->event_queue);
@@ -3015,7 +3002,7 @@ rhythmdb_do_full_query_internal (RhythmD
 	rhythmdb_read_enter (db);
 
 	rhythmdb_query_results_set_query (results, query);
-	g_object_ref (G_OBJECT (results));
+	g_object_ref (results);
 
 	rhythmdb_query_internal (data);
 	g_free (data);
diff -u -p -r1.100 main.c
--- shell/main.c	14 Jul 2006 12:53:45 -0000	1.100
+++ shell/main.c	17 Jul 2006 10:58:03 -0000
@@ -386,6 +386,10 @@ main (int argc, char **argv)
 #endif
 	}
 
+#ifdef HAVE_GSTREAMER_0_10
+	gst_deinit ();
+#endif
+
 	g_strfreev (new_argv);
 
 	rb_debug ("THE END");
diff -u -p -r1.9 rb-play-order-random.c
--- shell/rb-play-order-random.c	14 Jul 2006 12:30:49 -0000	1.9
+++ shell/rb-play-order-random.c	17 Jul 2006 10:58:04 -0000
@@ -30,6 +30,8 @@
  * will not see any changes to their history of played songs.
  */
 
+#include "config.h"
+
 #include <string.h>
 
 #include "rb-play-order-random-by-age.h"
@@ -361,7 +363,7 @@ rb_random_play_order_go_next (RBPlayOrde
 
 	rb_random_play_order_get_next (porder);
 
-	g_object_get (G_OBJECT (rorder), "playing-entry", &entry, NULL);
+	g_object_get (rorder, "playing-entry", &entry, NULL);
 	g_assert (entry == NULL || rb_history_current (history) == NULL || entry == rb_history_current (history));
 	if (rb_history_current (history) == NULL)
 		rb_history_go_first (history);
diff -u -p -r1.23 rb-play-order.c
--- shell/rb-play-order.c	14 Jul 2006 12:30:49 -0000	1.23
+++ shell/rb-play-order.c	17 Jul 2006 10:58:05 -0000
@@ -20,6 +20,8 @@
  *
  */
 
+#include "config.h"
+
 #include <string.h>
 
 #include <glib/gi18n.h>
@@ -181,36 +183,56 @@ rb_play_order_finalize (GObject *object)
 		g_signal_handlers_disconnect_by_func (G_OBJECT (porder->priv->query_model),
 						      G_CALLBACK (rb_play_order_row_deleted_cb),
 						      porder);
+		g_object_unref (porder->priv->query_model);
+	}
+
+	if (porder->priv->db != NULL) {
+		g_object_unref (porder->priv->db);
 	}
 
 	G_OBJECT_CLASS (rb_play_order_parent_class)->finalize (object);
 }
 
 static void
+rb_play_order_set_player (RBPlayOrder   *porder,
+			  RBShellPlayer *player)
+{
+	porder->priv->player = player;
+}
+
+static void
+rb_play_order_set_playing_entry_internal (RBPlayOrder   *porder,
+					  RhythmDBEntry *entry)
+{
+	RhythmDBEntry *old_entry;
+
+	old_entry = porder->priv->playing_entry;
+	porder->priv->playing_entry = entry;
+
+	if (RB_PLAY_ORDER_GET_CLASS (porder)->playing_entry_changed)
+		RB_PLAY_ORDER_GET_CLASS (porder)->playing_entry_changed (porder, old_entry, entry);
+
+	if (old_entry != NULL) {
+		rhythmdb_entry_unref (old_entry);
+	}
+
+	rb_play_order_update_have_next_previous (porder);
+}
+
+static void
 rb_play_order_set_property (GObject *object,
 			    guint prop_id,
 			    const GValue *value,
 			    GParamSpec *pspec)
 {
 	RBPlayOrder *porder = RB_PLAY_ORDER (object);
-	RhythmDBEntry *entry;
-	RhythmDBEntry *old_entry;
 
 	switch (prop_id) {
 	case PROP_PLAYER:
-		porder->priv->player = g_value_get_object (value);
+		rb_play_order_set_player (porder, g_value_get_object (value));
 		break;
 	case PROP_PLAYING_ENTRY:
-		old_entry = porder->priv->playing_entry;
-		entry = g_value_dup_boxed (value);
-		porder->priv->playing_entry = entry;
-
-		if (RB_PLAY_ORDER_GET_CLASS (porder)->playing_entry_changed)
-			RB_PLAY_ORDER_GET_CLASS (porder)->playing_entry_changed (porder, old_entry, entry);
-		if (old_entry)
-			rhythmdb_entry_unref (old_entry);
-
-		rb_play_order_update_have_next_previous (porder);
+		rb_play_order_set_playing_entry_internal (porder, g_value_dup_boxed (value));
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -417,16 +439,23 @@ rb_play_order_playing_source_changed (RB
 
 	g_return_if_fail (porder != NULL);
 
-	g_object_get (G_OBJECT (porder->priv->player),
+	g_object_get (porder->priv->player,
 		      "db", &db,
 		      NULL);
 
 	if (db != porder->priv->db) {
 		if (RB_PLAY_ORDER_GET_CLASS (porder)->db_changed)
 			RB_PLAY_ORDER_GET_CLASS (porder)->db_changed (porder, db);
-		porder->priv->db = db;
+
+		if (porder->priv->db != NULL) {
+			g_object_unref (porder->priv->db);
+		}
+
+		porder->priv->db = g_object_ref (db);
 	}
 
+	g_object_unref (db);
+
 	if (source != porder->priv->source) {
 		if (porder->priv->source) {
 			g_signal_handler_disconnect (G_OBJECT (porder->priv->source),
@@ -475,7 +504,7 @@ rb_play_order_query_model_changed (RBPla
 	RhythmDBQueryModel *new_model = NULL;
 
 	if (porder->priv->source)
-		g_object_get (G_OBJECT (porder->priv->source), "query-model", &new_model, NULL);
+		g_object_get (porder->priv->source, "query-model", &new_model, NULL);
 
 	if (porder->priv->query_model == new_model)
 		return;
diff -u -p -r1.110 rb-playlist-manager.c
--- shell/rb-playlist-manager.c	14 Jul 2006 12:30:49 -0000	1.110
+++ shell/rb-playlist-manager.c	17 Jul 2006 10:58:06 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <stdio.h>      /* rename() */
@@ -265,6 +265,10 @@ rb_playlist_manager_finalize (GObject *o
 
 	g_return_if_fail (mgr->priv != NULL);
 
+	if (mgr->priv->db != NULL) {
+		g_object_unref (mgr->priv->db);
+	}
+
 	g_mutex_free (mgr->priv->saving_mutex);
 
 	G_OBJECT_CLASS (rb_playlist_manager_parent_class)->finalize (object);
@@ -318,7 +322,7 @@ rb_playlist_manager_set_source (RBPlayli
 	mgr->priv->selected_source = source;
 	playlist_active = RB_IS_PLAYLIST_SOURCE (mgr->priv->selected_source);
 	if (playlist_active) {
-		g_object_get (G_OBJECT (mgr->priv->selected_source), "is-local", &playlist_local, NULL);
+		g_object_get (mgr->priv->selected_source, "is-local", &playlist_local, NULL);
 	}
 
 	can_save = playlist_local && !party_mode;
@@ -345,6 +349,30 @@ rb_playlist_manager_set_source (RBPlayli
 }
 
 static void
+rb_playlist_manager_set_shell_internal (RBPlaylistManager *mgr,
+					RBShell           *shell)
+{
+	GtkUIManager *uimanager = NULL;
+	RhythmDB     *db = NULL;
+
+	if (mgr->priv->db != NULL) {
+		g_object_unref (mgr->priv->db);
+	}
+
+	mgr->priv->shell = shell;
+
+	if (mgr->priv->shell != NULL) {
+		g_object_get (mgr->priv->shell,
+			      "ui-manager", &uimanager,
+			      "db", &db,
+			      NULL);
+	}
+
+	mgr->priv->db = db;
+	rb_playlist_manager_set_uimanager (mgr, uimanager);
+}
+
+static void
 rb_playlist_manager_set_property (GObject *object,
 				  guint prop_id,
 				  const GValue *value,
@@ -357,16 +385,8 @@ rb_playlist_manager_set_property (GObjec
 		rb_playlist_manager_set_source (mgr, g_value_get_object (value));
 		break;
 	case PROP_SHELL:
-	{
-		GtkUIManager *uimanager;
-		mgr->priv->shell = g_value_get_object (value);
-		g_object_get (G_OBJECT (mgr->priv->shell),
-			      "ui-manager", &uimanager,
-			      "db", &mgr->priv->db,
-			      NULL);
-		rb_playlist_manager_set_uimanager (mgr, uimanager);
+		rb_playlist_manager_set_shell_internal (mgr, g_value_get_object (value));
 		break;
-	}
 	case PROP_SOURCELIST:
 		mgr->priv->sourcelist = g_value_get_object (value);
 		mgr->priv->window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (mgr->priv->sourcelist)));
diff -u -p -r1.29 rb-removable-media-manager.c
--- shell/rb-removable-media-manager.c	14 Jul 2006 12:30:51 -0000	1.29
+++ shell/rb-removable-media-manager.c	17 Jul 2006 10:58:06 -0000
@@ -311,10 +311,11 @@ rb_removable_media_manager_set_property 
 		GtkUIManager *uimanager;
 
 		priv->shell = g_value_get_object (value);
-		g_object_get (G_OBJECT (priv->shell),
+		g_object_get (priv->shell,
 			      "ui-manager", &uimanager,
 			      NULL);
 		rb_removable_media_manager_set_uimanager (RB_REMOVABLE_MEDIA_MANAGER (object), uimanager);
+		g_object_unref (uimanager);
 		break;
 	}
 	case PROP_SOURCELIST:
@@ -736,6 +737,10 @@ rb_removable_media_manager_set_uimanager
 
 	priv->uimanager = uimanager;
 
+	if (priv->uimanager != NULL) {
+		g_object_ref (priv->uimanager);
+	}
+
 	if (priv->actiongroup == NULL) {
 		priv->actiongroup = gtk_action_group_new ("RemovableMediaActions");
 		gtk_action_group_set_translation_domain (priv->actiongroup,
@@ -779,7 +784,7 @@ rb_removable_media_manager_cmd_eject_med
 	RBRemovableMediaSource *source = RB_REMOVABLE_MEDIA_SOURCE (priv->selected_source);
 	GnomeVFSVolume *volume;
 
-	g_object_get (G_OBJECT (source), "volume", &volume, NULL);
+	g_object_get (source, "volume", &volume, NULL);
 	rb_removable_media_manager_unmount_volume (mgr, volume);
 	gnome_vfs_volume_eject (volume, (GnomeVFSVolumeOpCallback)rb_removable_media_manager_eject_medium_cb, mgr);
 	gnome_vfs_volume_unref (volume);
@@ -1027,14 +1032,14 @@ rb_removable_media_manager_cmd_copy_trac
 	GList *list = NULL;
 
 	source = RB_REMOVABLE_MEDIA_SOURCE (priv->selected_source);
-	g_object_get (G_OBJECT (source), "query-model", &model, NULL);
-	g_object_get (G_OBJECT (priv->shell), "library-source", &library, NULL);
+	g_object_get (source, "query-model", &model, NULL);
+	g_object_get (priv->shell, "library-source", &library, NULL);
 
 	gtk_tree_model_foreach (GTK_TREE_MODEL (model), (GtkTreeModelForeachFunc)copy_entry, &list);
 	rb_source_paste (RB_SOURCE (library), list);
 	g_list_free (list);
 
-	g_object_unref (G_OBJECT (model));
-	g_object_unref (G_OBJECT (library));
+	g_object_unref (model);
+	g_object_unref (library);
 #endif
 }
diff -u -p -r1.48 rb-shell-clipboard.c
--- shell/rb-shell-clipboard.c	14 Jul 2006 12:53:45 -0000	1.48
+++ shell/rb-shell-clipboard.c	17 Jul 2006 10:58:07 -0000
@@ -279,6 +279,7 @@ rb_shell_clipboard_finalize (GObject *ob
 
 	g_hash_table_destroy (shell_clipboard->priv->signal_hash);
 
+	g_list_foreach (shell_clipboard->priv->entries, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (shell_clipboard->priv->entries);
 
 	g_async_queue_unref (shell_clipboard->priv->deleted_queue);
@@ -468,7 +469,9 @@ rb_shell_clipboard_set_source (RBShellCl
 }
 
 RBShellClipboard *
-rb_shell_clipboard_new (GtkActionGroup *actiongroup,GtkUIManager *ui_mgr, RhythmDB *db)
+rb_shell_clipboard_new (GtkActionGroup *actiongroup,
+			GtkUIManager *ui_mgr,
+			RhythmDB *db)
 {
 	return g_object_new (RB_TYPE_SHELL_CLIPBOARD,
 			     "action-group", actiongroup,
@@ -506,9 +509,9 @@ rb_shell_clipboard_sync (RBShellClipboar
 
 	if (clipboard->priv->queue_source) {
 		RBEntryView *sidebar;
-		g_object_get (G_OBJECT (clipboard->priv->queue_source), "sidebar", &sidebar, NULL);
+		g_object_get (clipboard->priv->queue_source, "sidebar", &sidebar, NULL);
 		have_sidebar_selection = rb_entry_view_have_selection (sidebar);
-		g_object_unref (G_OBJECT (sidebar));
+		g_object_unref (sidebar);
 	}
 
 	rb_debug ("syncing clipboard");
@@ -566,7 +569,7 @@ rb_shell_clipboard_sync (RBShellClipboar
 	 * FIXME: change this when we support non-library playilst adding
 	 */
 	action = gtk_action_group_get_action (clipboard->priv->actiongroup, "EditPlaylistAdd");
-	g_object_get (G_OBJECT (clipboard->priv->source), "entry-type", &entry_type, NULL);
+	g_object_get (clipboard->priv->source, "entry-type", &entry_type, NULL);
 	gtk_action_set_sensitive (action, (entry_type == RHYTHMDB_ENTRY_TYPE_SONG));
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
 
@@ -649,7 +652,10 @@ static void
 rb_shell_clipboard_set (RBShellClipboard *clipboard,
 			GList *entries)
 {
-	g_list_free (clipboard->priv->entries);
+	if (clipboard->priv->entries != NULL) {
+		g_list_foreach (clipboard->priv->entries, (GFunc)rhythmdb_entry_unref, NULL);
+		g_list_free (clipboard->priv->entries);
+	}
 
 	clipboard->priv->entries = entries;
 }
@@ -753,6 +759,8 @@ rb_shell_clipboard_cmd_add_to_playlist_n
 	playlist_source = rb_playlist_manager_new_playlist (clipboard->priv->playlist_manager,
 							    NULL, FALSE);
 	rb_source_paste (playlist_source, entries);
+
+	g_list_foreach (entries, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (entries);
 }
 
@@ -794,6 +802,8 @@ rb_shell_clipboard_playlist_add_cb (GtkA
 
 	entries = rb_source_copy (clipboard->priv->source);
 	rb_source_paste (playlist_source, entries);
+
+	g_list_foreach (entries, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (entries);
 }
 
@@ -833,16 +843,16 @@ rb_shell_clipboard_playlist_renamed_cb (
 	char *name, *action_name;
 	GtkAction *action;
 
-	g_object_get (G_OBJECT (source), "name", &name, NULL);
+	g_object_get (source, "name", &name, NULL);
 
 	action_name = generate_action_name (source, clipboard);
 	action = gtk_action_group_get_action (clipboard->priv->actiongroup, action_name);
 	g_assert (action);
 	g_free (action_name);
 
-	g_object_set (G_OBJECT (action), "label", name, NULL);
+	g_object_set (action, "label", name, NULL);
 	g_free (name);
-	g_object_unref (G_OBJECT (action));
+	g_object_unref (action);
 }
 
 static void
@@ -854,7 +864,7 @@ rb_shell_clipboard_playlist_visible_cb (
 	char *action_name;
 	GtkAction *action;
 
-	g_object_get (G_OBJECT (source), "visibility", &visible, NULL);
+	g_object_get (source, "visibility", &visible, NULL);
 
 	action_name = generate_action_name (source, clipboard);
 	action = gtk_action_group_get_action (clipboard->priv->actiongroup, action_name);
@@ -887,7 +897,7 @@ add_playlist_to_menu (GtkTreeModel *mode
 	 * based on the currently selected source
 	 */
 	entry_type = RHYTHMDB_ENTRY_TYPE_SONG;
-	g_object_get (G_OBJECT (source), "entry-type", &source_entry_type, NULL);
+	g_object_get (source, "entry-type", &source_entry_type, NULL);
 	if (source_entry_type != entry_type) {
 		g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, source_entry_type);
 		return FALSE;
@@ -898,7 +908,7 @@ add_playlist_to_menu (GtkTreeModel *mode
 	if (action == NULL) {
 		char *name;
 
-		g_object_get (G_OBJECT (source), "name", &name, NULL);
+		g_object_get (source, "name", &name, NULL);
 		action = gtk_action_new (action_name, name, NULL, NULL);
 		gtk_action_group_add_action (clipboard->priv->actiongroup, action);
 		g_free (name);
@@ -927,6 +937,8 @@ add_playlist_to_menu (GtkTreeModel *mode
 	}
 
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, source_entry_type);
+	g_free (action_name);
+
 	return FALSE;
 }
 
@@ -957,7 +969,7 @@ rebuild_playlist_menu (RBShellClipboard 
 
 	if (model != NULL) {
 		gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)add_playlist_to_menu, clipboard);
-		g_object_unref (G_OBJECT (model));
+		g_object_unref (model);
 	}
 
 	clipboard->priv->idle_playlist_id = 0;
diff -u -p -r1.251 rb-shell-player.c
--- shell/rb-shell-player.c	14 Jul 2006 12:53:45 -0000	1.251
+++ shell/rb-shell-player.c	17 Jul 2006 10:58:09 -0000
@@ -21,7 +21,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -632,61 +632,61 @@ static void
 rb_shell_player_set_source_internal (RBShellPlayer *player,
 				     RBSource      *source)
 {
-		if (player->priv->selected_source != NULL) {
-			RBEntryView *songs = rb_source_get_entry_view (player->priv->selected_source);
-			GList *property_views = rb_source_get_property_views (player->priv->selected_source);
-
-			if (songs != NULL) {
-				g_signal_handlers_disconnect_by_func (G_OBJECT (songs),
-								      G_CALLBACK (rb_shell_player_entry_activated_cb),
-								      player);
-			}
-
-			for (; property_views; property_views = property_views->next) {
-				g_signal_handlers_disconnect_by_func (G_OBJECT (property_views->data),
-								      G_CALLBACK (rb_shell_player_property_row_activated_cb),
-								      player);
-			}
+	if (player->priv->selected_source != NULL) {
+		RBEntryView *songs = rb_source_get_entry_view (player->priv->selected_source);
+		GList *property_views = rb_source_get_property_views (player->priv->selected_source);
+
+		if (songs != NULL) {
+			g_signal_handlers_disconnect_by_func (G_OBJECT (songs),
+							      G_CALLBACK (rb_shell_player_entry_activated_cb),
+							      player);
+		}
 
-			g_list_free (property_views);
+		for (; property_views; property_views = property_views->next) {
+			g_signal_handlers_disconnect_by_func (G_OBJECT (property_views->data),
+							      G_CALLBACK (rb_shell_player_property_row_activated_cb),
+							      player);
 		}
 
-		player->priv->selected_source = source;
+		g_list_free (property_views);
+	}
 
-		rb_debug ("selected source %p", player->priv->selected_source);
+	player->priv->selected_source = source;
 
-		rb_shell_player_sync_with_selected_source (player);
-		rb_shell_player_sync_buttons (player);
+	rb_debug ("selected source %p", player->priv->selected_source);
 
-		if (player->priv->selected_source != NULL) {
-			RBEntryView *songs = rb_source_get_entry_view (player->priv->selected_source);
-			GList *property_views = rb_source_get_property_views (player->priv->selected_source);
+	rb_shell_player_sync_with_selected_source (player);
+	rb_shell_player_sync_buttons (player);
 
-			if (songs)
-				g_signal_connect_object (G_OBJECT (songs),
-							 "entry-activated",
-							 G_CALLBACK (rb_shell_player_entry_activated_cb),
-							 player, 0);
-			for (; property_views; property_views = property_views->next)
-				g_signal_connect_object (G_OBJECT (property_views->data),
-							 "property-activated",
-							 G_CALLBACK (rb_shell_player_property_row_activated_cb),
-							 player, 0);
-
-			g_list_free (property_views);
-		}
-
-		/* If we're not playing, change the play order's view of the current source;
-		 * if the selected source is the queue, however, set it to NULL so it'll stop
-		 * once the queue is empty.
-		 */
-		if (player->priv->current_playing_source == NULL) {
-			RBSource *source = player->priv->selected_source;
-			if (source == RB_SOURCE (player->priv->queue_source))
-				source = NULL;
+	if (player->priv->selected_source != NULL) {
+		RBEntryView *songs = rb_source_get_entry_view (player->priv->selected_source);
+		GList *property_views = rb_source_get_property_views (player->priv->selected_source);
+
+		if (songs)
+			g_signal_connect_object (G_OBJECT (songs),
+						 "entry-activated",
+						 G_CALLBACK (rb_shell_player_entry_activated_cb),
+						 player, 0);
+		for (; property_views; property_views = property_views->next)
+			g_signal_connect_object (G_OBJECT (property_views->data),
+						 "property-activated",
+						 G_CALLBACK (rb_shell_player_property_row_activated_cb),
+						 player, 0);
+
+		g_list_free (property_views);
+	}
+
+	/* If we're not playing, change the play order's view of the current source;
+	 * if the selected source is the queue, however, set it to NULL so it'll stop
+	 * once the queue is empty.
+	 */
+	if (player->priv->current_playing_source == NULL) {
+		RBSource *source = player->priv->selected_source;
+		if (source == RB_SOURCE (player->priv->queue_source))
+			source = NULL;
 
-			rb_play_order_playing_source_changed (player->priv->play_order, source);
-		}
+		rb_play_order_playing_source_changed (player->priv->play_order, source);
+	}
 }
 
 static void
@@ -717,7 +717,7 @@ rb_shell_player_set_queue_source_interna
 	if (player->priv->queue_source != NULL) {
 		RBEntryView *sidebar;
 
-		g_object_get (G_OBJECT (player->priv->queue_source), "sidebar", &sidebar, NULL);
+		g_object_get (player->priv->queue_source, "sidebar", &sidebar, NULL);
 		g_signal_handlers_disconnect_by_func (sidebar,
 						      G_CALLBACK (rb_shell_player_entry_activated_cb),
 						      player);
@@ -748,7 +748,7 @@ rb_shell_player_set_queue_source_interna
 		rb_play_order_playing_source_changed (player->priv->queue_play_order,
 						      RB_SOURCE (player->priv->queue_source));
 
-		g_object_get (G_OBJECT (player->priv->queue_source), "sidebar", &sidebar, NULL);
+		g_object_get (player->priv->queue_source, "sidebar", &sidebar, NULL);
 		g_signal_connect_object (G_OBJECT (sidebar),
 					 "entry-activated",
 					 G_CALLBACK (rb_shell_player_entry_activated_cb),
@@ -769,16 +769,13 @@ rb_shell_player_finalize (GObject *objec
 
 	g_return_if_fail (player->priv != NULL);
 
-	rb_shell_player_set_source_internal (player, NULL);
-	rb_shell_player_set_queue_source_internal (player, NULL);
-	rb_shell_player_set_db_internal (player, NULL);
-
 	eel_gconf_notification_remove (player->priv->gconf_play_order_id);
 
 	eel_gconf_set_float (CONF_STATE_VOLUME, player->priv->volume);
 
-	g_object_unref (G_OBJECT (player->priv->mmplayer));
-	g_object_unref (G_OBJECT (player->priv->play_order));
+	g_object_unref (player->priv->mmplayer);
+	g_object_unref (player->priv->play_order);
+	g_object_unref (player->priv->queue_play_order);
 
 	G_OBJECT_CLASS (rb_shell_player_parent_class)->finalize (object);
 }
@@ -1277,7 +1274,8 @@ static void
 rb_shell_player_set_play_order (RBShellPlayer *player, const gchar *new_val)
 {
 	char *old_val;
-	g_object_get (G_OBJECT (player), "play-order", &old_val, NULL);
+
+	g_object_get (player, "play-order", &old_val, NULL);
 	if (strcmp (old_val, new_val) != 0) {
 		/* The notify signal will be emitted by the gconf notifier */
 		eel_gconf_set_string (CONF_STATE_PLAY_ORDER, new_val);
@@ -1976,7 +1974,7 @@ rb_shell_player_entry_activated_cb (RBEn
 	if (playa->priv->queue_source) {
 		RBEntryView *queue_sidebar;
 
-		g_object_get (G_OBJECT (playa->priv->queue_source), "sidebar", &queue_sidebar, NULL);
+		g_object_get (playa->priv->queue_source, "sidebar", &queue_sidebar, NULL);
 
 		if (view == queue_sidebar || view == rb_source_get_entry_view (RB_SOURCE (playa->priv->queue_source))) {
 
@@ -2006,7 +2004,7 @@ rb_shell_player_entry_activated_cb (RBEn
 			}
 		}
 
-		g_object_unref (G_OBJECT (queue_sidebar));
+		g_object_unref (queue_sidebar);
 	}
 
 	/* bail out if queue only */
@@ -2052,17 +2050,23 @@ rb_shell_player_property_row_activated_c
 	 * keyboard to select then activate) and is pretty much always done by
 	 * the time we get in here.
 	 */
-	g_object_get (G_OBJECT (playa->priv->selected_source), "query-model", &model, NULL);
+	g_object_get (playa->priv->selected_source, "query-model", &model, NULL);
+
 	if (!model)
 		return;
-	if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
-		return;
+
+	if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) {
+		goto done;
+	}
 
 	entry = rhythmdb_query_model_iter_to_entry (model, &iter);
 	if (!rb_shell_player_set_playing_entry (playa, entry, TRUE, &error)) {
 		rb_shell_player_error (playa, FALSE, error);
 		g_clear_error (&error);
 	}
+
+ done:
+	g_object_unref (model);
 }
 
 static void
@@ -2899,7 +2903,7 @@ _idle_unblock_signal_cb (gpointer data)
 					      "ControlPlay");
 
 	/* sync the active state of the action again */
-	g_object_get (G_OBJECT (player), "playing", &playing, NULL);
+	g_object_get (player, "playing", &playing, NULL);
 	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), playing);
 
 	g_signal_handlers_unblock_by_func (action, rb_shell_player_cmd_play, player);
@@ -2915,7 +2919,7 @@ rb_shell_player_playing_changed_cb (RBSh
 	gboolean playing;
 	char *tooltip;
 
-	g_object_get (G_OBJECT (player), "playing", &playing, NULL);
+	g_object_get (player, "playing", &playing, NULL);
 	action = gtk_action_group_get_action (player->priv->actiongroup,
 					      "ControlPlay");
 	if (playing) {
diff -u -p -r1.61 rb-shell-preferences.c
--- shell/rb-shell-preferences.c	14 Jul 2006 12:30:52 -0000	1.61
+++ shell/rb-shell-preferences.c	17 Jul 2006 10:58:09 -0000
@@ -433,12 +433,13 @@ rb_shell_preferences_new (GList *views)
 
 	for (; views; views = views->next)
 	{
-		const char *name = NULL;
-		g_object_get (G_OBJECT (views->data), "name", &name, NULL);
+		char *name = NULL;
+		g_object_get (views->data, "name", &name, NULL);
 		g_assert (name != NULL);
 		rb_shell_preferences_append_view_page (shell_preferences,
 						       name,
 						       RB_SOURCE (views->data));
+		g_free (name);
 	}
 
 #ifdef WITH_DAAP_SUPPORT
diff -u -p -r1.462 rb-shell.c
--- shell/rb-shell.c	14 Jul 2006 12:53:45 -0000	1.462
+++ shell/rb-shell.c	17 Jul 2006 10:58:11 -0000
@@ -542,7 +542,7 @@ rb_shell_class_init (RBShellClass *klass
 							      "RhythmDB",
 							      "RhythmDB object",
 							      RHYTHMDB_TYPE,
-							       G_PARAM_READABLE));
+							      G_PARAM_READABLE));
 
 	g_object_class_install_property (object_class,
 					 PROP_UI_MANAGER,
@@ -550,7 +550,7 @@ rb_shell_class_init (RBShellClass *klass
 							      "GtkUIManager",
 							      "GtkUIManager object",
 							      GTK_TYPE_UI_MANAGER,
-							       G_PARAM_READABLE));
+							      G_PARAM_READABLE));
 
 	g_object_class_install_property (object_class,
 					 PROP_CLIPBOARD,
@@ -775,8 +775,9 @@ rb_shell_get_property (GObject *object,
 		{
 			GtkTreeModel *model = NULL;
 
-			g_object_get (G_OBJECT (shell->priv->sourcelist), "model", &model, NULL);
+			g_object_get (shell->priv->sourcelist, "model", &model, NULL);
  			g_value_set_object (value, model);
+			g_object_unref (model);
 		}
  		break;
 	case PROP_VISIBILITY:
@@ -890,12 +891,6 @@ rb_shell_finalize (GObject *object)
 	rb_debug ("unreffing clipboard shell");
 	g_object_unref (G_OBJECT (shell->priv->clipboard_shell));
 
-	rb_debug ("shutting down DB");
-	rhythmdb_shutdown (shell->priv->db);
-
-	rb_debug ("unreffing DB");
-	g_object_unref (G_OBJECT (shell->priv->db));
-
 	rb_debug ("destroying prefs");
 	if (shell->priv->prefs != NULL)
 		gtk_widget_destroy (shell->priv->prefs);
@@ -913,6 +908,12 @@ rb_shell_finalize (GObject *object)
 
 	g_hash_table_destroy (shell->priv->sources_hash);
 
+	rb_debug ("shutting down DB");
+	rhythmdb_shutdown (shell->priv->db);
+
+	rb_debug ("unreffing DB");
+	g_object_unref (G_OBJECT (shell->priv->db));
+
         ((GObjectClass*)rb_shell_parent_class)->finalize (G_OBJECT (shell));
 
 	rb_debug ("shell shutdown complete");
@@ -1066,7 +1067,7 @@ construct_widgets (RBShell *shell)
 	g_object_set (G_OBJECT(shell->priv->player_shell), "queue-source", shell->priv->queue_source, NULL);
 	g_object_set (G_OBJECT(shell->priv->clipboard_shell), "queue-source", shell->priv->queue_source, NULL);
 	rb_shell_append_source (shell, RB_SOURCE (shell->priv->queue_source), NULL);
-	g_object_get (G_OBJECT (shell->priv->queue_source), "sidebar", &shell->priv->queue_sidebar, NULL);
+	g_object_get (shell->priv->queue_source, "sidebar", &shell->priv->queue_sidebar, NULL);
 	gtk_widget_show_all (shell->priv->queue_sidebar);
 	gtk_widget_set_no_show_all (shell->priv->queue_sidebar, TRUE);
 
@@ -1818,7 +1819,8 @@ rb_shell_playing_from_queue_cb (RBShellP
 				RBShell *shell)
 {
 	gboolean from_queue;
-	g_object_get (G_OBJECT (player), "playing-from-queue", &from_queue, NULL);
+
+	g_object_get (player, "playing-from-queue", &from_queue, NULL);
 	if (!shell->priv->queue_as_sidebar) {
 		rb_sourcelist_set_playing_source (RB_SOURCELIST (shell->priv->sourcelist),
 						  rb_shell_player_get_playing_source (shell->priv->player_shell));
@@ -1969,7 +1971,8 @@ rb_shell_player_stream_song_changed_cb (
 					RBShell *shell)
 {
 	char *song;
-	g_object_get (G_OBJECT (player), "stream-song", &song, NULL);
+
+	g_object_get (player, "stream-song", &song, NULL);
 	if (song) {
 		rb_shell_hidden_notify (shell, 4000, song, NULL, NULL);
 		g_free (song);
@@ -3288,7 +3291,8 @@ rb_shell_player_volume_changed_cb (RBShe
 				   RBShell *shell)
 {
 	float volume;
-	g_object_get (G_OBJECT (player), "volume", &volume, NULL);
+
+	g_object_get (player, "volume", &volume, NULL);
 	shell->priv->syncing_volume = TRUE;
 	bacon_volume_button_set_value (BACON_VOLUME_BUTTON (shell->priv->volume_button),
 				       volume);
diff -u -p -r1.49 rb-statusbar.c
--- shell/rb-statusbar.c	14 Jul 2006 12:30:53 -0000	1.49
+++ shell/rb-statusbar.c	17 Jul 2006 10:58:12 -0000
@@ -21,7 +21,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -423,7 +423,8 @@ rb_statusbar_sync_status (RBStatusbar *s
 }
 
 RBStatusbar *
-rb_statusbar_new (RhythmDB *db, GtkActionGroup *actions)
+rb_statusbar_new (RhythmDB *db,
+                  GtkActionGroup *actions)
 {
         RBStatusbar *statusbar = g_object_new (RB_TYPE_STATUSBAR,
                                                "db", db,
diff -u -p -r1.33 rb-tray-icon.c
--- shell/rb-tray-icon.c	14 Jul 2006 12:30:53 -0000	1.33
+++ shell/rb-tray-icon.c	17 Jul 2006 10:58:12 -0000
@@ -235,6 +235,10 @@ rb_tray_icon_finalize (GObject *object)
 
 	g_return_if_fail (tray->priv != NULL);
 
+	if (tray->priv->shell_player != NULL) {
+		g_object_unref (tray->priv->shell_player);
+	}
+
 	gtk_object_destroy (GTK_OBJECT (tray->priv->tooltips));
 
 	G_OBJECT_CLASS (rb_tray_icon_parent_class)->finalize (object);
@@ -244,12 +248,13 @@ static void
 rb_tray_icon_sync_action (RBShell *shell, gboolean visible, RBTrayIcon *tray)
 {
 	GtkAction *action;
+
 	if ((tray->priv->actiongroup != NULL) && (tray->priv->shell != NULL)) {
 		gboolean visible;
 
 		action = gtk_action_group_get_action (tray->priv->actiongroup,
 						      "TrayShowWindow");
-		g_object_get (G_OBJECT (tray->priv->shell), "visibility", &visible, NULL);
+		g_object_get (tray->priv->shell, "visibility", &visible, NULL);
 		gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
 
 		action = gtk_action_group_get_action (tray->priv->actiongroup,
@@ -279,7 +284,7 @@ rb_tray_icon_set_property (GObject *obje
 					 "visibility_changed",
 					 G_CALLBACK (rb_tray_icon_sync_action),
 					 tray, 0);
-		g_object_get (G_OBJECT (tray->priv->shell),
+		g_object_get (tray->priv->shell,
 			      "shell-player", &tray->priv->shell_player,
 			      NULL);
 		rb_tray_icon_sync_action (NULL, FALSE, tray);
diff -u -p -r1.42 rb-audiocd-source.c
--- sources/rb-audiocd-source.c	14 Jul 2006 12:31:28 -0000	1.42
+++ sources/rb-audiocd-source.c	17 Jul 2006 10:58:13 -0000
@@ -40,7 +40,6 @@
 #include "eel-gconf-extensions.h"
 #include "rb-audiocd-source.h"
 #include "rb-util.h"
-#include "rb-stock-icons.h"
 #include "rb-debug.h"
 #include "rb-dialog.h"
 
@@ -162,9 +161,9 @@ rb_audiocd_source_new (RBShell *shell,
 
 	g_assert (rb_audiocd_is_volume_audiocd (volume));
 
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
+	g_object_get (shell, "db", &db, NULL);
 	entry_type =  rhythmdb_entry_register_type (db, NULL);
-	g_object_unref (G_OBJECT (db));
+	g_object_unref (db);
 
 	entry_type->can_sync_metadata = (RhythmDBEntryCanSyncFunc)rb_true_function;
 	/* TODO same the metadata somewhere */
@@ -378,6 +377,19 @@ rb_audiocd_scan_songs (RBAudioCdSource *
 	return ok;
 }
 
+static RhythmDB *
+get_db_for_source (RBAudioCdSource *source)
+{
+	RBShell *shell;
+	RhythmDB *db;
+
+  	g_object_get (source, "shell", &shell, NULL);
+  	g_object_get (shell, "db", &db, NULL);
+  	g_object_unref (shell);
+
+        return db;
+}
+
 #ifdef HAVE_MUSICBRAINZ
 static void
 metadata_cb (SjMetadata *metadata,
@@ -387,7 +399,6 @@ metadata_cb (SjMetadata *metadata,
 {
 	RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source);
 	GList *cd_track = priv->tracks;
-	RBShell *shell;
 	RhythmDB *db;
 	GValue true_value = {0,};
 
@@ -405,9 +416,7 @@ metadata_cb (SjMetadata *metadata,
 		return;
 	}
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-	g_object_unref (G_OBJECT (shell));
+	db = get_db_for_source (source);
 
 	g_value_init (&true_value, G_TYPE_BOOLEAN);
 	g_value_set_boolean (&true_value, TRUE);
@@ -470,7 +479,8 @@ metadata_cb (SjMetadata *metadata,
 
 	g_object_unref (metadata);
 	priv->metadata = NULL;
-	g_object_unref (G_OBJECT (db));
+
+	g_object_unref (db);
 }
 
 static void
@@ -519,17 +529,14 @@ static gpointer
 rb_audiocd_load_songs (RBAudioCdSource *source)
 {
 	RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source);
-	RBShell *shell;
 	RhythmDB *db;
 	GnomeVFSVolume *volume;
 
-	g_object_get (G_OBJECT (source), "volume", &volume, NULL);
+	g_object_get (source, "volume", &volume, NULL);
 	priv->device_path = gnome_vfs_volume_get_device_path (volume);
-	g_object_unref (G_OBJECT (volume));
+	g_object_unref (volume);
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-	g_object_unref (G_OBJECT (shell));
+	db = get_db_for_source (source);
 
 	rb_debug ("loading Audio CD from %s", priv->device_path);
 	/* create a cdda gstreamer element, to get cd info from */
@@ -556,8 +563,8 @@ rb_audiocd_load_songs (RBAudioCdSource *
 		rb_audiocd_load_metadata (source, db);
 
 error_out:
-	g_object_unref (G_OBJECT (db));
-	g_object_unref (G_OBJECT (source));
+	g_object_unref (db);
+	g_object_unref (source);
 
 	return NULL;
 }
@@ -566,20 +573,19 @@ static void
 impl_delete_thyself (RBSource *source)
 {
 	RhythmDB *db;
-	RBShell *shell;
 	RhythmDBEntryType entry_type;
+
 	rb_debug ("audio cd ejected\n");
 
 	/* cancel the loading of metadata */
 	rb_audiocd_load_metadata_cancel (RB_AUDIOCD_SOURCE (source));
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-	g_object_unref (G_OBJECT (shell));
+	db = get_db_for_source (RB_AUDIOCD_SOURCE (source));
 
-	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+	g_object_get (source, "entry-type", &entry_type, NULL);
 	rhythmdb_entry_delete_by_type (db, entry_type);
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
+
 	rhythmdb_commit (db);
 	g_object_unref (db);
 }
diff -u -p -r1.25 rb-auto-playlist-source.c
--- sources/rb-auto-playlist-source.c	14 Jul 2006 12:53:45 -0000	1.25
+++ sources/rb-auto-playlist-source.c	17 Jul 2006 10:58:13 -0000
@@ -100,14 +100,14 @@ struct _RBAutoPlaylistSourcePrivate
 	RhythmDBPropType search_prop;
 };
 
+static gpointer playlist_pixbuf = NULL;
+
 G_DEFINE_TYPE (RBAutoPlaylistSource, rb_auto_playlist_source, RB_TYPE_PLAYLIST_SOURCE)
 #define RB_AUTO_PLAYLIST_SOURCE_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), RB_TYPE_AUTO_PLAYLIST_SOURCE, RBAutoPlaylistSourcePrivate))
 
 static void
 rb_auto_playlist_source_class_init (RBAutoPlaylistSourceClass *klass)
 {
-	gint size;
-
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	RBSourceClass *source_class = RB_SOURCE_CLASS (klass);
 	RBPlaylistSourceClass *playlist_class = RB_PLAYLIST_SOURCE_CLASS (klass);
@@ -129,21 +129,31 @@ rb_auto_playlist_source_class_init (RBAu
 
 	playlist_class->impl_save_contents_to_xml = impl_save_contents_to_xml;
 
-	gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
-	klass->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-						  GNOME_MEDIA_AUTO_PLAYLIST,
-						  size,
-						  0, NULL);
-
 	g_type_class_add_private (klass, sizeof (RBAutoPlaylistSourcePrivate));
 }
 
 static void
 rb_auto_playlist_source_init (RBAutoPlaylistSource *source)
 {
-	RBAutoPlaylistSourceClass *klass = RB_AUTO_PLAYLIST_SOURCE_GET_CLASS (source);
+	if (playlist_pixbuf == NULL) {
+		gint size;
+
+		gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
+		playlist_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+							    GNOME_MEDIA_AUTO_PLAYLIST,
+							    size,
+							    0, NULL);
+		g_object_add_weak_pointer (playlist_pixbuf,
+					   (gpointer *) &playlist_pixbuf);
+
+		rb_source_set_pixbuf (RB_SOURCE (source), playlist_pixbuf);
+
+		/* drop the initial reference to the icon */
+		g_object_unref (playlist_pixbuf);
+	} else {
+		rb_source_set_pixbuf (RB_SOURCE (source), playlist_pixbuf);
+	}
 
-	rb_source_set_pixbuf (RB_SOURCE (source), klass->pixbuf);
 }
 
 static void
@@ -196,7 +206,7 @@ rb_auto_playlist_source_constructor (GTy
 				 G_CALLBACK (rb_auto_playlist_source_songs_sort_order_changed_cb),
 				 source, 0);
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
+	g_object_get (source, "shell", &shell, NULL);
 	priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
 							       "AutoPlaylistActions",
 							       NULL, 0,
@@ -208,7 +218,7 @@ rb_auto_playlist_source_constructor (GTy
 					    (GCallback)search_action_changed,
 					    shell);
 	priv->search_prop = RHYTHMDB_PROP_SEARCH_MATCH;
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	/* reparent the entry view */
 	g_object_ref (songs);
@@ -452,16 +462,17 @@ impl_receive_drag (RBSource *asource, Gt
 
 	names = g_strsplit ((char *)data->data, "\r\n", 0);
 	propid = rb_auto_playlist_source_drag_atom_to_prop (data->type);
-	g_object_get (G_OBJECT (asource), "db", &db, NULL);
 
-	for (i=0; names[i]; i++) {
-		if (subquery == NULL)
+	g_object_get (asource, "db", &db, NULL);
+
+	for (i = 0; names[i]; i++) {
+		if (subquery == NULL) {
 			subquery = rhythmdb_query_parse (db,
 							 RHYTHMDB_QUERY_PROP_EQUALS,
 							 propid,
 							 names[i],
 							 RHYTHMDB_QUERY_END);
-		else
+		} else {
 			rhythmdb_query_append (db,
 					       subquery,
 					       RHYTHMDB_QUERY_DISJUNCTION,
@@ -469,6 +480,7 @@ impl_receive_drag (RBSource *asource, Gt
 					       propid,
 					       names[i],
 					       RHYTHMDB_QUERY_END);
+		}
 	}
 
 	g_strfreev (names);
@@ -477,7 +489,7 @@ impl_receive_drag (RBSource *asource, Gt
 		RhythmDBEntryType qtype;
 		GPtrArray *query;
 
-		g_object_get (G_OBJECT (source), "entry-type", &qtype, NULL);
+		g_object_get (source, "entry-type", &qtype, NULL);
 		if (qtype == RHYTHMDB_ENTRY_TYPE_INVALID)
 			qtype = RHYTHMDB_ENTRY_TYPE_SONG;
 
@@ -493,7 +505,7 @@ impl_receive_drag (RBSource *asource, Gt
 						   NULL, 0);
 	}
 
-	g_object_unref (G_OBJECT (db));
+	g_object_unref (db);
 
 	return TRUE;
 }
@@ -591,10 +603,13 @@ static void
 rb_auto_playlist_source_do_query (RBAutoPlaylistSource *source, gboolean subset)
 {
 	RBAutoPlaylistSourcePrivate *priv = RB_AUTO_PLAYLIST_SOURCE_GET_PRIVATE (source);
-	RhythmDB *db = rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source));
+	RhythmDB *db;
 	RhythmDBQueryModel *query_model;
 	GPtrArray *query;
 
+	/* this doesn't add a ref */
+	db = rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source));
+
 	g_assert (priv->cached_all_query);
 
 	if (!priv->search_text) {
@@ -611,11 +626,11 @@ rb_auto_playlist_source_do_query (RBAuto
 
 	if (subset) {
 		/* just apply the new query to the existing query model */
-		g_object_get (G_OBJECT (priv->browser), "input-model", &query_model, NULL);
+		g_object_get (priv->browser, "input-model", &query_model, NULL);
 		g_assert (query_model != priv->cached_all_query);
-		g_object_set (G_OBJECT (query_model), "query", query, NULL);
+		g_object_set (query_model, "query", query, NULL);
 		rhythmdb_query_model_reapply_query (query_model, FALSE);
-		g_object_unref (G_OBJECT (query_model));
+		g_object_unref (query_model);
 	} else {
 		/* otherwise, we need a new query model */
 		query_model = g_object_new (RHYTHMDB_TYPE_QUERY_MODEL,
@@ -636,6 +651,7 @@ rb_auto_playlist_source_do_query (RBAuto
 						     query);
 		g_object_unref (G_OBJECT (query_model));
 	}
+
 	rhythmdb_query_free (query);
 }
 
@@ -656,6 +672,8 @@ rb_auto_playlist_source_set_query (RBAut
 		rhythmdb_query_free (priv->query);
 	if (priv->cached_all_query)
 		g_object_unref (G_OBJECT (priv->cached_all_query));
+	if (priv->limit_value)
+		g_value_array_free (priv->limit_value);
 
 	/* playlists that aren't limited, with a particular sort order, are user-orderable */
 	rb_entry_view_set_columns_clickable (songs, (limit_type == RHYTHMDB_QUERY_MODEL_LIMIT_NONE));
@@ -663,8 +681,6 @@ rb_auto_playlist_source_set_query (RBAut
 
 	priv->query = rhythmdb_query_copy (query);
 	priv->limit_type = limit_type;
-	if (priv->limit_value)
-		g_value_array_free (priv->limit_value);
 	priv->limit_value = limit_value ? g_value_array_copy (limit_value) : NULL;
 
 	priv->cached_all_query = g_object_new (RHYTHMDB_TYPE_QUERY_MODEL,
@@ -719,10 +735,10 @@ rb_auto_playlist_source_browser_changed_
 	RBEntryView *songs = rb_source_get_entry_view (RB_SOURCE (source));
 	RhythmDBQueryModel *query_model;
 
-	g_object_get (G_OBJECT (browser), "output-model", &query_model, NULL);
+	g_object_get (browser, "output-model", &query_model, NULL);
 	rb_entry_view_set_model (songs, query_model);
 	rb_playlist_source_set_query_model (RB_PLAYLIST_SOURCE (source), query_model);
-	g_object_unref (G_OBJECT (query_model));
+	g_object_unref (query_model);
 
 	rb_source_notify_filter_changed (RB_SOURCE (source));
 }
@@ -774,7 +790,8 @@ search_action_changed (GtkRadioAction  *
 	gboolean active;
 	RBAutoPlaylistSource *source;
 
-	g_object_get (G_OBJECT (shell), "selected-source", &source, NULL);
+	g_object_get (shell, "selected-source", &source, NULL);
+
 	priv = RB_AUTO_PLAYLIST_SOURCE_GET_PRIVATE (source);
 
 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current));
@@ -784,5 +801,9 @@ search_action_changed (GtkRadioAction  *
 		priv->search_prop = search_action_to_prop (GTK_ACTION (current));
 		rb_auto_playlist_source_do_query (source, FALSE);
 		rb_source_notify_filter_changed (RB_SOURCE (source));
+	}
+
+	if (source != NULL) {
+		g_object_unref (source);
 	}
 }
diff -u -p -r1.4 rb-auto-playlist-source.h
--- sources/rb-auto-playlist-source.h	14 Jul 2006 12:31:29 -0000	1.4
+++ sources/rb-auto-playlist-source.h	17 Jul 2006 10:58:13 -0000
@@ -44,7 +44,6 @@ typedef struct
 typedef struct
 {
 	RBPlaylistSourceClass parent;
-	GdkPixbuf *pixbuf;
 } RBAutoPlaylistSourceClass;
 
 GType		rb_auto_playlist_source_get_type 	(void);
diff -u -p -r1.14 rb-browser-source.c
--- sources/rb-browser-source.c	14 Jul 2006 12:31:29 -0000	1.14
+++ sources/rb-browser-source.c	17 Jul 2006 10:58:14 -0000
@@ -35,7 +35,6 @@
 #include "rhythmdb-query-model.h"
 #include "rb-property-view.h"
 #include "rb-glade-helpers.h"
-#include "rb-stock-icons.h"
 #include "rb-entry-view.h"
 #include "rb-library-browser.h"
 #include "rb-util.h"
@@ -282,6 +281,8 @@ rb_browser_source_finalize (GObject *obj
 	eel_gconf_notification_remove (source->priv->state_paned_notify_id);
 	eel_gconf_notification_remove (source->priv->state_sorting_notify_id);
 
+	g_object_unref (source->priv->action_group);
+
 	G_OBJECT_CLASS (rb_browser_source_parent_class)->finalize (object);
 }
 
@@ -338,7 +339,7 @@ search_action_changed (GtkRadioAction  *
 	gboolean         active;
 	RBBrowserSource *source;
 
-	g_object_get (G_OBJECT (shell), "selected-source", &source, NULL);
+	g_object_get (shell, "selected-source", &source, NULL);
 
 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current));
 
@@ -348,6 +349,10 @@ search_action_changed (GtkRadioAction  *
 		rb_browser_source_do_query (source, FALSE);
 		rb_source_notify_filter_changed (RB_SOURCE (source));
 	}
+
+	if (source != NULL) {
+		g_object_unref (source);
+	}
 }
 
 static GObject *
@@ -366,8 +371,8 @@ rb_browser_source_constructor (GType typ
 	source = RB_BROWSER_SOURCE (G_OBJECT_CLASS (rb_browser_source_parent_class)
 			->constructor (type, n_construct_properties, construct_properties));
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &source->priv->db, NULL);
 	shell_player = rb_shell_get_player (shell);
 
 	source->priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
@@ -382,7 +387,7 @@ rb_browser_source_constructor (GType typ
 					    0,
 					    (GCallback)search_action_changed,
 					    shell);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	source->priv->paned = gtk_vpaned_new ();
 
@@ -552,7 +557,7 @@ rb_browser_source_cmd_choose_artist (Gtk
 
 	rb_debug ("choosing artist");
 
-	g_object_get (G_OBJECT (shell), "selected-source", &source, NULL);
+	g_object_get (shell, "selected-source", &source, NULL);
 	props = rb_source_gather_selected_properties (RB_SOURCE (source), RHYTHMDB_PROP_ARTIST);
 	view = rb_library_browser_get_property_view (source->priv->browser, RHYTHMDB_PROP_ARTIST);
 	if (view)
@@ -680,6 +685,7 @@ impl_delete (RBSource *asource)
 		rhythmdb_entry_delete (source->priv->db, tem->data);
 		rhythmdb_commit (source->priv->db);
 	}
+	g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (sel);
 }
 
@@ -816,10 +822,10 @@ rb_browser_source_browser_changed_cb (RB
 {
 	RhythmDBQueryModel *query_model;
 
-	g_object_get (G_OBJECT (browser), "output-model", &query_model, NULL);
+	g_object_get (browser, "output-model", &query_model, NULL);
 	rb_entry_view_set_model (source->priv->songs, query_model);
-	g_object_set (RB_SOURCE (source), "query-model", query_model, NULL);
-	g_object_unref (G_OBJECT (query_model));
+	g_object_set (source, "query-model", query_model, NULL);
+	g_object_unref (query_model);
 
 	rb_source_notify_filter_changed (RB_SOURCE (source));
 }
@@ -852,7 +858,7 @@ rb_browser_source_do_query (RBBrowserSou
 		return;
 	}
 
-	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+	g_object_get (source, "entry-type", &entry_type, NULL);
 	query = rhythmdb_query_parse (source->priv->db,
 				      RHYTHMDB_QUERY_PROP_EQUALS,
 				      RHYTHMDB_PROP_TYPE,
@@ -868,10 +874,10 @@ rb_browser_source_do_query (RBBrowserSou
 		 * of the existing results, so we can just change the query on the existing query
 		 * model and reapply the query.
 		 */
-		g_object_get (G_OBJECT (source->priv->browser), "input-model", &query_model, NULL);
-		g_object_set (G_OBJECT (query_model), "query", query, NULL);
+		g_object_get (source->priv->browser, "input-model", &query_model, NULL);
+		g_object_set (query_model, "query", query, NULL);
 		rhythmdb_query_model_reapply_query (query_model, FALSE);
-		g_object_unref (G_OBJECT (query_model));
+		g_object_unref (query_model);
 	} else {/* otherwise build a query based on the search text and feed it to the browser */
 		query_model = rhythmdb_query_model_new_empty (source->priv->db);
 		rb_library_browser_set_model (source->priv->browser, query_model, TRUE);
diff -u -p -r1.40 rb-daap-source.c
--- sources/rb-daap-source.c	14 Jul 2006 12:53:45 -0000	1.40
+++ sources/rb-daap-source.c	17 Jul 2006 10:58:14 -0000
@@ -116,6 +116,28 @@ GtkActionGroup *daap_action_group;
 guint daap_ui_merge_id;
 
 static void
+rb_daap_source_dispose (GObject *object)
+{
+	RBDAAPSource *source = RB_DAAP_SOURCE (object);
+
+	/* we should already have been disconnected */
+	g_assert (source->priv->connection == NULL);
+
+	G_OBJECT_CLASS (rb_daap_source_parent_class)->dispose (object);
+}
+
+static void
+rb_daap_source_finalize (GObject *object)
+{
+	RBDAAPSource *source = RB_DAAP_SOURCE (object);
+
+	g_free (source->priv->service_name);
+	g_free (source->priv->host);
+
+	G_OBJECT_CLASS (rb_daap_source_parent_class)->finalize (object);
+}
+
+static void
 rb_daap_source_class_init (RBDAAPSourceClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -123,6 +145,7 @@ rb_daap_source_class_init (RBDAAPSourceC
 	RBBrowserSourceClass *browser_source_class = RB_BROWSER_SOURCE_CLASS (klass);
 
 	object_class->dispose      = rb_daap_source_dispose;
+	object_class->finalize     = rb_daap_source_finalize;
 	object_class->get_property = rb_daap_source_get_property;
 	object_class->set_property = rb_daap_source_set_property;
 
@@ -187,22 +210,6 @@ rb_daap_source_init (RBDAAPSource *sourc
 }
 
 static void
-rb_daap_source_dispose (GObject *object)
-{
-	RBDAAPSource *source = RB_DAAP_SOURCE (object);
-
-	if (source->priv) {
-		/* we should already have been disconnected */
-		g_assert (source->priv->connection == NULL);
-
-		g_free (source->priv->service_name);
-		g_free (source->priv->host);
-	}
-
-	G_OBJECT_CLASS (rb_daap_source_parent_class)->dispose (object);
-}
-
-static void
 rb_daap_source_set_property (GObject *object,
 			    guint prop_id,
 			    const GValue *value,
@@ -266,15 +273,10 @@ rb_daap_get_icon (gboolean password_prot
 		  gboolean connected)
 {
 	GdkPixbuf *icon;
-	GtkIconTheme *theme;
-	gint size;
 
 	g_return_val_if_fail (daap_share_pixbuf != NULL, NULL);
 	g_return_val_if_fail (daap_share_locked_pixbuf != NULL, NULL);
 
-	theme = gtk_icon_theme_get_default ();
-	gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
-
 	if (! password_protected) {
 		icon = g_object_ref (daap_share_pixbuf);
 	} else if (connected) {
@@ -299,12 +301,11 @@ rb_daap_source_new (RBShell *shell,
 	GdkPixbuf *icon;
 	RhythmDB *db;
 
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
+	g_object_get (shell, "db", &db, NULL);
 	type = rhythmdb_entry_register_type (db, NULL);
-	g_object_unref (G_OBJECT (db));
+	g_object_unref (db);
 
 	icon = rb_daap_get_icon (password_protected, FALSE);
-
 	source = RB_SOURCE (g_object_new (RB_TYPE_DAAP_SOURCE,
 					  "service-name", service_name,
 					  "name", name,
@@ -561,6 +562,7 @@ destroy_pixbufs (void)
 	if (daap_share_pixbuf != NULL) {
 		g_object_unref (daap_share_pixbuf);
 	}
+
 	daap_share_pixbuf = NULL;
 
 	if (daap_share_locked_pixbuf != NULL) {
@@ -598,7 +600,7 @@ rb_daap_sources_init (RBShell *shell)
 	create_pixbufs ();
 
 	/* add UI */
-	g_object_get (G_OBJECT (shell),
+	g_object_get (shell,
 		      "ui-manager", &uimanager,
 		      NULL);
 	daap_action_group = gtk_action_group_new ("DaapActions");
@@ -611,7 +613,7 @@ rb_daap_sources_init (RBShell *shell)
 	daap_ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager,
 							    rb_file ("daap-ui.xml"),
 							    NULL);
-	g_object_unref (G_OBJECT (uimanager));
+	g_object_unref (uimanager);
 
 	return NULL;
 }
@@ -626,7 +628,7 @@ rb_daap_sources_shutdown (RBShell *shell
 	g_assert (!daap_was_shutdown);
 	daap_was_shutdown = TRUE;
 
-	g_object_get (G_OBJECT (shell),
+	g_object_get (shell,
 		      "ui-manager", &uimanager,
 		      NULL);
 
@@ -642,7 +644,7 @@ rb_daap_sources_shutdown (RBShell *shell
 	gtk_ui_manager_remove_ui (uimanager, daap_ui_merge_id);
 	gtk_ui_manager_remove_action_group (uimanager, daap_action_group);
 
-	g_object_unref (G_OBJECT (uimanager));
+	g_object_unref (uimanager);
 	g_object_unref (shell);
 
 	destroy_pixbufs ();
@@ -760,7 +762,7 @@ rb_daap_source_connection_cb (RBDAAPConn
 		return;
 	}
 
-	g_object_get (G_OBJECT (daap_source),
+	g_object_get (daap_source,
 		      "shell", &shell,
 		      "entry-type", &entry_type,
 		      NULL);
@@ -775,7 +777,8 @@ rb_daap_source_connection_cb (RBDAAPConn
 		rb_shell_append_source (shell, playlist_source, RB_SOURCE (daap_source));
 		daap_source->priv->playlist_sources = g_slist_prepend (daap_source->priv->playlist_sources, playlist_source);
 	}
-	g_object_unref (G_OBJECT (shell));
+
+	g_object_unref (shell);
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
 }
 
@@ -792,12 +795,12 @@ rb_daap_source_activate (RBSource *sourc
 		return;
 	}
 
-	g_object_get (G_OBJECT (daap_source),
+	g_object_get (daap_source,
 		      "shell", &shell,
 		      "entry-type", &type,
 		      "name", &name,
 		      NULL);
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
+	g_object_get (shell, "db", &db, NULL);
 
 	daap_source->priv->connection = rb_daap_connection_new (name,
 								daap_source->priv->host,
@@ -811,8 +814,9 @@ rb_daap_source_activate (RBSource *sourc
 				    (RBDAAPConnectionCallback) rb_daap_source_connection_cb,
 				    source);
 
-	g_object_unref (G_OBJECT (db));
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (db);
+	g_object_unref (shell);
+	g_free (name);
 
         g_signal_connect (daap_source->priv->connection,
 			  "authenticate",
@@ -849,7 +853,7 @@ rb_daap_source_cmd_disconnect (GtkAction
 {
 	RBSource *source;
 
-	g_object_get (G_OBJECT (shell),
+	g_object_get (shell,
 		      "selected-source", &source,
 		      NULL);
 
@@ -859,6 +863,10 @@ rb_daap_source_cmd_disconnect (GtkAction
 	}
 
 	rb_daap_source_disconnect (RB_DAAP_SOURCE (source));
+
+	if (source != NULL) {
+		g_object_unref (source);
+	}
 }
 
 static void
@@ -874,13 +882,14 @@ rb_daap_source_disconnect (RBDAAPSource 
 
 		daap_source->priv->disconnecting = TRUE;
 
-		g_object_get (G_OBJECT (daap_source), "shell", &shell, "entry-type", &type, NULL);
-		g_object_get (G_OBJECT (shell), "db", &db, NULL);
-		g_object_unref (G_OBJECT (shell));
+		g_object_get (daap_source, "shell", &shell, "entry-type", &type, NULL);
+		g_object_get (shell, "db", &db, NULL);
+		g_object_unref (shell);
 
 		rhythmdb_entry_delete_by_type (db, type);
 		rhythmdb_commit (db);
-		g_object_unref (G_OBJECT (db));
+
+		g_object_unref (db);
 
 		for (l = daap_source->priv->playlist_sources; l!= NULL; l = l->next) {
 			RBSource *playlist_source = RB_SOURCE (l->data);
@@ -982,13 +991,13 @@ rb_daap_source_get_headers (RBDAAPSource
 		RhythmDBEntry *entry;
 		gulong bitrate;
 
-		g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-		g_object_get (G_OBJECT (shell), "db", &db, NULL);
+		g_object_get (source, "shell", &shell, NULL);
+		g_object_get (shell, "db", &db, NULL);
 
 		entry = rhythmdb_entry_lookup_by_location (db, uri);
 
-		g_object_unref (G_OBJECT (shell));
-		g_object_unref (G_OBJECT (db));
+		g_object_unref (shell);
+		g_object_unref (db);
 
 		bitrate = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_BITRATE);
 		/* bitrate is kilobits per second */
diff -u -p -r1.8 rb-import-errors-source.c
--- sources/rb-import-errors-source.c	12 Jul 2006 23:30:07 -0000	1.8
+++ sources/rb-import-errors-source.c	17 Jul 2006 10:58:14 -0000
@@ -119,10 +119,10 @@ rb_import_errors_source_constructor (GTy
 	source = RB_IMPORT_ERRORS_SOURCE (G_OBJECT_CLASS (rb_import_errors_source_parent_class)->
 			constructor (type, n_construct_properties, construct_properties));
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &source->priv->db, NULL);
 	shell_player = rb_shell_get_player (shell);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	/* construct real query */
 	query = rhythmdb_query_parse (source->priv->db,
@@ -184,7 +184,7 @@ rb_import_errors_source_new (RBShell *sh
 	RBSource *source;
 	RhythmDBEntryType entry_type;
 
-	g_object_get (G_OBJECT (library), "entry-type", &entry_type, NULL);
+	g_object_get (library, "entry-type", &entry_type, NULL);
 	source = RB_SOURCE (g_object_new (RB_TYPE_IMPORT_ERRORS_SOURCE,
 					  "name", _("Import Errors"),
 					  "shell", shell,
@@ -206,6 +206,8 @@ impl_delete (RBSource *asource)
 		rhythmdb_entry_delete (source->priv->db, tem->data);
 		rhythmdb_commit (source->priv->db);
 	}
+
+	g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (sel);
 }
 
@@ -215,7 +217,7 @@ impl_get_status (RBSource *asource, char
 	RhythmDBQueryModel *model;
 	gint count;
 
-	g_object_get (G_OBJECT (asource), "query-model", &model, NULL);
+	g_object_get (asource, "query-model", &model, NULL);
 	count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
 	g_object_unref (model);
 
diff -u -p -r1.60 rb-ipod-source.c
--- sources/rb-ipod-source.c	14 Jul 2006 12:53:45 -0000	1.60
+++ sources/rb-ipod-source.c	17 Jul 2006 10:58:15 -0000
@@ -138,7 +138,7 @@ rb_ipod_source_name_changed_cb (RBiPodSo
 {
 	char *name;
 
-	g_object_get (RB_SOURCE (source), "name", &name, NULL);
+	g_object_get (source, "name", &name, NULL);
 	rb_ipod_source_set_ipod_name (source, name);
 	g_free (name);
 }
@@ -195,7 +195,8 @@ rb_ipod_source_dispose (GObject *object)
 }
 
 RBRemovableMediaSource *
-rb_ipod_source_new (RBShell *shell, GnomeVFSVolume *volume)
+rb_ipod_source_new (RBShell *shell,
+                    GnomeVFSVolume *volume)
 {
 	RBiPodSource *source;
 	RhythmDBEntryType entry_type;
@@ -203,9 +204,9 @@ rb_ipod_source_new (RBShell *shell, Gnom
 
 	g_assert (rb_ipod_is_volume_ipod (volume));
 
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
+	g_object_get (shell, "db", &db, NULL);
 	entry_type =  rhythmdb_entry_register_type (db, NULL);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (db);
 
 	source = RB_IPOD_SOURCE (g_object_new (RB_TYPE_IPOD_SOURCE,
 					  "entry-type", entry_type,
@@ -259,7 +260,7 @@ add_rb_playlist (RBiPodSource *source, I
 	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
 	RhythmDBEntryType entry_type;
 
-  	g_object_get (G_OBJECT (source),
+  	g_object_get (source,
 		      "shell", &shell,
 		      "entry-type", &entry_type,
 		      NULL);
@@ -283,7 +284,7 @@ add_rb_playlist (RBiPodSource *source, I
 	}
 
 	rb_shell_append_source (shell, playlist_source, RB_SOURCE (source));
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 }
 
 static void
@@ -348,7 +349,7 @@ add_ipod_song_to_db (RBiPodSource *sourc
 	char *pc_path;
 
 	/* Set URI */
-	g_object_get (G_OBJECT (source), "entry-type", &entry_type,
+	g_object_get (source, "entry-type", &entry_type,
 		      NULL);
 
 	pc_path = ipod_path_to_uri (priv->ipod_mount_path,
@@ -495,17 +496,27 @@ add_ipod_song_to_db (RBiPodSource *sourc
 	rhythmdb_commit (RHYTHMDB (db));
 }
 
+static RhythmDB *
+get_db_for_source (RBiPodSource *source)
+{
+	RBShell *shell;
+	RhythmDB *db;
+
+  	g_object_get (source, "shell", &shell, NULL);
+  	g_object_get (shell, "db", &db, NULL);
+  	g_object_unref (shell);
+
+        return db;
+}
+
 static gboolean
 load_ipod_db_idle_cb (RBiPodSource *source)
 {
-	RBShell *shell;
 	RhythmDB *db;
  	GList *it;
 	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
 
-  	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-  	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-  	g_object_unref (G_OBJECT (shell));
+        db = get_db_for_source (source);
 
   	g_assert (db != NULL);
  	for (it = priv->ipod_db->tracks; it != NULL; it = it->next) {
@@ -514,7 +525,8 @@ load_ipod_db_idle_cb (RBiPodSource *sour
 
 	load_ipod_playlists (source);
 
-	g_object_unref (G_OBJECT (db));
+	g_object_unref (db);
+
 	return FALSE;
 }
 
@@ -524,7 +536,7 @@ rb_ipod_load_songs (RBiPodSource *source
 	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
 	GnomeVFSVolume *volume;
 
-	g_object_get (G_OBJECT (source), "volume", &volume, NULL);
+	g_object_get (source, "volume", &volume, NULL);
 	priv->ipod_mount_path = rb_ipod_get_mount_path (volume);
 
  	priv->ipod_db = itdb_parse (priv->ipod_mount_path, NULL);
@@ -538,6 +550,8 @@ rb_ipod_load_songs (RBiPodSource *source
 			      NULL);
 		g_idle_add ((GSourceFunc)load_ipod_db_idle_cb, source);
 	}
+
+        g_object_unref (volume);
 }
 
 static gchar *
@@ -707,15 +721,16 @@ hal_udi_is_ipod (const char *udi)
 		}
 	}
 #endif
-	g_free (parent_udi);
 	if (parent_name == NULL || dbus_error_is_set (&error))
 		goto end;
 
 	if (strcmp (parent_name, "iPod") == 0)
 		result = TRUE;
 
-	g_free (parent_name);
 end:
+	g_free (parent_udi);
+	g_free (parent_name);
+
 	if (dbus_error_is_set (&error)) {
 		rb_debug ("Error: %s\n", error.message);
 		dbus_error_free (&error);
@@ -800,14 +815,11 @@ impl_move_to_trash (RBSource *asource)
 {
 	GList *sel, *tem;
 	RBEntryView *songs;
-	RBShell *shell;
 	RhythmDB *db;
 	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (asource);
 	RBiPodSource *source = RB_IPOD_SOURCE (asource);
 
-  	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-  	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-  	g_object_unref (G_OBJECT (shell));
+        db = get_db_for_source (source);
 
 	songs = rb_source_get_entry_view (RB_SOURCE (asource));
 	sel = rb_entry_view_get_selected_entries (songs);
@@ -830,10 +842,13 @@ impl_move_to_trash (RBSource *asource)
 		rhythmdb_entry_move_to_trash (db, entry);
 		rhythmdb_commit (db);
 	}
+
 	if (sel != NULL) {
 		itdb_write (priv->ipod_db, NULL);
 	}
 
+  	g_object_unref (db);
+
 	g_list_free (sel);
 }
 
@@ -874,13 +889,10 @@ build_filename (RBSource *asource, Rhyth
 static void
 completed_cb (RhythmDBEntry *entry, const char *dest, RBiPodSource *source)
 {
-	RBShell *shell;
 	RhythmDB *db;
 	Itdb_Track *song;
 
-  	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-  	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-  	g_object_unref (G_OBJECT (shell));
+        db = get_db_for_source (source);
 
 	song = create_ipod_song_from_entry (entry);
 	if (song != NULL) {
@@ -908,11 +920,11 @@ impl_paste (RBSource *asource, GList *en
 	GList *l;
 	RBShell *shell;
 
-	g_object_get (G_OBJECT (asource), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell),
+	g_object_get (asource, "shell", &shell, NULL);
+	g_object_get (shell,
 		      "removable-media-manager", &rm_mgr,
 		      NULL);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	for (l = entries; l != NULL; l = l->next) {
 		RhythmDBEntry *entry;
@@ -922,7 +934,7 @@ impl_paste (RBSource *asource, GList *en
 
 		entry = (RhythmDBEntry *)l->data;
 		entry_type = rhythmdb_entry_get_entry_type (entry);
-		g_object_get (G_OBJECT (asource),
+		g_object_get (asource,
 			      "entry-type", &ipod_entry_type,
 			      NULL);
 		if (entry_type == RHYTHMDB_ENTRY_TYPE_IRADIO_STATION ||
@@ -945,7 +957,8 @@ impl_paste (RBSource *asource, GList *en
 		g_free (dest);
 		g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
 	}
-	g_object_unref (G_OBJECT (rm_mgr));
+
+	g_object_unref (rm_mgr);
 }
 
 static gboolean
@@ -954,15 +967,12 @@ impl_receive_drag (RBSource *asource, Gt
 	RBBrowserSource *source = RB_BROWSER_SOURCE (asource);
 	GList *list, *i;
 	GList *entries = NULL;
-	RBShell *shell;
 	RhythmDB *db;
 
 	rb_debug ("parsing uri list");
 	list = rb_uri_list_parse ((const char *) data->data);
 
-  	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-  	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-  	g_object_unref (G_OBJECT (shell));
+        db = get_db_for_source (RB_IPOD_SOURCE (source));
 
 	for (i = list; i != NULL; i = g_list_next (i)) {
 		if (i->data != NULL) {
diff -u -p -r1.125 rb-iradio-source.c
--- sources/rb-iradio-source.c	14 Jul 2006 12:53:45 -0000	1.125
+++ sources/rb-iradio-source.c	17 Jul 2006 10:58:16 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 
@@ -136,6 +136,8 @@ struct RBIRadioSourcePrivate
 	char *search_text;
 	char *selected_genre;
 
+	guint prefs_notify_id;
+	guint first_time_notify_id;
 	gboolean firstrun_done;
 
 	RhythmDBEntryType entry_type;
@@ -256,6 +258,9 @@ rb_iradio_source_finalize (GObject *obje
 
 	rb_debug ("finalizing iradio source");
 
+	eel_gconf_notification_remove (source->priv->prefs_notify_id);
+	eel_gconf_notification_remove (source->priv->first_time_notify_id);
+
 	G_OBJECT_CLASS (rb_iradio_source_parent_class)->finalize (object);
 }
 
@@ -275,10 +280,10 @@ rb_iradio_source_constructor (GType type
 
 	source->priv->paned = gtk_hpaned_new ();
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &source->priv->db, NULL);
 	shell_player = rb_shell_get_player (shell);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	source->priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
 								       "IRadioActions",
@@ -345,13 +350,17 @@ rb_iradio_source_constructor (GType type
 	gtk_box_pack_start_defaults (GTK_BOX (source->priv->vbox), source->priv->paned);
 
 	rb_iradio_source_state_prefs_sync (source);
-	eel_gconf_notification_add (CONF_STATE_IRADIO_DIR,
-				    (GConfClientNotifyFunc) rb_iradio_source_state_pref_changed,
-				    source);
+
+	source->priv->prefs_notify_id =
+		eel_gconf_notification_add (CONF_STATE_IRADIO_DIR,
+					    (GConfClientNotifyFunc) rb_iradio_source_state_pref_changed,
+					    source);
 	source->priv->firstrun_done = eel_gconf_get_boolean (CONF_FIRST_TIME);
-	eel_gconf_notification_add (CONF_FIRST_TIME,
-				    (GConfClientNotifyFunc) rb_iradio_source_first_time_changed,
-				    source);
+
+	source->priv->first_time_notify_id =
+		eel_gconf_notification_add (CONF_FIRST_TIME,
+					    (GConfClientNotifyFunc) rb_iradio_source_first_time_changed,
+					    source);
 	gtk_widget_show_all (GTK_WIDGET (source));
 
 	if (source->priv->entry_type == RHYTHMDB_ENTRY_TYPE_INVALID ||
@@ -563,9 +572,9 @@ impl_get_status (RBSource *asource, char
 	RhythmDBQueryModel *model;
 	guint num_entries;
 
-	g_object_get (G_OBJECT (asource), "query-model", &model, NULL);
+	g_object_get (asource, "query-model", &model, NULL);
 	num_entries = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
-	g_object_unref (G_OBJECT (model));
+	g_object_unref (model);
 
 	*text = g_strdup_printf (ngettext ("%d station", "%d stations", num_entries),
 				 num_entries);
@@ -581,13 +590,17 @@ static void
 impl_delete (RBSource *asource)
 {
 	RBIRadioSource *source = RB_IRADIO_SOURCE (asource);
+	GList *sel;
 	GList *l;
 
-	for (l = rb_entry_view_get_selected_entries (source->priv->stations); l != NULL;
-	     l = g_list_next (l)) {
+	sel = rb_entry_view_get_selected_entries (source->priv->stations);
+	for (l = sel; l != NULL; l = g_list_next (l)) {
 		rhythmdb_entry_delete (source->priv->db, l->data);
 		rhythmdb_commit (source->priv->db);
 	}
+
+	g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL);
+	g_list_free (sel);
 }
 
 static void
@@ -595,6 +608,7 @@ impl_song_properties (RBSource *asource)
 {
 	RBIRadioSource *source = RB_IRADIO_SOURCE (asource);
 	GtkWidget *dialog = rb_station_properties_dialog_new (source->priv->stations);
+
 	rb_debug ("in song properties");
 	if (dialog)
 		gtk_widget_show_all (dialog);
diff -u -p -r1.177 rb-library-source.c
--- sources/rb-library-source.c	14 Jul 2006 12:53:45 -0000	1.177
+++ sources/rb-library-source.c	17 Jul 2006 10:58:17 -0000
@@ -263,8 +263,8 @@ rb_library_source_constructor (GType typ
 	source = RB_LIBRARY_SOURCE (G_OBJECT_CLASS (rb_library_source_parent_class)
 			->constructor (type, n_construct_properties, construct_properties));
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &source->priv->db, NULL);
 
 	rb_library_source_ui_prefs_sync (source);
 
@@ -284,7 +284,7 @@ rb_library_source_constructor (GType typ
 
 	g_idle_add ((GSourceFunc)add_child_sources_idle, source);
 
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	return G_OBJECT (source);
 }
@@ -301,7 +301,6 @@ rb_library_source_new (RBShell *shell)
 					 "stock_music-library",
 					 size,
 					 0, NULL);
-
 	source = RB_SOURCE (g_object_new (RB_TYPE_LIBRARY_SOURCE,
 					  "name", _("Library"),
 					  "entry-type", RHYTHMDB_ENTRY_TYPE_SONG,
@@ -309,6 +308,10 @@ rb_library_source_new (RBShell *shell)
 					  "shell", shell,
 					  "icon", icon,
 					  NULL));
+	if (icon != NULL) {
+		g_object_unref (icon);
+	}
+
 	rb_shell_register_entry_type_for_source (shell, source,
 						 RHYTHMDB_ENTRY_TYPE_SONG);
 
@@ -1164,9 +1167,9 @@ impl_paste (RBSource *asource, GList *en
 		return;
 	}
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "removable-media-manager", &rm_mgr, NULL);
-	g_object_unref (G_OBJECT (shell));
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "removable-media-manager", &rm_mgr, NULL);
+	g_object_unref (shell);
 
 	for (l = entries; l != NULL; l = g_list_next (l)) {
 		RhythmDBEntry *entry = (RhythmDBEntry *)l->data;
@@ -1195,7 +1198,7 @@ impl_paste (RBSource *asource, GList *en
 							  (RBTranferCompleteCallback)completed_cb, source);
 	}
 
-	g_object_unref (G_OBJECT (rm_mgr));
+	g_object_unref (rm_mgr);
 }
 #endif
 
@@ -1209,7 +1212,7 @@ rb_library_source_add_child_source (cons
 	char *name;
 	GdkPixbuf *icon;
 
-	g_object_get (G_OBJECT (library_source), "shell", &shell, NULL);
+	g_object_get (library_source, "shell", &shell, NULL);
 	uri = gnome_vfs_uri_new (path);
 	name = gnome_vfs_uri_extract_short_name (uri);
 	gnome_vfs_uri_unref (uri);
@@ -1224,8 +1227,11 @@ rb_library_source_add_child_source (cons
 					   NULL, 0);
 	rhythmdb_query_free (query);
 
-	g_object_get (G_OBJECT (library_source), "icon", &icon, NULL);
-	g_object_set (G_OBJECT (source), "icon", icon, NULL);
+	g_object_get (library_source, "icon", &icon, NULL);
+	g_object_set (source, "icon", icon, NULL);
+	if (icon != NULL) {
+		g_object_unref (icon);
+	}
 
 	rb_shell_append_source (shell, source, RB_SOURCE (library_source));
 	library_source->priv->child_sources = g_list_prepend (library_source->priv->child_sources, source);
diff -u -p -r1.7 rb-missing-files-source.c
--- sources/rb-missing-files-source.c	12 Jul 2006 23:30:07 -0000	1.7
+++ sources/rb-missing-files-source.c	17 Jul 2006 10:58:17 -0000
@@ -23,7 +23,8 @@
  * you from trying to play them.
  */
 
-#include <config.h>
+#include "config.h"
+
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
@@ -317,6 +318,8 @@ impl_delete (RBSource *asource)
 		rhythmdb_entry_delete (source->priv->db, tem->data);
 		rhythmdb_commit (source->priv->db);
 	}
+
+	g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (sel);
 }
 
@@ -333,7 +336,7 @@ impl_get_status (RBSource *asource, char
 	RhythmDBQueryModel *model;
 	gint count;
 
-	g_object_get (G_OBJECT (asource), "query-model", &model, NULL);
+	g_object_get (asource, "query-model", &model, NULL);
 	count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
 	g_object_unref (model);
 
diff -u -p -r1.16 rb-play-queue-source.c
--- sources/rb-play-queue-source.c	14 Jul 2006 12:53:45 -0000	1.16
+++ sources/rb-play-queue-source.c	17 Jul 2006 10:58:17 -0000
@@ -152,9 +152,9 @@ rb_play_queue_source_constructor (GType 
 	GtkCellRenderer *renderer;
 	RhythmDBQueryModel *model;
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
+	g_object_get (source, "shell", &shell, NULL);
 	shell_player = rb_shell_get_player (shell);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 	priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
 							       "PlayQueueActions",
diff -u -p -r1.125 rb-playlist-source.c
--- sources/rb-playlist-source.c	14 Jul 2006 12:53:45 -0000	1.125
+++ sources/rb-playlist-source.c	17 Jul 2006 10:58:19 -0000
@@ -21,7 +21,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <unistd.h>
 #include <string.h>
@@ -32,7 +32,6 @@
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <totem-pl-parser.h>
 
-#include "rb-stock-icons.h"
 #include "rb-entry-view.h"
 #include "rb-search-entry.h"
 #include "rb-file-helpers.h"
@@ -194,17 +193,41 @@ static void
 rb_playlist_source_init (RBPlaylistSource *source)
 {
 	source->priv = RB_PLAYLIST_SOURCE_GET_PRIVATE (source);
+}
+
+static void
+rb_playlist_source_set_db (RBPlaylistSource *source,
+			   RhythmDB         *db)
+{
+	if (source->priv->db != NULL) {
+		g_signal_handlers_disconnect_by_func (source->priv->db,
+						      rb_playlist_source_entry_added_cb,
+						      source);
+		g_object_unref (source->priv->db);
+
+	}
+
+	source->priv->db = db;
+
+	if (source->priv->db != NULL) {
+		g_object_ref (source->priv->db);
+		g_signal_connect_object (G_OBJECT (source->priv->db), "entry_added",
+					 G_CALLBACK (rb_playlist_source_entry_added_cb),
+					 source, 0);
+	}
 
 }
 
 static GObject *
-rb_playlist_source_constructor (GType type, guint n_construct_properties,
+rb_playlist_source_constructor (GType type,
+				guint n_construct_properties,
 				GObjectConstructParam *construct_properties)
 {
 	GObject *shell_player;
 	RBPlaylistSource *source;
 	RBPlaylistSourceClass *klass;
 	RBShell *shell;
+	RhythmDB *db;
 
 	klass = RB_PLAYLIST_SOURCE_CLASS (g_type_class_peek (RB_TYPE_PLAYLIST_SOURCE));
 
@@ -214,17 +237,15 @@ rb_playlist_source_constructor (GType ty
 	if (source->priv->entry_type == NULL)
 		source->priv->entry_type = RHYTHMDB_ENTRY_TYPE_INVALID;
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &db, NULL);
 	shell_player = rb_shell_get_player (shell);
-	g_object_unref (G_OBJECT (shell));
+	rb_playlist_source_set_db (source, db);
+	g_object_unref (db);
+	g_object_unref (shell);
 
 	source->priv->entries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
-	g_signal_connect_object (G_OBJECT (source->priv->db), "entry_added",
-				 G_CALLBACK (rb_playlist_source_entry_added_cb),
-				 source, 0);
-
 	source->priv->songs = rb_entry_view_new (source->priv->db, shell_player,
 					 	 NULL, TRUE, TRUE);
 	rb_playlist_source_set_query_model (source, rhythmdb_query_model_new_empty (source->priv->db));
@@ -286,6 +307,7 @@ static void
 rb_playlist_source_dispose (GObject *object)
 {
 	RBPlaylistSource *source = RB_PLAYLIST_SOURCE (object);
+
 	if (source->priv->db) {
 		g_object_unref (source->priv->db);
 		source->priv->db = NULL;
@@ -490,7 +512,7 @@ rb_playlist_source_save_playlist (RBPlay
 	rb_debug ("saving playlist");
 	playlist = totem_pl_parser_new ();
 
-	g_object_get (G_OBJECT (source), "name", &name, NULL);
+	g_object_get (source, "name", &name, NULL);
 
 	totem_pl_parser_write_with_title (playlist, GTK_TREE_MODEL (source->priv->model),
 					  playlist_iter_func, uri, name,
@@ -595,6 +617,7 @@ rb_playlist_source_new_from_xml	(RBShell
 	name = get_playlist_name_from_xml (node);
 
 	tmp = xmlGetProp (node, RB_PLAYLIST_TYPE);
+
 	if (!xmlStrcmp (tmp, RB_PLAYLIST_AUTOMATIC))
 		source = rb_auto_playlist_source_new_from_xml (shell, node);
 	else if (!xmlStrcmp (tmp, RB_PLAYLIST_STATIC))
@@ -604,16 +627,17 @@ rb_playlist_source_new_from_xml	(RBShell
 
 		g_object_get (shell, "queue-source", &queue, NULL);
 		rb_static_playlist_source_load_from_xml (queue, node);
-		g_object_unref (G_OBJECT (queue));
-		return NULL;
+		g_object_unref (queue);
 	} else {
 		g_warning ("attempting to load playlist '%s' of unknown type '%s'", name, tmp);
 	}
 
-	if (source)
+	if (source != NULL) {
 		g_object_set (G_OBJECT (source), "name", name, NULL);
+	}
 
-	g_free (name);
+	xmlFree (name);
+	xmlFree (tmp);
 
 	return source;
 }
@@ -626,7 +650,7 @@ rb_playlist_source_save_to_xml (RBPlayli
 	RBPlaylistSourceClass *klass = RB_PLAYLIST_SOURCE_GET_CLASS (source);
 
 	node = xmlNewChild (parent_node, NULL, RB_PLAYLIST_PLAYLIST, NULL);
-	g_object_get (G_OBJECT (source), "name", &name, NULL);
+	g_object_get (source, "name", &name, NULL);
 	xmlSetProp (node, RB_PLAYLIST_NAME, name);
 	g_free (name);
 
diff -u -p -r1.72 rb-podcast-source.c
--- sources/rb-podcast-source.c	14 Jul 2006 12:53:45 -0000	1.72
+++ sources/rb-podcast-source.c	17 Jul 2006 10:58:20 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #define __USE_XOPEN
@@ -255,6 +255,7 @@ struct RBPodcastSourcePrivate
 	RhythmDB *db;
 
 	guint toolbar_ui_merge_id;
+	guint prefs_notify_id;
 
 	GtkWidget *vbox;
 	GtkWidget *config_widget;
@@ -383,10 +384,8 @@ rb_podcast_source_class_init (RBPodcastS
 static void
 rb_podcast_source_init (RBPodcastSource *source)
 {
-	GtkWidget *dummy;
 	GdkPixbuf *pixbuf;
-
-	dummy = gtk_tree_view_new ();
+	gint       size;
 
 	source->priv = RB_PODCAST_SOURCE_GET_PRIVATE (source);
 
@@ -396,17 +395,17 @@ rb_podcast_source_init (RBPodcastSource 
 
 	gtk_container_add (GTK_CONTAINER (source), source->priv->vbox);
 
-	pixbuf = gtk_widget_render_icon (dummy,
-					 RB_STOCK_PODCAST,
-					 GTK_ICON_SIZE_LARGE_TOOLBAR,
-					 NULL);
+	/* FIXME: we use size LARGE_TOOLBAR for everything else but it doesn't look right */
+	gtk_icon_size_lookup (GTK_ICON_SIZE_SMALL_TOOLBAR, &size, NULL);
+	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+					   RB_STOCK_PODCAST,
+					   size,
+					   0, NULL);
 
 	rb_source_set_pixbuf (RB_SOURCE (source), pixbuf);
 	if (pixbuf != NULL) {
 		g_object_unref (pixbuf);
 	}
-
-	gtk_widget_destroy (dummy);
 }
 
 static void
@@ -420,6 +419,10 @@ rb_podcast_source_dispose (GObject *obje
 	if (source->priv->disposed)
 		return;
 
+	if (source->priv->db != NULL) {
+		g_object_unref (source->priv->db);
+	}
+
 	source->priv->disposed = TRUE;
 
 	G_OBJECT_CLASS (rb_podcast_source_parent_class)->dispose (object);
@@ -439,6 +442,8 @@ rb_podcast_source_finalize (GObject *obj
 
 	rb_debug ("finalizing podcast source");
 
+	eel_gconf_notification_remove (source->priv->prefs_notify_id);
+
 	g_object_unref (source->priv->feeds);
 	g_object_unref (source->priv->podcast_mg);
 
@@ -484,7 +489,7 @@ search_action_changed (GtkRadioAction  *
 	gboolean active;
 	RBPodcastSource *source;
 
-	g_object_get (G_OBJECT (shell), "selected-source", &source, NULL);
+	g_object_get (shell, "selected-source", &source, NULL);
 
 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current));
 
@@ -494,6 +499,10 @@ search_action_changed (GtkRadioAction  *
 		rb_podcast_source_do_query (source, RB_PODCAST_QUERY_TYPE_SEARCH);
 		rb_source_notify_filter_changed (RB_SOURCE (source));
 	}
+
+	if (source != NULL) {
+		g_object_unref (source);
+	}
 }
 
 static GObject *
@@ -515,8 +524,8 @@ rb_podcast_source_constructor (GType typ
 	source = RB_PODCAST_SOURCE (G_OBJECT_CLASS (rb_podcast_source_parent_class)->
 			constructor (type, n_construct_properties, construct_properties));
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &source->priv->db, NULL);
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &source->priv->db, NULL);
 
 	source->priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
 								       "PodcastActions",
@@ -741,9 +750,9 @@ rb_podcast_source_constructor (GType typ
 
 	rb_podcast_source_state_prefs_sync (source);
 
-	eel_gconf_notification_add (CONF_STATE_PODCAST_PREFIX,
-				    (GConfClientNotifyFunc) rb_podcast_source_state_pref_changed,
-				    source);
+	source->priv->prefs_notify_id = eel_gconf_notification_add (CONF_STATE_PODCAST_PREFIX,
+								    (GConfClientNotifyFunc) rb_podcast_source_state_pref_changed,
+								    source);
 
 	gtk_widget_show_all (GTK_WIDGET (source));
 
@@ -863,6 +872,7 @@ static void
 impl_delete (RBSource *asource)
 {
 	RBPodcastSource *source = RB_PODCAST_SOURCE (asource);
+	GList *entries;
 	GList *l;
 	gint ret;
 	GtkWidget *dialog;
@@ -872,9 +882,9 @@ impl_delete (RBSource *asource)
 
 	rb_debug ("Delete episode action");
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "window", &window, NULL);
-	g_object_unref (G_OBJECT (shell));
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "window", &window, NULL);
+	g_object_unref (shell);
 
 	dialog = gtk_message_dialog_new (window,
 			                 GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -912,10 +922,14 @@ impl_delete (RBSource *asource)
 	rb_podcast_manager_set_remove_files (source->priv->podcast_mg,
 					     (ret == GTK_RESPONSE_YES));
 
-	for (l = rb_entry_view_get_selected_entries (source->priv->posts); l != NULL;
-	     l = g_list_next (l)) {
+	entries = rb_entry_view_get_selected_entries (source->priv->posts);
+	for (l = entries; l != NULL; l = g_list_next (l)) {
 		rhythmdb_entry_delete (source->priv->db, l->data);
 	}
+
+	g_list_foreach (entries, (GFunc)rhythmdb_entry_unref, NULL);
+	g_list_free (entries);
+
 	rhythmdb_commit (source->priv->db);
 }
 
@@ -1011,6 +1025,9 @@ rb_podcast_source_songs_show_popup_cb (R
 			lst = lst->next;
 		}
 
+		g_list_foreach (lst, (GFunc)rhythmdb_entry_unref, NULL);
+		g_list_free (lst);
+
 		action = gtk_action_group_get_action (source->priv->action_group, "PodcastSrcDownloadPost");
 		gtk_action_set_sensitive (action, downloadable);
 
@@ -1097,7 +1114,7 @@ construct_query_from_selection (RBPodcas
 	GPtrArray *query;
 	RhythmDBEntryType entry_type;
 
-	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+	g_object_get (source, "entry-type", &entry_type, NULL);
 
 	query = rhythmdb_query_parse (source->priv->db,
 				      RHYTHMDB_QUERY_PROP_EQUALS,
@@ -1304,6 +1321,9 @@ rb_podcast_source_cmd_download_post (Gtk
 	}
 	g_value_unset (&val);
 	rhythmdb_commit (source->priv->db);
+
+	g_list_foreach (lst, (GFunc)rhythmdb_entry_unref, NULL);
+	g_list_free (lst);
 }
 
 static void
@@ -1333,8 +1353,12 @@ rb_podcast_source_cmd_cancel_download (G
 
 		lst = lst->next;
 	}
+
 	g_value_unset (&val);
 	rhythmdb_commit (source->priv->db);
+
+	g_list_foreach (lst, (GFunc)rhythmdb_entry_unref, NULL);
+	g_list_free (lst);
 }
 
 static void
@@ -1350,9 +1374,9 @@ rb_podcast_source_cmd_delete_feed (GtkAc
 
 	rb_debug ("Delete feed action");
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "window", &window, NULL);
-	g_object_unref (G_OBJECT (shell));
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "window", &window, NULL);
+	g_object_unref (shell);
 
 	dialog = gtk_message_dialog_new (window,
 			                 GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1715,9 +1739,10 @@ rb_podcast_source_start_download_cb (RBP
 {
 	RBShell *shell = rb_podcast_source_get_shell (source);
 	const gchar *podcast_name = rhythmdb_entry_get_string(entry, RHYTHMDB_PROP_TITLE);
+
 	rb_debug ("Start download");
 	rb_shell_hidden_notify (shell, 4000, _("Downloading podcast"), NULL, podcast_name);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 }
 
 static void
@@ -1727,9 +1752,10 @@ rb_podcast_source_finish_download_cb (RB
 {
 	RBShell *shell = rb_podcast_source_get_shell (source);
 	const gchar *podcast_name = rhythmdb_entry_get_string(entry, RHYTHMDB_PROP_TITLE);
+
 	rb_debug ("Finish download");
 	rb_shell_hidden_notify (shell, 4000, _("Finished downloading podcast"), NULL, podcast_name);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 }
 
 static void
@@ -1739,17 +1765,20 @@ rb_podcast_source_feed_updates_avaliable
 {
 	RBShell *shell = rb_podcast_source_get_shell (source);
 	const gchar *podcast_name = rhythmdb_entry_get_string(entry, RHYTHMDB_PROP_TITLE);
+
 	rb_debug ("Updates avaliable");
 	rb_shell_hidden_notify (shell, 4000, _("New updates avaliable from"), NULL, podcast_name);
-	g_object_unref (G_OBJECT (shell));
+	g_object_unref (shell);
 
 }
 
-static RBShell*
+static RBShell *
 rb_podcast_source_get_shell (RBPodcastSource *source)
 {
 	RBShell *shell;
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
+
+	g_object_get (source, "shell", &shell, NULL);
+
 	return shell;
 }
 
@@ -1879,7 +1908,9 @@ impl_can_add_to_queue (RBSource *source)
 		ok |= rb_podcast_manager_entry_downloaded (entry);
 	}
 
+	g_list_foreach (selection, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (selection);
+
 	return ok;
 }
 
@@ -1904,6 +1935,7 @@ impl_add_to_queue (RBSource *source, RBS
 						     entry, -1);
 	}
 
+	g_list_foreach (selection, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (selection);
 }
 
@@ -1938,10 +1970,13 @@ rb_podcast_source_cmd_new_podcast (GtkAc
 	GObject *object;
 
 	rb_debug ("Got new podcast command");
-	g_object_get (G_OBJECT (source), "podcast-manager", &object, NULL);
+	g_object_get (source, "podcast-manager", &object, NULL);
+
 	dialog = rb_new_podcast_dialog_new (RB_PODCAST_MANAGER (object));
 	gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
+
+	g_object_unref (object);
 }
 
 static void
@@ -1954,14 +1989,15 @@ impl_get_status (RBSource *source, char 
 		ngettext ("%d episode", "%d episodes", 0);
 	}
 
-	g_object_get (G_OBJECT (source), "query-model", &query_model, NULL);
-	if (query_model) {
+	g_object_get (source, "query-model", &query_model, NULL);
+	if (query_model != NULL) {
 		*text = rhythmdb_query_model_compute_status_normal (query_model,
 								    "%d episode",
 								    "%d episodes");
 		if (rhythmdb_query_model_has_pending_changes (query_model))
 			*progress = -1.0f;
-		g_object_unref (G_OBJECT (query_model));
+
+		g_object_unref (query_model);
 	} else {
 		*text = g_strdup ("");
 	}
diff -u -p -r1.17 rb-removable-media-source.c
--- sources/rb-removable-media-source.c	14 Jul 2006 12:31:34 -0000	1.17
+++ sources/rb-removable-media-source.c	17 Jul 2006 10:58:20 -0000
@@ -217,13 +217,14 @@ impl_delete_thyself (RBSource *source)
 	RBShell *shell;
 	RhythmDBEntryType entry_type;
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
-	g_object_get (G_OBJECT (shell), "db", &db, NULL);
-	g_object_unref (G_OBJECT (shell));
+	g_object_get (source, "shell", &shell, NULL);
+	g_object_get (shell, "db", &db, NULL);
+	g_object_unref (shell);
 
-	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+	g_object_get (source, "entry-type", &entry_type, NULL);
 	rhythmdb_entry_delete_by_type (db, entry_type);
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
+
 	rhythmdb_commit (db);
 	g_object_unref (db);
 }
diff -u -p -r1.74 rb-source.c
--- sources/rb-source.c	14 Jul 2006 12:53:45 -0000	1.74
+++ sources/rb-source.c	17 Jul 2006 10:58:20 -0000
@@ -455,11 +455,11 @@ rb_source_get_property (GObject *object,
 	case PROP_UI_MANAGER:
 	{
 		GtkUIManager *manager;
-		g_object_get (G_OBJECT (priv->shell),
+		g_object_get (priv->shell,
 			      "ui-manager", &manager,
 			      NULL);
 		g_value_set_object (value, manager);
-		g_object_unref (G_OBJECT(manager));
+		g_object_unref (manager);
 		break;
 	}
 	case PROP_QUERY_MODEL:
@@ -763,6 +763,7 @@ default_add_to_queue (RBSource *source, 
 						     (RhythmDBEntry *)iter->data, -1);
 	}
 
+	g_list_foreach (selection, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (selection);
 }
 
@@ -789,16 +790,19 @@ default_move_to_trash (RBSource *source)
 	RhythmDB *db;
 	RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
 
-	g_object_get (G_OBJECT (priv->shell), "db", &db, NULL);
+	g_object_get (priv->shell, "db", &db, NULL);
 
 	entry_view = rb_source_get_entry_view (source);
 	sel = rb_entry_view_get_selected_entries (entry_view);
+
 	for (tem = sel; tem != NULL; tem = tem->next) {
 		rhythmdb_entry_move_to_trash (db, (RhythmDBEntry *)tem->data);
 		rhythmdb_commit (db);
 	}
+
+	g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (sel);
-	g_object_unref (G_OBJECT (db));
+	g_object_unref (db);
 }
 
 void
@@ -897,10 +901,10 @@ _rb_source_show_popup (RBSource *source,
 {
 	GtkUIManager *uimanager;
 
-	g_object_get (G_OBJECT (RB_SOURCE_GET_PRIVATE (source)->shell),
+	g_object_get (RB_SOURCE_GET_PRIVATE (source)->shell,
 		      "ui-manager", &uimanager, NULL);
 	rb_gtk_action_popup_menu (uimanager, ui_path);
-	g_object_unref (G_OBJECT (uimanager));
+	g_object_unref (uimanager);
 
 }
 
@@ -1038,12 +1042,14 @@ rb_source_gather_selected_properties (RB
 
 	selected_set = g_hash_table_new (g_str_hash, g_str_equal);
 	selected = rb_entry_view_get_selected_entries (rb_source_get_entry_view (RB_SOURCE (source)));
+
 	for (tem = selected; tem; tem = tem->next) {
 		RhythmDBEntry *entry = tem->data;
 		char *val = g_strdup (rhythmdb_entry_get_string (entry, prop));
 		g_hash_table_insert (selected_set, val, NULL);
 	}
 
+	g_list_foreach (selected, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (selected);
 
 	tem = NULL;
@@ -1065,7 +1071,7 @@ _rb_source_register_action_group (RBSour
 	GList *i;
 	GtkActionGroup *group;
 
-	g_object_get (G_OBJECT (source), "ui-manager", &uimanager, NULL);
+	g_object_get (source, "ui-manager", &uimanager, NULL);
 	actiongroups = gtk_ui_manager_get_action_groups (uimanager);
 
 	/* Don't create the action group if it's already registered */
@@ -1086,7 +1092,7 @@ _rb_source_register_action_group (RBSour
 				      actions, num_actions,
 				      user_data);
 	gtk_ui_manager_insert_action_group (uimanager, group, 0);
-	g_object_unref (G_OBJECT (uimanager));
+	g_object_unref (uimanager);
 
 	return group;
 }
diff -u -p -r1.28 rb-sourcelist-model.c
--- sources/rb-sourcelist-model.c	14 Jul 2006 12:31:34 -0000	1.28
+++ sources/rb-sourcelist-model.c	17 Jul 2006 10:58:21 -0000
@@ -223,6 +223,7 @@ rb_sourcelist_model_new (void)
 						   "child-model", store,
 						   "virtual-root", NULL,
 						   NULL));
+	g_object_unref (store);
 
 	/* create marker rows used to separate source groups */
 	for (i = 0; i < RB_SOURCELIST_GROUP_LAST; i++) {
@@ -312,7 +313,7 @@ rb_sourcelist_model_is_row_visible (GtkT
 
 	if (source != NULL) {
 		gboolean visible;
-		g_object_get (G_OBJECT (source), "visibility", &visible, NULL);
+		g_object_get (source, "visibility", &visible, NULL);
 
 		return visible;
 	} else {
@@ -429,7 +430,7 @@ rb_sourcelist_model_drag_data_received (
 		gtk_tree_model_get (GTK_TREE_MODEL (real_model), &real_iter,
 				    RB_SOURCELIST_MODEL_COLUMN_SOURCE, &source,
 				    -1);
-		g_object_get (G_OBJECT (source), "sourcelist-group", &group, NULL);
+		g_object_get (source, "sourcelist-group", &group, NULL);
 
 		/* restrict sources to within their group */
 		dest_group = get_group_for_path (model, real_dest);
@@ -521,7 +522,7 @@ path_is_reorderable (RBSourceListModel *
 		if (source == NULL)
 			return FALSE;
 
-		g_object_get (G_OBJECT (source), "sourcelist-group", &group, NULL);
+		g_object_get (source, "sourcelist-group", &group, NULL);
 
 		/* fixed and transient sources are not reorderable, everything else is */
 		return (group != RB_SOURCELIST_GROUP_FIXED &&
@@ -623,7 +624,7 @@ rb_sourcelist_model_row_draggable (RbTre
 		gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
 				    RB_SOURCELIST_MODEL_COLUMN_SOURCE, &source, -1);
 
-		g_object_get (G_OBJECT (source), "sourcelist-group", &group, NULL);
+		g_object_get (source, "sourcelist-group", &group, NULL);
 
 		return (group != RB_SOURCELIST_GROUP_FIXED &&
 			group != RB_SOURCELIST_GROUP_TRANSIENT);
@@ -675,7 +676,7 @@ rb_sourcelist_model_drag_data_get (RbTre
 		data = g_string_new ("");
 		gtk_tree_model_get (GTK_TREE_MODEL (drag_source), &iter,
 				    RB_SOURCELIST_MODEL_COLUMN_SOURCE, &source, -1);
-		g_object_get (G_OBJECT (source), "query-model", &query_model, NULL);
+		g_object_get (source, "query-model", &query_model, NULL);
 
 		if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (query_model), &iter)) {
 			g_object_unref (G_OBJECT (query_model));
@@ -693,7 +694,8 @@ rb_sourcelist_model_drag_data_get (RbTre
 			g_string_append (data, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
 
 		} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (query_model), &iter));
-		g_object_unref (G_OBJECT (query_model));
+
+		g_object_unref (query_model);
 
 		gtk_selection_data_set (selection_data,
 					selection_data->target,
diff -u -p -r1.40 rb-sourcelist.c
--- sources/rb-sourcelist.c	14 Jul 2006 12:53:45 -0000	1.40
+++ sources/rb-sourcelist.c	17 Jul 2006 10:58:21 -0000
@@ -108,7 +108,6 @@ static gboolean popup_menu_cb (GtkTreeVi
 static void name_notify_cb (GObject *obj, GParamSpec *pspec, gpointer data);
 static void visibility_notify_cb (GObject *obj, GParamSpec *pspec,
 				  gpointer data);
-static void icon_notify_cb (GObject *obj, GParamSpec *pspec, gpointer data);
 static void source_name_edited_cb (GtkCellRendererText *renderer, const char *pathstr,
 				   const char *text, RBSourceList *sourcelist);
 static void rb_sourcelist_title_cell_data_func (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
@@ -281,6 +280,12 @@ rb_sourcelist_init (RBSourceList *source
 static void
 rb_sourcelist_finalize (GObject *object)
 {
+	RBSourceList *sourcelist = RB_SOURCELIST (object);
+
+	if (sourcelist->priv->filter_model != NULL) {
+		g_object_unref (sourcelist->priv->filter_model);
+	}
+
 	G_OBJECT_CLASS (rb_sourcelist_parent_class)->finalize (object);
 }
 
@@ -343,6 +348,28 @@ rb_sourcelist_new (RBShell *shell)
 	return GTK_WIDGET (sourcelist);
 }
 
+static void
+icon_notify_cb (RBSource *source,
+		GParamSpec *pspec,
+		RBSourceList *sourcelist)
+{
+	GtkTreeIter iter;
+
+	if (rb_sourcelist_source_to_iter (sourcelist, source, &iter)) {
+		GdkPixbuf *pixbuf;
+
+		g_object_get (source, "icon", &pixbuf, NULL);
+		gtk_tree_store_set (GTK_TREE_STORE (sourcelist->priv->real_model),
+				    &iter,
+				    RB_SOURCELIST_MODEL_COLUMN_PIXBUF, pixbuf, -1);
+		if (pixbuf != NULL) {
+			g_object_unref (pixbuf);
+		}
+	}
+
+	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (sourcelist->priv->treeview));
+}
+
 void
 rb_sourcelist_append (RBSourceList *sourcelist,
 		      RBSource *source,
@@ -350,16 +377,16 @@ rb_sourcelist_append (RBSourceList *sour
 {
 	GtkTreeIter iter;
 	PangoAttrList *attrs;
-	const char *name;
+	char *name;
 	GdkPixbuf *pixbuf;
 	gboolean visible;
 
 	g_return_if_fail (RB_IS_SOURCELIST (sourcelist));
 	g_return_if_fail (RB_IS_SOURCE (source));
 
-	g_object_get (G_OBJECT (source), "name", &name, NULL);
-	g_object_get (G_OBJECT (source), "icon", &pixbuf, NULL);
-	g_object_get (G_OBJECT (source), "visibility", &visible, NULL);
+	g_object_get (source, "name", &name, NULL);
+	g_object_get (source, "icon", &pixbuf, NULL);
+	g_object_get (source, "visibility", &visible, NULL);
 
 	if (parent) {
 		GtkTreeIter parent_iter;
@@ -441,6 +468,7 @@ rb_sourcelist_append (RBSourceList *sour
 	if (pixbuf != NULL) {
 		g_object_unref (pixbuf);
 	}
+	g_free (name);
 
 	g_signal_connect_object (G_OBJECT (source), "notify::name", G_CALLBACK (name_notify_cb), sourcelist, 0);
 	g_signal_connect_object (G_OBJECT (source), "notify::visibility", G_CALLBACK (visibility_notify_cb), sourcelist, 0);
@@ -535,7 +563,8 @@ rb_sourcelist_edit_source_name (RBSource
 	gtk_tree_path_free (path);
 }
 
-static void set_source_playing (RBSourceList *sourcelist, RBSource *source, gboolean playing)
+static void
+set_source_playing (RBSourceList *sourcelist, RBSource *source, gboolean playing)
 {
 	GtkTreeIter iter;
 	g_assert (rb_sourcelist_source_to_iter (sourcelist, source, &iter));
@@ -564,7 +593,7 @@ rb_sourcelist_remove (RBSourceList *sour
 	if (gtk_tree_store_iter_depth (GTK_TREE_STORE (sourcelist->priv->real_model), &iter) > 0) {
 		gboolean visible;
 
-		g_object_get (G_OBJECT (source), "visibility", &visible, NULL);
+		g_object_get (source, "visibility", &visible, NULL);
 		if (visible)
 			sourcelist->priv->child_source_count--;
 		rb_sourcelist_update_expander_visibility (sourcelist);
@@ -676,9 +705,9 @@ button_press_cb (GtkTreeView *treeview,
 					   &path, NULL, NULL, NULL) == FALSE) {
 		/* pointer is over empty space */
 		GtkUIManager *uimanager;
-		g_object_get (G_OBJECT (sourcelist->priv->shell), "ui-manager", &uimanager, NULL);
+		g_object_get (sourcelist->priv->shell, "ui-manager", &uimanager, NULL);
 		rb_gtk_action_popup_menu (uimanager, "/SourceListPopup");
-		g_object_unref (G_OBJECT (uimanager));
+		g_object_unref (uimanager);
 		return TRUE;
 	}
 
@@ -730,13 +759,14 @@ name_notify_cb (GObject *obj, GParamSpec
 	RBSourceList *sourcelist = RB_SOURCELIST (data);
 	RBSource *source = RB_SOURCE (obj);
 	GtkTreeIter iter;
-	gchar *name;
+	char *name;
 
 	if (rb_sourcelist_source_to_iter (sourcelist, source, &iter)) {
 		g_object_get (obj, "name", &name, NULL);
 		gtk_tree_store_set (GTK_TREE_STORE (sourcelist->priv->real_model),
 				    &iter,
 				    RB_SOURCELIST_MODEL_COLUMN_NAME, name, -1);
+		g_free (name);
 	}
 
 	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (sourcelist->priv->treeview));
@@ -775,27 +805,6 @@ visibility_notify_cb (GObject *obj, GPar
 			gtk_tree_store_set (GTK_TREE_STORE (sourcelist->priv->real_model), &iter,
 					    RB_SOURCELIST_MODEL_COLUMN_VISIBILITY, new_visibility,
 					    -1);
-		}
-	}
-
-	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (sourcelist->priv->treeview));
-}
-
-static void
-icon_notify_cb (GObject *obj, GParamSpec *pspec, gpointer data)
-{
-	RBSourceList *sourcelist = RB_SOURCELIST (data);
-	RBSource *source = RB_SOURCE (obj);
-	GtkTreeIter iter;
-	GdkPixbuf *pixbuf;
-
-	if (rb_sourcelist_source_to_iter (sourcelist, source, &iter)) {
-		g_object_get (obj, "icon", &pixbuf, NULL);
-		gtk_tree_store_set (GTK_TREE_STORE (sourcelist->priv->real_model),
-				    &iter,
-				    RB_SOURCELIST_MODEL_COLUMN_PIXBUF, pixbuf, -1);
-		if (pixbuf != NULL) {
-			g_object_unref (pixbuf);
 		}
 	}
 
diff -u -p -r1.26 rb-static-playlist-source.c
--- sources/rb-static-playlist-source.c	14 Jul 2006 12:53:45 -0000	1.26
+++ sources/rb-static-playlist-source.c	17 Jul 2006 10:58:22 -0000
@@ -109,10 +109,11 @@ typedef struct
 	RhythmDBPropType search_prop;
 } RBStaticPlaylistSourcePrivate;
 
+static gpointer playlist_pixbuf = NULL;
+
 static void
 rb_static_playlist_source_class_init (RBStaticPlaylistSourceClass *klass)
 {
-	gint size;
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	RBSourceClass *source_class = RB_SOURCE_CLASS (klass);
 	RBPlaylistSourceClass *playlist_class = RB_PLAYLIST_SOURCE_CLASS (klass);
@@ -138,21 +139,29 @@ rb_static_playlist_source_class_init (RB
 
 	playlist_class->impl_save_contents_to_xml = impl_save_contents_to_xml;
 
-	gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
-	klass->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-						  GNOME_MEDIA_PLAYLIST,
-						  size,
-						  0, NULL);
-
 	g_type_class_add_private (klass, sizeof (RBStaticPlaylistSourcePrivate));
 }
 
 static void
 rb_static_playlist_source_init (RBStaticPlaylistSource *source)
 {
-	RBStaticPlaylistSourceClass *klass = RB_STATIC_PLAYLIST_SOURCE_GET_CLASS (source);
+	if (playlist_pixbuf == NULL) {
+		gint size;
+		gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
+		playlist_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+							    GNOME_MEDIA_PLAYLIST,
+							    size,
+							    0, NULL);
+		g_object_add_weak_pointer (playlist_pixbuf,
+					   (gpointer *) &playlist_pixbuf);
 
-	rb_source_set_pixbuf (RB_SOURCE (source), klass->pixbuf);
+		rb_source_set_pixbuf (RB_SOURCE (source), playlist_pixbuf);
+
+		/* drop the initial reference to the icon */
+		g_object_unref (playlist_pixbuf);
+	} else {
+		rb_source_set_pixbuf (RB_SOURCE (source), playlist_pixbuf);
+	}
 }
 
 static void
@@ -199,7 +208,7 @@ rb_static_playlist_source_constructor (G
 
 	priv->paned = gtk_vpaned_new ();
 
-	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
+	g_object_get (source, "shell", &shell, NULL);
 	priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
 							       "StaticPlaylistActions",
 							       NULL, 0,
@@ -211,9 +220,10 @@ rb_static_playlist_source_constructor (G
 					    (GCallback)search_action_changed,
 					    shell);
 	priv->search_prop = RHYTHMDB_PROP_SEARCH_MATCH;
-	g_object_unref (G_OBJECT (shell));
 
-	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+	g_object_unref (shell);
+
+	g_object_get (source, "entry-type", &entry_type, NULL);
 	priv->browser = rb_library_browser_new (rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source)),
 						entry_type);
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
@@ -330,6 +340,7 @@ impl_delete (RBSource *asource)
 	for (tem = sel; tem != NULL; tem = tem->next) {
 		rb_static_playlist_source_remove_entry (source, (RhythmDBEntry *) tem->data);
 	}
+	g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL);
 	g_list_free (sel);
 }
 
@@ -454,10 +465,10 @@ rb_static_playlist_source_browser_change
 	RBEntryView *songs = rb_source_get_entry_view (RB_SOURCE (source));
 	RhythmDBQueryModel *query_model;
 
-	g_object_get (G_OBJECT (browser), "output-model", &query_model, NULL);
+	g_object_get (browser, "output-model", &query_model, NULL);
 	rb_entry_view_set_model (songs, query_model);
 	rb_playlist_source_set_query_model (RB_PLAYLIST_SOURCE (source), query_model);
-	g_object_unref (G_OBJECT (query_model));
+	g_object_unref (query_model);
 
 	rb_source_notify_filter_changed (RB_SOURCE (source));
 }
@@ -560,7 +571,7 @@ rb_static_playlist_source_add_location_i
 		RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source);
 		RhythmDBEntryType entry_type;
 
-		g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+		g_object_get (source, "entry-type", &entry_type, NULL);
 		if (entry_type != RHYTHMDB_ENTRY_TYPE_INVALID &&
 		    rhythmdb_entry_get_entry_type (entry) != entry_type) {
 			g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
@@ -747,7 +758,7 @@ search_action_changed (GtkRadioAction  *
 	RBStaticPlaylistSourcePrivate *priv;
 	gboolean active;
 
-	g_object_get (G_OBJECT (shell), "selected-source", &source, NULL);
+	g_object_get (shell, "selected-source", &source, NULL);
 	priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source);
 
 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current));
@@ -757,5 +768,9 @@ search_action_changed (GtkRadioAction  *
 		priv->search_prop = search_action_to_prop (GTK_ACTION (current));
 		rb_static_playlist_source_do_query (source);
 		rb_source_notify_filter_changed (RB_SOURCE (source));
+	}
+
+	if (source != NULL) {
+		g_object_unref (source);
 	}
 }
diff -u -p -r1.5 rb-static-playlist-source.h
--- sources/rb-static-playlist-source.h	14 Jul 2006 12:31:34 -0000	1.5
+++ sources/rb-static-playlist-source.h	17 Jul 2006 10:58:22 -0000
@@ -45,7 +45,6 @@ typedef struct
 typedef struct
 {
 	RBPlaylistSourceClass parent;
-	GdkPixbuf *pixbuf;
 } RBStaticPlaylistSourceClass;
 
 GType		rb_static_playlist_source_get_type 	(void);
diff -u -p -r1.17 rb-druid.c
--- widgets/rb-druid.c	14 Jul 2006 12:32:00 -0000	1.17
+++ widgets/rb-druid.c	17 Jul 2006 10:58:24 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
diff -u -p -r1.151 rb-entry-view.c
--- widgets/rb-entry-view.c	14 Jul 2006 12:53:46 -0000	1.151
+++ widgets/rb-entry-view.c	17 Jul 2006 10:58:25 -0000
@@ -20,7 +20,7 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -423,75 +423,92 @@ rb_entry_view_finalize (GObject *object)
 }
 
 static void
+rb_entry_view_set_shell_player_internal (RBEntryView   *view,
+					 RBShellPlayer *player)
+{
+	if (view->priv->shell_player != NULL) {
+		g_signal_handlers_disconnect_by_func (view->priv->shell_player,
+						      G_CALLBACK (rb_entry_view_playing_song_changed),
+						      view);
+	}
+
+	view->priv->shell_player = player;
+
+	g_signal_connect_object (G_OBJECT (view->priv->shell_player),
+				 "playing-song-changed",
+				 G_CALLBACK (rb_entry_view_playing_song_changed),
+				 view, 0);
+}
+
+static void
+rb_entry_view_set_model_internal (RBEntryView        *view,
+				  RhythmDBQueryModel *model)
+{
+	if (view->priv->model != NULL) {
+		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
+						      G_CALLBACK (rb_entry_view_row_inserted_cb),
+						      view);
+		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
+						      G_CALLBACK (rb_entry_view_row_deleted_cb),
+						      view);
+		g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
+						      G_CALLBACK (rb_entry_view_rows_reordered_cb),
+						      view);
+	}
+
+	g_signal_connect_object (G_OBJECT (model),
+				 "row_inserted",
+				 G_CALLBACK (rb_entry_view_row_inserted_cb),
+				 view,
+				 0);
+	g_signal_connect_object (G_OBJECT (model),
+				 "row_deleted",
+				 G_CALLBACK (rb_entry_view_row_deleted_cb),
+				 view,
+				 0);
+	g_signal_connect_object (G_OBJECT (model),
+				 "rows_reordered",
+				 G_CALLBACK (rb_entry_view_rows_reordered_cb),
+				 view,
+				 0);
+
+	gtk_tree_selection_unselect_all (view->priv->selection);
+	view->priv->model = model;
+
+	if (view->priv->sorting_column) {
+		rb_entry_view_resort_model (view);
+	}
+
+	gtk_tree_view_set_model (GTK_TREE_VIEW (view->priv->treeview),
+				 GTK_TREE_MODEL (model));
+	view->priv->have_selection = FALSE;
+	view->priv->have_complete_selection = FALSE;
+
+	g_signal_emit (G_OBJECT (view), rb_entry_view_signals[ENTRIES_REPLACED], 0);
+}
+
+static void
 rb_entry_view_set_property (GObject *object,
-			   guint prop_id,
-			   const GValue *value,
-			   GParamSpec *pspec)
+			    guint prop_id,
+			    const GValue *value,
+			    GParamSpec *pspec)
 {
 	RBEntryView *view = RB_ENTRY_VIEW (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_DB:
 		view->priv->db = g_value_get_object (value);
 		break;
 	case PROP_SHELL_PLAYER:
-		view->priv->shell_player = g_value_get_object (value);
-		g_signal_connect_object (G_OBJECT (view->priv->shell_player),
-					 "playing-song-changed",
-					 G_CALLBACK (rb_entry_view_playing_song_changed),
-					 view, 0);
+		rb_entry_view_set_shell_player_internal (view, g_value_get_object (value));
 		break;
 	case PROP_SORTING_KEY:
 		g_free (view->priv->sorting_key);
 		view->priv->sorting_key = g_value_dup_string (value);
 		break;
 	case PROP_MODEL:
-	{
-		RhythmDBQueryModel *new_model;
-
-		if (view->priv->model) {
-			g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
-							      G_CALLBACK (rb_entry_view_row_inserted_cb),
-							      view);
-			g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
-							      G_CALLBACK (rb_entry_view_row_deleted_cb),
-							      view);
-			g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->model),
-							      G_CALLBACK (rb_entry_view_rows_reordered_cb),
-							      view);
-		}
-		new_model = g_value_get_object (value);
-
-		g_signal_connect_object (G_OBJECT (new_model),
-					 "row_inserted",
-					 G_CALLBACK (rb_entry_view_row_inserted_cb),
-					 view,
-					 0);
-		g_signal_connect_object (G_OBJECT (new_model),
-					 "row_deleted",
-					 G_CALLBACK (rb_entry_view_row_deleted_cb),
-					 view,
-					 0);
-		g_signal_connect_object (G_OBJECT (new_model),
-					 "rows_reordered",
-					 G_CALLBACK (rb_entry_view_rows_reordered_cb),
-					 view,
-					 0);
-
-		gtk_tree_selection_unselect_all (view->priv->selection);
-		view->priv->model = new_model;
-		if (view->priv->sorting_column)
-			rb_entry_view_resort_model (view);
-
-		gtk_tree_view_set_model (GTK_TREE_VIEW (view->priv->treeview),
-					 GTK_TREE_MODEL (new_model));
-		view->priv->have_selection = FALSE;
-		view->priv->have_complete_selection = FALSE;
-
-		g_signal_emit (G_OBJECT (view), rb_entry_view_signals[ENTRIES_REPLACED], 0);
+		rb_entry_view_set_model_internal (view, g_value_get_object (value));
 		break;
-	}
 	case PROP_IS_DRAG_SOURCE:
 		view->priv->is_drag_source = g_value_get_boolean (value);
 		break;
@@ -514,9 +531,9 @@ rb_entry_view_set_property (GObject *obj
 
 static void
 rb_entry_view_get_property (GObject *object,
-			   guint prop_id,
-			   GValue *value,
-			   GParamSpec *pspec)
+			    guint prop_id,
+			    GValue *value,
+			    GParamSpec *pspec)
 {
 	RBEntryView *view = RB_ENTRY_VIEW (object);
 
@@ -547,8 +564,10 @@ rb_entry_view_get_property (GObject *obj
 }
 
 RBEntryView *
-rb_entry_view_new (RhythmDB *db, GObject *shell_player,
-		   const char *sort_key, gboolean is_drag_source,
+rb_entry_view_new (RhythmDB *db,
+		   GObject *shell_player,
+		   const char *sort_key,
+		   gboolean is_drag_source,
 		   gboolean is_drag_dest)
 {
 	RBEntryView *view;
@@ -1457,6 +1476,7 @@ rb_entry_view_button_press_cb (GtkTreeVi
 			if (!g_list_find (selected, entry))
 				rb_entry_view_select_entry (view, entry);
 
+			/* FIXME: unref entries */
 			g_list_free (selected);
 
 		}
diff -u -p -r1.14 rb-library-browser.c
--- widgets/rb-library-browser.c	14 Jul 2006 12:32:01 -0000	1.14
+++ widgets/rb-library-browser.c	17 Jul 2006 10:58:25 -0000
@@ -206,7 +206,7 @@ rb_library_browser_finalize (GObject *ob
 
 	eel_gconf_notification_remove (priv->browser_view_notify_id);
 
-	g_object_unref (G_OBJECT (priv->db));
+	g_object_unref (priv->db);
 
 	g_hash_table_destroy (priv->property_views);
 	g_hash_table_destroy (priv->selections);
@@ -222,16 +222,16 @@ rb_library_browser_set_property (GObject
 {
 	RBLibraryBrowserPrivate *priv = RB_LIBRARY_BROWSER_GET_PRIVATE (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_DB:
-		if (priv->db) {
-			g_object_unref (G_OBJECT (priv->db));
+		if (priv->db != NULL) {
+			g_object_unref (priv->db);
 		}
 		priv->db = g_value_get_object (value);
 
-		if (priv->db)
+		if (priv->db != NULL) {
 			g_object_ref (priv->db);
+		}
 		break;
 	case PROP_ENTRY_TYPE:
 		priv->entry_type = g_value_get_boxed (value);
@@ -250,8 +250,7 @@ rb_library_browser_get_property (GObject
 {
 	RBLibraryBrowserPrivate *priv = RB_LIBRARY_BROWSER_GET_PRIVATE (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_DB:
 		g_value_set_object (value, priv->db);
 		break;
@@ -382,7 +381,7 @@ construct_query_cb (RhythmDBPropType typ
 					     selections);
 }
 
-RhythmDBQuery*
+RhythmDBQuery *
 rb_library_browser_construct_query (RBLibraryBrowser *widget)
 {
 	RBLibraryBrowserPrivate *priv = RB_LIBRARY_BROWSER_GET_PRIVATE (widget);
diff -u -p -r1.40 rb-query-creator.c
--- widgets/rb-query-creator.c	14 Jul 2006 12:32:01 -0000	1.40
+++ widgets/rb-query-creator.c	17 Jul 2006 10:58:26 -0000
@@ -19,10 +19,11 @@
  *
  */
 
-#include <config.h>
+#include "config.h"
 #include <string.h>
 #include <stdlib.h>
-#include <libgnome/gnome-i18n.h>
+
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #include "rhythmdb.h"
@@ -425,8 +426,10 @@ rb_query_creator_set_sorting (RBQueryCre
 
 GtkWidget *
 rb_query_creator_new_from_query (RhythmDB *db, GPtrArray *query,
-				 RhythmDBQueryModelLimitType limit_type, GValueArray *limit_value,
-				 const char *sort_column, gint sort_direction)
+				 RhythmDBQueryModelLimitType limit_type,
+                                 GValueArray *limit_value,
+				 const char *sort_column,
+                                 gint sort_direction)
 {
 	RBQueryCreator *creator = g_object_new (RB_TYPE_QUERY_CREATOR, "db", db,
 						"creating", FALSE, NULL);
@@ -464,7 +467,8 @@ get_box_widget_at_pos (GtkBox *box, guin
 }
 
 static GtkWidget *
-get_entry_for_property (RBQueryCreator *creator, RhythmDBPropType prop,
+get_entry_for_property (RBQueryCreator *creator,
+                        RhythmDBPropType prop,
 			gboolean *constrain)
 {
 	const RBQueryCreatorPropertyType *property_type;
@@ -689,7 +693,8 @@ append_row (RBQueryCreator *creator)
 
 static int
 get_property_index_from_proptype (const RBQueryCreatorPropertyOption *options,
-			    int length, RhythmDBPropType prop)
+                                  int length,
+                                  RhythmDBPropType prop)
 {
 	int i;
 
diff -u -p -r1.67 rb-song-info.c
--- widgets/rb-song-info.c	14 Jul 2006 12:53:46 -0000	1.67
+++ widgets/rb-song-info.c	17 Jul 2006 10:58:27 -0000
@@ -25,7 +25,7 @@
  * Yes, this code is ugly.
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <string.h>
 #include <time.h>
@@ -364,6 +364,8 @@ rb_song_info_constructor (GType type, gu
 	if (selected_entries->next == NULL) {
 		song_info->priv->current_entry = selected_entries->data;
 		song_info->priv->selected_entries = NULL;
+
+		g_list_foreach (selected_entries, (GFunc)rhythmdb_entry_unref, NULL);
 		g_list_free (selected_entries);
 	} else {
 		song_info->priv->current_entry = NULL;
@@ -487,82 +489,90 @@ rb_song_info_finalize (GObject *object)
 	g_object_unref (G_OBJECT (song_info->priv->source));
 	g_object_unref (G_OBJECT (song_info->priv->query_model));
 
+	if (song_info->priv->selected_entries != NULL) {
+		g_list_foreach (song_info->priv->selected_entries, (GFunc)rhythmdb_entry_unref, NULL);
+		g_list_free (song_info->priv->selected_entries);
+	}
+
 	G_OBJECT_CLASS (rb_song_info_parent_class)->finalize (object);
 }
 
 static void
-rb_song_info_set_property (GObject *object,
-			   guint prop_id,
-			   const GValue *value,
-			   GParamSpec *pspec)
+rb_song_info_set_source_internal (RBSongInfo *song_info,
+				  RBSource   *source)
 {
-	RBSongInfo *song_info = RB_SONG_INFO (object);
+	RhythmDB *old_db = song_info->priv->db;
 
-	switch (prop_id)
-	{
-	case PROP_SOURCE:
-	{
-		RhythmDB *old_db = song_info->priv->db;
+	if (song_info->priv->source != NULL) {
+		g_signal_handlers_disconnect_by_func (song_info->priv->source,
+						      rb_song_info_query_model_changed_cb,
+						      song_info);
+		g_object_unref (song_info->priv->source);
+		g_object_unref (song_info->priv->query_model);
+		g_object_unref (song_info->priv->db);
+	}
+
+	song_info->priv->source = source;
+
+	g_object_ref (song_info->priv->source);
+
+	g_object_get (G_OBJECT (song_info->priv->source), "query-model", &song_info->priv->query_model, NULL);
 
-		if (song_info->priv->source != NULL) {
-			g_signal_handlers_disconnect_by_func (song_info->priv->source,
-							      rb_song_info_query_model_changed_cb,
-							      song_info);
-			g_object_unref (song_info->priv->source);
-			g_object_unref (song_info->priv->query_model);
-			g_object_unref (song_info->priv->db);
+	g_signal_connect_object (G_OBJECT (song_info->priv->source),
+				 "notify::query-model",
+				 G_CALLBACK (rb_song_info_query_model_changed_cb),
+				 song_info, 0);
+
+	g_object_get (G_OBJECT (song_info->priv->query_model), "db", &song_info->priv->db, NULL);
+
+	if (old_db != song_info->priv->db) {
+		if (song_info->priv->albums) {
+			g_object_unref (song_info->priv->albums);
+		}
+		if (song_info->priv->artists) {
+			g_object_unref (song_info->priv->artists);
+		}
+		if (song_info->priv->genres) {
+			g_object_unref (song_info->priv->genres);
+		}
+
+		song_info->priv->albums  = rhythmdb_property_model_new (song_info->priv->db, RHYTHMDB_PROP_ALBUM);
+		song_info->priv->artists = rhythmdb_property_model_new (song_info->priv->db, RHYTHMDB_PROP_ARTIST);
+		song_info->priv->genres  = rhythmdb_property_model_new (song_info->priv->db, RHYTHMDB_PROP_GENRE);
+
+		g_object_set (song_info->priv->albums,  "query-model", song_info->priv->query_model, NULL);
+		g_object_set (song_info->priv->artists, "query-model", song_info->priv->query_model, NULL);
+		g_object_set (song_info->priv->genres,  "query-model", song_info->priv->query_model, NULL);
+
+		if(song_info->priv->album) {
+			GtkEntryCompletion *comp = gtk_entry_get_completion (GTK_ENTRY (song_info->priv->album));
+			gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (song_info->priv->albums));
 		}
 
-		song_info->priv->source = g_value_get_object (value);
+		if(song_info->priv->artist) {
+			GtkEntryCompletion *comp = gtk_entry_get_completion (GTK_ENTRY (song_info->priv->artist));
+			gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (song_info->priv->artist));
+		}
 
-		g_object_ref (G_OBJECT (song_info->priv->source));
-		g_object_get (G_OBJECT (song_info->priv->source),
-			      "query-model", &song_info->priv->query_model, NULL);
-
-		g_signal_connect_object (G_OBJECT (song_info->priv->source),
-					 "notify::query-model",
-					 G_CALLBACK (rb_song_info_query_model_changed_cb),
-					 song_info, 0);
-
-		g_object_get (G_OBJECT (song_info->priv->query_model), "db",
-			      &song_info->priv->db, NULL);
-
-		if (old_db != song_info->priv->db) {
-			if (song_info->priv->albums) {
-				g_object_unref (song_info->priv->albums);
-			}
-			if (song_info->priv->artists) {
-				g_object_unref (song_info->priv->artists);
-			}
-			if (song_info->priv->genres) {
-				g_object_unref (song_info->priv->genres);
-			}
-
-			song_info->priv->albums  = rhythmdb_property_model_new (song_info->priv->db, RHYTHMDB_PROP_ALBUM);
-			song_info->priv->artists = rhythmdb_property_model_new (song_info->priv->db, RHYTHMDB_PROP_ARTIST);
-			song_info->priv->genres  = rhythmdb_property_model_new (song_info->priv->db, RHYTHMDB_PROP_GENRE);
-
-			g_object_set (song_info->priv->albums,  "query-model", song_info->priv->query_model, NULL);
-			g_object_set (song_info->priv->artists, "query-model", song_info->priv->query_model, NULL);
-			g_object_set (song_info->priv->genres,  "query-model", song_info->priv->query_model, NULL);
-
-			if(song_info->priv->album) {
-				GtkEntryCompletion* comp = gtk_entry_get_completion (GTK_ENTRY (song_info->priv->album));
-				gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (song_info->priv->albums));
-			}
-
-			if(song_info->priv->artist) {
-				GtkEntryCompletion* comp = gtk_entry_get_completion (GTK_ENTRY (song_info->priv->artist));
-				gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (song_info->priv->artist));
-			}
-
-			if(song_info->priv->genre) {
-				GtkEntryCompletion* comp = gtk_entry_get_completion (GTK_ENTRY (song_info->priv->genre));
-				gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (song_info->priv->genre));
-			}
+		if(song_info->priv->genre) {
+			GtkEntryCompletion *comp = gtk_entry_get_completion (GTK_ENTRY (song_info->priv->genre));
+			gtk_entry_completion_set_model (comp, GTK_TREE_MODEL (song_info->priv->genre));
 		}
 	}
-	break;
+}
+
+static void
+rb_song_info_set_property (GObject *object,
+			   guint prop_id,
+			   const GValue *value,
+			   GParamSpec *pspec)
+{
+	RBSongInfo *song_info = RB_SONG_INFO (object);
+
+	switch (prop_id) {
+	case PROP_SOURCE:
+		rb_song_info_set_source_internal (song_info, g_value_get_object (value));
+		break;
 	case PROP_ENTRY_VIEW:
 		song_info->priv->entry_view = g_value_get_object (value);
 		break;
@@ -580,8 +590,7 @@ rb_song_info_get_property (GObject *obje
 {
 	RBSongInfo *song_info = RB_SONG_INFO (object);
 
-	switch (prop_id)
-	{
+	switch (prop_id) {
 	case PROP_SOURCE:
 		g_value_set_object (value, song_info->priv->source);
 		break;
