diff --git a/plugins/audiocd/rb-audiocd-source.c b/plugins/audiocd/rb-audiocd-source.c
index 58f6f21..2e74025 100644
--- a/plugins/audiocd/rb-audiocd-source.c
+++ b/plugins/audiocd/rb-audiocd-source.c
@@ -500,6 +500,7 @@ metadata_cb (SjMetadataGetter *metadata,
 	RhythmDB *db;
 	GValue true_value = {0,};
 	AlbumDetails *album;
+	RBRefString *albumartist_kw = NULL;
 
 	g_assert (metadata == priv->metadata);
 
@@ -540,7 +541,17 @@ metadata_cb (SjMetadataGetter *metadata,
 		return;
 	}
 
+	if (album->artist && strlen(album->artist) > 0) {
+		char *kw;
+
+		kw = g_strdup_printf (RHYTHMDB_KEYWORD_ALBUM_ARTIST "%s", album->artist);
+		albumartist_kw = rb_refstring_new (kw);
+		g_free (kw);
+	}
+
 	g_object_set (G_OBJECT (source), "name", album->title, NULL);
+	rb_debug ("musicbrainz_albumartistid: %s", album->artist_id);
+	rb_debug ("album artist: %s", album->artist);
 
 	while (album->tracks && cd_track) {
 		TrackDetails *track = (TrackDetails*)album->tracks->data;
@@ -553,8 +564,7 @@ metadata_cb (SjMetadataGetter *metadata,
 		rb_debug ("musicbrainz_trackid: %s", track->track_id);
 		rb_debug ("musicbrainz_artistid: %s", track->artist_id);
 		rb_debug ("musicbrainz_albumid: %s", album->album_id);
-		rb_debug ("musicbrainz_albumartistid: %s", album->artist_id);
-		rb_debug ("album sortname: %s", album->artist_sortname);
+		rb_debug ("artist sortname: %s", track->artist_sortname);
 
 		/* record track info in entry*/
 		entry_set_string_prop (db, entry, TRUE, RHYTHMDB_PROP_TITLE, track->title);
@@ -565,7 +575,7 @@ metadata_cb (SjMetadataGetter *metadata,
 		entry_set_string_prop (db, entry, TRUE, RHYTHMDB_PROP_MUSICBRAINZ_ARTISTID, track->artist_id);
 		entry_set_string_prop (db, entry, TRUE, RHYTHMDB_PROP_MUSICBRAINZ_ALBUMID, album->album_id);
 		entry_set_string_prop (db, entry, TRUE, RHYTHMDB_PROP_MUSICBRAINZ_ALBUMARTISTID, album->artist_id);
-		entry_set_string_prop (db, entry, TRUE, RHYTHMDB_PROP_ARTIST_SORTNAME, album->artist_sortname);
+		entry_set_string_prop (db, entry, TRUE, RHYTHMDB_PROP_ARTIST_SORTNAME, track->artist_sortname);
 
 		g_value_init (&value, G_TYPE_ULONG);
 		g_value_set_ulong (&value, track->duration);
@@ -583,6 +593,10 @@ metadata_cb (SjMetadataGetter *metadata,
 			g_value_unset (&value);
 		}
 
+		if (albumartist_kw) {
+			rhythmdb_entry_keyword_add (db, entry, albumartist_kw);
+		}
+
 		rhythmdb_commit (db);
 
 		album->tracks = g_list_next (album->tracks);
@@ -600,6 +614,10 @@ metadata_cb (SjMetadataGetter *metadata,
 		cd_track = g_list_next (cd_track);
 	}
 
+	if (albumartist_kw) {
+		rb_refstring_unref (albumartist_kw);
+	}
+
 	g_object_unref (metadata);
 	priv->metadata = NULL;
 
diff --git a/rhythmdb/rhythmdb.h b/rhythmdb/rhythmdb.h
index 1226449..6b8a981 100644
--- a/rhythmdb/rhythmdb.h
+++ b/rhythmdb/rhythmdb.h
@@ -230,6 +230,9 @@ enum {
 #define RHYTHMDB_PROP_COVER_ART			"rb:coverArt"
 #define RHYTHMDB_PROP_COVER_ART_URI		"rb:coverArt-uri"
 
+/* commonly used keyword prefixes */
+#define RHYTHMDB_KEYWORD_ALBUM_ARTIST		"rb-album-artist:"
+
 GType rhythmdb_query_type_get_type (void);
 GType rhythmdb_prop_type_get_type (void);
 
diff --git a/sources/rb-library-source.c b/sources/rb-library-source.c
index 0fa680d..93cabfa 100644
--- a/sources/rb-library-source.c
+++ b/sources/rb-library-source.c
@@ -830,17 +830,40 @@ sanitize_pattern (const char *pat)
  * %tS -- track artist sortname (lowercase)
  */
 static char *
-filepath_parse_pattern (const char *pattern,
+filepath_parse_pattern (RhythmDB *db,
+			const char *pattern,
 			RhythmDBEntry *entry)
 {
 	/* p is the pattern iterator, i is a general purpose iterator */
 	const char *p;
 	char *temp;
 	GString *s;
+	GList *keywords;
+	GList *i;
+	RBRefString *albumartist = NULL;
 
 	if (pattern == NULL || pattern[0] == 0)
 		return g_strdup (" ");
 
+	/* extract album artist info (this is sort of temporary) */
+	keywords = rhythmdb_entry_keywords_get (db, entry);
+	for (i = keywords; i != NULL; i = i->next) {
+		RBRefString *k = (RBRefString *)i->data;
+		if (g_str_has_prefix (rb_refstring_get (k), RHYTHMDB_KEYWORD_ALBUM_ARTIST)) {
+			const char *aa;
+
+			/* remove the prefix */
+			aa = rb_refstring_get (k) + strlen (RHYTHMDB_KEYWORD_ALBUM_ARTIST);
+			albumartist = rb_refstring_new (aa);
+			break;
+		}
+	}
+
+	rb_list_destroy_free (keywords, (GDestroyNotify) rb_refstring_unref);
+	if (albumartist == NULL) {
+		albumartist = rhythmdb_entry_get_refstring (entry, RHYTHMDB_PROP_ARTIST);
+	}
+
 	s = g_string_new (NULL);
 
 	p = pattern;
@@ -875,10 +898,10 @@ filepath_parse_pattern (const char *pattern,
 				string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM_FOLDED));
 				break;
 			case 'a':
-				string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST));
+				string = sanitize_path (rb_refstring_get (albumartist));
 				break;
 			case 'A':
-				string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_FOLDED));
+				string = sanitize_path (rb_refstring_get_folded (albumartist));
 				break;
 			case 's':
 				string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_SORTNAME));
