diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
index f9905d3..6dd6773 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
@@ -47,6 +47,7 @@
     <Compile Include="Banshee.PlayQueue\PlayQueueSource.cs" />
     <Compile Include="Banshee.PlayQueue\PlayQueueActions.cs" />
     <Compile Include="Banshee.PlayQueue\IPlayQueue.cs" />
+    <Compile Include="Banshee.PlayQueue\ConfigurationPane.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Resources\ActiveSourceUI.xml">
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/ConfigurationPane.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/ConfigurationPane.cs
new file mode 100644
index 0000000..01e3553
--- /dev/null
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/ConfigurationPane.cs
@@ -0,0 +1,62 @@
+//
+// ConfigurationPane.cs
+//
+// Author:
+//   Alexander Kojevnikov <alexander@kojevnikov.com>
+//
+// Copyright (C) 2009 Alexander Kojevnikov
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using Gtk;
+using Mono.Unix;
+
+namespace Banshee.PlayQueue
+{
+    public class ConfigurationPane : Hyena.Widgets.RoundedFrame
+    {
+        private HBox main_box;
+
+        public ConfigurationPane () : base ()
+        {
+            main_box = new HBox ();
+            main_box.BorderWidth = 5;
+
+            // Translators: this label will be part of the following sentense: "Display: X recently played songs"
+            Label display_label = new Label (Catalog.GetString ("Display:"));
+
+            SpinButton played_songs_spin_button = new SpinButton (0, 100, 1);
+            played_songs_spin_button.Value = PlayQueueSource.PlayedSongsNumber;
+            played_songs_spin_button.ValueChanged += delegate {
+                PlayQueueSource.PlayedSongsNumber = (int) played_songs_spin_button.Value;
+            };
+
+            // Translators: this label will be part of the following sentense: "Display: X recently played songs"
+            Label played_songs_label = new Label (Catalog.GetString ("recently played songs"));
+
+            main_box.PackStart (display_label, false, false, 0);
+            main_box.PackStart (played_songs_spin_button, false, false, 5);
+            main_box.PackStart (played_songs_label, false, false, 0);
+
+            Add (main_box);
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
index 59f55bc..b6aaada 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
@@ -1,10 +1,11 @@
 //
 // PlayQueueSource.cs
 //
-// Author:
+// Authors:
 //   Aaron Bockover <abockover@novell.com>
+//   Alexander Kojevnikov <alexander@kojevnikov.com>
 //
-// Copyright (C) 2008 Novell, Inc.
+// Copyright (C) 2008-2009 Novell, Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,6 +31,7 @@ using System;
 
 using Mono.Unix;
 
+using Hyena.Collections;
 using Hyena.Data.Sqlite;
 
 using Banshee.ServiceStack;
@@ -48,13 +50,14 @@ namespace Banshee.PlayQueue
 {
     public class PlayQueueSource : PlaylistSource, IBasicPlaybackController, IPlayQueue, IDBusExportable, IDisposable
     {
-        private static string special_playlist_name = "Play Queue";//typeof (PlayQueueSource).ToString ();
+        private static string special_playlist_name = "Play Queue";
 
         private ITrackModelSource prior_playback_source;
-        private DatabaseTrackInfo playing_track;
+        private DatabaseTrackInfo current_track;
         private TrackInfo prior_playback_track;
         private PlayQueueActions actions;
         private bool was_playing = false;
+        private ConfigurationPane pane;
         
         protected override bool HasArtistAlbum {
             get { return false; }
@@ -73,9 +76,12 @@ namespace Banshee.PlayQueue
             
             DatabaseTrackModel.ForcedSortQuery = "CorePlaylistEntries.ViewOrder ASC, CorePlaylistEntries.EntryID ASC";
             DatabaseTrackModel.CanReorder = true;
-            
+
             ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent);
-            ServiceManager.PlaybackController.Transition += OnCanonicalPlaybackControllerTransition;
+            ServiceManager.SourceManager.ActiveSourceChanged += OnActiveSourceChanged;
+            ServiceManager.PlaybackController.TrackStarted += delegate {
+                SetAsPlaybackSourceUnlessPlaying ();
+            };
 
             ServiceManager.SourceManager.AddSource (this);
             
@@ -93,17 +99,33 @@ namespace Banshee.PlayQueue
             ServiceManager.SourceManager.VideoLibrary.TracksDeleted += HandleTracksDeleted;
             
             TrackModel.Reloaded += delegate {
-                if (Count == 0) {
-                    if (this == ServiceManager.PlaybackController.Source || this == ServiceManager.PlaybackController.NextSource) {
-                        ServiceManager.PlaybackController.NextSource = ServiceManager.PlaybackController.Source = PriorSource;
+                if (current_track == null) {
+                    if (this == ServiceManager.PlaybackController.Source ||
+                        this == ServiceManager.PlaybackController.NextSource) {
+                        ServiceManager.PlaybackController.NextSource = PriorSource;
                     }
                 }
             };
             
             Reload ();
+            int track_index = CurrentTrackSchema.Get ();
+            if (track_index < Count) {
+                current_track = TrackModel[track_index] as DatabaseTrackInfo;
+            }
             SetAsPlaybackSourceUnlessPlaying ();
         }
-        
+
+        protected override void Initialize ()
+        {
+            base.Initialize ();
+
+            pane = new ConfigurationPane ();
+            BaseClientWindow nereid = ServiceManager.Get<IService> ("NereidPlayerInterface") as Banshee.Gui.BaseClientWindow;
+            if (nereid != null) {
+                nereid.ViewContainer.PackEnd (pane, false, false, 0);
+            }
+        }
+
 #region IPlayQueue, IDBusExportable
 
         public void EnqueueUri (string uri)
@@ -154,10 +176,10 @@ namespace Banshee.PlayQueue
         }
 
 #endregion
-        
+
         private void SetAsPlaybackSourceUnlessPlaying ()
         {
-            if (Count > 0 && ServiceManager.PlaybackController.Source != this) {
+            if (current_track != null && ServiceManager.PlaybackController.Source != this) {
                 PriorSource = ServiceManager.PlaybackController.Source;
                 ServiceManager.PlaybackController.NextSource = this;
             }
@@ -165,19 +187,26 @@ namespace Banshee.PlayQueue
 
         public void Clear ()
         {
-            playing_track = null;
-            RemoveTrackRange (DatabaseTrackModel, new Hyena.Collections.RangeCollection.Range (0, Count));
-            Reload ();
+            RemoveTrackRange (DatabaseTrackModel, new RangeCollection.Range (0, Count - 1));
+            OnTracksRemoved ();
         }
 
         public void Dispose ()
         {
+            int track_index = Math.Max (0, TrackModel.IndexOf (current_track));
+            CurrentTrackSchema.Set (track_index);
+
             ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
 
             if (actions != null) {
                 actions.Dispose ();
             }
 
+            if (pane != null) {
+                pane.Destroy ();
+                pane = null;
+            }
+
             if (ClearOnQuitSchema.Get ()) {
                 Clear ();
             }
@@ -201,22 +230,48 @@ namespace Banshee.PlayQueue
 
         protected override void OnTracksAdded ()
         {
+            int old_count = Count;
+
             base.OnTracksAdded ();
+
+            if (current_track == null && old_count < Count) {
+                current_track = TrackModel[old_count] as DatabaseTrackInfo;
+            }
+
             SetAsPlaybackSourceUnlessPlaying ();
         }
-        
-        private void OnCanonicalPlaybackControllerTransition (object o, EventArgs args)
+
+        protected override void OnTracksRemoved ()
         {
-            if (Count > 0) {
-                PriorSource = ServiceManager.PlaybackController.Source;
-                ServiceManager.PlaybackController.Source = this;
+            base.OnTracksRemoved ();
+            if (this == ServiceManager.PlaybackController.Source &&
+                ServiceManager.PlayerEngine.IsPlaying () &&
+                TrackModel.IndexOf (ServiceManager.PlayerEngine.CurrentTrack) == -1) {
+                if (ServiceManager.PlayerEngine.CurrentState == PlayerState.Paused || current_track == null) {
+                    ServiceManager.PlayerEngine.Close();
+                } else {
+                    ServiceManager.PlayerEngine.OpenPlay (current_track);
+                }
             }
         }
-        
+
+        protected override void RemoveTrackRange (DatabaseTrackListModel model, RangeCollection.Range range)
+        {
+            base.RemoveTrackRange (model, range);
+
+            int index = TrackModel.IndexOf (current_track);
+            if (range.Start <= index && index <= range.End) {
+                current_track = range.End + 1 < Count ? TrackModel[range.End + 1] as DatabaseTrackInfo : null;
+            }
+        }
+
         private void OnPlayerEvent (PlayerEventArgs args)
         {
             if (args.Event == PlayerEvent.EndOfStream) {
-                if (RemovePlayingTrack () && Count == 0) {
+                if (this == ServiceManager.PlaybackController.Source &&
+                    TrackModel.IndexOf (current_track) == Count - 1) {
+                    current_track = null;
+                    UpdatePlayQueue ();
                     if (was_playing) {
                         ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
                     } else {
@@ -225,9 +280,9 @@ namespace Banshee.PlayQueue
                 }
             } else if (args.Event == PlayerEvent.StartOfStream) {
                 if (this == ServiceManager.PlaybackController.Source) {
-                    playing_track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
+                    current_track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
+                    UpdatePlayQueue ();
                 } else {
-                    playing_track = null;
                     prior_playback_track = ServiceManager.PlayerEngine.CurrentTrack;
                 }
             }
@@ -240,9 +295,12 @@ namespace Banshee.PlayQueue
         
         bool IBasicPlaybackController.Next (bool restart)
         {
-            RemovePlayingTrack ();
-            
-            if (Count == 0) {
+            if (current_track != null && ServiceManager.PlayerEngine.CurrentTrack == current_track) {
+                int index = TrackModel.IndexOf (current_track) + 1;
+                current_track = index < Count ? TrackModel[index] as DatabaseTrackInfo : null;
+            }
+            if (current_track == null) {
+                UpdatePlayQueue ();
                 ServiceManager.PlaybackController.Source = PriorSource;
                 if (was_playing) {
                     ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
@@ -252,26 +310,44 @@ namespace Banshee.PlayQueue
                 }
                 return true;
             }
-            
-            ServiceManager.PlayerEngine.OpenPlay ((DatabaseTrackInfo)TrackModel[0]);
+
+            ServiceManager.PlayerEngine.OpenPlay (current_track);
             return true;
         }
         
         bool IBasicPlaybackController.Previous (bool restart)
         {
+            if (current_track != null && ServiceManager.PlayerEngine.CurrentTrack == current_track) {
+                int index = TrackModel.IndexOf (current_track);
+                if (index > 0) {
+                    current_track = TrackModel[index - 1] as DatabaseTrackInfo;
+                }
+                ServiceManager.PlayerEngine.OpenPlay (current_track);
+            }
             return true;
         }
         
-        private bool RemovePlayingTrack ()
+        private void UpdatePlayQueue ()
         {
-            if (playing_track != null) {
-                RemoveTrack (playing_track);
-                playing_track = null;
-                return true;
+            // TODO: grey out the prev tracks, see ColumnCellText.Opacity
+            int index = current_track == null ? Count : TrackModel.IndexOf (current_track);
+            if (index > PlayedSongsNumber) {
+                RemoveTrackRange (DatabaseTrackModel, new RangeCollection.Range (0, index - PlayedSongsNumber - 1));
+                OnTracksRemoved ();
             }
-            return false;
         }
-        
+
+        private void OnActiveSourceChanged (SourceEventArgs args)
+        {
+            Banshee.Base.ThreadAssist.ProxyToMain (delegate {
+                if (args.Source == this) {
+                    pane.ShowAll ();
+                } else {
+                    pane.Hide ();
+                }
+            });
+        }
+
         private ITrackModelSource PriorSource {
             get {
                 if (prior_playback_source == null || prior_playback_source == this) {
@@ -287,6 +363,20 @@ namespace Banshee.PlayQueue
                 was_playing = ServiceManager.PlayerEngine.IsPlaying ();
             }
         }
+
+        private static int played_songs_number = -1;
+        public static int PlayedSongsNumber {
+            get {
+                if (played_songs_number == -1) {
+                    played_songs_number = PlayedSongsNumberSchema.Get ();
+                }
+                return played_songs_number;
+            }
+            set {
+                played_songs_number = value;
+                PlayedSongsNumberSchema.Set (value);
+            }
+        }
         
         public override bool CanRename {
             get { return false; }
@@ -303,12 +393,26 @@ namespace Banshee.PlayQueue
         public override bool CanUnmap {
             get { return false; }
         }
-        
+
         public static readonly SchemaEntry<bool> ClearOnQuitSchema = new SchemaEntry<bool> (
             "plugins.play_queue", "clear_on_quit",
             false,
             "Clear on Quit",
             "Clear the play queue when quitting"
         );
+
+        public static readonly SchemaEntry<int> CurrentTrackSchema = new SchemaEntry<int> (
+            "plugins.play_queue", "current_track",
+            0,
+            "Current Track",
+            "Current track in the Play Queue"
+        );
+
+        public static readonly SchemaEntry<int> PlayedSongsNumberSchema = new SchemaEntry<int> (
+            "plugins.play_queue", "played_songs_number",
+            10,
+            "Played Songs Number",
+            "Number of played songs to show in the Play Queue"
+        );
     }
 }
diff --git a/src/Extensions/Banshee.PlayQueue/Makefile.am b/src/Extensions/Banshee.PlayQueue/Makefile.am
index 68ca5cc..47d985a 100644
--- a/src/Extensions/Banshee.PlayQueue/Makefile.am
+++ b/src/Extensions/Banshee.PlayQueue/Makefile.am
@@ -4,6 +4,7 @@ LINK = $(REF_EXTENSION_PLAYQUEUE)
 INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
 SOURCES =  \
+	Banshee.PlayQueue/ConfigurationPane.cs \
 	Banshee.PlayQueue/IPlayQueue.cs \
 	Banshee.PlayQueue/PlayQueueActions.cs \
 	Banshee.PlayQueue/PlayQueueSource.cs 