@@ -946,6 +969,7 @@ filepath_parse_pattern (const char *pattern,
 
 	temp = s->str;
 	g_string_free (s, FALSE);
+	rb_refstring_unref (albumartist);
 	return temp;
 }
 
@@ -983,8 +1007,8 @@ layout_example_label_update (RBLibrarySource *source)
 	sample_entry = rhythmdb_entry_example_new (source->priv->db, entry_type, NULL);
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
 
-	file_value = filepath_parse_pattern (file_pattern, sample_entry);
-	path_value = filepath_parse_pattern (path_pattern, sample_entry);
+	file_value = filepath_parse_pattern (source->priv->db, file_pattern, sample_entry);
+	path_value = filepath_parse_pattern (source->priv->db, path_pattern, sample_entry);
 	rhythmdb_entry_unref (sample_entry);
 
 	example = g_build_filename (G_DIR_SEPARATOR_S, path_value, file_value, NULL);
@@ -1109,7 +1133,7 @@ build_filename (RBLibrarySource *source, RhythmDBEntry *entry)
 	g_free (layout_filename);
 	layout_filename = tmp;
 
-	realpath = filepath_parse_pattern (layout_path, entry);
+	realpath = filepath_parse_pattern (source->priv->db, layout_path, entry);
 
 	library_location = g_file_new_for_uri ((const char *)list->data);
 	dir = g_file_resolve_relative_path (library_location, realpath);
@@ -1143,7 +1167,7 @@ build_filename (RBLibrarySource *source, RhythmDBEntry *entry)
 			*tmp = '\0';
 	}
 
-	realfile = filepath_parse_pattern (layout_filename, entry);
+	realfile = filepath_parse_pattern (source->priv->db, layout_filename, entry);
 	if (extension) {
 		filename = g_strdup_printf ("%s.%s", realfile, extension);
 		g_free (realfile);
