[f-spot] Lots of little code changes



commit 9f3d0c34ff91e600a44b8545f3752f821bcd85b9
Author: Stephen Shaw <sshaw decriptor com>
Date:   Fri Mar 23 17:17:41 2012 -0600

    Lots of little code changes
    
    This commit shouldn't change the logic.
    
    This is just changes to Clients
    
    Big thanks to jetbrains for giving me a
    license to resharper.  Most of these changes
    come from resharper suggestions.

 .../MainApp/FSpot.Editors/AutoStretchEditor.cs     |   17 +-
 src/Clients/MainApp/FSpot.Editors/ColorEditor.cs   |    1 +
 src/Clients/MainApp/FSpot.Editors/CropEditor.cs    |    3 +-
 .../MainApp/FSpot.Editors/DesaturateEditor.cs      |   19 +-
 src/Clients/MainApp/FSpot.Editors/Editor.cs        |   17 +-
 src/Clients/MainApp/FSpot.Editors/RedEyeEditor.cs  |    1 +
 src/Clients/MainApp/FSpot.Editors/SepiaEditor.cs   |   19 +-
 .../MainApp/FSpot.Editors/SoftFocusEditor.cs       |    3 +-
 src/Clients/MainApp/FSpot.Editors/TiltEditor.cs    |    7 +-
 .../FSpot.Extensions/CommandMenuItemNode.cs        |    2 +-
 .../FSpot.Extensions/ComplexMenuItemNode.cs        |   18 +-
 .../MainApp/FSpot.Extensions/ExportMenuItemNode.cs |    2 +-
 src/Clients/MainApp/FSpot.Extensions/IExporter.cs  |    2 -
 .../FSpot.Extensions/PhotoSelectionCondition.cs    |   11 +-
 .../MainApp/FSpot.Extensions/PopupCommands.cs      |    1 +
 .../MainApp/FSpot.Extensions/ServiceNode.cs        |    1 +
 .../MainApp/FSpot.Extensions/SidebarPage.cs        |   33 +-
 .../MainApp/FSpot.Extensions/SidebarPageNode.cs    |    3 +-
 .../MainApp/FSpot.Extensions/TransitionNode.cs     |    7 +-
 .../MainApp/FSpot.Extensions/ViewModeCondition.cs  |   13 +-
 src/Clients/MainApp/FSpot.Filters/FilterRequest.cs |    2 +-
 src/Clients/MainApp/FSpot.Filters/JpegFilter.cs    |   27 +-
 src/Clients/MainApp/FSpot.Filters/ResizeFilter.cs  |   29 +-
 .../MainApp/FSpot.Filters/WhiteListFilter.cs       |    2 +-
 src/Clients/MainApp/FSpot.Imaging/Ciff.cs          |   18 +-
 src/Clients/MainApp/FSpot.Imaging/IOChannel.cs     |    4 +-
 src/Clients/MainApp/FSpot.Imaging/ImageFile.cs     |   44 +-
 .../MainApp/FSpot.Imaging/InternalProcess.cs       |   17 +-
 src/Clients/MainApp/FSpot.Imaging/RafFile.cs       |    5 +-
 src/Clients/MainApp/FSpot.Imaging/Tiff.cs          |   11 +-
 .../MainApp/FSpot.Import/FileImportSource.cs       |   23 +-
 .../MainApp/FSpot.Import/ImportController.cs       |   31 +-
 .../MainApp/FSpot.Import/MetadataImporter.cs       |    4 +-
 src/Clients/MainApp/FSpot.Jobs/CalculateHashJob.cs |    2 +-
 src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs  |    2 +-
 .../MainApp/FSpot.Loaders/AreaPreparedEventArgs.cs |    2 +-
 .../MainApp/FSpot.Loaders/AreaUpdatedEventArgs.cs  |    2 +-
 .../MainApp/FSpot.Loaders/GdkImageLoader.cs        |   53 +-
 src/Clients/MainApp/FSpot.Loaders/ImageLoader.cs   |    4 +-
 src/Clients/MainApp/FSpot.Query/HiddenTag.cs       |   19 +-
 src/Clients/MainApp/FSpot.UI.Dialog/AboutDialog.cs |  256 ++--
 .../MainApp/FSpot.UI.Dialog/AdjustTimeDialog.cs    |   26 +-
 .../MainApp/FSpot.UI.Dialog/BuilderDialog.cs       |    4 +-
 .../MainApp/FSpot.UI.Dialog/DateRangeDialog.cs     |   21 +-
 .../MainApp/FSpot.UI.Dialog/EditExceptionDialog.cs |   22 +-
 .../MainApp/FSpot.UI.Dialog/EditTagDialog.cs       |    2 +-
 .../MainApp/FSpot.UI.Dialog/EditTagIconDialog.cs   |   12 +-
 .../MainApp/FSpot.UI.Dialog/ImportDialog.cs        |   16 +-
 .../MainApp/FSpot.UI.Dialog/ImportFailureDialog.cs |  202 ++--
 .../MainApp/FSpot.UI.Dialog/LastRollDialog.cs      |    8 +-
 .../MainApp/FSpot.UI.Dialog/ProgressDialog.cs      |   45 +-
 .../MainApp/FSpot.UI.Dialog/RatingFilterDialog.cs  |   42 +-
 .../MainApp/FSpot.UI.Dialog/RepairDialog.cs        |    3 +-
 .../MainApp/FSpot.UI.Dialog/TagSelectionDialog.cs  |    5 +-
 .../FSpot.Widgets/BrowseablePointerGridView.cs     |    5 +-
 .../FSpot.Widgets/CollectionCellGridView.cs        |   71 +-
 src/Clients/MainApp/FSpot.Widgets/EditorPage.cs    |    4 +-
 src/Clients/MainApp/FSpot.Widgets/Filmstrip.cs     |   57 +-
 src/Clients/MainApp/FSpot.Widgets/FindBar.cs       |  208 ++--
 .../MainApp/FSpot.Widgets/FolderTreeModel.cs       |    2 +-
 .../MainApp/FSpot.Widgets/FolderTreePage.cs        |    1 +
 .../MainApp/FSpot.Widgets/FolderTreeView.cs        |   22 +-
 src/Clients/MainApp/FSpot.Widgets/InfoBox.cs       | 1479 ++++++++--------
 src/Clients/MainApp/FSpot.Widgets/Loupe.cs         |   64 +-
 .../MainApp/FSpot.Widgets/MetadataDisplay.cs       |   21 +-
 .../MainApp/FSpot.Widgets/PhotoImageView.cs        |   75 +-
 .../FSpot.Widgets/SelectionCollectionGridView.cs   |  877 +++++-----
 src/Clients/MainApp/FSpot.Widgets/Sidebar.cs       |   18 +-
 src/Clients/MainApp/FSpot.Widgets/SlideShow.cs     |    2 +-
 src/Clients/MainApp/FSpot.Widgets/SoftFocus.cs     |   27 +-
 src/Clients/MainApp/FSpot.Widgets/TagEntry.cs      |   41 +-
 src/Clients/MainApp/FSpot.Widgets/TagMenu.cs       |    2 +-
 .../FSpot.Widgets/ThumbnailCaptionRenderer.cs      |    8 -
 .../FSpot.Widgets/ThumbnailDateCaptionRenderer.cs  |   10 +-
 .../FSpot.Widgets/ThumbnailDecorationRenderer.cs   |    8 -
 .../ThumbnailFilenameCaptionRenderer.cs            |    7 -
 .../ThumbnailRatingDecorationRenderer.cs           |    8 -
 .../FSpot.Widgets/ThumbnailTextCaptionRenderer.cs  |    7 -
 src/Clients/MainApp/FSpot/Accelerometer.cs         |    3 +-
 src/Clients/MainApp/FSpot/App.cs                   |   32 +-
 src/Clients/MainApp/FSpot/ExportStore.cs           |   12 +-
 src/Clients/MainApp/FSpot/FolderQueryWidget.cs     |    2 +-
 src/Clients/MainApp/FSpot/FullScreenView.cs        |   53 +-
 src/Clients/MainApp/FSpot/GroupSelector.cs         |   54 +-
 src/Clients/MainApp/FSpot/JobStore.cs              |   19 +-
 src/Clients/MainApp/FSpot/MainWindow.cs            |  234 ++--
 src/Clients/MainApp/FSpot/MetaStore.cs             |   10 +-
 src/Clients/MainApp/FSpot/Photo.cs                 |   76 +-
 src/Clients/MainApp/FSpot/PhotoPopup.cs            |   13 +-
 src/Clients/MainApp/FSpot/PhotoQuery.cs            |   41 +-
 src/Clients/MainApp/FSpot/PhotoStore.cs            | 1777 ++++++++++----------
 src/Clients/MainApp/FSpot/PhotoView.cs             |   45 +-
 src/Clients/MainApp/FSpot/PixbufCache.cs           |    5 +-
 src/Clients/MainApp/FSpot/PrintOperation.cs        |    2 +-
 src/Clients/MainApp/FSpot/ProgressItem.cs          |    5 +-
 src/Clients/MainApp/FSpot/RollStore.cs             |   13 +-
 src/Clients/MainApp/FSpot/RotateCommand.cs         |  121 +-
 .../MainApp/FSpot/SelectionDataExtensions.cs       |   24 +-
 src/Clients/MainApp/FSpot/SendEmail.cs             |    3 +-
 src/Clients/MainApp/FSpot/SingleView.cs            |    4 +-
 src/Clients/MainApp/FSpot/TagQueryWidget.cs        |   89 +-
 src/Clients/MainApp/FSpot/TagSelectionWidget.cs    |  132 +-
 src/Clients/MainApp/FSpot/TagStore.cs              |   36 +-
 src/Clients/MainApp/FSpot/Term.cs                  |   33 +-
 src/Clients/MainApp/FSpot/ThumbnailCache.cs        |   36 +-
 src/Clients/MainApp/FSpot/ThumbnailGenerator.cs    |    2 +-
 src/Clients/MainApp/FSpot/TimeAdaptor.cs           |   31 +-
 src/Clients/MainApp/FSpot/UriCollection.cs         |    4 +-
 src/Clients/MainApp/FSpot/XScreenSaverSlide.cs     |    2 +-
 src/Clients/MainApp/FSpot/main.cs                  |    5 +-
 src/Clients/MainApp/ImageLoaderThread.cs           |   25 +-
 src/Clients/MainApp/MainApp.csproj                 |    1 +
 src/Clients/MainApp/PhotoTagMenu.cs                |    3 +-
 src/Clients/MainApp/PixbufUtils.cs                 |   28 +-
 src/Clients/MainApp/TagCommands.cs                 |   15 +-
 115 files changed, 3424 insertions(+), 3735 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot.Editors/AutoStretchEditor.cs b/src/Clients/MainApp/FSpot.Editors/AutoStretchEditor.cs
index f47ecc0..a773f36 100644
--- a/src/Clients/MainApp/FSpot.Editors/AutoStretchEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/AutoStretchEditor.cs
@@ -34,15 +34,16 @@ using Gdk;
 using Mono.Unix;
 
 namespace FSpot.Editors {
-    class AutoStretchEditor : Editor {
-        public AutoStretchEditor () : base (Catalog.GetString ("Auto Color"), "autocolor") {
+	// FIXME: This class is never used
+	class AutoStretchEditor : Editor {
+		public AutoStretchEditor () : base (Catalog.GetString ("Auto Color"), "autocolor") {
 			// FIXME: need tooltip Catalog.GetString ("Automatically adjust the colors")
 			CanHandleMultiple = true;
-        }
+		}
 
-        protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile) {
-            AutoStretch autostretch = new AutoStretch (input, input_profile);
-            return autostretch.Adjust ();
-        }
-    }
+		protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile) {
+			AutoStretch autostretch = new AutoStretch (input, input_profile);
+			return autostretch.Adjust ();
+		}
+	}
 }
diff --git a/src/Clients/MainApp/FSpot.Editors/ColorEditor.cs b/src/Clients/MainApp/FSpot.Editors/ColorEditor.cs
index 58ad56c..3ab9ade 100644
--- a/src/Clients/MainApp/FSpot.Editors/ColorEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/ColorEditor.cs
@@ -40,6 +40,7 @@ using GtkBeans;
 using Mono.Unix;
 
 namespace FSpot.Editors {
+	// FIXME: This class is never used
 	class ColorEditor : Editor {
 		GtkBeans.Builder builder;
 
diff --git a/src/Clients/MainApp/FSpot.Editors/CropEditor.cs b/src/Clients/MainApp/FSpot.Editors/CropEditor.cs
index 49db471..2c791f9 100644
--- a/src/Clients/MainApp/FSpot.Editors/CropEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/CropEditor.cs
@@ -42,7 +42,8 @@ using Hyena;
 
 using Mono.Unix;
 
-namespace FSpot.Editors {
+namespace FSpot.Editors {
+	// FIXME: This is never used
 	class CropEditor : Editor {
 		private TreeStore constraints_store;
 		private ComboBox constraints_combo;
diff --git a/src/Clients/MainApp/FSpot.Editors/DesaturateEditor.cs b/src/Clients/MainApp/FSpot.Editors/DesaturateEditor.cs
index 718608d..8850631 100644
--- a/src/Clients/MainApp/FSpot.Editors/DesaturateEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/DesaturateEditor.cs
@@ -33,16 +33,17 @@ using Gdk;
 
 using Mono.Unix;
 
-namespace FSpot.Editors {
-    class DesaturateEditor : Editor {
-        public DesaturateEditor () : base (Catalog.GetString ("Desaturate"), "color-desaturate") {
+namespace FSpot.Editors {
+	// FIXME: This is never used
+	class DesaturateEditor : Editor {
+		public DesaturateEditor () : base (Catalog.GetString ("Desaturate"), "color-desaturate") {
 			// FIXME: need tooltip Catalog.GetString ("Convert the photo to black and white")
 			CanHandleMultiple = true;
-        }
+		}
 
-        protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile) {
-            Desaturate desaturate = new Desaturate (input, input_profile);
-            return desaturate.Adjust ();
-        }
-    }
+		protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile) {
+			Desaturate desaturate = new Desaturate (input, input_profile);
+			return desaturate.Adjust ();
+		}
+	}
 }
diff --git a/src/Clients/MainApp/FSpot.Editors/Editor.cs b/src/Clients/MainApp/FSpot.Editors/Editor.cs
index 3d9051b..9f034ec 100644
--- a/src/Clients/MainApp/FSpot.Editors/Editor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/Editor.cs
@@ -37,13 +37,13 @@ using Gdk;
 using Gtk;
 
 using Mono.Addins;
-using Mono.Unix;
 
 using System;
 
 namespace FSpot.Editors {
 
 	// TODO: Move EditorNode to FSpot.Extionsions?
+	// FIXME: EditorNode is never instantiated
 	[ExtensionNode ("Editor")]
 	public class EditorNode : ExtensionNode {
 		[NodeAttribute (Required=true)]
@@ -193,14 +193,10 @@ namespace FSpot.Editors {
 
 		protected virtual Pixbuf ProcessFast (Pixbuf input, Cms.Profile input_profile) {
 			return Process (input, input_profile);
-		}
-
-		private bool has_settings;
-		public bool HasSettings {
-			get { return has_settings; }
-			protected set { has_settings = value; }
-		}
-
+		}
+
+		public bool HasSettings { get; protected set; }
+
 		private Pixbuf original;
 		private Pixbuf preview;
 		protected void UpdatePreview () {
@@ -269,9 +265,8 @@ namespace FSpot.Editors {
 		}
 
 		private void Reset () {
-			if (preview != null) {
+			if (preview != null) 
 				preview.Dispose ();
-			}
 
 			preview = null;
 			original = null;
diff --git a/src/Clients/MainApp/FSpot.Editors/RedEyeEditor.cs b/src/Clients/MainApp/FSpot.Editors/RedEyeEditor.cs
index 3ae323a..411fa12 100644
--- a/src/Clients/MainApp/FSpot.Editors/RedEyeEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/RedEyeEditor.cs
@@ -35,6 +35,7 @@ using Gtk;
 using Mono.Unix;
 
 namespace FSpot.Editors {
+	// FIXME: This is never used
 	class RedEyeEditor : Editor {
 		public RedEyeEditor () : base (Catalog.GetString ("Red-eye Reduction"), "red-eye-remove") {
 			// FIXME: ??? need tooltip Catalog.GetString ("Remove red-eye form the photo")
diff --git a/src/Clients/MainApp/FSpot.Editors/SepiaEditor.cs b/src/Clients/MainApp/FSpot.Editors/SepiaEditor.cs
index 55805d4..3327045 100644
--- a/src/Clients/MainApp/FSpot.Editors/SepiaEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/SepiaEditor.cs
@@ -33,16 +33,17 @@ using Gdk;
 
 using Mono.Unix;
 
-namespace FSpot.Editors {
-    class SepiaEditor : Editor {
-        public SepiaEditor () : base (Catalog.GetString ("Sepia Tone"), "color-sepia") {
+namespace FSpot.Editors {
+	// FIXME: This is never used
+	class SepiaEditor : Editor {
+		public SepiaEditor () : base (Catalog.GetString ("Sepia Tone"), "color-sepia") {
 			// FIXME: need tooltip Catalog.GetString ("Convert the photo to sepia tones")
 			CanHandleMultiple = true;
-        }
+		}
 
-        protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile) {
-            SepiaTone sepia = new SepiaTone (input, input_profile);
-            return sepia.Adjust ();
-        }
-    }
+		protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile) {
+			SepiaTone sepia = new SepiaTone (input, input_profile);
+			return sepia.Adjust ();
+		}
+	}
 }
diff --git a/src/Clients/MainApp/FSpot.Editors/SoftFocusEditor.cs b/src/Clients/MainApp/FSpot.Editors/SoftFocusEditor.cs
index 772b779..cc69226 100644
--- a/src/Clients/MainApp/FSpot.Editors/SoftFocusEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/SoftFocusEditor.cs
@@ -43,6 +43,7 @@ using Pinta.Core;
 namespace FSpot.Editors
 {
 	// TODO: This had a keybinding e. Maybe we should add it back, but did people even knew it?
+	// FIXME: This class is never used
 	class SoftFocusEditor : Editor
 	{
 		double radius;
@@ -87,7 +88,7 @@ namespace FSpot.Editors
 							soft.Apply (ctx, info.Bounds);
 						}
 
-                        result = surface.ToPixbuf();
+						result = surface.ToPixbuf();
 						surface.Flush ();
 					}
 				}
diff --git a/src/Clients/MainApp/FSpot.Editors/TiltEditor.cs b/src/Clients/MainApp/FSpot.Editors/TiltEditor.cs
index f7f0343..c720d98 100644
--- a/src/Clients/MainApp/FSpot.Editors/TiltEditor.cs
+++ b/src/Clients/MainApp/FSpot.Editors/TiltEditor.cs
@@ -44,7 +44,8 @@ using Pinta.Core;
 
 namespace FSpot.Editors
 {
-	// TODO: there were keybindings (left/right) to adjust tilt, maybe they should be added back.
+	// TODO: there were keybindings (left/right) to adjust tilt, maybe they should be added back.
+	// FIXME: This is never used
 	class TiltEditor : Editor
 	{
 		double angle;
@@ -53,7 +54,7 @@ namespace FSpot.Editors
 		public TiltEditor () : base (Catalog.GetString ("Straighten"), "align-horizon") {
 			// FIXME: need tooltip Catalog.GetString ("Adjust the angle of the image to straighten the horizon")
 			HasSettings = true;
-        }
+		}
 
 		public override Widget ConfigurationWidget ()
 		{
@@ -89,7 +90,7 @@ namespace FSpot.Editors
 							ctx.Paint ();
 						}
 						result = surface.ToPixbuf();
-                        surface.Flush ();
+						surface.Flush ();
 					}
 				}
 			}
diff --git a/src/Clients/MainApp/FSpot.Extensions/CommandMenuItemNode.cs b/src/Clients/MainApp/FSpot.Extensions/CommandMenuItemNode.cs
index 51e65f3..1609e4d 100644
--- a/src/Clients/MainApp/FSpot.Extensions/CommandMenuItemNode.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/CommandMenuItemNode.cs
@@ -42,7 +42,7 @@ namespace FSpot.Extensions
 
 		protected override void OnActivated (object o, EventArgs e)
 		{
-			ICommand cmd = (ICommand) Addin.CreateInstance (command_type);
+			ICommand cmd = Addin.CreateInstance (command_type) as ICommand;
 			cmd.Run (o, e);
 		}
 	}
diff --git a/src/Clients/MainApp/FSpot.Extensions/ComplexMenuItemNode.cs b/src/Clients/MainApp/FSpot.Extensions/ComplexMenuItemNode.cs
index ac26075..6bb5260 100644
--- a/src/Clients/MainApp/FSpot.Extensions/ComplexMenuItemNode.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/ComplexMenuItemNode.cs
@@ -53,16 +53,16 @@ namespace FSpot.Extensions
 			ComplexMenuItem item = System.Activator.CreateInstance (Type.GetType (widget_type), parent) as ComplexMenuItem;
 			cmd = (ICommand) Addin.CreateInstance (command_type);
 
-            if (item != null)
-                item.Activated += OnActivated;
-            return item;
-        }
+			if (item != null)
+				item.Activated += OnActivated;
+			return item;
+		}
 
-        private void OnActivated (object o, EventArgs e)
-        {
-            if (cmd != null)
-                cmd.Run (o, e);
-        }
+		private void OnActivated (object o, EventArgs e)
+		{
+			if (cmd != null)
+				cmd.Run (o, e);
+		}
 	}
 
 }
diff --git a/src/Clients/MainApp/FSpot.Extensions/ExportMenuItemNode.cs b/src/Clients/MainApp/FSpot.Extensions/ExportMenuItemNode.cs
index 5c16eae..30a9059 100644
--- a/src/Clients/MainApp/FSpot.Extensions/ExportMenuItemNode.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/ExportMenuItemNode.cs
@@ -48,7 +48,7 @@ namespace FSpot.Extensions
 
 		protected override void OnActivated (object o, EventArgs e)
 		{
-			IExporter exporter = (IExporter) Addin.CreateInstance (class_name);
+			IExporter exporter = Addin.CreateInstance (class_name) as IExporter;
 			exporter.Run (SelectedImages ());
 		}
 	}
diff --git a/src/Clients/MainApp/FSpot.Extensions/IExporter.cs b/src/Clients/MainApp/FSpot.Extensions/IExporter.cs
index 23228be..83be35c 100644
--- a/src/Clients/MainApp/FSpot.Extensions/IExporter.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/IExporter.cs
@@ -30,8 +30,6 @@
 //
 
 using FSpot.Core;
-
-using Mono.Addins;
 
 namespace FSpot.Extensions
 {
diff --git a/src/Clients/MainApp/FSpot.Extensions/PhotoSelectionCondition.cs b/src/Clients/MainApp/FSpot.Extensions/PhotoSelectionCondition.cs
index 77a69e5..9b48f23 100644
--- a/src/Clients/MainApp/FSpot.Extensions/PhotoSelectionCondition.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/PhotoSelectionCondition.cs
@@ -38,6 +38,7 @@ namespace FSpot.Extensions
 	// should be added to the Condition tag.
 	//   - single: One photo is selected
 	//   - multiple: Multiple photos are selected
+	// FIXME: This is never used
 	public class PhotoSelectionCondition : ConditionType
 	{
 		public PhotoSelectionCondition()
@@ -50,13 +51,15 @@ namespace FSpot.Extensions
 			int count = App.Instance.Organizer.Selection.Count;
 			string val = conditionNode.GetAttribute ("selection");
 			if (val.Length > 0) {
-				foreach (string selection in val.Split(',')) {
+				foreach (string selection in val.Split(','))
+				{
 					if (selection == "multiple" && count > 1) {
 						return true;
-					} else if (selection == "single" && count == 1) {
+					}
+					if (selection == "single" && count == 1) {
 						return true;
-					}
-				}
+					}
+				}
 			}
 			return false;
 		}
diff --git a/src/Clients/MainApp/FSpot.Extensions/PopupCommands.cs b/src/Clients/MainApp/FSpot.Extensions/PopupCommands.cs
index 28b5514..dfe93e8 100644
--- a/src/Clients/MainApp/FSpot.Extensions/PopupCommands.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/PopupCommands.cs
@@ -33,6 +33,7 @@ using System;
 
 namespace FSpot.Extensions
 {
+	// FIXME: Nothing in here is called
 	public class Copy : ICommand
 	{
 		public void Run (object o, EventArgs e)
diff --git a/src/Clients/MainApp/FSpot.Extensions/ServiceNode.cs b/src/Clients/MainApp/FSpot.Extensions/ServiceNode.cs
index c022c53..1f9ddcb 100644
--- a/src/Clients/MainApp/FSpot.Extensions/ServiceNode.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/ServiceNode.cs
@@ -33,6 +33,7 @@ using Mono.Addins;
 
 namespace FSpot.Extensions
 {
+	// FIXME: This is never instantiated
 	public class ServiceNode : ExtensionNode
 	{
 		[NodeAttribute ("class", true)]
diff --git a/src/Clients/MainApp/FSpot.Extensions/SidebarPage.cs b/src/Clients/MainApp/FSpot.Extensions/SidebarPage.cs
index fad2af7..29e12c8 100644
--- a/src/Clients/MainApp/FSpot.Extensions/SidebarPage.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/SidebarPage.cs
@@ -36,12 +36,9 @@ using Mono.Addins;
 namespace FSpot.Extensions
 {
 	public class SidebarPage {
-		// The widget shown on the sidebar page.
-		private readonly Widget widget;
-		public Widget SidebarWidget {
-			get { return widget; }
-		}
-
+		// The widget shown on the sidebar page.
+		public Widget SidebarWidget { get; private set; }
+
 		// Whether this page can be selected
 		private bool can_select;
 		public bool CanSelect {
@@ -55,18 +52,12 @@ namespace FSpot.Extensions
 
 		public event EventHandler CanSelectChanged;
 
-		// The label of the sidebar page.
-		private readonly string label;
-		public string Label {
-			get { return label; }
-		}
-
-		// The icon name, used for the selector
-		private readonly string icon_name;
-		public string IconName {
-			get { return icon_name; }
-		}
-
+		// The label of the sidebar page.
+		public string Label { get; private set; }
+
+		// The icon name, used for the selector
+		public string IconName { get; private set; }
+
 		// The sidebar onto which this page is attached
 		private Gtk.Widget sidebar;
 		public Gtk.Widget Sidebar {
@@ -86,9 +77,9 @@ namespace FSpot.Extensions
 //		}
 
 		public SidebarPage (Widget widget, string label, string icon_name) {
-			this.widget = widget;
-			this.label = label;
-			this.icon_name = icon_name;
+			SidebarWidget = widget;
+			Label = label;
+			IconName = icon_name;
 		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.Extensions/SidebarPageNode.cs b/src/Clients/MainApp/FSpot.Extensions/SidebarPageNode.cs
index e31766d..471e4d4 100644
--- a/src/Clients/MainApp/FSpot.Extensions/SidebarPageNode.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/SidebarPageNode.cs
@@ -31,12 +31,13 @@ using Mono.Addins;
 
 namespace FSpot.Extensions
 {
+	// FIXME: This is never instantiated
 	public class SidebarPageNode : ExtensionNode {
 		[NodeAttribute (Required=true)]
 		protected string sidebar_page_type;
 
 		public SidebarPage GetPage () {
-			return (SidebarPage) Addin.CreateInstance (sidebar_page_type);
+			return Addin.CreateInstance (sidebar_page_type) as SidebarPage;
 		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.Extensions/TransitionNode.cs b/src/Clients/MainApp/FSpot.Extensions/TransitionNode.cs
index 5d247d3..bacadc2 100644
--- a/src/Clients/MainApp/FSpot.Extensions/TransitionNode.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/TransitionNode.cs
@@ -33,6 +33,7 @@ using Mono.Addins;
 
 namespace FSpot.Extensions
 {
+	// FIXME: This is never instantiated
 	public class TransitionNode : ExtensionNode
 	{
 		[NodeAttribute ("transition_type", true)]
@@ -40,11 +41,7 @@ namespace FSpot.Extensions
 
 		SlideShowTransition transition = null;
 		public SlideShowTransition Transition {
-			get {
-				if (transition == null)
-					transition = Addin.CreateInstance (class_name) as SlideShowTransition;
-				return transition;
-			}
+			get { return transition ?? (transition = Addin.CreateInstance(class_name) as SlideShowTransition); }
 		}
 	}
 }
\ No newline at end of file
diff --git a/src/Clients/MainApp/FSpot.Extensions/ViewModeCondition.cs b/src/Clients/MainApp/FSpot.Extensions/ViewModeCondition.cs
index 2b38ddc..487be1f 100644
--- a/src/Clients/MainApp/FSpot.Extensions/ViewModeCondition.cs
+++ b/src/Clients/MainApp/FSpot.Extensions/ViewModeCondition.cs
@@ -47,6 +47,7 @@ namespace FSpot.Extensions
 	// This class contains a very nasty hack using a static initialization method
 	// to keep track of the current view mode. This is (unfortunately) needed
 	// because there is no way to get hold of a reference to the current window.
+	// FIXME: This class is never instantiated
 	public class ViewModeCondition : ConditionType
 	{
 		private delegate void ViewModeChangedHandler ();
@@ -65,20 +66,22 @@ namespace FSpot.Extensions
 
 		public ViewModeCondition ()
 		{
-			ViewModeChanged += delegate { NotifyChanged (); };
+			ViewModeChanged += () => NotifyChanged();
 		}
 
 		public override bool Evaluate (NodeElement conditionNode)
 		{
 			string val = conditionNode.GetAttribute ("mode");
 			if (val.Length > 0) {
-				foreach (string mode in val.Split(',')) {
+				foreach (string mode in val.Split(','))
+				{
 					if (mode == "single" && Mode == ViewMode.Single) {
 						return true;
-					} else if (mode == "library" && Mode == ViewMode.Library) {
+					}
+					if (mode == "library" && Mode == ViewMode.Library) {
 						return true;
-					}
-				}
+					}
+				}
 			}
 			return false;
 		}
diff --git a/src/Clients/MainApp/FSpot.Filters/FilterRequest.cs b/src/Clients/MainApp/FSpot.Filters/FilterRequest.cs
index ea3c913..ba17caa 100644
--- a/src/Clients/MainApp/FSpot.Filters/FilterRequest.cs
+++ b/src/Clients/MainApp/FSpot.Filters/FilterRequest.cs
@@ -47,7 +47,7 @@ namespace FSpot.Filters {
 		public FilterRequest (SafeUri source)
 		{
 			Source = source;
-			this.current = source;
+			current = source;
 			temp_uris = new List<SafeUri> ();
 		}
 
diff --git a/src/Clients/MainApp/FSpot.Filters/JpegFilter.cs b/src/Clients/MainApp/FSpot.Filters/JpegFilter.cs
index 9f0bbba..f64dea3 100644
--- a/src/Clients/MainApp/FSpot.Filters/JpegFilter.cs
+++ b/src/Clients/MainApp/FSpot.Filters/JpegFilter.cs
@@ -30,28 +30,25 @@
 //
 
 namespace FSpot.Filters {
-    public class JpegFilter : IFilter {
-        private uint quality = 95;
-        public uint Quality {
-            get { return quality; }
-            set { quality = value; }
-        }
-
-        public JpegFilter (uint quality)
-        {
-            this.quality = quality;
-        }
-
-        public JpegFilter()
+    public class JpegFilter : IFilter {
+    	public uint Quality { get; set; }
+
+    	public JpegFilter (uint quality)
         {
+            Quality = quality;
         }
 
-        public bool Convert (FilterRequest req)
+        public JpegFilter()
+        {
+        	Quality = 95;
+        }
+
+    	public bool Convert (FilterRequest req)
         {
             var source = req.Current;
             req.Current = req.TempUri ("jpg");
 
-            PixbufUtils.CreateDerivedVersion (source, req.Current, quality);
+            PixbufUtils.CreateDerivedVersion (source, req.Current, Quality);
 
             return true;
         }
diff --git a/src/Clients/MainApp/FSpot.Filters/ResizeFilter.cs b/src/Clients/MainApp/FSpot.Filters/ResizeFilter.cs
index 9e7b8eb..98fbb80 100644
--- a/src/Clients/MainApp/FSpot.Filters/ResizeFilter.cs
+++ b/src/Clients/MainApp/FSpot.Filters/ResizeFilter.cs
@@ -35,24 +35,15 @@ using Gdk;
 
 namespace FSpot.Filters {
     public class ResizeFilter : IFilter
-    {
-        public ResizeFilter ()
+    {
+    	public ResizeFilter (uint size)
         {
-        }
-
-        public ResizeFilter (uint size)
-        {
-            this.size = size;
-        }
-
-        private uint size = 600;
-
-        public uint Size {
-            get { return size; }
-            set { size = value; }
-        }
-
-        public bool Convert (FilterRequest req)
+            Size = size;
+        }
+
+    	public uint Size { get; set; }
+
+    	public bool Convert (FilterRequest req)
         {
             string source = req.Current.LocalPath;
             var dest_uri = req.TempUri (System.IO.Path.GetExtension (source));
@@ -60,11 +51,11 @@ namespace FSpot.Filters {
             using (var img = ImageFile.Create (req.Current)) {
 
                 using (Pixbuf pixbuf = img.Load ()) {
-                    if (pixbuf.Width < size && pixbuf.Height < size)
+                    if (pixbuf.Width < Size && pixbuf.Height < Size)
                         return false;
                 }
 
-                using (Pixbuf pixbuf = img.Load ((int)size, (int)size)) {
+                using (Pixbuf pixbuf = img.Load ((int)Size, (int)Size)) {
                     PixbufUtils.CreateDerivedVersion (req.Current, dest_uri, 95, pixbuf);
                 }
             }
diff --git a/src/Clients/MainApp/FSpot.Filters/WhiteListFilter.cs b/src/Clients/MainApp/FSpot.Filters/WhiteListFilter.cs
index b29fbda..38c7ac8 100644
--- a/src/Clients/MainApp/FSpot.Filters/WhiteListFilter.cs
+++ b/src/Clients/MainApp/FSpot.Filters/WhiteListFilter.cs
@@ -35,7 +35,7 @@ namespace FSpot.Filters {
 	{
 		List<string> valid_extensions;
 
-		public WhiteListFilter (string [] valid_extensions)
+		public WhiteListFilter (IEnumerable<string> valid_extensions)
 		{
 			this.valid_extensions = new List<string> ();
 			foreach (string extension in valid_extensions)
diff --git a/src/Clients/MainApp/FSpot.Imaging/Ciff.cs b/src/Clients/MainApp/FSpot.Imaging/Ciff.cs
index ffabf03..7799998 100644
--- a/src/Clients/MainApp/FSpot.Imaging/Ciff.cs
+++ b/src/Clients/MainApp/FSpot.Imaging/Ciff.cs
@@ -119,7 +119,7 @@ namespace FSpot.Imaging.Ciff {
 
 		public byte [] ReadEntry (int pos)
 		{
-			Entry e = (Entry) entry_list [pos];
+			Entry e = entry_list [pos];
 
 			stream.Position = this.start + e.Offset;
 
@@ -185,9 +185,8 @@ namespace FSpot.Imaging.Ciff {
 			byte [] data = GetEmbeddedJpeg ();
 
 			if (data != null)
-				return new System.IO.MemoryStream (data);
-			else
-				return DCRawFile.RawPixbufStream (Uri);
+				return new System.IO.MemoryStream (data);
+			return DCRawFile.RawPixbufStream (Uri);
 		}
 
 		private byte [] GetEmbeddedJpeg ()
@@ -196,11 +195,12 @@ namespace FSpot.Imaging.Ciff {
 		}
 
 		protected override void Close ()
-		{
-			if (stream != null) {
-				stream.Close ();
-				stream = null;
-			}
+		{
+			if (stream == null)
+				return;
+
+			stream.Close ();
+			stream = null;
 		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.Imaging/IOChannel.cs b/src/Clients/MainApp/FSpot.Imaging/IOChannel.cs
index 3356433..22cac15 100644
--- a/src/Clients/MainApp/FSpot.Imaging/IOChannel.cs
+++ b/src/Clients/MainApp/FSpot.Imaging/IOChannel.cs
@@ -210,7 +210,7 @@ namespace FSpot.Imaging {
 			if (error != IntPtr.Zero)
 				throw new GException (error);
 
-			return (int)read;
+			return read;
 		}
 
 		[DllImport("libglib-2.0-0.dll")]
@@ -261,7 +261,7 @@ namespace FSpot.Imaging {
 
 		public override long Seek (long position, SeekOrigin origin)
 		{
-      		      throw new NotSupportedException ();
+				  throw new NotSupportedException ();
 		}
 
 		[DllImport("libglib-2.0-0.dll")]
diff --git a/src/Clients/MainApp/FSpot.Imaging/ImageFile.cs b/src/Clients/MainApp/FSpot.Imaging/ImageFile.cs
index 6fd1fca..53d9f2f 100644
--- a/src/Clients/MainApp/FSpot.Imaging/ImageFile.cs
+++ b/src/Clients/MainApp/FSpot.Imaging/ImageFile.cs
@@ -32,7 +32,7 @@
 
 using System;
 using System.Collections.Generic;
-
+using System.Linq;
 using Hyena;
 
 using TagLib.Image;
@@ -121,13 +121,13 @@ namespace FSpot.Imaging
 			// with filenames with invalid encoding
 			var file = GLib.FileFactory.NewForUri (uri);
 			if (!file.Exists)
-             		   return null;
+					   return null;
 
 			string extension = uri.GetExtension ().ToLower ();
 
 			// Ignore video thumbnails
 			if (extension == ".thm")
-		                return null;
+						return null;
 
 			// Detect mime-type
 			var info = file.QueryInfo ("standard::content-type,standard::size", FileQueryInfoFlags.None, null);
@@ -136,15 +136,16 @@ namespace FSpot.Imaging
 
 			// Empty file
 			if (size == 0)
-		                return null;
+						return null;
 
 			Type t = null;
 
 			if (NameTable.TryGetValue (mime, out t))
-				return t;
-			else if (NameTable.TryGetValue (extension, out t))
-				return t;
-
+				return t;
+
+			if (NameTable.TryGetValue (extension, out t))
+				return t;
+
 			return null;
 		}
 
@@ -177,23 +178,24 @@ namespace FSpot.Imaging
 				".raf",
 				".rw2",
 			};
-			var extension = uri.GetExtension ().ToLower ();
-			foreach (string ext in raw_extensions) {
-				if (ext == extension)
-					return true;
-			}
-			return false;
+
+			var extension = uri.GetExtension ().ToLower ();
+			return raw_extensions.Any(ext => ext == extension);
 		}
 
 		public static bool IsJpeg (SafeUri uri)
 		{
-			string [] jpg_extensions = {".jpg", ".jpeg", ".jpe", ".jfi", ".jfif", ".jif"};
-			var extension = uri.GetExtension ().ToLower ();
-			foreach (string ext in jpg_extensions) {
-				if (ext == extension)
-					return true;
-			}
-			return false;
+			string [] jpg_extensions = {
+			    ".jpg",
+				".jpeg",
+				".jpe",
+				".jfi",
+				".jfif",
+				".jif"
+			    };
+
+			var extension = uri.GetExtension ().ToLower ();
+			return jpg_extensions.Any(ext => ext == extension);
 		}
 		#endregion
 	}
diff --git a/src/Clients/MainApp/FSpot.Imaging/InternalProcess.cs b/src/Clients/MainApp/FSpot.Imaging/InternalProcess.cs
index 0d2d793..9d95323 100644
--- a/src/Clients/MainApp/FSpot.Imaging/InternalProcess.cs
+++ b/src/Clients/MainApp/FSpot.Imaging/InternalProcess.cs
@@ -46,16 +46,11 @@ namespace FSpot.Imaging {
 
 	internal class InternalProcess {
 		int stdin;
-		int stdout;
-		IOChannel input;
-		IOChannel output;
-
-		public IOChannel StandardInput {
-			get {
-				return input;
-			}
-		}
-
+		int stdout;
+		IOChannel output;
+
+		public IOChannel StandardInput { get; private set; }
+
 		public IOChannel StandardOutput {
 			get {
 				return output;
@@ -93,7 +88,7 @@ namespace FSpot.Imaging {
 			if (error != IntPtr.Zero)
 				throw new GException (error);
 
-			input = new IOChannel (stdin);
+			StandardInput = new IOChannel (stdin);
 			output = new IOChannel (stdout);
 			//errorput = new IOChannel (stderr);
 		}
diff --git a/src/Clients/MainApp/FSpot.Imaging/RafFile.cs b/src/Clients/MainApp/FSpot.Imaging/RafFile.cs
index 3fd1728..791095a 100644
--- a/src/Clients/MainApp/FSpot.Imaging/RafFile.cs
+++ b/src/Clients/MainApp/FSpot.Imaging/RafFile.cs
@@ -56,9 +56,8 @@ namespace FSpot.Imaging {
 			byte [] data = GetEmbeddedJpeg ();
 
 			if (data != null)
-				return new System.IO.MemoryStream (data);
-			else
-				return DCRawFile.RawPixbufStream (Uri);
+				return new System.IO.MemoryStream (data);
+			return DCRawFile.RawPixbufStream (Uri);
 		}
 
 		private byte [] GetEmbeddedJpeg ()
diff --git a/src/Clients/MainApp/FSpot.Imaging/Tiff.cs b/src/Clients/MainApp/FSpot.Imaging/Tiff.cs
index af7ea0a..20754d6 100644
--- a/src/Clients/MainApp/FSpot.Imaging/Tiff.cs
+++ b/src/Clients/MainApp/FSpot.Imaging/Tiff.cs
@@ -195,13 +195,12 @@ namespace FSpot.Imaging
 			}
 		}
 
-		public override System.IO.Stream PixbufStream ()
-		{
+		public override System.IO.Stream PixbufStream ()
+		{
 			if (jpeg_data != null)
-				return new MemoryStream (jpeg_data);
-			else
-				return DCRawFile.RawPixbufStream (Uri);
-		}
+				return new MemoryStream (jpeg_data);
+			return DCRawFile.RawPixbufStream (Uri);
+		}
 	}
 
 	public class Cr2File : BaseImageFile
diff --git a/src/Clients/MainApp/FSpot.Import/FileImportSource.cs b/src/Clients/MainApp/FSpot.Import/FileImportSource.cs
index 84df28e..c408231 100644
--- a/src/Clients/MainApp/FSpot.Import/FileImportSource.cs
+++ b/src/Clients/MainApp/FSpot.Import/FileImportSource.cs
@@ -55,17 +55,18 @@ namespace FSpot.Import
 		public FileImportSource (SafeUri root, string name, string icon_name)
 		{
 			Root = root;
-			Name = name;
-
-			if (root != null) {
-				if (IsIPodPhoto) {
-					IconName = "multimedia-player";
-				} else if (IsCamera) {
-					IconName = "media-flash";
-				} else {
-					IconName = icon_name;
-				}
-			}
+			Name = name;
+
+			if (root == null)
+				return;
+
+			if (IsIPodPhoto) {
+				IconName = "multimedia-player";
+			} else if (IsCamera) {
+				IconName = "media-flash";
+			} else {
+				IconName = icon_name;
+			}
 		}
 
 		public void StartPhotoScan (ImportController controller, PhotoList photo_list)
diff --git a/src/Clients/MainApp/FSpot.Import/ImportController.cs b/src/Clients/MainApp/FSpot.Import/ImportController.cs
index c4e2ce4..fa03d1c 100644
--- a/src/Clients/MainApp/FSpot.Import/ImportController.cs
+++ b/src/Clients/MainApp/FSpot.Import/ImportController.cs
@@ -131,12 +131,8 @@ namespace FSpot.Import
 #region Source Scanning
 
         private List<IImportSource> sources;
-        public List<IImportSource> Sources {
-            get {
-                if (sources == null)
-                    sources = ScanSources ();
-                return sources;
-            }
+        public IEnumerable<IImportSource> Sources {
+            get { return sources ?? (sources = ScanSources()); }
         }
 
         List<IImportSource> ScanSources ()
@@ -476,21 +472,22 @@ namespace FSpot.Import
         {
             var parts = uri.AbsolutePath.Split('/');
             SafeUri current = new SafeUri (uri.Scheme + ":///", true);
-            for (int i = 0; i < parts.Length; i++) {
-                current = current.Append (parts [i]);
-                var file = GLib.FileFactory.NewForUri (current);
-                if (!file.Exists) {
-                    file.MakeDirectory (null);
-                }
+            foreach (string t in parts)
+            {
+            	current = current.Append (t);
+            	var file = GLib.FileFactory.NewForUri (current);
+            	if (!file.Exists) {
+            		file.MakeDirectory (null);
+            	}
             }
         }
 
 #endregion
 
-#region Tagging
-
-        List<Tag> attach_tags = new List<Tag> ();
-        TagStore tag_store = App.Instance.Database.Tags;
+#region Tagging
+
+    	readonly List<Tag> attach_tags = new List<Tag> ();
+    	readonly TagStore tag_store = App.Instance.Database.Tags;
 
         // Set the tags that will be added on import.
         public void AttachTags (IEnumerable<string> tags)
@@ -500,7 +497,7 @@ namespace FSpot.Import
             foreach (var tagname in tags) {
                 var tag = tag_store.GetTagByName (tagname);
                 if (tag == null) {
-                    tag = tag_store.CreateCategory (import_category, tagname, false) as Tag;
+                    tag = tag_store.CreateCategory (import_category, tagname, false);
                     tag_store.Commit (tag);
                 }
                 attach_tags.Add (tag);
diff --git a/src/Clients/MainApp/FSpot.Import/MetadataImporter.cs b/src/Clients/MainApp/FSpot.Import/MetadataImporter.cs
index 8226ebf..93727a7 100644
--- a/src/Clients/MainApp/FSpot.Import/MetadataImporter.cs
+++ b/src/Clients/MainApp/FSpot.Import/MetadataImporter.cs
@@ -68,7 +68,7 @@ namespace FSpot.Import {
 
         public MetadataImporter ()
         {
-            this.tag_store = App.Instance.Database.Tags;
+            tag_store = App.Instance.Database.Tags;
             tags_created = new Stack<Tag> ();
 
             li_root_tag = new TagInfo (Catalog.GetString ("Imported Tags"), LastImportIcon);
@@ -96,7 +96,7 @@ namespace FSpot.Import {
 
         private void AddTagToPhoto (Photo photo, string new_tag_name)
         {
-            if (new_tag_name == null || new_tag_name.Length == 0)
+            if (string.IsNullOrEmpty(new_tag_name))
                 return;
 
             Tag parent = EnsureTag (li_root_tag, tag_store.RootCategory);
diff --git a/src/Clients/MainApp/FSpot.Jobs/CalculateHashJob.cs b/src/Clients/MainApp/FSpot.Jobs/CalculateHashJob.cs
index a9cecbb..79770c0 100644
--- a/src/Clients/MainApp/FSpot.Jobs/CalculateHashJob.cs
+++ b/src/Clients/MainApp/FSpot.Jobs/CalculateHashJob.cs
@@ -62,7 +62,7 @@ namespace FSpot.Jobs {
 			Log.DebugFormat ("Calculating Hash {0}...", photo_id);
 
 			try {
-				Photo photo = FSpot.App.Instance.Database.Photos.Get (Convert.ToUInt32 (photo_id)) as Photo;
+				Photo photo = FSpot.App.Instance.Database.Photos.Get (Convert.ToUInt32 (photo_id));
 				FSpot.App.Instance.Database.Photos.CalculateMD5Sum (photo);
 				return true;
 			} catch (System.Exception e) {
diff --git a/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs b/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs
index 3d97a55..197da86 100644
--- a/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs
+++ b/src/Clients/MainApp/FSpot.Jobs/SyncMetadataJob.cs
@@ -61,7 +61,7 @@ namespace FSpot.Jobs {
             System.Threading.Thread.Sleep (500);
 
             try {
-                Photo photo = FSpot.App.Instance.Database.Photos.Get (Convert.ToUInt32 (JobOptions)) as Photo;
+                Photo photo = FSpot.App.Instance.Database.Photos.Get (Convert.ToUInt32 (JobOptions));
                 if (photo == null)
                     return false;
 
diff --git a/src/Clients/MainApp/FSpot.Loaders/AreaPreparedEventArgs.cs b/src/Clients/MainApp/FSpot.Loaders/AreaPreparedEventArgs.cs
index 0d4bc19..ea8ae80 100644
--- a/src/Clients/MainApp/FSpot.Loaders/AreaPreparedEventArgs.cs
+++ b/src/Clients/MainApp/FSpot.Loaders/AreaPreparedEventArgs.cs
@@ -34,7 +34,7 @@ namespace FSpot.Loaders {
 	{
 		public bool ReducedResolution { get; private set; }
 
-		public AreaPreparedEventArgs (bool reduced_resolution) : base ()
+		public AreaPreparedEventArgs (bool reduced_resolution)
 		{
 			ReducedResolution = reduced_resolution;
 		}
diff --git a/src/Clients/MainApp/FSpot.Loaders/AreaUpdatedEventArgs.cs b/src/Clients/MainApp/FSpot.Loaders/AreaUpdatedEventArgs.cs
index 0a059b3..fdb0726 100644
--- a/src/Clients/MainApp/FSpot.Loaders/AreaUpdatedEventArgs.cs
+++ b/src/Clients/MainApp/FSpot.Loaders/AreaUpdatedEventArgs.cs
@@ -34,7 +34,7 @@ namespace FSpot.Loaders {
 	{
 		public Gdk.Rectangle Area { get; private set; }
 
-		public AreaUpdatedEventArgs (Gdk.Rectangle area) : base ()
+		public AreaUpdatedEventArgs (Gdk.Rectangle area)
 		{
 			Area = area;
 		}
diff --git a/src/Clients/MainApp/FSpot.Loaders/GdkImageLoader.cs b/src/Clients/MainApp/FSpot.Loaders/GdkImageLoader.cs
index c2091e1..fc73175 100644
--- a/src/Clients/MainApp/FSpot.Loaders/GdkImageLoader.cs
+++ b/src/Clients/MainApp/FSpot.Loaders/GdkImageLoader.cs
@@ -44,11 +44,8 @@ namespace FSpot.Loaders
 {
 	public class GdkImageLoader : Gdk.PixbufLoader, IImageLoader
 	{
-#region public api
-		public GdkImageLoader () : base ()
-		{
-		}
-
+#region public api
+
 		~GdkImageLoader ()
 		{
 			if (!is_disposed) {
@@ -79,7 +76,7 @@ namespace FSpot.Loaders
 				pixbuf_orientation = image_file.Orientation;
 			}
 
-			loading = true;
+			Loading = true;
 			// The ThreadPool.QueueUserWorkItem hack is there cause, as the bytes to read are present in the stream,
 			// the Read is CompletedAsynchronously, blocking the mainloop
 			image_stream.BeginRead (buffer, 0, count, delegate (IAsyncResult r) {
@@ -95,27 +92,15 @@ namespace FSpot.Loaders
 		Pixbuf thumb;
 
 		new public Pixbuf Pixbuf {
-			get {
-				if (thumb != null) {
-					return thumb;
-				}
-				return base.Pixbuf;
-			}
-		}
-
-		bool loading = false;
-
-		public bool Loading {
-			get { return loading; }
-		}
-
-		bool notify_prepared = false;
-		bool prepared = false;
-
-		public bool Prepared {
-			get { return prepared; }
-		}
-
+			get { return thumb != null ? thumb : base.Pixbuf; }
+		}
+
+		public bool Loading { get; private set; }
+
+		bool notify_prepared = false;
+
+		public bool Prepared { get; private set; }
+
 		ImageOrientation pixbuf_orientation = ImageOrientation.TopLeft;
 
 		public ImageOrientation PixbufOrientation {
@@ -155,7 +140,7 @@ namespace FSpot.Loaders
 			if (is_disposed)
 				return;
 
-			prepared = notify_prepared = true;
+			Prepared = notify_prepared = true;
 			damage = Rectangle.Zero;
 			base.OnAreaPrepared ();
 		}
@@ -189,8 +174,14 @@ namespace FSpot.Loaders
 		byte[] buffer = new byte [count];
 		bool notify_completed = false;
 		Rectangle damage;
-		object sync_handle = new object ();
-
+		object sync_handle = new object ();
+
+		public GdkImageLoader()
+		{
+			Prepared = false;
+			Loading = false;
+		}
+
 		void HandleReadDone (IAsyncResult ar)
 		{
 			if (is_disposed)
@@ -201,7 +192,7 @@ namespace FSpot.Loaders
 				if (byte_read == 0) {
 					image_stream.Close ();
 					Close ();
-					loading = false;
+					Loading = false;
 					notify_completed = true;
 				} else {
 					try {
diff --git a/src/Clients/MainApp/FSpot.Loaders/ImageLoader.cs b/src/Clients/MainApp/FSpot.Loaders/ImageLoader.cs
index 89a5dee..25a3205 100644
--- a/src/Clients/MainApp/FSpot.Loaders/ImageLoader.cs
+++ b/src/Clients/MainApp/FSpot.Loaders/ImageLoader.cs
@@ -38,7 +38,7 @@ using Hyena;
 
 namespace FSpot.Loaders {
 	public static class ImageLoader {
-		static Dictionary<string, System.Type> name_table;
+		static readonly Dictionary<string, System.Type> name_table;
 
 		static ImageLoader ()
 		{
@@ -71,7 +71,7 @@ namespace FSpot.Loaders {
 					throw new Exception ("Loader requested for unknown file type: "+extension);
 			}
 
-			loader = (IImageLoader) System.Activator.CreateInstance (t);
+			loader = System.Activator.CreateInstance (t) as IImageLoader;
 
 			return loader;
 		}
diff --git a/src/Clients/MainApp/FSpot.Query/HiddenTag.cs b/src/Clients/MainApp/FSpot.Query/HiddenTag.cs
index e5141b6..317309c 100644
--- a/src/Clients/MainApp/FSpot.Query/HiddenTag.cs
+++ b/src/Clients/MainApp/FSpot.Query/HiddenTag.cs
@@ -42,21 +42,11 @@ namespace FSpot.Query
 		private static HiddenTag hide_hidden_tag;
 
 		public static HiddenTag ShowHiddenTag {
-			get {
-				if (show_hidden_tag == null)
-					show_hidden_tag = new HiddenTag (true);
-
-				return show_hidden_tag;
-			}
+			get { return show_hidden_tag ?? (show_hidden_tag = new HiddenTag(true)); }
 		}
 
 		public static HiddenTag HideHiddenTag {
-			get {
-				if (hide_hidden_tag == null)
-					hide_hidden_tag = new HiddenTag (false);
-
-				return hide_hidden_tag;
-			}
+			get { return hide_hidden_tag ?? (hide_hidden_tag = new HiddenTag(false)); }
 		}
 
 
@@ -73,9 +63,8 @@ namespace FSpot.Query
 
 			if ( ! show_hidden && hidden != null)
 				return String.Format (" photos.id NOT IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0}) ",
-				                      hidden.Id);
-			else
-				return null;
+				                      hidden.Id);
+			return null;
 		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/AboutDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/AboutDialog.cs
index 3b4b12c..1592aaa 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/AboutDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/AboutDialog.cs
@@ -36,134 +36,134 @@ using Mono.Unix;
 
 namespace FSpot.UI.Dialog
 {
-    public class AboutDialog : Gtk.AboutDialog
-    {
-        private static AboutDialog about = null;
+	public class AboutDialog : Gtk.AboutDialog
+	{
+		private static AboutDialog about = null;
 
-        private AboutDialog () {
-            Artists = new string [] {
-                    "Jakub Steiner",
-                    "Matthew Paul Thomas",
-            };
-            Authors = new string [] {
-                "Primary Development",
-                    "\tLawrence Ewing",
-                    "\tStephane Delcroix",
-                    "\tRuben Vermeersch",
-		    "\tStephen  Shaw",
-                    "",
-                    "Active Contributors to this release",
-                    "\tAdemir Mendoza",
-                    "\tAlex Launi",
-                    "\tAnton Keks",
-                    "\tBertrand Lorentz",
-                    "\tChristian Krause",
-                    "\tChristopher Halse Rogers",
-                    "\tDaniel KÃb",
-                    "\tEric Faehnrich",
-                    "\tEvan Briones",
-                    "\tGabriel Burt",
-                    "\tIain Churcher",
-                    "\tIain Lane",
-                    "\tLorenzo Milesi",
-                    "\tÅukasz JernaÅ",
-                    "\tMike Gem\x00fcnde",
-                    "\tMike Wallick",
-                    "\tNick Van Eeckhout",
-                    "\tPaul Lange",
-                    "\tPaul Wellner Bou",
-                    "\tPeter Goetz",
-                    "\tRuben Vermeersch",
-                    "\tTim Retout",
-                    "\tTomas Kovacik",
-                    "\tTrevor Buchanan",
-                    "\tVincent Pomey",
-                    "\tWojciech DzierÅanowski",
-                    "",
-                    "Contributors",
-                    "\tAaron Bockover",
-                    "\tAlessandro Gervaso",
-                    "\tAlex Graveley",
-                    "\tAlvaro del Castillo",
-                    "\tBengt Thuree",
-                    "\tBen Monnahan",
-                    "\tChad Files",
-                    "\tEttore Perazzoli",
-                    "\tEwen Cheslack-Postava",
-                    "\tGrahm Orr",
-                    "\tJeffrey Finkelstein",
-                    "\tJeffrey Stedfast",
-                    "\tJoerg Buesse",
-                    "\tJoe Shaw",
-                    "\tJon Trowbridge",
-                    "\tJoshua Tauberer",
-                    "\tKarl Mikaelsson",
-                    "\tLaurence Hygate",
-                    "\tLee Willis",
-                    "\tMartin Willemoes Hansen",
-                    "\tMatt Jones",
-                    "\tMatt Perry",
-                    "\tMichal NÃnÃsi",
-                    "\tMiguel de Icaza",
-                    "\tNat Friedman",
-                    "\tPascal de Bruijn",
-                    "\tPatanjali Somayaji",
-                    "\tPeter Johanson",
-                    "\tTambet Ingo",
-                    "\tThomas Van Machelen",
-                    "\tTodd Berman",
-                    "\tVasily Kirilichev",
-                    "\tVincent Moreau",
-                    "\tVladimir Vukicevic",
-                    "\tXavier Bouchoux",
-                    "\tYann Leprince",
-                    "\tYves Kurz",
-                    "",
-                    "In memory Of",
-                    "\tEttore Perazzoli",
-            };
-            Comments = Catalog.GetString ("Photo management for GNOME");
-            Copyright = Catalog.GetString ("Copyright \x00a9 2003-2010 Novell Inc.");
-            Documenters = new string[] {
-                    "Aaron Bockover",
-                    "Alexandre Prokoudine",
-                    "Bengt Thuree",
-                    "Gabriel Burt",
-                    "Harold Schreckengost",
-                    "Miguel de Icaza",
-                    "Stephane Delcroix",
-            };
-            //Read license from COPYING
-            try {
-                System.Reflection.Assembly assembly = System.Reflection.Assembly.GetCallingAssembly ();
-                using (Stream s = assembly.GetManifestResourceStream ("COPYING")) {
-                    StreamReader reader = new StreamReader (s);
-                    License = reader.ReadToEnd ();
-                    s.Close ();
-                }
-            } catch (Exception e) {
-                Log.DebugException (e);
-                License = "GPL v2";
-            }
-            Logo = new Gdk.Pixbuf (System.Reflection.Assembly.GetEntryAssembly (), "f-spot-128.png");
-            ProgramName = "F-Spot";
-            TranslatorCredits = Catalog.GetString ("translator-credits");
-            if (System.String.Compare (TranslatorCredits, "translator-credits") == 0)
-                TranslatorCredits = null;
-            Version = FSpot.Core.Defines.VERSION;
-            Website = "http://f-spot.org";;
-            WebsiteLabel = Catalog.GetString ("F-Spot Website");
-            WrapLicense = true;
-        }
+		private AboutDialog () {
+			Artists = new string [] {
+					"Jakub Steiner",
+					"Matthew Paul Thomas",
+			};
+			Authors = new string [] {
+				"Primary Development",
+					"\tLawrence Ewing",
+					"\tStephane Delcroix",
+					"\tRuben Vermeersch",
+					"\tStephen  Shaw",
+					"",
+					"Active Contributors to this release",
+					"\tAdemir Mendoza",
+					"\tAlex Launi",
+					"\tAnton Keks",
+					"\tBertrand Lorentz",
+					"\tChristian Krause",
+					"\tChristopher Halse Rogers",
+					"\tDaniel KÃb",
+					"\tEric Faehnrich",
+					"\tEvan Briones",
+					"\tGabriel Burt",
+					"\tIain Churcher",
+					"\tIain Lane",
+					"\tLorenzo Milesi",
+					"\tÅukasz JernaÅ",
+					"\tMike Gem\x00fcnde",
+					"\tMike Wallick",
+					"\tNick Van Eeckhout",
+					"\tPaul Lange",
+					"\tPaul Wellner Bou",
+					"\tPeter Goetz",
+					"\tRuben Vermeersch",
+					"\tTim Retout",
+					"\tTomas Kovacik",
+					"\tTrevor Buchanan",
+					"\tVincent Pomey",
+					"\tWojciech DzierÅanowski",
+					"",
+					"Contributors",
+					"\tAaron Bockover",
+					"\tAlessandro Gervaso",
+					"\tAlex Graveley",
+					"\tAlvaro del Castillo",
+					"\tBengt Thuree",
+					"\tBen Monnahan",
+					"\tChad Files",
+					"\tEttore Perazzoli",
+					"\tEwen Cheslack-Postava",
+					"\tGrahm Orr",
+					"\tJeffrey Finkelstein",
+					"\tJeffrey Stedfast",
+					"\tJoerg Buesse",
+					"\tJoe Shaw",
+					"\tJon Trowbridge",
+					"\tJoshua Tauberer",
+					"\tKarl Mikaelsson",
+					"\tLaurence Hygate",
+					"\tLee Willis",
+					"\tMartin Willemoes Hansen",
+					"\tMatt Jones",
+					"\tMatt Perry",
+					"\tMichal NÃnÃsi",
+					"\tMiguel de Icaza",
+					"\tNat Friedman",
+					"\tPascal de Bruijn",
+					"\tPatanjali Somayaji",
+					"\tPeter Johanson",
+					"\tTambet Ingo",
+					"\tThomas Van Machelen",
+					"\tTodd Berman",
+					"\tVasily Kirilichev",
+					"\tVincent Moreau",
+					"\tVladimir Vukicevic",
+					"\tXavier Bouchoux",
+					"\tYann Leprince",
+					"\tYves Kurz",
+					"",
+					"In memory Of",
+					"\tEttore Perazzoli",
+			};
+			Comments = Catalog.GetString ("Photo management for GNOME");
+			Copyright = Catalog.GetString ("Copyright \x00a9 2003-2010 Novell Inc.");
+			Documenters = new string[] {
+					"Aaron Bockover",
+					"Alexandre Prokoudine",
+					"Bengt Thuree",
+					"Gabriel Burt",
+					"Harold Schreckengost",
+					"Miguel de Icaza",
+					"Stephane Delcroix",
+			};
+			//Read license from COPYING
+			try {
+				System.Reflection.Assembly assembly = System.Reflection.Assembly.GetCallingAssembly ();
+				using (Stream s = assembly.GetManifestResourceStream ("COPYING")) {
+					StreamReader reader = new StreamReader (s);
+					License = reader.ReadToEnd ();
+					s.Close ();
+				}
+			} catch (Exception e) {
+				Log.DebugException (e);
+				License = "GPL v2";
+			}
+			Logo = new Gdk.Pixbuf (System.Reflection.Assembly.GetEntryAssembly (), "f-spot-128.png");
+			ProgramName = "F-Spot";
+			TranslatorCredits = Catalog.GetString ("translator-credits");
+			if (System.String.Compare (TranslatorCredits, "translator-credits") == 0)
+				TranslatorCredits = null;
+			Version = FSpot.Core.Defines.VERSION;
+			Website = "http://f-spot.org";;
+			WebsiteLabel = Catalog.GetString ("F-Spot Website");
+			WrapLicense = true;
+		}
 
-        public static void ShowUp ()
-        {
-            if (about == null) {
-                about = new AboutDialog ();
-                about.Destroyed += delegate (object o, EventArgs e) {about = null;};
-                about.Response += delegate (object o, Gtk.ResponseArgs e) {if (about != null) about.Destroy ();};
-            }
-            about.Show ();
-        }
-    }
+		public static void ShowUp ()
+		{
+			if (about == null) {
+				about = new AboutDialog ();
+				about.Destroyed += delegate (object o, EventArgs e) {about = null;};
+				about.Response += delegate (object o, Gtk.ResponseArgs e) {if (about != null) about.Destroy ();};
+			}
+			about.Show ();
+		}
+	}
 }
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/AdjustTimeDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/AdjustTimeDialog.cs
index c82411d..183aec0 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/AdjustTimeDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/AdjustTimeDialog.cs
@@ -80,13 +80,13 @@ namespace FSpot.UI.Dialog {
 			item.Changed += HandleItemChanged;
 			item.MoveFirst ();
 
-            tray = new BrowseablePointerGridView (view.Item) {
-                MaxColumns = 1,
-                DisplayRatings = false,
-                DisplayTags = false,
-                DisplayDates = true
-            };
-            tray_scrolled.Add (tray);
+			tray = new BrowseablePointerGridView (view.Item) {
+				MaxColumns = 1,
+				DisplayRatings = false,
+				DisplayTags = false,
+				DisplayDates = true
+			};
+			tray_scrolled.Add (tray);
 
 			//forward_button.Clicked += HandleForwardClicked;
 			//back_button.Clicked += HandleBackClicked;
@@ -138,7 +138,7 @@ namespace FSpot.UI.Dialog {
 
 			starting_label.Text = "min.";
 			difference_check.Label = String.Format (Catalog.GetString ("Shift all photos by {0}"),
-							      Offset);
+								  Offset);
 		}
 
 		void HandleItemChanged (object sender, BrowsablePointerChangedEventArgs args)
@@ -184,7 +184,7 @@ namespace FSpot.UI.Dialog {
 		private void SpaceByInterval ()
 		{
 			DateTime date = EditTime;
-		        long ticks = (long) (double.Parse (spacing_entry.Text) * TimeSpan.TicksPerMinute);
+			long ticks = (long) (double.Parse (spacing_entry.Text) * TimeSpan.TicksPerMinute);
 			TimeSpan span = new TimeSpan (ticks);
 			Photo [] photos = new Photo [collection.Count];
 
@@ -197,9 +197,10 @@ namespace FSpot.UI.Dialog {
 				date -= span;
 			}
 
-			for (int i = 0; i < photos.Length; i++) {
-				photos [i].Time = date + accum;
-				accum += span;
+			foreach (Photo t in photos)
+			{
+				t.Time = date + accum;
+				accum += span;
 			}
 
 			db.Photos.Commit (photos);
@@ -222,7 +223,6 @@ namespace FSpot.UI.Dialog {
 			else
 				SpaceByInterval ();
 
-
 			Destroy ();
 		}
 
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/BuilderDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/BuilderDialog.cs
index fe99e24..da3f475 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/BuilderDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/BuilderDialog.cs
@@ -25,8 +25,8 @@
 // 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 GtkBeans;
 
 namespace FSpot.UI.Dialog
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/DateRangeDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/DateRangeDialog.cs
index 2ffdc4d..7bd21b3 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/DateRangeDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/DateRangeDialog.cs
@@ -126,14 +126,12 @@ namespace FSpot.UI.Dialog
 				return Catalog.GetString("Previous Week (Mon-Sun)");
 			case "thismonth":
 				if (today.Year == (today.AddMonths(-1)).Year) // Same year for current and previous month. Present only MONTH
-					return today.ToString("MMMM");
-				else // Different year for current and previous month. Present both MONTH, and YEAR
-					return today.ToString("MMMM, yyyy");
+					return today.ToString("MMMM");
+				return today.ToString("MMMM, yyyy");
 			case "previousmonth":
 				if (today.Year == (today.AddMonths(-1)).Year) // Same year for current and previous month. Present only MONTH
-					return (today.AddMonths(-1)).ToString("MMMM");
-				else // Different year for current and previous month. Present both MONTH, and YEAR
-					return (today.AddMonths(-1)).ToString("MMMM, yyyy");
+					return (today.AddMonths(-1)).ToString("MMMM");
+				return (today.AddMonths(-1)).ToString("MMMM, yyyy");
 			case "thisyear":
 				return today.ToString("yyyy");
 			case "previousyear":
@@ -225,11 +223,8 @@ namespace FSpot.UI.Dialog
 			default:
 				clear = true;
 				break;
-			}
-			if (!clear)
-				return new DateRange (startdate, enddate.Add (new System.TimeSpan(23,59,59)));
-			else
-				return null;
+			}
+			return clear ? null : new DateRange (startdate, enddate.Add (new System.TimeSpan(23,59,59)));
 		}
 
 		void HandleDateEditChanged (object o, EventArgs args)
@@ -260,9 +255,9 @@ namespace FSpot.UI.Dialog
 			}
 
 			start_dateedit.DateChanged += HandleDateEditChanged;
-			((Gtk.Entry) start_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
+			((Gtk.Entry) start_dateedit.Children [0]).Changed += HandleDateEditChanged;
 			end_dateedit.DateChanged += HandleDateEditChanged;
-			((Gtk.Entry) end_dateedit.Children [0] as Gtk.Entry).Changed += HandleDateEditChanged;
+			((Gtk.Entry) end_dateedit.Children [0]).Changed += HandleDateEditChanged;
 		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/EditExceptionDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/EditExceptionDialog.cs
index aaf5f05..9a4e314 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/EditExceptionDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/EditExceptionDialog.cs
@@ -43,18 +43,14 @@ using Mono.Unix;
 namespace FSpot.UI.Dialog
 {
 	public class EditException : Exception
-	{
-		IPhoto item;
-
-		public IPhoto Item {
-			get { return item; }
-		}
-
+	{
+		public IPhoto Item { get; private set; }
+
 		public EditException (IPhoto item, Exception e) : base (
-                        String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"),
-				       e.Message, item.Name), e)
+						String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"),
+					   e.Message, item.Name), e)
 		{
-			this.item = item;
+			this.Item = item;
 		}
 	}
 
@@ -63,9 +59,9 @@ namespace FSpot.UI.Dialog
 		private const int MaxErrors = 10;
 
 		public EditExceptionDialog (Gtk.Window parent, Exception [] errors) : base (parent, DialogFlags.DestroyWithParent,
-											    Gtk.MessageType.Error, ButtonsType.Ok,
-											    Catalog.GetString ("Error editing photo"),
-											    GenerateMessage (errors))
+												Gtk.MessageType.Error, ButtonsType.Ok,
+												Catalog.GetString ("Error editing photo"),
+												GenerateMessage (errors))
 		{
 			foreach (Exception e in errors)
 				Log.Exception (e);
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/EditTagDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/EditTagDialog.cs
index 4b3468d..163d90f 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/EditTagDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/EditTagDialog.cs
@@ -119,7 +119,7 @@ namespace FSpot.UI.Dialog
 			return false;
 		}
 
-		void PopulateCategories (List<Tag> categories, Category parent)
+		void PopulateCategories (ICollection<Tag> categories, Category parent)
 		{
 			foreach (Tag tag in parent.Children) {
 				if (tag is Category && tag != this.tag && !this.tag.IsAncestorOf (tag)) {
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/EditTagIconDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/EditTagIconDialog.cs
index 2caf49f..af31adf 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/EditTagIconDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/EditTagIconDialog.cs
@@ -93,7 +93,7 @@ namespace FSpot.UI.Dialog
 
 			external_photo_chooser.Filter = new FileFilter();
 			external_photo_chooser.Filter.AddPixbufFormats();
-                        external_photo_chooser.LocalOnly = false;
+						external_photo_chooser.LocalOnly = false;
 			external_photo_chooser_hbox.PackStart (external_photo_chooser);
 			external_photo_chooser.Show ();
 			external_photo_chooser.SelectionChanged += HandleExternalFileSelectionChanged;
@@ -192,11 +192,11 @@ namespace FSpot.UI.Dialog
 				string message = String.Format (Catalog.GetString ("Unable to load \"{0}\" as icon for the tag"),
 									external_photo_chooser.Uri.ToString ());
 				HigMessageDialog md = new HigMessageDialog (this,
-									    DialogFlags.DestroyWithParent,
-									    MessageType.Error,
-									    ButtonsType.Close,
-									    caption,
-									    message);
+										DialogFlags.DestroyWithParent,
+										MessageType.Error,
+										ButtonsType.Close,
+										caption,
+										message);
 				md.Run();
 				md.Destroy();
 			}
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/ImportDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/ImportDialog.cs
index 2975123..e0da81a 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/ImportDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/ImportDialog.cs
@@ -265,11 +265,10 @@ namespace FSpot.UI.Dialog
             if (sources_combo.Active == current_index) {
                 Log.Debug ("Skipping double fire!");
                 return;
-            } else {
-                current_index = sources_combo.Active;
-            }
-
-            TreeIter iter;
+            }
+        	current_index = sources_combo.Active;
+
+        	TreeIter iter;
             sources_combo.GetActiveIter (out iter);
             var source = Sources.GetValue (iter, 0) as IImportSource;
             if (source == null) {
@@ -277,10 +276,9 @@ namespace FSpot.UI.Dialog
                 if (label == select_folder_label) {
                     ShowFolderSelector ();
                     return;
-                } else {
-                    sources_combo.Active = 0;
-                    return;
-                }
+                }
+            	sources_combo.Active = 0;
+            	return;
             }
             Controller.ActiveSource = source;
         }
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/ImportFailureDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/ImportFailureDialog.cs
index b1ae7e0..0a1c5de 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/ImportFailureDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/ImportFailureDialog.cs
@@ -42,28 +42,24 @@ namespace FSpot.UI.Dialog
 	{
 		// FIXME: Replace with ErrorListDialog from Banshee when possible
 
-        private VBox inner_vbox;
+		private VBox inner_vbox;
 
-        private Label header_label;
-        private Hyena.Widgets.WrapLabel message_label;
-        private TreeView list_view;
-        private Expander details_expander;
-
-        private AccelGroup accel_group;
-        protected AccelGroup AccelGroup {
-            get { return accel_group; }
-        }
-
-
-
-		public ImportFailureDialog (List<SafeUri> files) : base ()
+		private Label header_label;
+		private Hyena.Widgets.WrapLabel message_label;
+		private TreeView list_view;
+		private Expander details_expander;
+
+		protected AccelGroup AccelGroup { get; private set; }
+
+
+		public ImportFailureDialog (IEnumerable<SafeUri> files)
 		{
 			BuildUI ();
 
-            ListView.Model = new ListStore (typeof (string), typeof (string));
-            ListView.AppendColumn ("Filename", new CellRendererText (), "text", 0);
-            ListView.AppendColumn ("Path", new CellRendererText (), "text", 1);
-            ListView.HeadersVisible = false;
+			ListView.Model = new ListStore (typeof (string), typeof (string));
+			ListView.AppendColumn ("Filename", new CellRendererText (), "text", 0);
+			ListView.AppendColumn ("Path", new CellRendererText (), "text", 1);
+			ListView.HeadersVisible = false;
 
 			Title = Catalog.GetString ("Import failures");
 			Header = Catalog.GetString ("Some files failed to import");
@@ -77,100 +73,100 @@ namespace FSpot.UI.Dialog
 
 		private void BuildUI ()
 		{
-            // The BorderWidth situation here is a bit nuts b/c the
-            // ActionArea's is set to 5.  So we work everything else out
-            // so it all totals to 12.
-            //
-            // WIDGET           BorderWidth
-            // Dialog           5
-            //   VBox           2
-            //     inner_vbox   5 => total = 12
-            //     ActionArea   5 => total = 12
-            BorderWidth = 5;
-            base.VBox.BorderWidth = 0;
-
-            // This spacing is 2 b/c the inner_vbox and ActionArea should be
-            // 12 apart, and they already have BorderWidth 5 each
-            base.VBox.Spacing = 2;
-
-            inner_vbox = new VBox () { Spacing = 12, BorderWidth = 5, Visible = true };
-            base.VBox.PackStart (inner_vbox, true, true, 0);
-
-            Visible = false;
-            HasSeparator = false;
-
-            var table = new Table (3, 2, false) {
-                RowSpacing = 12,
-                ColumnSpacing = 16
-            };
-
-            table.Attach (new Image () {
-                    IconName = "dialog-error",
-                    IconSize = (int)IconSize.Dialog,
-                    Yalign = 0.0f
-                }, 0, 1, 0, 3, AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, 0, 0);
-
-            table.Attach (header_label = new Label () { Xalign = 0.0f }, 1, 2, 0, 1,
-                AttachOptions.Fill | AttachOptions.Expand,
-                AttachOptions.Shrink, 0, 0);
-
-            table.Attach (message_label = new Hyena.Widgets.WrapLabel (), 1, 2, 1, 2,
-                AttachOptions.Fill | AttachOptions.Expand,
-                AttachOptions.Shrink, 0, 0);
-
-            var scrolled_window = new ScrolledWindow () {
-                HscrollbarPolicy = PolicyType.Automatic,
-                VscrollbarPolicy = PolicyType.Automatic,
-                ShadowType = ShadowType.In
-            };
-
-            list_view = new TreeView () {
-                HeightRequest = 120,
-                WidthRequest = 200
-            };
-            scrolled_window.Add (list_view);
-
-            table.Attach (details_expander = new Expander (Catalog.GetString ("Details")),
-                1, 2, 2, 3,
-                AttachOptions.Fill | AttachOptions.Expand,
-                AttachOptions.Fill | AttachOptions.Expand,
-                0, 0);
-            details_expander.Add (scrolled_window);
-
-            VBox.PackStart (table, true, true, 0);
-            VBox.Spacing = 12;
-            VBox.ShowAll ();
-
-            accel_group = new AccelGroup ();
-            AddAccelGroup (accel_group);
-
-            Button button = new Button (Stock.Close);
-            button.CanDefault = true;
-            button.UseStock = true;
-            button.Show ();
+			// The BorderWidth situation here is a bit nuts b/c the
+			// ActionArea's is set to 5.  So we work everything else out
+			// so it all totals to 12.
+			//
+			// WIDGET           BorderWidth
+			// Dialog           5
+			//   VBox           2
+			//     inner_vbox   5 => total = 12
+			//     ActionArea   5 => total = 12
+			BorderWidth = 5;
+			base.VBox.BorderWidth = 0;
+
+			// This spacing is 2 b/c the inner_vbox and ActionArea should be
+			// 12 apart, and they already have BorderWidth 5 each
+			base.VBox.Spacing = 2;
+
+			inner_vbox = new VBox () { Spacing = 12, BorderWidth = 5, Visible = true };
+			base.VBox.PackStart (inner_vbox, true, true, 0);
+
+			Visible = false;
+			HasSeparator = false;
+
+			var table = new Table (3, 2, false) {
+				RowSpacing = 12,
+				ColumnSpacing = 16
+			};
+
+			table.Attach (new Image () {
+					IconName = "dialog-error",
+					IconSize = (int)IconSize.Dialog,
+					Yalign = 0.0f
+				}, 0, 1, 0, 3, AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, 0, 0);
+
+			table.Attach (header_label = new Label () { Xalign = 0.0f }, 1, 2, 0, 1,
+				AttachOptions.Fill | AttachOptions.Expand,
+				AttachOptions.Shrink, 0, 0);
+
+			table.Attach (message_label = new Hyena.Widgets.WrapLabel (), 1, 2, 1, 2,
+				AttachOptions.Fill | AttachOptions.Expand,
+				AttachOptions.Shrink, 0, 0);
+
+			var scrolled_window = new ScrolledWindow () {
+				HscrollbarPolicy = PolicyType.Automatic,
+				VscrollbarPolicy = PolicyType.Automatic,
+				ShadowType = ShadowType.In
+			};
+
+			list_view = new TreeView () {
+				HeightRequest = 120,
+				WidthRequest = 200
+			};
+			scrolled_window.Add (list_view);
+
+			table.Attach (details_expander = new Expander (Catalog.GetString ("Details")),
+				1, 2, 2, 3,
+				AttachOptions.Fill | AttachOptions.Expand,
+				AttachOptions.Fill | AttachOptions.Expand,
+				0, 0);
+			details_expander.Add (scrolled_window);
+
+			VBox.PackStart (table, true, true, 0);
+			VBox.Spacing = 12;
+			VBox.ShowAll ();
+
+			AccelGroup = new AccelGroup ();
+			AddAccelGroup (AccelGroup);
+
+			Button button = new Button (Stock.Close);
+			button.CanDefault = true;
+			button.UseStock = true;
+			button.Show ();
 			button.Clicked += (o, a) => {
 				Destroy ();
 			};
 
-            AddActionWidget (button, ResponseType.Close);
+			AddActionWidget (button, ResponseType.Close);
 
 			DefaultResponse = ResponseType.Close;
-			button.AddAccelerator ("activate", accel_group, (uint)Gdk.Key.Return, 0, AccelFlags.Visible);
+			button.AddAccelerator ("activate", AccelGroup, (uint)Gdk.Key.Return, 0, AccelFlags.Visible);
 		}
 
-        public string Header {
-            set {
-                header_label.Markup = String.Format("<b><big>{0}</big></b>",
-                    GLib.Markup.EscapeText(value));
-            }
-        }
+		public string Header {
+			set {
+				header_label.Markup = String.Format("<b><big>{0}</big></b>",
+					GLib.Markup.EscapeText(value));
+			}
+		}
 
-        public string Message {
-            set { message_label.Text = value; }
-        }
+		public string Message {
+			set { message_label.Text = value; }
+		}
 
-        public TreeView ListView {
-            get { return list_view; }
-        }
+		public TreeView ListView {
+			get { return list_view; }
+		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/LastRollDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/LastRollDialog.cs
index 35239c3..5e3a230 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/LastRollDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/LastRollDialog.cs
@@ -31,7 +31,7 @@
 //
 using System;
 using System.Collections.Generic;
-
+using System.Linq;
 using FSpot.Core;
 using FSpot.Query;
 
@@ -98,10 +98,8 @@ namespace FSpot.UI.Dialog
 		{
 			Roll [] selected_rolls = SelectedRolls ();
 			uint sum = 0;
-			if (selected_rolls != null)
-				foreach (Roll roll in selected_rolls) {
-					sum = sum + rollstore.PhotosInRoll (roll);
-				}
+			if (selected_rolls != null)
+				sum = selected_rolls.Aggregate(sum, (current, roll) => current + rollstore.PhotosInRoll(roll));
 			photos_in_selected_rolls.Text = sum.ToString ();
 		}
 
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/ProgressDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/ProgressDialog.cs
index 9d92c73..85a8635 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/ProgressDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/ProgressDialog.cs
@@ -51,25 +51,14 @@ namespace FSpot.UI.Dialog {
 			None
 		};
 
-		private int total_count;
-
-		private ProgressBar progress_bar;
-		public ProgressBar Bar {
-			get { return progress_bar; }
-		}
-
-		private Label message_label;
-		public Label Message {
-			get { return message_label; }
-		}
-
-		private Gtk.Button button;
-		public Gtk.Button Button {
-			get {
-				return button;
-			}
-		}
-
+		private int total_count;
+
+		public ProgressBar Bar { get; private set; }
+
+		public Label Message { get; private set; }
+
+		public Button Button { get; private set; }
+
 		public ProgressDialog (string title, CancelButtonType cancel_button_type, int total_count, Gtk.Window parent_window)
 		{
 			Title = title;
@@ -82,18 +71,18 @@ namespace FSpot.UI.Dialog {
 			BorderWidth = 6;
 			SetDefaultSize (300, -1);
 
-			message_label = new Label (String.Empty);
-			VBox.PackStart (message_label, true, true, 12);
+			Message = new Label (String.Empty);
+			VBox.PackStart (Message, true, true, 12);
 
-			progress_bar = new ProgressBar ();
-			VBox.PackStart (progress_bar, true, true, 6);
+			Bar = new ProgressBar ();
+			VBox.PackStart (Bar, true, true, 6);
 
 			switch (cancel_button_type) {
 			case CancelButtonType.Cancel:
-				button = (Gtk.Button)AddButton (Gtk.Stock.Cancel, (int) ResponseType.Cancel);
+				Button = (Gtk.Button)AddButton (Gtk.Stock.Cancel, (int) ResponseType.Cancel);
 				break;
 			case CancelButtonType.Stop:
-				button = (Gtk.Button)AddButton (Gtk.Stock.Stop, (int) ResponseType.Cancel);
+				Button = (Gtk.Button)AddButton (Gtk.Stock.Stop, (int) ResponseType.Cancel);
 				break;
 			}
 
@@ -107,9 +96,9 @@ namespace FSpot.UI.Dialog {
 		{
 			current_count ++;
 
-			message_label.Text = message;
-			progress_bar.Text = String.Format (Catalog.GetString ("{0} of {1}"), current_count, total_count);
-			progress_bar.Fraction = (double) current_count / total_count;
+			Message.Text = message;
+			Bar.Text = String.Format (Catalog.GetString ("{0} of {1}"), current_count, total_count);
+			Bar.Fraction = (double) current_count / total_count;
 
 			ShowAll ();
 
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/RatingFilterDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/RatingFilterDialog.cs
index 3e20321..d765c61 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/RatingFilterDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/RatingFilterDialog.cs
@@ -49,7 +49,7 @@ namespace FSpot.UI.Dialog
 		private RatingEntry maxrating;
 
 		public RatingFilterDialog (FSpot.PhotoQuery query, Gtk.Window parent_window)
-            : base ("RatingFilterDialog.ui", "rating_filter_dialog")
+			: base ("RatingFilterDialog.ui", "rating_filter_dialog")
 		{
 			TransientFor = parent_window;
 			DefaultResponse = ResponseType.Ok;
@@ -64,11 +64,11 @@ namespace FSpot.UI.Dialog
 			minrating_hbox.PackStart (minrating, false, false, 0);
 			maxrating_hbox.PackStart (maxrating, false, false, 0);
 
-            minrating.Show ();
-            maxrating.Show ();
+			minrating.Show ();
+			maxrating.Show ();
 
-            minrating.Changed += HandleMinratingChanged;
-            maxrating.Changed += HandleMaxratingChanged;
+			minrating.Changed += HandleMinratingChanged;
+			maxrating.Changed += HandleMaxratingChanged;
 
 			ResponseType response = (ResponseType) Run ();
 
@@ -79,22 +79,22 @@ namespace FSpot.UI.Dialog
 			Destroy ();
 		}
 
-        void HandleMinratingChanged (object sender, System.EventArgs e)
-        {
-            if (minrating.Value > maxrating.Value) {
-                maxrating.Changed -= HandleMaxratingChanged;
-                maxrating.Value = minrating.Value;
-                maxrating.Changed += HandleMaxratingChanged;
-            }
-        }
+		void HandleMinratingChanged (object sender, System.EventArgs e)
+		{
+			if (minrating.Value > maxrating.Value) {
+				maxrating.Changed -= HandleMaxratingChanged;
+				maxrating.Value = minrating.Value;
+				maxrating.Changed += HandleMaxratingChanged;
+			}
+		}
 
-        void HandleMaxratingChanged (object sender, System.EventArgs e)
-        {
-            if (maxrating.Value < minrating.Value) {
-                minrating.Changed -= HandleMinratingChanged;
-                minrating.Value = maxrating.Value;
-                minrating.Changed += HandleMinratingChanged;
-            }
-        }
+		void HandleMaxratingChanged (object sender, System.EventArgs e)
+		{
+			if (maxrating.Value < minrating.Value) {
+				minrating.Changed -= HandleMinratingChanged;
+				minrating.Value = maxrating.Value;
+				minrating.Changed += HandleMinratingChanged;
+			}
+		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/RepairDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/RepairDialog.cs
index 9b4dc7d..dc387b0 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/RepairDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/RepairDialog.cs
@@ -38,6 +38,7 @@ using Gtk;
 
 namespace FSpot. UI.Dialog
 {
+	// FIXME: This is never used
 	public class RepairDialog : BuilderDialog
 	{
 		[GtkBeans.Builder.Object] ScrolledWindow view_scrolled;
@@ -54,7 +55,7 @@ namespace FSpot. UI.Dialog
 			TrayView view = new TrayView (missing);
 			view_scrolled.Add (view);
 
-			this.ShowAll ();
+			ShowAll ();
 		}
 
 		public void FindMissing ()
diff --git a/src/Clients/MainApp/FSpot.UI.Dialog/TagSelectionDialog.cs b/src/Clients/MainApp/FSpot.UI.Dialog/TagSelectionDialog.cs
index 48d3afb..9db97e5 100644
--- a/src/Clients/MainApp/FSpot.UI.Dialog/TagSelectionDialog.cs
+++ b/src/Clients/MainApp/FSpot.UI.Dialog/TagSelectionDialog.cs
@@ -52,10 +52,7 @@ namespace FSpot.UI.Dialog {
 		public new Tag[] Run ()
 		{
 			int response = base.Run ();
-			if ((ResponseType) response == ResponseType.Ok)
-				return tag_selection_widget.TagHighlight;
-
-			return null;
+			return (ResponseType) response == ResponseType.Ok ? tag_selection_widget.TagHighlight : null;
 		}
 
 		public new void Hide ()
diff --git a/src/Clients/MainApp/FSpot.Widgets/BrowseablePointerGridView.cs b/src/Clients/MainApp/FSpot.Widgets/BrowseablePointerGridView.cs
index 5266a7a..65e13ad 100644
--- a/src/Clients/MainApp/FSpot.Widgets/BrowseablePointerGridView.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/BrowseablePointerGridView.cs
@@ -44,10 +44,7 @@ namespace FSpot.Widgets
     {
 
 #region Public Properties
-
-        public BrowsablePointer Pointer {
-            get; private set;
-        }
+        public BrowsablePointer Pointer { get; private set; }
 
 #endregion
 
diff --git a/src/Clients/MainApp/FSpot.Widgets/CollectionCellGridView.cs b/src/Clients/MainApp/FSpot.Widgets/CollectionCellGridView.cs
index fb3bfc8..f0fbe7f 100644
--- a/src/Clients/MainApp/FSpot.Widgets/CollectionCellGridView.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/CollectionCellGridView.cs
@@ -47,23 +47,17 @@ namespace FSpot.Widgets
 
 #region Private Fields
 
-        private ThumbnailDecorationRenderer rating_renderer = new ThumbnailRatingDecorationRenderer ();
+        private readonly ThumbnailDecorationRenderer rating_renderer = new ThumbnailRatingDecorationRenderer ();
 
-        private ThumbnailCaptionRenderer tag_renderer = new ThumbnailTagsCaptionRenderer ();
-        private ThumbnailCaptionRenderer date_renderer = new ThumbnailDateCaptionRenderer ();
-        private ThumbnailCaptionRenderer filename_renderer = new ThumbnailFilenameCaptionRenderer ();
+        private readonly ThumbnailCaptionRenderer tag_renderer = new ThumbnailTagsCaptionRenderer ();
+        private readonly ThumbnailCaptionRenderer date_renderer = new ThumbnailDateCaptionRenderer ();
+        private readonly ThumbnailCaptionRenderer filename_renderer = new ThumbnailFilenameCaptionRenderer ();
 
 #endregion
 
 #region Public Properties
-
-        public IBrowsableCollection Collection {
-            get; private set;
-        }
-
-        public FSpot.PixbufCache Cache {
-            get; private set;
-        }
+        public IBrowsableCollection Collection { get; private set; }
+        public FSpot.PixbufCache Cache { get; private set; }
 
 #endregion
 
@@ -73,13 +67,11 @@ namespace FSpot.Widgets
         {
         }
 
-        public CollectionGridView (IBrowsableCollection collection) : base ()
+        public CollectionGridView (IBrowsableCollection collection)
         {
             Collection = collection;
 
-            Collection.Changed += (obj) => {
-                QueueResize ();
-            };
+            Collection.Changed += (obj) => QueueResize ();
 
             Collection.ItemsChanged += (obj, args) => {
                 foreach (int item in args.Items) {
@@ -196,12 +188,10 @@ namespace FSpot.Widgets
         }
 
         protected override int CellCount {
-            get {
-                if (Collection == null)
-                    return 0;
-
-                return Collection.Count;
-            }
+            get
+            {
+            	return Collection == null ? 0 : Collection.Count;
+            }
         }
 
 #endregion
@@ -222,14 +212,12 @@ namespace FSpot.Widgets
 
         private bool display_dates = true;
         public bool DisplayDates {
-            get {
-                if (MinCellWidth > 100)
-                    return display_dates;
-                else
-                    return false;
-            }
-
-            set {
+            get
+            {
+            	return MinCellWidth > 100 && display_dates;
+            }
+
+        	set {
                 display_dates = value;
                 QueueResize ();
             }
@@ -248,14 +236,11 @@ namespace FSpot.Widgets
 
         private bool display_ratings = true;
         public bool DisplayRatings {
-            get {
-                if (MinCellWidth > 100)
-                    return display_ratings;
-                else
-                    return false;
-            }
-
-            set {
+            get {
+            	return MinCellWidth > 100 && display_ratings;
+            }
+
+        	set {
                 display_ratings  = value;
                 QueueResize ();
             }
@@ -521,11 +506,11 @@ namespace FSpot.Widgets
             InvalidateCell (throb_cell);
             if (throb_state++ < throb_state_max) {
                 return true;
-            } else {
-                throb_cell = -1;
-                throb_timer_id = 0;
-                return false;
-            }
+            }
+
+        	throb_cell = -1;
+        	throb_timer_id = 0;
+        	return false;
         }
 
         private int ThrobExpansion (int cell, bool selected)
diff --git a/src/Clients/MainApp/FSpot.Widgets/EditorPage.cs b/src/Clients/MainApp/FSpot.Widgets/EditorPage.cs
index 8aed1c2..2aeb345 100644
--- a/src/Clients/MainApp/FSpot.Widgets/EditorPage.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/EditorPage.cs
@@ -61,7 +61,7 @@ namespace FSpot.Widgets {
 		}
 
 		protected override void AddedToSidebar () {
-			(Sidebar as Sidebar).SelectionChanged += delegate (IBrowsableCollection collection) { EditorPageWidget.ShowTools (); };
+			(Sidebar as Sidebar).SelectionChanged += collection => EditorPageWidget.ShowTools();
 			(Sidebar as Sidebar).ContextChanged += HandleContextChanged;
 		}
 
@@ -141,7 +141,7 @@ namespace FSpot.Widgets {
 			Button button = new Button (editor.Label);
 			if (editor.IconName != null)
 				button.Image = new Image (GtkUtil.TryLoadIcon (FSpot.Core.Global.IconTheme, editor.IconName, 22, (Gtk.IconLookupFlags)0));
-			button.Clicked += delegate (object o, EventArgs e) { ChooseEditor (editor); };
+			button.Clicked += (o, e) => ChooseEditor(editor);
 			button.Show ();
 			buttons.Add (button);
 			editor_buttons.Add (editor, button);
diff --git a/src/Clients/MainApp/FSpot.Widgets/Filmstrip.cs b/src/Clients/MainApp/FSpot.Widgets/Filmstrip.cs
index 71eb754..99b7416 100644
--- a/src/Clients/MainApp/FSpot.Widgets/Filmstrip.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/Filmstrip.cs
@@ -50,7 +50,7 @@ using Hyena;
 
 namespace FSpot.Widgets
 {
-	public class Filmstrip : EventBox, IDisposable
+	public class Filmstrip : EventBox
 	{
 
 //		public event OrientationChangedHandler OrientationChanged;
@@ -109,14 +109,10 @@ namespace FSpot.Widgets
 					throw new ArgumentException ("ThumbSize is negative!");
 				thumb_size = value;
 			}
-		}
-
-		bool squared_thumbs = false;
-		public bool SquaredThumbs {
-			get { return squared_thumbs; }
-			set { squared_thumbs = value; }
-		}
-
+		}
+
+		public bool SquaredThumbs { get; set; }
+
 		Pixbuf background_tile;
 		public Pixbuf BackgroundTile {
 			get {
@@ -215,20 +211,16 @@ namespace FSpot.Widgets
 		}
 
 		BrowsablePointer selection;
-		DisposableCache<SafeUri, Pixbuf> thumb_cache;
-
-		public Filmstrip (BrowsablePointer selection) : this (selection, true)
-		{
-		}
-
-		public Filmstrip (BrowsablePointer selection, bool squared_thumbs) : base ()
+		DisposableCache<SafeUri, Pixbuf> thumb_cache;
+
+		public Filmstrip (BrowsablePointer selection, bool squared_thumbs = true)
 		{
 			CanFocus = true;
 			this.selection = selection;
 			this.selection.Changed += HandlePointerChanged;
 			this.selection.Collection.Changed += HandleCollectionChanged;
 			this.selection.Collection.ItemsChanged += HandleCollectionItemsChanged;
-			this.squared_thumbs = squared_thumbs;
+			this.SquaredThumbs = squared_thumbs;
 			thumb_cache = new DisposableCache<SafeUri, Pixbuf> (30);
 			ThumbnailLoader.Default.OnPixbufLoaded += HandlePixbufLoaded;
 
@@ -526,14 +518,9 @@ namespace FSpot.Widgets
 					pos = key;
 			ActiveItem = start_indexes [pos];
 			return true;
-		}
-
-		protected Pixbuf GetPixbuf (int i)
-		{
-			return GetPixbuf (i, false);
-		}
-
-		protected virtual Pixbuf GetPixbuf (int i, bool highlighted)
+		}
+
+		protected virtual Pixbuf GetPixbuf (int i, bool highlighted = false)
 		{
 			Pixbuf current = null;
 			SafeUri uri = (selection.Collection [i]).DefaultVersion.Uri;
@@ -546,19 +533,19 @@ namespace FSpot.Widgets
 			}
 
 			if (current == null) {
-                var pixbuf = XdgThumbnailSpec.LoadThumbnail (uri, ThumbnailSize.Large, null);
-                if (pixbuf == null) {
+				var pixbuf = XdgThumbnailSpec.LoadThumbnail (uri, ThumbnailSize.Large, null);
+				if (pixbuf == null) {
 					ThumbnailLoader.Default.Request (uri, ThumbnailSize.Large, 0);
-                    current = FSpot.Core.Global.IconTheme.LoadIcon ("gtk-missing-image", ThumbSize, (Gtk.IconLookupFlags)0);
-                } else {
+					current = FSpot.Core.Global.IconTheme.LoadIcon ("gtk-missing-image", ThumbSize, (Gtk.IconLookupFlags)0);
+				} else {
 					if (SquaredThumbs) {
-                        current = PixbufUtils.IconFromPixbuf (pixbuf, ThumbSize);
-                    } else {
-                        current = pixbuf.ScaleSimple (ThumbSize, ThumbSize, InterpType.Nearest);
-                    }
-                    pixbuf.Dispose ();
+						current = PixbufUtils.IconFromPixbuf (pixbuf, ThumbSize);
+					} else {
+						current = pixbuf.ScaleSimple (ThumbSize, ThumbSize, InterpType.Nearest);
+					}
+					pixbuf.Dispose ();
 					thumb_cache.Add (uri, current);
-                }
+				}
 			}
 
 			//FIXME: we might end up leaking a pixbuf here
diff --git a/src/Clients/MainApp/FSpot.Widgets/FindBar.cs b/src/Clients/MainApp/FSpot.Widgets/FindBar.cs
index 52e8fa8..700969c 100644
--- a/src/Clients/MainApp/FSpot.Widgets/FindBar.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/FindBar.cs
@@ -45,12 +45,10 @@ using Hyena;
 using Mono.Unix;
 
 namespace FSpot.Widgets {
-	public class FindBar : HighlightedBox {
-		private Entry entry;
+	public class FindBar : HighlightedBox {
 		private string last_entry_text = String.Empty;
 		private int open_parens = 0, close_parens = 0;
-		private PhotoQuery query;
-		private Term root_term = null;
+		private PhotoQuery query;
 		private HBox box;
 
 		/*
@@ -58,23 +56,20 @@ namespace FSpot.Widgets {
 		 */
 		public bool Completing {
 			get {
-				return (entry.Completion as LogicEntryCompletion).Completing;
+				return (Entry.Completion as LogicEntryCompletion).Completing;
 			}
-		}
-
-		public Gtk.Entry Entry {
-			get { return entry; }
-		}
-
-		public Term RootTerm  {
-			get { return root_term; }
-		}
-
+		}
+
+		public Entry Entry { get; private set; }
+
+		public Term RootTerm { get; private set; }
+
 		/*
 		 * Constructor
 		 */
 		public FindBar (PhotoQuery query, TreeModel model) : base(new HBox())
-		{
+		{
+			RootTerm = null;
 			this.query = query;
 			box = Child as HBox;
 
@@ -83,14 +78,14 @@ namespace FSpot.Widgets {
 
 			box.PackStart (new Label (Catalog.GetString ("Find:")), false, false, 0);
 
-			entry = new Entry ();
-			entry.Completion = new LogicEntryCompletion (entry, model);
+			Entry = new Entry ();
+			Entry.Completion = new LogicEntryCompletion (Entry, model);
 
-			entry.TextInserted  += HandleEntryTextInserted;
-			entry.TextDeleted   += HandleEntryTextDeleted;
-			entry.KeyPressEvent += HandleEntryKeyPress;
+			Entry.TextInserted  += HandleEntryTextInserted;
+			Entry.TextDeleted   += HandleEntryTextDeleted;
+			Entry.KeyPressEvent += HandleEntryKeyPress;
 
-			box.PackStart (entry, true, true, 0);
+			box.PackStart (Entry, true, true, 0);
 
 			Button clear_button = new Gtk.Button ();
 			clear_button.Add (new Gtk.Image ("gtk-close", Gtk.IconSize.Button));
@@ -114,25 +109,25 @@ namespace FSpot.Widgets {
 
 			//int start = args.Position - args.Length;
 
-			for (int i = 0; i < args.Text.Length; i++) {
-				char c = args.Text [i];
+			foreach (char c in args.Text)
+			{
 				if (c == '(')
 					open_parens++;
 				else if (c == ')')
-					close_parens++;
+					close_parens++;
 			}
 
-			int pos = entry.Position + 1;
+			int pos = Entry.Position + 1;
 			int close_parens_needed = open_parens - close_parens;
 			for (int i = 0; i < close_parens_needed; i++) {
-				entry.TextInserted -= HandleEntryTextInserted;
-				entry.InsertText (")", ref pos);
+				Entry.TextInserted -= HandleEntryTextInserted;
+				Entry.InsertText (")", ref pos);
 				close_parens++;
-				entry.TextInserted += HandleEntryTextInserted;
+				Entry.TextInserted += HandleEntryTextInserted;
 				pos++;
 			}
 			//Log.DebugFormat ("done w/ insert, {0}, ( = {1}  ) = {2}", args.Text, open_parens, close_parens);
-			last_entry_text = entry.Text;
+			last_entry_text = Entry.Text;
 
 			QueueUpdate ();
 		}
@@ -143,14 +138,15 @@ namespace FSpot.Widgets {
 			//Log.DebugFormat ("start {0} end {1} len {2} last {3}", args.StartPos, args.EndPos, length, last_entry_text);
 			string txt = length < 0 ? last_entry_text : last_entry_text.Substring (args.StartPos, length);
 
-			for (int i = 0; i < txt.Length; i++) {
-				if (txt [i] == '(')
+			foreach (char t in txt)
+			{
+				if (t == '(')
 					open_parens--;
-				else if (txt [i] == ')')
-					close_parens--;
-			}
-
-			last_entry_text = entry.Text;
+				else if (t == ')')
+					close_parens--;
+			}
+
+			last_entry_text = Entry.Text;
 
 			QueueUpdate ();
 		}
@@ -167,17 +163,17 @@ namespace FSpot.Widgets {
 
 			case (Gdk.Key.Tab):
 				// If we are at the end of the entry box, let the normal Tab handler do its job
-				if (entry.Position == entry.Text.Length) {
+				if (Entry.Position == Entry.Text.Length) {
 					args.RetVal = false;
 					return;
 				}
 
 				// Go until the current character is an open paren
-				while (entry.Position < entry.Text.Length && entry.Text [entry.Position] != '(')
-					entry.Position++;
+				while (Entry.Position < Entry.Text.Length && Entry.Text [Entry.Position] != '(')
+					Entry.Position++;
 
 				// Put the cursor right after the open paren
-				entry.Position++;
+				Entry.Position++;
 
 				args.RetVal = true;
 				break;
@@ -194,7 +190,7 @@ namespace FSpot.Widgets {
 
 		private void Clear ()
 		{
-			entry.Text = String.Empty;
+			Entry.Text = String.Empty;
 			Hide ();
 		}
 
@@ -234,7 +230,7 @@ namespace FSpot.Widgets {
 
 		private bool ConstructQuery (Term parent, int depth, string txt, bool negated)
 		{
-			if (txt == null || txt.Length == 0)
+			if (string.IsNullOrEmpty(txt))
 				return true;
 
 			string indent = String.Format ("{0," + depth*2 + "}", " ");
@@ -305,62 +301,62 @@ namespace FSpot.Widgets {
 				}
 
 				if (RootTerm == null)
-					root_term = parent;
+					RootTerm = parent;
 
 				return true;
-			} else {
-				Term us = null;
-				if (op != null && op != String.Empty) {
-					us = Term.TermFromOperator (op, parent, null);
-					if (RootTerm == null)
-						root_term = us;
-				}
-
-				foreach (Capture capture in match.Groups ["Term"].Captures) {
-					string subterm = capture.Value.Trim ();
-
-					if (subterm == null || subterm.Length == 0)
-						continue;
+			}
+
+			Term us = null;
+			if (op != null && op != String.Empty) {
+				us = Term.TermFromOperator (op, parent, null);
+				if (RootTerm == null)
+					RootTerm = us;
+			}
 
-					// Strip leading/trailing parens
-					if (subterm [0] == '(' && subterm [subterm.Length - 1] == ')') {
-						subterm = subterm.Remove (subterm.Length - 1, 1);
-						subterm = subterm.Remove (0, 1);
-					}
+			foreach (Capture capture in match.Groups ["Term"].Captures) {
+				string subterm = capture.Value.Trim ();
 
-					//Log.DebugFormat (indent + "Breaking subterm apart: {0}", subterm);
+				if (subterm == null || subterm.Length == 0)
+					continue;
 
-					if (!ConstructQuery (us, depth + 1, subterm, negated))
-						return false;
+				// Strip leading/trailing parens
+				if (subterm [0] == '(' && subterm [subterm.Length - 1] == ')') {
+					subterm = subterm.Remove (subterm.Length - 1, 1);
+					subterm = subterm.Remove (0, 1);
 				}
 
-				foreach (Capture capture in match.Groups ["NotTerm"].Captures) {
-					string subterm = capture.Value.Trim ();
+				//Log.DebugFormat (indent + "Breaking subterm apart: {0}", subterm);
 
-					if (subterm == null || subterm.Length == 0)
-						continue;
+				if (!ConstructQuery (us, depth + 1, subterm, negated))
+					return false;
+			}
 
-					// Strip leading/trailing parens
-					if (subterm [0] == '(' && subterm [subterm.Length - 1] == ')') {
-						subterm = subterm.Remove (subterm.Length - 1, 1);
-						subterm = subterm.Remove (0, 1);
-					}
+			foreach (Capture capture in match.Groups ["NotTerm"].Captures) {
+				string subterm = capture.Value.Trim ();
 
-					//Log.DebugFormat (indent + "Breaking not subterm apart: {0}", subterm);
+				if (subterm == null || subterm.Length == 0)
+					continue;
 
-					if (!ConstructQuery (us, depth + 1, subterm, true))
-						return false;
+				// Strip leading/trailing parens
+				if (subterm [0] == '(' && subterm [subterm.Length - 1] == ')') {
+					subterm = subterm.Remove (subterm.Length - 1, 1);
+					subterm = subterm.Remove (0, 1);
 				}
 
-				if (negated && us != null) {
-					if (us == RootTerm)
-						root_term = us.Invert(false);
-					else
-						us.Invert(false);
-				}
+				//Log.DebugFormat (indent + "Breaking not subterm apart: {0}", subterm);
 
-				return true;
+				if (!ConstructQuery (us, depth + 1, subterm, true))
+					return false;
+			}
+
+			if (negated && us != null) {
+				if (us == RootTerm)
+					RootTerm = us.Invert(false);
+				else
+					us.Invert(false);
 			}
+
+			return true;
 		}
 
 		private bool updating = false;
@@ -404,9 +400,9 @@ namespace FSpot.Widgets {
 		private void Update ()
 		{
 			// Clear the last root term
-			root_term = null;
+			RootTerm = null;
 
-			if (ParensValid () && ConstructQuery (null, 0, entry.Text)) {
+			if (ParensValid () && ConstructQuery (null, 0, Entry.Text)) {
 				if (RootTerm != null) {
 					//Log.DebugFormat("rootTerm = {0}", RootTerm);
 					if (!(RootTerm is AndTerm)) {
@@ -414,7 +410,7 @@ namespace FSpot.Widgets {
 						// ensure we handle the Hidden tag properly
 						AndTerm root_parent = new AndTerm(null, null);
 						RootTerm.Parent = root_parent;
-						root_term = root_parent;
+						RootTerm = root_parent;
 					}
 
 					//Log.DebugFormat("rootTerm = {0}", RootTerm);
@@ -423,7 +419,7 @@ namespace FSpot.Widgets {
 						// ensure we handle the Hidden tag properly
 						AndTerm root_parent = new AndTerm(null, null);
 						RootTerm.Parent = root_parent;
-						root_term = root_parent;
+						RootTerm = root_parent;
 					}
 					//Log.DebugFormat ("condition = {0}", RootTerm.SqlCondition ());
 					query.TagTerm = new ConditionWrapper (RootTerm.SqlCondition ());
@@ -436,9 +432,9 @@ namespace FSpot.Widgets {
 
 		private bool ParensValid ()
 		{
-			for (int i = 0; i < entry.Text.Length; i++) {
-				if (entry.Text [i] == '(' || entry.Text [i] == ')') {
-					int pair_pos = ParenPairPosition (entry.Text, i);
+			for (int i = 0; i < Entry.Text.Length; i++) {
+				if (Entry.Text [i] == '(' || Entry.Text [i] == ')') {
+					int pair_pos = ParenPairPosition (Entry.Text, i);
 
 					if (pair_pos == -1)
 						return false;
@@ -472,12 +468,12 @@ namespace FSpot.Widgets {
 
 				if (txt [pos] == one)
 					sames++;
-				else if (txt [pos] == two) {
+				else if (txt [pos] == two)
+				{
 					if (sames == 0)
-						return pos;
-					else
-						sames--;
-				}
+						return pos;
+					sames--;
+				}
 			}
 
 			return -1;
@@ -492,15 +488,13 @@ namespace FSpot.Widgets {
 	}
 
 	public class LogicEntryCompletion : EntryCompletion {
-		private Entry entry;
-
-		private bool completing = false;
-		public bool Completing {
-			get { return completing; }
-		}
-
+		private Entry entry;
+
+		public bool Completing { get; private set; }
+
 		public LogicEntryCompletion (Entry entry, TreeModel tree_model)
-		{
+		{
+			Completing = false;
 			this.entry = entry;
 
 			Model = new DependentListStore(tree_model);
@@ -527,10 +521,10 @@ namespace FSpot.Widgets {
 			int pos = entry.Position;
 			string updated_text = completion_logic.ReplaceKey (entry.Text, name, ref pos);
 
-			completing = true;
+			Completing = true;
 			entry.Text = updated_text;
 			entry.Position = pos;
-			completing = false;
+			Completing = false;
 
 			args.RetVal = true;
 			//Log.Debug ("done w/ match selected");
@@ -568,7 +562,7 @@ namespace FSpot.Widgets {
 			if (key != last_key) {
 				last_key = key;
 
-				if (key == null || key.Length == 0 || pos < 0 || pos > key.Length - 1)
+				if (string.IsNullOrEmpty(key) || pos < 0 || pos > key.Length - 1)
 					transformed_key = String.Empty;
 				else if (key [pos] == '(' || key [pos] == ')' || key [pos] == ',')
 					transformed_key = String.Empty;
diff --git a/src/Clients/MainApp/FSpot.Widgets/FolderTreeModel.cs b/src/Clients/MainApp/FSpot.Widgets/FolderTreeModel.cs
index b00a41f..0324fe2 100644
--- a/src/Clients/MainApp/FSpot.Widgets/FolderTreeModel.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/FolderTreeModel.cs
@@ -199,7 +199,7 @@ namespace FSpot.Widgets
 					last_count += (int)GetValue (iter, 1);
 					SetValue (iter, 1, last_count);
 				}
-				count_all += (int)last_count;
+				count_all += last_count;
 			}
 		}
 	}
diff --git a/src/Clients/MainApp/FSpot.Widgets/FolderTreePage.cs b/src/Clients/MainApp/FSpot.Widgets/FolderTreePage.cs
index 24442fd..f26e92c 100644
--- a/src/Clients/MainApp/FSpot.Widgets/FolderTreePage.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/FolderTreePage.cs
@@ -37,6 +37,7 @@ using Mono.Unix;
 
 namespace FSpot.Widgets
 {
+	// FIXME: This is never used
 	public class FolderTreePage : SidebarPage
 	{
 		readonly FolderTreeView folder_tree_widget;
diff --git a/src/Clients/MainApp/FSpot.Widgets/FolderTreeView.cs b/src/Clients/MainApp/FSpot.Widgets/FolderTreeView.cs
index 3a5e742..e388210 100644
--- a/src/Clients/MainApp/FSpot.Widgets/FolderTreeView.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/FolderTreeView.cs
@@ -30,7 +30,6 @@
 //
 
 using System;
-
 using FSpot.Utils;
 
 using Gtk;
@@ -47,14 +46,14 @@ namespace FSpot.Widgets
 
 		protected FolderTreeView (IntPtr raw) : base (raw) {}
 
-        private static TargetList folderTreeSourceTargetList = new TargetList();
+		private static readonly TargetList folderTreeSourceTargetList = new TargetList();
 
-        static FolderTreeView()
-        {
-            folderTreeSourceTargetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText);
-            folderTreeSourceTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
-            folderTreeSourceTargetList.AddTargetEntry(DragDropTargets.UriQueryEntry);
-        }
+		static FolderTreeView()
+		{
+			folderTreeSourceTargetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText);
+			folderTreeSourceTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
+			folderTreeSourceTargetList.AddTargetEntry(DragDropTargets.UriQueryEntry);
+		}
 
 		public FolderTreeView () : this (new FolderTreeModel ())
 		{
@@ -79,7 +78,7 @@ namespace FSpot.Widgets
 			AppendColumn (column);
 
 			Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
-				    (TargetEntry[])folderTreeSourceTargetList, Gdk.DragAction.Copy | Gdk.DragAction.Move);
+					(TargetEntry[])folderTreeSourceTargetList, Gdk.DragAction.Copy | Gdk.DragAction.Move);
 		}
 
 		public UriList SelectedUris {
@@ -165,11 +164,10 @@ namespace FSpot.Widgets
 		protected override void OnDragDataGet (Gdk.DragContext context, Gtk.SelectionData selection_data, uint info, uint time_)
 		{
 			if (info == DragDropTargets.UriQueryEntry.Info
-			    || info == (uint)DragDropTargets.TargetType.UriList
-			    || info == (uint)DragDropTargets.TargetType.PlainText) {
+				|| info == (uint)DragDropTargets.TargetType.UriList
+				|| info == (uint)DragDropTargets.TargetType.PlainText) {
 
 				selection_data.SetUriListData (SelectedUris, context.Targets[0]);
-				return;
 			}
 		}
 
diff --git a/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs b/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs
index 7ea7307..b79f897 100644
--- a/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/InfoBox.cs
@@ -29,763 +29,754 @@
 // 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 System;
-using System.Collections.Generic;
-using System.IO;
-using FSpot.Core;
-using FSpot.Imaging;
-using Mono.Unix;
-using FSpot.Utils;
-using GLib;
-using GFile = GLib.File;
+//
+
+using System;
+using System.Collections.Generic;
+using Cairo;
+using FSpot.Core;
+using FSpot.Imaging;
+using FSpot.Utils;
+
+using Gtk;
+
+using Mono.Unix;
+
+using GFile = GLib.File;
 using GFileInfo = GLib.FileInfo;
-using Hyena;
 
 // FIXME TODO: We want to use something like EClippedLabel here throughout so it handles small sizes
 // gracefully using ellipsis.
 
 namespace FSpot.Widgets
 {
-    public class InfoBox : VBox
-    {
-        DelayedOperation update_delay;
-
-        public struct InfoEntry
-        {
-            public bool TwoColumns;
-            public bool AlwaysVisible;
-            public bool DefaultVisibility;
-            public string Id;
-            public string Description;
-            public Widget LabelWidget;
-            public Widget InfoWidget;
-            public Action<Widget, IPhoto, TagLib.Image.File> SetSingle;
-            public Action<Widget, IPhoto[]> SetMultiple;
-        }
-
-        private List<InfoEntry> entries = new List<InfoEntry> ();
-
-        private void AddEntry (string id, string name, string description, Widget info_widget, float label_y_align,
-                               bool default_visibility,
-                               Action<Widget, IPhoto, TagLib.Image.File> set_single,
-                               Action<Widget, IPhoto[]> set_multiple)
-        {
-            entries.Add (new InfoEntry {
-                TwoColumns = (name == null),
-                AlwaysVisible = (id == null) || (description == null),
-                DefaultVisibility = default_visibility,
-                Id = id,
-                Description = description,
-                LabelWidget = CreateRightAlignedLabel (String.Format ("<b>{0}</b>", name), label_y_align),
-                InfoWidget = info_widget,
-                SetSingle = set_single,
-                SetMultiple = set_multiple
-            });
-        }
-
-        private void AddEntry (string id, string name, string description, Widget info_widget, float label_y_align,
-                               Action<Widget, IPhoto, TagLib.Image.File> set_single,
-                               Action<Widget, IPhoto[]> set_multiple)
-        {
-            AddEntry (id, name, description, info_widget, label_y_align, true, set_single, set_multiple);
-        }
-
-        private void AddEntry (string id, string name, string description, Widget info_widget, bool default_visibility,
-                               Action<Widget, IPhoto, TagLib.Image.File> set_single,
-                               Action<Widget, IPhoto[]> set_multiple)
-        {
-            AddEntry (id, name, description, info_widget, 0.0f, default_visibility, set_single, set_multiple);
-        }
-
-        private void AddEntry (string id, string name, string description, Widget info_widget,
-                               Action<Widget, IPhoto, TagLib.Image.File> set_single,
-                               Action<Widget, IPhoto[]> set_multiple)
-        {
-            AddEntry (id, name, description, info_widget, 0.0f, set_single, set_multiple);
-        }
-
-        private void AddLabelEntry (string id, string name, string description,
-                                    Func<IPhoto, TagLib.Image.File, string> single_string,
-                                    Func<IPhoto[], string> multiple_string)
-        {
-            AddLabelEntry (id, name, description, true, single_string, multiple_string);
-        }
-
-        private void AddLabelEntry (string id, string name, string description, bool default_visibility,
-                                    Func<IPhoto, TagLib.Image.File, string> single_string,
-                                    Func<IPhoto[], string> multiple_string)
-        {
-            Action<Widget, IPhoto, TagLib.Image.File> set_single = (widget, photo, metadata) => {
-                if (metadata != null)
-                    (widget as Label).Text = single_string (photo, metadata);
-                else
-                    (widget as Label).Text = Catalog.GetString ("(Unknown)");
-            };
-            
-            Action<Widget, IPhoto[]> set_multiple = (widget, photos) => {
-                (widget as Label).Text = multiple_string (photos);
-            };
-            
-            AddEntry (id, name, description, CreateLeftAlignedLabel (String.Empty), default_visibility,
-                      single_string == null ? null : set_single,
-                      multiple_string == null ? null : set_multiple);
-        }
-
-
-        private IPhoto[] photos = new IPhoto[0];
-        public IPhoto[] Photos {
-            private get { return photos; }
-            set {
-                photos = value;
-                update_delay.Start ();
-            }
-        }
-
-        public IPhoto Photo {
-            set {
-                if (value != null) {
-                    Photos = new IPhoto[] { value };
-                }
-            }
-        }
-
-        private bool show_tags = false;
-        public bool ShowTags {
-            get { return show_tags; }
-            set {
-                if (show_tags == value)
-                    return;
-                
-                show_tags = value;
-                //      tag_view.Visible = show_tags;
-            }
-        }
-
-        private bool show_rating = false;
-        public bool ShowRating {
-            get { return show_rating; }
-            set {
-                if (show_rating == value)
-                    return;
-                
-                show_rating = value;
-                //      rating_label.Visible = show_rating;
-                //      rating_view.Visible = show_rating;
-            }
-        }
-
-        public delegate void VersionChangedHandler (InfoBox info_box, IPhotoVersion version);
-        public event VersionChangedHandler VersionChanged;
-
-        private Expander info_expander;
-        private Expander histogram_expander;
-
-        private Gtk.Image histogram_image;
-        private Histogram histogram;
-
-        private DelayedOperation histogram_delay;
-
-        // Context switching (toggles visibility).
-        public event EventHandler ContextChanged;
-
-        private ViewContext view_context = ViewContext.Unknown;
-        public ViewContext Context {
-            get { return view_context; }
-            set {
-                view_context = value;
-                if (ContextChanged != null)
-                    ContextChanged (this, null);
-            }
-        }
-
-        private readonly InfoBoxContextSwitchStrategy ContextSwitchStrategy;
-
-        // Widgetry.
-        private ListStore version_list;
-        private ComboBox version_combo;
-
-
-        private void HandleRatingChanged (object o, EventArgs e)
-        {
-            App.Instance.Organizer.HandleRatingMenuSelected ((o as Widgets.RatingEntry).Value);
-        }
-
-        private Label CreateRightAlignedLabel (string text, float yalign)
-        {
-            Label label = new Label ();
-            label.UseMarkup = true;
-            label.Markup = text;
-            label.Xalign = 1.0f;
-            label.Yalign = yalign;
-            
-            return label;
-        }
-
-        private Label CreateLeftAlignedLabel (string text)
-        {
-            Label label = new Label ();
-            label.UseMarkup = true;
-            label.Markup = text;
-            label.Xalign = 0.0f;
-            label.Yalign = 0.0f;
-            label.Selectable = true;
-            label.Ellipsize = Pango.EllipsizeMode.End;
-            
-            return label;
-        }
-
-        private Table info_table;
-
-        private void AttachRow (int row, InfoEntry entry)
-        {
-            if (!entry.TwoColumns) {
-                info_table.Attach (entry.LabelWidget, 0, 1, (uint)row, (uint)row + 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
-            }
-            
-            info_table.Attach (entry.InfoWidget, entry.TwoColumns ? 0u : 1u, 2, (uint)row, (uint)row + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
-            
-            var info_label = entry.InfoWidget as Label;
-            if (info_label != null)
-                info_label.PopulatePopup += HandlePopulatePopup;
-            
-            var info_entry = entry.InfoWidget as Entry;
-            if (info_entry != null)
-                info_entry.PopulatePopup += HandlePopulatePopup;
-            ;
-        }
-
-        private void UpdateTable ()
-        {
-            info_table.Resize ((uint)(head_rows + entries.Count), 2);
-            int i = 0;
-            foreach (var entry in entries) {
-                AttachRow (head_rows + i, entry);
-                i++;
-            }
-        }
-
-
-        private void SetEntryWidgetVisibility (InfoEntry entry, bool def)
-        {
-            entry.InfoWidget.Visible = ContextSwitchStrategy.InfoEntryVisible (Context, entry) && def;
-            entry.LabelWidget.Visible = ContextSwitchStrategy.InfoEntryVisible (Context, entry) && def;
-            
-        }
-
-        private void UpdateEntries ()
-        {
-            
-        }
-
-        const int TABLE_XPADDING = 3;
-        const int TABLE_YPADDING = 3;
-        private Label AttachLabel (Table table, int row_num, Widget entry)
-        {
-            Label label = new Label (String.Empty);
-            label.Xalign = 0;
-            label.Selectable = true;
-            label.Ellipsize = Pango.EllipsizeMode.End;
-            label.Show ();
-            
-            label.PopulatePopup += HandlePopulatePopup;
-            
-            table.Attach (label, 1, 2, (uint)row_num, (uint)row_num + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, (uint)entry.Style.XThickness + TABLE_XPADDING, (uint)entry.Style.YThickness);
-            
-            return label;
-        }
-
-        private const int head_rows = 0;
-
-        private void SetupWidgets ()
-        {
-            
-            histogram_expander = new Expander (Catalog.GetString ("Histogram"));
-            histogram_expander.Activated += delegate(object sender, EventArgs e) {
-                ContextSwitchStrategy.SetHistogramVisible (Context, histogram_expander.Expanded);
-                UpdateHistogram ();
-            };
-            histogram_expander.StyleSet += delegate(object sender, StyleSetArgs args) {
-                Gdk.Color c = this.Toplevel.Style.Backgrounds[(int)Gtk.StateType.Active];
-                histogram.RedColorHint = (byte)(c.Red / 0xff);
-                histogram.GreenColorHint = (byte)(c.Green / 0xff);
-                histogram.BlueColorHint = (byte)(c.Blue / 0xff);
-                histogram.BackgroundColorHint = 0xff;
-                UpdateHistogram ();
-            };
-            histogram_image = new Gtk.Image ();
-            histogram = new Histogram ();
-            histogram_expander.Add (histogram_image);
-            
-            Add (histogram_expander);
-            
-            info_expander = new Expander (Catalog.GetString ("Image Information"));
-            info_expander.Activated += (sender, e) => {
-                ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded);
-            };
-
-            info_table = new Table (head_rows, 2, false) { BorderWidth = 0 };
-            
-            AddLabelEntry (null, null, null, null,
-                           photos => { return String.Format (Catalog.GetString ("{0} Photos"), photos.Length); });
-            
-            AddLabelEntry (null, Catalog.GetString ("Name"), null,
-                           (photo, file) => { return photo.Name ?? String.Empty; }, null);
-            
-            version_list = new ListStore (typeof(IPhotoVersion), typeof(string), typeof(bool));
-            version_combo = new ComboBox ();
-            CellRendererText version_name_cell = new CellRendererText ();
-            version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
-            version_combo.PackStart (version_name_cell, true);
-            version_combo.SetCellDataFunc (version_name_cell, new CellLayoutDataFunc (VersionNameCellFunc));
-            version_combo.Model = version_list;
-            version_combo.Changed += OnVersionComboChanged;
-            
-            AddEntry (null, Catalog.GetString ("Version"), null, version_combo, 0.5f,
-                      (widget, photo, file) => {
-                            version_list.Clear ();
-                            version_combo.Changed -= OnVersionComboChanged;
-            
-                            int count = 0;
-                            foreach (IPhotoVersion version in photo.Versions) {
-                                version_list.AppendValues (version, version.Name, true);
-                                if (version == photo.DefaultVersion)
-                                    version_combo.Active = count;
-                                count++;
-                            }
-            
-                            if (count <= 1) {
-                                version_combo.Sensitive = false;
-                                version_combo.TooltipText = Catalog.GetString ("(No Edits)");
-                            } else {
-                                version_combo.Sensitive = true;
-                                version_combo.TooltipText =
-                                    String.Format (Catalog.GetPluralString ("(One Edit)", "({0} Edits)", count - 1),
-                                                   count - 1);
-                            }
-                            version_combo.Changed += OnVersionComboChanged;
-                       }, null);
-            
-            AddLabelEntry ("date", Catalog.GetString ("Date"), Catalog.GetString ("Show Date"),
-                           (photo, file) => {
-                               return String.Format ("{0}{2}{1}",
-                                                     photo.Time.ToShortDateString (),
-                                                     photo.Time.ToShortTimeString (),
-                                                     Environment.NewLine); },
-                           photos => {
-                                IPhoto first = photos[photos.Length - 1];
-                                IPhoto last = photos[0];
-                                if (first.Time.Date == last.Time.Date) {
-                                    //Note for translators: {0} is a date, {1} and {2} are times.
-                                    return String.Format (Catalog.GetString ("On {0} between \n{1} and {2}"),
-                                                          first.Time.ToShortDateString (),
-                                                          first.Time.ToShortTimeString (),
-                                                          last.Time.ToShortTimeString ());
-                                } else {
-                                    return String.Format (Catalog.GetString ("Between {0} \nand {1}"),
-                                                          first.Time.ToShortDateString (),
-                                                          last.Time.ToShortDateString ());
-                                }
-                           });
-
-            AddLabelEntry ("size", Catalog.GetString ("Size"), Catalog.GetString ("Show Size"),
-                           (photo, metadata) => {
+	public class InfoBox : VBox
+	{
+		DelayedOperation update_delay;
+
+		public struct InfoEntry
+		{
+			public bool TwoColumns;
+			public bool AlwaysVisible;
+			public bool DefaultVisibility;
+			public string Id;
+			public string Description;
+			public Widget LabelWidget;
+			public Widget InfoWidget;
+			public Action<Widget, IPhoto, TagLib.Image.File> SetSingle;
+			public Action<Widget, IPhoto[]> SetMultiple;
+		}
+
+		private readonly List<InfoEntry> entries = new List<InfoEntry> ();
+
+		private void AddEntry (string id, string name, string description, Widget info_widget, float label_y_align,
+							   bool default_visibility,
+							   Action<Widget, IPhoto, TagLib.Image.File> set_single,
+							   Action<Widget, IPhoto[]> set_multiple)
+		{
+			entries.Add (new InfoEntry {
+				TwoColumns = (name == null),
+				AlwaysVisible = (id == null) || (description == null),
+				DefaultVisibility = default_visibility,
+				Id = id,
+				Description = description,
+				LabelWidget = CreateRightAlignedLabel (String.Format ("<b>{0}</b>", name), label_y_align),
+				InfoWidget = info_widget,
+				SetSingle = set_single,
+				SetMultiple = set_multiple
+			});
+		}
+
+		private void AddEntry (string id, string name, string description, Widget info_widget, float label_y_align,
+							   Action<Widget, IPhoto, TagLib.Image.File> set_single,
+							   Action<Widget, IPhoto[]> set_multiple)
+		{
+			AddEntry (id, name, description, info_widget, label_y_align, true, set_single, set_multiple);
+		}
+
+		private void AddEntry (string id, string name, string description, Widget info_widget, bool default_visibility,
+							   Action<Widget, IPhoto, TagLib.Image.File> set_single,
+							   Action<Widget, IPhoto[]> set_multiple)
+		{
+			AddEntry (id, name, description, info_widget, 0.0f, default_visibility, set_single, set_multiple);
+		}
+
+		private void AddEntry (string id, string name, string description, Widget info_widget,
+							   Action<Widget, IPhoto, TagLib.Image.File> set_single,
+							   Action<Widget, IPhoto[]> set_multiple)
+		{
+			AddEntry (id, name, description, info_widget, 0.0f, set_single, set_multiple);
+		}
+
+		private void AddLabelEntry (string id, string name, string description,
+									Func<IPhoto, TagLib.Image.File, string> single_string,
+									Func<IPhoto[], string> multiple_string)
+		{
+			AddLabelEntry (id, name, description, true, single_string, multiple_string);
+		}
+
+		private void AddLabelEntry (string id, string name, string description, bool default_visibility,
+									Func<IPhoto, TagLib.Image.File, string> single_string,
+									Func<IPhoto[], string> multiple_string)
+		{
+			Action<Widget, IPhoto, TagLib.Image.File> set_single = (widget, photo, metadata) => {
+				if (metadata != null)
+					(widget as Label).Text = single_string (photo, metadata);
+				else
+					(widget as Label).Text = Catalog.GetString ("(Unknown)");
+			};
+			
+			Action<Widget, IPhoto[]> set_multiple = (widget, photos) => {
+				(widget as Label).Text = multiple_string (photos);
+			};
+			
+			AddEntry (id, name, description, CreateLeftAlignedLabel (String.Empty), default_visibility,
+					  single_string == null ? null : set_single,
+					  multiple_string == null ? null : set_multiple);
+		}
+
+
+		private IPhoto[] photos = new IPhoto[0];
+		public IPhoto[] Photos {
+			private get { return photos; }
+			set {
+				photos = value;
+				update_delay.Start ();
+			}
+		}
+
+		public IPhoto Photo {
+			set {
+				if (value != null) {
+					Photos = new IPhoto[] { value };
+				}
+			}
+		}
+
+		private bool show_tags = false;
+		public bool ShowTags {
+			get { return show_tags; }
+			set {
+				if (show_tags == value)
+					return;
+				
+				show_tags = value;
+				//      tag_view.Visible = show_tags;
+			}
+		}
+
+		private bool show_rating = false;
+		public bool ShowRating {
+			get { return show_rating; }
+			set {
+				if (show_rating == value)
+					return;
+				
+				show_rating = value;
+				//      rating_label.Visible = show_rating;
+				//      rating_view.Visible = show_rating;
+			}
+		}
+
+		public delegate void VersionChangedHandler (InfoBox info_box, IPhotoVersion version);
+		public event VersionChangedHandler VersionChanged;
+
+		private Expander info_expander;
+		private Expander histogram_expander;
+
+		private Gtk.Image histogram_image;
+		private Histogram histogram;
+
+		private DelayedOperation histogram_delay;
+
+		// Context switching (toggles visibility).
+		public event EventHandler ContextChanged;
+
+		private ViewContext view_context = ViewContext.Unknown;
+		public ViewContext Context {
+			get { return view_context; }
+			set {
+				view_context = value;
+				if (ContextChanged != null)
+					ContextChanged (this, null);
+			}
+		}
+
+		private readonly InfoBoxContextSwitchStrategy ContextSwitchStrategy;
+
+		// Widgetry.
+		private ListStore version_list;
+		private ComboBox version_combo;
+
+
+		private void HandleRatingChanged (object o, EventArgs e)
+		{
+			App.Instance.Organizer.HandleRatingMenuSelected ((o as Widgets.RatingEntry).Value);
+		}
+
+		private Label CreateRightAlignedLabel (string text, float yalign)
+		{
+			Label label = new Label ();
+			label.UseMarkup = true;
+			label.Markup = text;
+			label.Xalign = 1.0f;
+			label.Yalign = yalign;
+			
+			return label;
+		}
+
+		private Label CreateLeftAlignedLabel (string text)
+		{
+			Label label = new Label ();
+			label.UseMarkup = true;
+			label.Markup = text;
+			label.Xalign = 0.0f;
+			label.Yalign = 0.0f;
+			label.Selectable = true;
+			label.Ellipsize = Pango.EllipsizeMode.End;
+			
+			return label;
+		}
+
+		private Table info_table;
+
+		private void AttachRow (int row, InfoEntry entry)
+		{
+			if (!entry.TwoColumns) {
+				info_table.Attach (entry.LabelWidget, 0, 1, (uint)row, (uint)row + 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
+			}
+			
+			info_table.Attach (entry.InfoWidget, entry.TwoColumns ? 0u : 1u, 2, (uint)row, (uint)row + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
+			
+			var info_label = entry.InfoWidget as Label;
+			if (info_label != null)
+				info_label.PopulatePopup += HandlePopulatePopup;
+			
+			var info_entry = entry.InfoWidget as Entry;
+			if (info_entry != null)
+				info_entry.PopulatePopup += HandlePopulatePopup;
+			;
+		}
+
+		private void UpdateTable ()
+		{
+			info_table.Resize ((uint)(head_rows + entries.Count), 2);
+			int i = 0;
+			foreach (var entry in entries) {
+				AttachRow (head_rows + i, entry);
+				i++;
+			}
+		}
+
+
+		private void SetEntryWidgetVisibility (InfoEntry entry, bool def)
+		{
+			entry.InfoWidget.Visible = ContextSwitchStrategy.InfoEntryVisible (Context, entry) && def;
+			entry.LabelWidget.Visible = ContextSwitchStrategy.InfoEntryVisible (Context, entry) && def;
+			
+		}
+
+		private void UpdateEntries ()
+		{
+			// FIXME: Pretty sure this does nothing :)
+			// not to mention its never called
+		}
+
+		const int TABLE_XPADDING = 3;
+		const int TABLE_YPADDING = 3;
+		private Label AttachLabel (Table table, int row_num, Widget entry)
+		{
+			Label label = new Label (String.Empty);
+			label.Xalign = 0;
+			label.Selectable = true;
+			label.Ellipsize = Pango.EllipsizeMode.End;
+			label.Show ();
+			
+			label.PopulatePopup += HandlePopulatePopup;
+			
+			table.Attach (label, 1, 2, (uint)row_num, (uint)row_num + 1, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, (uint)entry.Style.XThickness + TABLE_XPADDING, (uint)entry.Style.YThickness);
+			
+			return label;
+		}
+
+		private const int head_rows = 0;
+
+		private void SetupWidgets ()
+		{
+			
+			histogram_expander = new Expander (Catalog.GetString ("Histogram"));
+			histogram_expander.Activated += delegate(object sender, EventArgs e) {
+				ContextSwitchStrategy.SetHistogramVisible (Context, histogram_expander.Expanded);
+				UpdateHistogram ();
+			};
+			histogram_expander.StyleSet += delegate(object sender, StyleSetArgs args) {
+				Gdk.Color c = this.Toplevel.Style.Backgrounds[(int)Gtk.StateType.Active];
+				histogram.RedColorHint = (byte)(c.Red / 0xff);
+				histogram.GreenColorHint = (byte)(c.Green / 0xff);
+				histogram.BlueColorHint = (byte)(c.Blue / 0xff);
+				histogram.BackgroundColorHint = 0xff;
+				UpdateHistogram ();
+			};
+			histogram_image = new Gtk.Image ();
+			histogram = new Histogram ();
+			histogram_expander.Add (histogram_image);
+			
+			Add (histogram_expander);
+			
+			info_expander = new Expander (Catalog.GetString ("Image Information"));
+			info_expander.Activated += (sender, e) => ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded);
+
+			info_table = new Table (head_rows, 2, false) { BorderWidth = 0 };
+			
+			AddLabelEntry (null, null, null, null,
+						   photos => String.Format (Catalog.GetString ("{0} Photos"), photos.Length));
+			
+			AddLabelEntry (null, Catalog.GetString ("Name"), null,
+						   (photo, file) => photo.Name ?? String.Empty, null);
+			
+			version_list = new ListStore (typeof(IPhotoVersion), typeof(string), typeof(bool));
+			version_combo = new ComboBox ();
+			CellRendererText version_name_cell = new CellRendererText ();
+			version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
+			version_combo.PackStart (version_name_cell, true);
+			version_combo.SetCellDataFunc (version_name_cell, new CellLayoutDataFunc (VersionNameCellFunc));
+			version_combo.Model = version_list;
+			version_combo.Changed += OnVersionComboChanged;
+			
+			AddEntry (null, Catalog.GetString ("Version"), null, version_combo, 0.5f,
+					  (widget, photo, file) => {
+							version_list.Clear ();
+							version_combo.Changed -= OnVersionComboChanged;
+			
+							int count = 0;
+							foreach (IPhotoVersion version in photo.Versions) {
+								version_list.AppendValues (version, version.Name, true);
+								if (version == photo.DefaultVersion)
+									version_combo.Active = count;
+								count++;
+							}
+			
+							if (count <= 1) {
+								version_combo.Sensitive = false;
+								version_combo.TooltipText = Catalog.GetString ("(No Edits)");
+							} else {
+								version_combo.Sensitive = true;
+								version_combo.TooltipText =
+									String.Format (Catalog.GetPluralString ("(One Edit)", "({0} Edits)", count - 1),
+												   count - 1);
+							}
+							version_combo.Changed += OnVersionComboChanged;
+					   }, null);
+			
+			AddLabelEntry ("date", Catalog.GetString ("Date"), Catalog.GetString ("Show Date"),
+						   (photo, file) => {
+							   return String.Format ("{0}{2}{1}",
+													 photo.Time.ToShortDateString (),
+													 photo.Time.ToShortTimeString (),
+													 Environment.NewLine); },
+						   photos => {
+								IPhoto first = photos[photos.Length - 1];
+								IPhoto last = photos[0];
+								if (first.Time.Date == last.Time.Date) {
+									//Note for translators: {0} is a date, {1} and {2} are times.
+									return String.Format (Catalog.GetString ("On {0} between \n{1} and {2}"),
+														  first.Time.ToShortDateString (),
+														  first.Time.ToShortTimeString (),
+														  last.Time.ToShortTimeString ());
+								}
+						        return String.Format (Catalog.GetString ("Between {0} \nand {1}"),
+						             	                first.Time.ToShortDateString (),
+						             	                last.Time.ToShortDateString ());
+						   });
+
+			AddLabelEntry ("size", Catalog.GetString ("Size"), Catalog.GetString ("Show Size"),
+						   (photo, metadata) => {
 				int width = 0;
 				int height = 0;
 				if (null != metadata.Properties) {
-   	                             width = metadata.Properties.PhotoWidth;
-   	                             height = metadata.Properties.PhotoHeight;
+								 width = metadata.Properties.PhotoWidth;
+								 height = metadata.Properties.PhotoHeight;
 				}
 
-                                if (width != 0 && height != 0)
-                                    return String.Format ("{0}x{1}", width, height);
-                                else
-                                    return Catalog.GetString ("(Unknown)");
-                           }, null);
-
-            AddLabelEntry ("exposure", Catalog.GetString ("Exposure"), Catalog.GetString ("Show Exposure"),
-                           (photo, metadata) => {
-                                var fnumber = metadata.ImageTag.FNumber;
-                                var exposure_time = metadata.ImageTag.ExposureTime;
-                                var iso_speed = metadata.ImageTag.ISOSpeedRatings;
-
-                                string info = String.Empty;
-
-                                if (fnumber.HasValue && fnumber.Value != 0.0) {
-                                    info += String.Format ("f/{0:.0} ", fnumber.Value);
-                                }
-
-                                if (exposure_time.HasValue) {
-                                    if (Math.Abs (exposure_time.Value) >= 1.0) {
-                                        info += String.Format ("{0} sec ", exposure_time.Value);
-                                    } else {
-                                        info += String.Format ("1/{0} sec ", (int)(1 / exposure_time.Value));
-                                    }
-                                }
-
-                                if (iso_speed.HasValue) {
-                                    info += String.Format ("{0}ISO {1}", Environment.NewLine, iso_speed.Value);
-                                }
-
-                                var exif = metadata.ImageTag.Exif;
-                                if (exif != null) {
-                                    var flash = exif.ExifIFD.GetLongValue (0, (ushort)TagLib.IFD.Tags.ExifEntryTag.Flash);
-
-                                    if (flash.HasValue) {
-                                        if ((flash.Value & 0x01) == 0x01)
-                                            info += String.Format (", {0}", Catalog.GetString ("flash fired"));
-                                        else
-                                            info += String.Format (", {0}", Catalog.GetString ("flash didn't fire"));
-                                    }
-                                }
-
-                                if (info == String.Empty)
-                                    return Catalog.GetString ("(None)");
-
-                                return info;
-                           }, null);
-            
-            AddLabelEntry ("focal_length", Catalog.GetString ("Focal Length"), Catalog.GetString ("Show Focal Length"),
-                           false, (photo, metadata) => {
-                                var focal_length = metadata.ImageTag.FocalLength;
-                
-                                if (focal_length == null)
-                                    return Catalog.GetString ("(Unknown)");
-                                else
-                                    return String.Format ("{0} mm", focal_length.Value);
-                            }, null);
-
-            AddLabelEntry ("camera", Catalog.GetString ("Camera"), Catalog.GetString ("Show Camera"), false,
-                           (photo, metadata) => { return metadata.ImageTag.Model ?? Catalog.GetString ("(Unknown)"); },
-                           null);
-            
-            AddLabelEntry ("creator", Catalog.GetString ("Creator"), Catalog.GetString ("Show Creator"),
-                           (photo, metadata) => { return metadata.ImageTag.Creator ?? Catalog.GetString ("(Unknown)"); },
-                           null);
-
-            AddLabelEntry ("file_size", Catalog.GetString ("File Size"), Catalog.GetString ("Show File Size"), false,
-                           (photo, metadata) => {
-                                try {
-                                    GFile file = FileFactory.NewForUri (photo.DefaultVersion.Uri);
-                                    GFileInfo file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null);
-                                    return Format.SizeForDisplay (file_info.Size);
-                                } catch (GLib.GException e) {
-                                    Hyena.Log.DebugException (e);
-                                    return Catalog.GetString ("(File read error)");
-                                }
-                            }, null);
-            
-            var rating_entry = new RatingEntry { HasFrame = false, AlwaysShowEmptyStars = true };
-            rating_entry.Changed += HandleRatingChanged;
-            var rating_align = new Gtk.Alignment (0, 0, 0, 0);
-            rating_align.Add (rating_entry);
-            AddEntry ("rating", Catalog.GetString ("Rating"), Catalog.GetString ("Show Rating"), rating_align, false,
-                      (widget, photo, metadata) => { ((widget as Alignment).Child as RatingEntry).Value = (int) photo.Rating; },
-                      null);
-            
-            AddEntry ("tag", null, Catalog.GetString ("Show Tags"), new TagView (), false,
-                      (widget, photo, metadata) => { (widget as TagView).Current = photo; }, null);
-
-            UpdateTable ();
-
-            EventBox eb = new EventBox ();
-            eb.Add (info_table);
-            info_expander.Add (eb);
-            eb.ButtonPressEvent += HandleButtonPressEvent;
-
-            Add (info_expander);
-        }
-
-        public bool Update ()
-        {
-            if (Photos == null || Photos.Length == 0) {
-                Hide ();
-            } else if (Photos.Length == 1) {
-                var photo = Photos[0];
-
-                histogram_expander.Visible = true;
-                UpdateHistogram();
-
-                using (var metadata = Metadata.Parse (photo.DefaultVersion.Uri)) {
-                    foreach (var entry in entries) {
-                        bool is_single = (entry.SetSingle != null);
-                        
-                        if (is_single)
-                            entry.SetSingle (entry.InfoWidget, photo, metadata);
-
-                        SetEntryWidgetVisibility (entry, is_single);
-                    }
-                }
-                Show ();
-            } else if (Photos.Length > 1) {
-                foreach (var entry in entries) {
-                    bool is_multiple = (entry.SetMultiple != null);
-                    
-                    if (is_multiple)
-                        entry.SetMultiple (entry.InfoWidget, Photos);
-                    
-                    SetEntryWidgetVisibility (entry, is_multiple);
-                }
-                histogram_expander.Visible = false;
-                Show ();
-            }
-            return false;
-        }
-
-        void VersionNameCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
-        {
-            string name = (string)tree_model.GetValue (iter, 1);
-            (cell as CellRendererText).Text = name;
-            
-            cell.Sensitive = (bool)tree_model.GetValue (iter, 2);
-        }
-
-        void OnVersionComboChanged (object o, EventArgs e)
-        {
-            ComboBox combo = o as ComboBox;
-            if (combo == null)
-                return;
-            
-            TreeIter iter;
-            
-            if (combo.GetActiveIter (out iter))
-                VersionChanged (this, (IPhotoVersion)version_list.GetValue (iter, 0));
-        }
-
-        private Gdk.Pixbuf histogram_hint;
-
-        private void UpdateHistogram ()
-        {
-            if (histogram_expander.Expanded)
-                histogram_delay.Start ();
-        }
-
-        public void UpdateHistogram (Gdk.Pixbuf pixbuf)
-        {
-            histogram_hint = pixbuf;
-            UpdateHistogram ();
-        }
-
-        private bool DelayedUpdateHistogram ()
-        {
-            if (Photos.Length == 0)
-                return false;
-
-            IPhoto photo = Photos[0];
-            
-            Gdk.Pixbuf hint = histogram_hint;
-            histogram_hint = null;
-            int max = histogram_expander.Allocation.Width;
-            
-            try {
-                if (hint == null)
-                    using (var img = ImageFile.Create (photo.DefaultVersion.Uri)) {
-                        hint = img.Load (256, 256);
-                    }
-                
-                histogram_image.Pixbuf = histogram.Generate (hint, max);
-                
-                hint.Dispose ();
-            } catch (System.Exception e) {
-                Hyena.Log.Debug (e.StackTrace);
-                using (Gdk.Pixbuf empty = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 256, 256)) {
-                    empty.Fill (0x0);
-                    histogram_image.Pixbuf = histogram.Generate (empty, max);
-                }
-            }
-            
-            return false;
-        }
-
-        // Context switching
-
-        private void HandleContextChanged (object sender, EventArgs args)
-        {
-            bool infobox_visible = ContextSwitchStrategy.InfoBoxVisible (Context);
-            info_expander.Expanded = infobox_visible;
-            
-            bool histogram_visible = ContextSwitchStrategy.HistogramVisible (Context);
-            histogram_expander.Expanded = histogram_visible;
-            
-            if (infobox_visible)
-                update_delay.Start ();
-        }
-
-        public void HandleMainWindowViewModeChanged (object o, EventArgs args)
-        {
-            MainWindow.ModeType mode = App.Instance.Organizer.ViewMode;
-            if (mode == MainWindow.ModeType.IconView)
-                Context = ViewContext.Library; else if (mode == MainWindow.ModeType.PhotoView) {
-                Context = ViewContext.Edit;
-            }
-        }
-
-        void HandleButtonPressEvent (object sender, ButtonPressEventArgs args)
-        {
-            if (args.Event.Button == 3) {
-                Menu popup_menu = new Menu ();
-                
-                AddMenuItems (popup_menu);
-                
-                if (args.Event != null)
-                    popup_menu.Popup (null, null, null, args.Event.Button, args.Event.Time);
-                else
-                    popup_menu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
-                
-                args.RetVal = true;
-            }
-        }
-
-        void HandlePopulatePopup (object sender, PopulatePopupArgs args)
-        {
-            AddMenuItems (args.Menu);
-            
-            args.RetVal = true;
-        }
-
-        private void AddMenuItems (Menu popup_menu)
-        {
-            var items = new Dictionary <MenuItem, InfoEntry> ();
-
-            if (popup_menu.Children.Length > 0 && entries.Count > 0) {
-                GtkUtil.MakeMenuSeparator (popup_menu);
-            }
-            
-            foreach (var entry in entries) {
-                if (entry.AlwaysVisible)
-                    continue;
-
-                var item =
-                    GtkUtil.MakeCheckMenuItem (popup_menu, entry.Description, (sender, args) => {
-                        ContextSwitchStrategy.SetInfoEntryVisible (Context, items [sender as CheckMenuItem], (sender as CheckMenuItem).Active);
-                        Update ();
-                    },
-                    true, ContextSwitchStrategy.InfoEntryVisible (Context, entry), false);
-
-                items.Add (item, entry);
-            }
-        }
-
-        private void HandleMenuItemSelected (object sender, EventArgs args)
-        {
-
-        }
+								if (width != 0 && height != 0)
+									return String.Format ("{0}x{1}", width, height);
+								return Catalog.GetString ("(Unknown)");
+						   }, null);
+
+			AddLabelEntry ("exposure", Catalog.GetString ("Exposure"), Catalog.GetString ("Show Exposure"),
+						   (photo, metadata) => {
+								var fnumber = metadata.ImageTag.FNumber;
+								var exposure_time = metadata.ImageTag.ExposureTime;
+								var iso_speed = metadata.ImageTag.ISOSpeedRatings;
+
+								string info = String.Empty;
+
+								if (fnumber.HasValue && fnumber.Value != 0.0) {
+									info += String.Format ("f/{0:.0} ", fnumber.Value);
+								}
+
+								if (exposure_time.HasValue) {
+									if (Math.Abs (exposure_time.Value) >= 1.0) {
+										info += String.Format ("{0} sec ", exposure_time.Value);
+									} else {
+										info += String.Format ("1/{0} sec ", (int)(1 / exposure_time.Value));
+									}
+								}
+
+								if (iso_speed.HasValue) {
+									info += String.Format ("{0}ISO {1}", Environment.NewLine, iso_speed.Value);
+								}
+
+								var exif = metadata.ImageTag.Exif;
+								if (exif != null) {
+									var flash = exif.ExifIFD.GetLongValue (0, (ushort)TagLib.IFD.Tags.ExifEntryTag.Flash);
+
+									if (flash.HasValue) {
+										if ((flash.Value & 0x01) == 0x01)
+											info += String.Format (", {0}", Catalog.GetString ("flash fired"));
+										else
+											info += String.Format (", {0}", Catalog.GetString ("flash didn't fire"));
+									}
+								}
+
+								if (info == String.Empty)
+									return Catalog.GetString ("(None)");
+
+								return info;
+						   }, null);
+			
+			AddLabelEntry ("focal_length", Catalog.GetString ("Focal Length"), Catalog.GetString ("Show Focal Length"),
+						   false, (photo, metadata) => {
+								var focal_length = metadata.ImageTag.FocalLength;
+				
+								if (focal_length == null)
+									return Catalog.GetString ("(Unknown)");
+								return String.Format ("{0} mm", focal_length.Value);
+						   }, null);
+
+			AddLabelEntry ("camera", Catalog.GetString ("Camera"), Catalog.GetString ("Show Camera"), false,
+						   (photo, metadata) => metadata.ImageTag.Model ?? Catalog.GetString ("(Unknown)"),
+						   null);
+			
+			AddLabelEntry ("creator", Catalog.GetString ("Creator"), Catalog.GetString ("Show Creator"),
+						   (photo, metadata) => metadata.ImageTag.Creator ?? Catalog.GetString ("(Unknown)"),
+						   null);
+
+			AddLabelEntry ("file_size", Catalog.GetString ("File Size"), Catalog.GetString ("Show File Size"), false,
+						   (photo, metadata) => {
+								try {
+									GFile file = FileFactory.NewForUri (photo.DefaultVersion.Uri);
+									GFileInfo file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null);
+									return Format.SizeForDisplay (file_info.Size);
+								} catch (GLib.GException e) {
+									Hyena.Log.DebugException (e);
+									return Catalog.GetString ("(File read error)");
+								}
+							}, null);
+			
+			var rating_entry = new RatingEntry { HasFrame = false, AlwaysShowEmptyStars = true };
+			rating_entry.Changed += HandleRatingChanged;
+			var rating_align = new Gtk.Alignment (0, 0, 0, 0);
+			rating_align.Add (rating_entry);
+			AddEntry ("rating", Catalog.GetString ("Rating"), Catalog.GetString ("Show Rating"), rating_align, false,
+					  (widget, photo, metadata) => { ((widget as Alignment).Child as RatingEntry).Value = (int) photo.Rating; },
+					  null);
+			
+			AddEntry ("tag", null, Catalog.GetString ("Show Tags"), new TagView (), false,
+					  (widget, photo, metadata) => { (widget as TagView).Current = photo; }, null);
+
+			UpdateTable ();
+
+			EventBox eb = new EventBox ();
+			eb.Add (info_table);
+			info_expander.Add (eb);
+			eb.ButtonPressEvent += HandleButtonPressEvent;
+
+			Add (info_expander);
+		}
+
+		public bool Update ()
+		{
+			if (Photos == null || Photos.Length == 0) {
+				Hide ();
+			} else if (Photos.Length == 1) {
+				var photo = Photos[0];
+
+				histogram_expander.Visible = true;
+				UpdateHistogram();
+
+				using (var metadata = Metadata.Parse (photo.DefaultVersion.Uri)) {
+					foreach (var entry in entries) {
+						bool is_single = (entry.SetSingle != null);
+						
+						if (is_single)
+							entry.SetSingle (entry.InfoWidget, photo, metadata);
+
+						SetEntryWidgetVisibility (entry, is_single);
+					}
+				}
+				Show ();
+			} else if (Photos.Length > 1) {
+				foreach (var entry in entries) {
+					bool is_multiple = (entry.SetMultiple != null);
+					
+					if (is_multiple)
+						entry.SetMultiple (entry.InfoWidget, Photos);
+					
+					SetEntryWidgetVisibility (entry, is_multiple);
+				}
+				histogram_expander.Visible = false;
+				Show ();
+			}
+			return false;
+		}
+
+		void VersionNameCellFunc (CellLayout cell_layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
+		{
+			string name = (string)tree_model.GetValue (iter, 1);
+			(cell as CellRendererText).Text = name;
+			
+			cell.Sensitive = (bool)tree_model.GetValue (iter, 2);
+		}
+
+		void OnVersionComboChanged (object o, EventArgs e)
+		{
+			ComboBox combo = o as ComboBox;
+			if (combo == null)
+				return;
+			
+			TreeIter iter;
+			
+			if (combo.GetActiveIter (out iter))
+				VersionChanged (this, (IPhotoVersion)version_list.GetValue (iter, 0));
+		}
+
+		private Gdk.Pixbuf histogram_hint;
+
+		private void UpdateHistogram ()
+		{
+			if (histogram_expander.Expanded)
+				histogram_delay.Start ();
+		}
+
+		public void UpdateHistogram (Gdk.Pixbuf pixbuf)
+		{
+			histogram_hint = pixbuf;
+			UpdateHistogram ();
+		}
+
+		private bool DelayedUpdateHistogram ()
+		{
+			if (Photos.Length == 0)
+				return false;
+
+			IPhoto photo = Photos[0];
+			
+			Gdk.Pixbuf hint = histogram_hint;
+			histogram_hint = null;
+			int max = histogram_expander.Allocation.Width;
+			
+			try {
+				if (hint == null)
+					using (var img = ImageFile.Create (photo.DefaultVersion.Uri)) {
+						hint = img.Load (256, 256);
+					}
+				
+				histogram_image.Pixbuf = histogram.Generate (hint, max);
+				
+				hint.Dispose ();
+			} catch (System.Exception e) {
+				Hyena.Log.Debug (e.StackTrace);
+				using (Gdk.Pixbuf empty = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 256, 256)) {
+					empty.Fill (0x0);
+					histogram_image.Pixbuf = histogram.Generate (empty, max);
+				}
+			}
+			
+			return false;
+		}
+
+		// Context switching
+
+		private void HandleContextChanged (object sender, EventArgs args)
+		{
+			bool infobox_visible = ContextSwitchStrategy.InfoBoxVisible (Context);
+			info_expander.Expanded = infobox_visible;
+			
+			bool histogram_visible = ContextSwitchStrategy.HistogramVisible (Context);
+			histogram_expander.Expanded = histogram_visible;
+			
+			if (infobox_visible)
+				update_delay.Start ();
+		}
+
+		public void HandleMainWindowViewModeChanged (object o, EventArgs args)
+		{
+			MainWindow.ModeType mode = App.Instance.Organizer.ViewMode;
+			if (mode == MainWindow.ModeType.IconView)
+				Context = ViewContext.Library; else if (mode == MainWindow.ModeType.PhotoView) {
+				Context = ViewContext.Edit;
+			}
+		}
+
+		void HandleButtonPressEvent (object sender, ButtonPressEventArgs args)
+		{
+			if (args.Event.Button == 3) {
+				Menu popup_menu = new Menu ();
+				
+				AddMenuItems (popup_menu);
+				
+				if (args.Event != null)
+					popup_menu.Popup (null, null, null, args.Event.Button, args.Event.Time);
+				else
+					popup_menu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
+				
+				args.RetVal = true;
+			}
+		}
+
+		void HandlePopulatePopup (object sender, PopulatePopupArgs args)
+		{
+			AddMenuItems (args.Menu);
+			
+			args.RetVal = true;
+		}
+
+		private void AddMenuItems (Menu popup_menu)
+		{
+			var items = new Dictionary <MenuItem, InfoEntry> ();
+
+			if (popup_menu.Children.Length > 0 && entries.Count > 0) {
+				GtkUtil.MakeMenuSeparator (popup_menu);
+			}
+			
+			foreach (var entry in entries) {
+				if (entry.AlwaysVisible)
+					continue;
+
+				var item =
+					GtkUtil.MakeCheckMenuItem (popup_menu, entry.Description, (sender, args) => {
+						ContextSwitchStrategy.SetInfoEntryVisible (Context, items [sender as CheckMenuItem], (sender as CheckMenuItem).Active);
+						Update ();
+					},
+					true, ContextSwitchStrategy.InfoEntryVisible (Context, entry), false);
+
+				items.Add (item, entry);
+			}
+		}
+
+		private void HandleMenuItemSelected (object sender, EventArgs args)
+		{
+			// FIXME: No ones home??? (never called either)
+		}
 
 		#region Constructor
-        public InfoBox () : base(false, 0)
-        {
-            ContextSwitchStrategy = new MRUInfoBoxContextSwitchStrategy ();
-            ContextChanged += HandleContextChanged;
-            
-            SetupWidgets ();
-            
-            update_delay = new DelayedOperation (Update);
-            update_delay.Start ();
-            
-            histogram_delay = new DelayedOperation (DelayedUpdateHistogram);
-            
-            BorderWidth = 2;
-            Hide ();
-        }
+		public InfoBox () : base(false, 0)
+		{
+			ContextSwitchStrategy = new MRUInfoBoxContextSwitchStrategy ();
+			ContextChanged += HandleContextChanged;
+			
+			SetupWidgets ();
+			
+			update_delay = new DelayedOperation (Update);
+			update_delay.Start ();
+			
+			histogram_delay = new DelayedOperation (DelayedUpdateHistogram);
+			
+			BorderWidth = 2;
+			Hide ();
+		}
 		#endregion
-    }
-
-    // Decides whether infobox / histogram should be shown for each context. Implemented
-    // using the Strategy pattern, to make it swappable easily, in case the
-    // default MRUInfoBoxContextSwitchStrategy is not sufficiently usable.
-    public abstract class InfoBoxContextSwitchStrategy
-    {
-        public abstract bool InfoBoxVisible (ViewContext context);
-        public abstract bool HistogramVisible (ViewContext context);
-
-        public abstract bool InfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry);
-
-        public abstract void SetInfoBoxVisible (ViewContext context, bool visible);
-        public abstract void SetHistogramVisible (ViewContext context, bool visible);
-
-        public abstract void SetInfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry, bool visible);
-    }
-
-    // Values are stored as strings, because bool is not nullable through Preferences.
-    public class MRUInfoBoxContextSwitchStrategy : InfoBoxContextSwitchStrategy
-    {
-        public const string PREF_PREFIX = Preferences.APP_FSPOT + "ui";
-
-        private string PrefKeyForContext (ViewContext context, string item)
-        {
-            return String.Format ("{0}/{1}_visible/{2}", PREF_PREFIX, item, context);
-        }
-
-        private string PrefKeyForContext (ViewContext context, string parent, string item)
-        {
-            return String.Format ("{0}/{1}_visible/{2}/{3}", PREF_PREFIX, parent, item, context);
-        }
-
-        private bool VisibilityForContext (ViewContext context, string item, bool default_value)
-        {
-            string visible = Preferences.Get<string> (PrefKeyForContext (context, item));
-            if (visible == null)
-                return default_value;
-            else
-                return visible == "1";
-        }
-
-        private bool VisibilityForContext (ViewContext context, string parent, string item, bool default_value)
-        {
-            string visible = Preferences.Get<string> (PrefKeyForContext (context, parent, item));
-            if (visible == null)
-                return default_value;
-            else
-                return visible == "1";
-        }
-
-        private void SetVisibilityForContext (ViewContext context, string item, bool visible)
-        {
-            Preferences.Set (PrefKeyForContext (context, item), visible ? "1" : "0");
-        }
-
-        private void SetVisibilityForContext (ViewContext context, string parent, string item, bool visible)
-        {
-            Preferences.Set (PrefKeyForContext (context, parent, item), visible ? "1" : "0");
-        }
-
-        public override bool InfoBoxVisible (ViewContext context)
-        {
-            return VisibilityForContext (context, "infobox", true);
-        }
-
-        public override bool HistogramVisible (ViewContext context)
-        {
-            return VisibilityForContext (context, "histogram", true);
-        }
-
-        public override bool InfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry)
-        {
-            if (entry.AlwaysVisible)
-                return true;
-            
-            return VisibilityForContext (context, "infobox", entry.Id, true);
-        }
-
-        public override void SetInfoBoxVisible (ViewContext context, bool visible)
-        {
-            SetVisibilityForContext (context, "infobox", visible);
-        }
-
-        public override void SetHistogramVisible (ViewContext context, bool visible)
-        {
-            SetVisibilityForContext (context, "histogram", visible);
-        }
-
-        public override void SetInfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry, bool visible)
-        {
-            Hyena.Log.DebugFormat ("Set Visibility for Entry {0} to {1}", entry.Id, visible);
-            if (entry.AlwaysVisible)
-                throw new Exception ("entry visibility cannot be set");
-            
-            SetVisibilityForContext (context, "infobox", entry.Id, visible);
-        }
-    }
+	}
+
+	// Decides whether infobox / histogram should be shown for each context. Implemented
+	// using the Strategy pattern, to make it swappable easily, in case the
+	// default MRUInfoBoxContextSwitchStrategy is not sufficiently usable.
+	public abstract class InfoBoxContextSwitchStrategy
+	{
+		public abstract bool InfoBoxVisible (ViewContext context);
+		public abstract bool HistogramVisible (ViewContext context);
+
+		public abstract bool InfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry);
+
+		public abstract void SetInfoBoxVisible (ViewContext context, bool visible);
+		public abstract void SetHistogramVisible (ViewContext context, bool visible);
+
+		public abstract void SetInfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry, bool visible);
+	}
+
+	// Values are stored as strings, because bool is not nullable through Preferences.
+	public class MRUInfoBoxContextSwitchStrategy : InfoBoxContextSwitchStrategy
+	{
+		public const string PREF_PREFIX = Preferences.APP_FSPOT + "ui";
+
+		private string PrefKeyForContext (ViewContext context, string item)
+		{
+			return String.Format ("{0}/{1}_visible/{2}", PREF_PREFIX, item, context);
+		}
+
+		private string PrefKeyForContext (ViewContext context, string parent, string item)
+		{
+			return String.Format ("{0}/{1}_visible/{2}/{3}", PREF_PREFIX, parent, item, context);
+		}
+
+		private bool VisibilityForContext (ViewContext context, string item, bool default_value)
+		{
+			string visible = Preferences.Get<string> (PrefKeyForContext (context, item));
+			return visible == null ? default_value : visible == "1";
+		}
+
+		private bool VisibilityForContext (ViewContext context, string parent, string item, bool default_value)
+		{
+			string visible = Preferences.Get<string> (PrefKeyForContext (context, parent, item));
+			return visible == null ? default_value : visible == "1";
+		}
+
+		private void SetVisibilityForContext (ViewContext context, string item, bool visible)
+		{
+			Preferences.Set (PrefKeyForContext (context, item), visible ? "1" : "0");
+		}
+
+		private void SetVisibilityForContext (ViewContext context, string parent, string item, bool visible)
+		{
+			Preferences.Set (PrefKeyForContext (context, parent, item), visible ? "1" : "0");
+		}
+
+		public override bool InfoBoxVisible (ViewContext context)
+		{
+			return VisibilityForContext (context, "infobox", true);
+		}
+
+		public override bool HistogramVisible (ViewContext context)
+		{
+			return VisibilityForContext (context, "histogram", true);
+		}
+
+		public override bool InfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry)
+		{
+			if (entry.AlwaysVisible)
+				return true;
+			
+			return VisibilityForContext (context, "infobox", entry.Id, true);
+		}
+
+		public override void SetInfoBoxVisible (ViewContext context, bool visible)
+		{
+			SetVisibilityForContext (context, "infobox", visible);
+		}
+
+		public override void SetHistogramVisible (ViewContext context, bool visible)
+		{
+			SetVisibilityForContext (context, "histogram", visible);
+		}
+
+		public override void SetInfoEntryVisible (ViewContext context, InfoBox.InfoEntry entry, bool visible)
+		{
+			Hyena.Log.DebugFormat ("Set Visibility for Entry {0} to {1}", entry.Id, visible);
+			if (entry.AlwaysVisible)
+				throw new Exception ("entry visibility cannot be set");
+			
+			SetVisibilityForContext (context, "infobox", entry.Id, visible);
+		}
+	}
 }
diff --git a/src/Clients/MainApp/FSpot.Widgets/Loupe.cs b/src/Clients/MainApp/FSpot.Widgets/Loupe.cs
index 4d22df6..01dba05 100644
--- a/src/Clients/MainApp/FSpot.Widgets/Loupe.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/Loupe.cs
@@ -233,7 +233,7 @@ namespace FSpot.Widgets {
 		}
 
 		Gdk.Point Center;
-	        Requisition Bounds;
+		Requisition Bounds;
 
 		public void Layout ()
 		{
@@ -298,16 +298,17 @@ namespace FSpot.Widgets {
 			CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);
 
 			g.Arc (0, 0, radius, 0, 2 * Math.PI);
-			g.Fill ();
-
-			if (overlay != null) {
-				CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
-				g.Arc (0, 0, radius, angle, angle + Math.PI);
-				g.ClosePath ();
-				g.FillPreserve ();
-				g.Source = new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0));
-				g.Stroke ();
-			}
+			g.Fill ();
+
+			if (overlay == null)
+				return;
+
+			CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
+			g.Arc (0, 0, radius, angle, angle + Math.PI);
+			g.ClosePath ();
+			g.FillPreserve ();
+			g.Source = new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0));
+			g.Stroke ();
 		}
 
 		protected override bool OnExposeEvent (Gdk.EventExpose args)
@@ -350,28 +351,28 @@ namespace FSpot.Widgets {
 
 			if (!rotate) {
 				return MoveWindow ();
-			} else {
-				Gdk.Point initial = start_root;
-				Gdk.Point hot = start_hot;
-				Gdk.Point win = Gdk.Point.Zero;
+			}
+
+			Gdk.Point initial = start_root;
+			Gdk.Point hot = start_hot;
+			Gdk.Point win = Gdk.Point.Zero;
 
-				hot.X += win.X;
-				hot.Y += win.Y;
+			hot.X += win.X;
+			hot.Y += win.Y;
 
-				initial.X -= hot.X;
-				initial.Y -= hot.Y;
-				Gdk.Point now = root_pos;
-				now.X -= hot.X;
-				now.Y -= hot.Y;
+			initial.X -= hot.X;
+			initial.Y -= hot.Y;
+			Gdk.Point now = root_pos;
+			now.X -= hot.X;
+			now.Y -= hot.Y;
 
-				Vector v1 = new Vector (initial);
-				Vector v2 = new Vector (now);
+			Vector v1 = new Vector (initial);
+			Vector v2 = new Vector (now);
 
-				double angle = Vector.AngleBetween (v1, v2);
+			double angle = Vector.AngleBetween (v1, v2);
 
-				Angle = start_angle + angle;
-				return false;
-			}
+			Angle = start_angle + angle;
+			return false;
 		}
 
 		private bool MoveWindow ()
@@ -448,11 +449,8 @@ namespace FSpot.Widgets {
 			case Gdk.Key.v:
 				App.Instance.Organizer.HideLoupe ();
 				args.RetVal = true;
-				break;
-			default:
-				break;
-			}
-			return;
+				break;
+			}
 		}
 
 		protected override void OnDestroyed ()
diff --git a/src/Clients/MainApp/FSpot.Widgets/MetadataDisplay.cs b/src/Clients/MainApp/FSpot.Widgets/MetadataDisplay.cs
index e412af5..c182731 100644
--- a/src/Clients/MainApp/FSpot.Widgets/MetadataDisplay.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/MetadataDisplay.cs
@@ -63,22 +63,18 @@ namespace FSpot.Widgets {
 
 		VBox main_vbox;
 		Label metadata_message;
-		State display;
-
-		private MetadataDisplayPage page;
-		public MetadataDisplayPage Page {
-			set { page = value; }
-			get { return page; }
-		}
-
+		State display;
+
+		public MetadataDisplayPage Page { get; set; }
+
 		// stores list of the expanded expanders
 		List<string> open_list;
 
 		ListStore extended_metadata;
 
-		bool up_to_date = false;
-
-		enum State {
+		bool up_to_date = false;
+
+		new enum State {
 			metadata,
 			message
 		};
@@ -215,7 +211,7 @@ namespace FSpot.Widgets {
 
 		public void HandleExpanderActivated (object sender, EventArgs e)
 		{
-			Expander expander = (Expander) sender;
+			Expander expander = sender as Expander;
 			if (expander.Expanded)
 				open_list.Add (expander.Label);
 			else
@@ -372,6 +368,7 @@ namespace FSpot.Widgets {
 				}
 			}*/
 
+			// FIXME: Some of this will not work because of the variables declared about (unreachable code)
 			if (empty) {
 				string msg;
 				if (photo == null) {
diff --git a/src/Clients/MainApp/FSpot.Widgets/PhotoImageView.cs b/src/Clients/MainApp/FSpot.Widgets/PhotoImageView.cs
index 1f8806b..a0ad833 100644
--- a/src/Clients/MainApp/FSpot.Widgets/PhotoImageView.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/PhotoImageView.cs
@@ -46,33 +46,33 @@ namespace FSpot.Widgets {
 	public class PhotoImageView : ImageView {
 #region public API
 
-		protected PhotoImageView (IntPtr raw) : base (raw) { }
-
+		protected PhotoImageView (IntPtr raw) : base (raw)
+		{
+			ShowProgress = true;
+		}
+
 		public PhotoImageView (IBrowsableCollection query) : this (new BrowsablePointer (query, -1))
 		{
 		}
 
-		public PhotoImageView (BrowsablePointer item) : base ()
-		{
+		public PhotoImageView (BrowsablePointer item)
+		{
+			ShowProgress = true;
 			Accelerometer.OrientationChanged += HandleOrientationChanged;
 			Preferences.SettingChanged += OnPreferencesChanged;
 
-			this.item = item;
+			this.Item = item;
 			item.Changed += HandlePhotoItemChanged;
-		}
-
-		public BrowsablePointer Item {
-			get { return item; }
-		}
-
+		}
+
+		public BrowsablePointer Item { get; protected set; }
+
 		public IBrowsableCollection Query {
-			get { return item.Collection; }
-		}
-
-		public Loupe Loupe {
-			get { return loupe; }
-		}
-
+			get { return Item.Collection; }
+		}
+
+		public Loupe Loupe { get; protected set; }
+
 		public Gdk.Pixbuf CompletePixbuf ()
 		{
 			//FIXME: this should be an async call
@@ -256,7 +256,7 @@ namespace FSpot.Widgets {
 				// than try to load the image one last time.
 				try {
 					Log.Warning ("Falling back to file loader");
-					Pixbuf = PhotoLoader.Load (item.Collection, item.Index);
+					Pixbuf = PhotoLoader.Load (Item.Collection, Item.Index);
 				} catch (Exception e) {
 					LoadErrorImage (e);
 				}
@@ -272,27 +272,22 @@ namespace FSpot.Widgets {
 			else
 				ZoomFit ();
 
-			progressive_display = true;
+			ShowProgress = true;
 
 			if (prev != this.Pixbuf && prev != null)
 				prev.Dispose ();
 		}
-#endregion
-
-		protected BrowsablePointer item;
-		protected Loupe loupe;
+#endregion
+
 		protected Loupe sharpener;
 
 		void HandleOrientationChanged (object sender, EventArgs e)
 		{
 			Reload ();
-		}
-
-		bool progressive_display = true;
-		bool ShowProgress {
-			get { return progressive_display; }
-		}
-
+		}
+
+		private bool ShowProgress { get; set; }
+
 		void LoadErrorImage (System.Exception e)
 		{
 			// FIXME we should check the exception type and do something
@@ -315,7 +310,7 @@ namespace FSpot.Widgets {
 			if (args != null &&
 			    args.PreviousItem != null &&
 			    Item.IsValid &&
-			    (args.PreviousIndex != item.Index) &&
+			    (args.PreviousIndex != Item.Index) &&
 			    (this.Item.Current.DefaultVersion.Uri == args.PreviousItem.DefaultVersion.Uri))
 				return;
 
@@ -332,7 +327,7 @@ namespace FSpot.Widgets {
 			    args.PreviousItem != null &&
 			    Item.IsValid &&
 			    Item.Current.DefaultVersion.Uri == args.PreviousItem.DefaultVersion.Uri)
-				progressive_display = false;
+				ShowProgress = false;
 
 			try {
 				if (Item.IsValid)
@@ -354,8 +349,8 @@ namespace FSpot.Widgets {
 
 		private void HandleLoupeDestroy (object sender, EventArgs args)
 		{
-			if (sender == loupe)
-				loupe = null;
+			if (sender == Loupe)
+				Loupe = null;
 
 			if (sender == sharpener)
 				sharpener = null;
@@ -365,12 +360,12 @@ namespace FSpot.Widgets {
 
 		public void ShowHideLoupe ()
 		{
-			if (loupe == null) {
-				loupe = new Loupe (this);
-				loupe.Destroyed += HandleLoupeDestroy;
-				loupe.Show ();
+			if (Loupe == null) {
+				Loupe = new Loupe (this);
+				Loupe.Destroyed += HandleLoupeDestroy;
+				Loupe.Show ();
 			} else {
-				loupe.Destroy ();
+				Loupe.Destroy ();
 			}
 
 		}
diff --git a/src/Clients/MainApp/FSpot.Widgets/SelectionCollectionGridView.cs b/src/Clients/MainApp/FSpot.Widgets/SelectionCollectionGridView.cs
index 4d22b22..404f95f 100644
--- a/src/Clients/MainApp/FSpot.Widgets/SelectionCollectionGridView.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/SelectionCollectionGridView.cs
@@ -39,494 +39,493 @@ using Gtk;
 namespace FSpot.Widgets
 {
 
-    // TODO: This event ahndler is a hack. The default event from a widget
-    //       (DragBegin) should be used, but therfore, the event must be fired
-    //       correctly.
-    public delegate void StartDragHandler (object o, StartDragArgs args);
+	// TODO: This event ahndler is a hack. The default event from a widget
+	//       (DragBegin) should be used, but therfore, the event must be fired
+	//       correctly.
+	public delegate void StartDragHandler (object o, StartDragArgs args);
 
-    public class StartDragArgs {
-        public Event Event { get; set; }
-        public uint Button { get; set; }
+	public class StartDragArgs {
+		public Event Event { get; set; }
+		public uint Button { get; set; }
 
-        public StartDragArgs (uint but, Event evt) {
-            this.Button = but;
-            this.Event = evt;
-        }
-    }
+		public StartDragArgs (uint but, Event evt) {
+			this.Button = but;
+			this.Event = evt;
+		}
+	}
 
 
-    public class SelectionCollectionGridView : CollectionGridView
-    {
+	public class SelectionCollectionGridView : CollectionGridView
+	{
 
 #region Public Properties
 
-        public SelectionCollection Selection {
-            get; private set;
-        }
-
-        // Focus Handling
-        private int real_focus_cell;
-        public int FocusCell {
-            get { return real_focus_cell; }
-            set {
-                if (value != real_focus_cell) {
-                    value = Math.Max (value, 0);
-                    value = Math.Min (value, Collection.Count - 1);
-                    InvalidateCell (value);
-                    InvalidateCell (real_focus_cell);
-                    real_focus_cell = value;
-                }
-            }
-        }
+		public SelectionCollection Selection {
+			get; private set;
+		}
+
+		// Focus Handling
+		private int real_focus_cell;
+		public int FocusCell {
+			get { return real_focus_cell; }
+			set {
+				if (value != real_focus_cell) {
+					value = Math.Max (value, 0);
+					value = Math.Min (value, Collection.Count - 1);
+					InvalidateCell (value);
+					InvalidateCell (real_focus_cell);
+					real_focus_cell = value;
+				}
+			}
+		}
 
 #endregion
 
 #region Constructors
 
-        public SelectionCollectionGridView (IntPtr raw) : base (raw)
-        {
-        }
+		public SelectionCollectionGridView (IntPtr raw) : base (raw)
+		{
+		}
 
-        public SelectionCollectionGridView (IBrowsableCollection collection) : base (collection)
-        {
-            Selection = new SelectionCollection (Collection);
+		public SelectionCollectionGridView (IBrowsableCollection collection) : base (collection)
+		{
+			Selection = new SelectionCollection (Collection);
 
-            Selection.DetailedChanged += delegate(IBrowsableCollection sender, Int32 [] ids) {
-                if (ids == null)
-                    QueueDraw ();
-                else
-                    foreach (int id in ids)
-                        InvalidateCell (id);
-            };
+			Selection.DetailedChanged += delegate(IBrowsableCollection sender, Int32 [] ids) {
+				if (ids == null)
+					QueueDraw ();
+				else
+					foreach (int id in ids)
+						InvalidateCell (id);
+			};
 
-            AddEvents ((int) EventMask.KeyPressMask
-                     | (int) EventMask.KeyReleaseMask
-                     | (int) EventMask.ButtonPressMask
-                     | (int) EventMask.ButtonReleaseMask
-                     | (int) EventMask.PointerMotionMask
-                     | (int) EventMask.PointerMotionHintMask);
+			AddEvents ((int) EventMask.KeyPressMask
+					 | (int) EventMask.KeyReleaseMask
+					 | (int) EventMask.ButtonPressMask
+					 | (int) EventMask.ButtonReleaseMask
+					 | (int) EventMask.PointerMotionMask
+					 | (int) EventMask.PointerMotionHintMask);
 
-            CanFocus = true;
-        }
+			CanFocus = true;
+		}
 
 #endregion
 
 #region Event Handlers
 
-        public event EventHandler<BrowsableEventArgs> DoubleClicked;
+		public event EventHandler<BrowsableEventArgs> DoubleClicked;
 
-        // TODO: hack. See definition of StartDragHandler
-        public event StartDragHandler StartDrag;
+		// TODO: hack. See definition of StartDragHandler
+		public event StartDragHandler StartDrag;
 
 #endregion
 
 #region Drawing Methods
 
-        protected override void DrawPhoto (int cell_num, Rectangle cell_area, Rectangle expose_area, bool selected, bool focussed)
-        {
-            base.DrawPhoto (cell_num, cell_area, expose_area, Selection.Contains (cell_num), (FocusCell == cell_num));
-        }
+		protected override void DrawPhoto (int cell_num, Rectangle cell_area, Rectangle expose_area, bool selected, bool focussed)
+		{
+			base.DrawPhoto (cell_num, cell_area, expose_area, Selection.Contains (cell_num), (FocusCell == cell_num));
+		}
 
-        protected override bool OnExposeEvent (Gdk.EventExpose args)
-        {
-            bool ret = base.OnExposeEvent (args);
+		protected override bool OnExposeEvent (Gdk.EventExpose args)
+		{
+			bool ret = base.OnExposeEvent (args);
 
-            foreach (Rectangle area in args.Region.GetRectangles ()) {
-                DrawSelection (area);
-            }
+			foreach (Rectangle area in args.Region.GetRectangles ()) {
+				DrawSelection (area);
+			}
 
-            return ret;
-        }
+			return ret;
+		}
 
-        private void DrawSelection (Rectangle expose_area)
-        {
-            if ( ! isRectSelection)
-                return;
+		private void DrawSelection (Rectangle expose_area)
+		{
+			if ( ! isRectSelection)
+				return;
 
-            Gdk.Rectangle region;
-            if ( ! expose_area.Intersect (rect_select, out region))
-                return;
+			Gdk.Rectangle region;
+			if ( ! expose_area.Intersect (rect_select, out region))
+				return;
 
-            // draw selection
-            using (Cairo.Context cairo_g = CairoHelper.Create (BinWindow)) {
+			// draw selection
+			using (Cairo.Context cairo_g = CairoHelper.Create (BinWindow)) {
 
-                Gdk.Color color = Style.Background(StateType.Selected);
-                cairo_g.Color = new Cairo.Color (color.Red/65535.0, color.Green/65535.0, color.Blue/65535.0, 0.5);
-                cairo_g.Rectangle (region.X, region.Y, region.Width, region.Height);
-                cairo_g.Fill ();
+				Gdk.Color color = Style.Background(StateType.Selected);
+				cairo_g.Color = new Cairo.Color (color.Red/65535.0, color.Green/65535.0, color.Blue/65535.0, 0.5);
+				cairo_g.Rectangle (region.X, region.Y, region.Width, region.Height);
+				cairo_g.Fill ();
 
-            }
+			}
 
-            //((IDisposable) cairo_g.Target).Dispose ();
-            //((IDisposable) cairo_g).Dispose ();
-        }
+			//((IDisposable) cairo_g.Target).Dispose ();
+			//((IDisposable) cairo_g).Dispose ();
+		}
 
 #endregion
 
 #region Utility Methods
 
-        // TODO: move this to SelectionCollection
-        public void SelectAllCells ()
-        {
-            Selection.Add (0, Collection.Count - 1);
-        }
+		// TODO: move this to SelectionCollection
+		public void SelectAllCells ()
+		{
+			Selection.Add (0, Collection.Count - 1);
+		}
 
-        protected virtual void ContextMenu (EventButton evnt, int cell_num)
-        {
-        }
+		protected virtual void ContextMenu (EventButton evnt, int cell_num)
+		{
+		}
 
 #endregion
 
 #region Event Handler
 
-        // TODO: the following code need to be cleaned up.
-        // TODO: rubberband selection behaves different than Gtk.IconView. This needs to be fixed.
-        // TODO: selection by clicks behaves different than Gtk.IconView. This needs to be fixed.
-
-        protected override bool OnButtonPressEvent (EventButton evnt)
-        {
-            int cell_num = CellAtPosition ((int) evnt.X, (int) evnt.Y);
-
-            start_select_event = evnt;
-
-            selection_start = new Point ((int) evnt.X, (int) evnt.Y);
-            selection_modifier = evnt.State;
-
-            isRectSelection = false;
-            isDragDrop = false;
-
-            switch (evnt.Type) {
-            case EventType.TwoButtonPress:
-                if (evnt.Button != 1 ||
-                    (evnt.State &  (ModifierType.ControlMask | ModifierType.ShiftMask)) != 0)
-                    return false;
-                if (DoubleClicked != null)
-                    DoubleClicked (this, new BrowsableEventArgs (cell_num, null));
-                return true;
-
-            case EventType.ButtonPress:
-                GrabFocus ();
-                // on a cell : context menu if button 3
-                // cell selection is done on button release
-                if (evnt.Button == 3) {
-                    ContextMenu (evnt, cell_num);
-                    return true;
-                } else {
-                    return false;
-                }
-            }
-
-            return false;
-        }
-
-        protected override bool OnButtonReleaseEvent (EventButton evnt)
-        {
-            if (isRectSelection) {
-                // remove scrolling and rectangular selection
-                if (scroll_timeout != 0) {
-                    GLib.Source.Remove (scroll_timeout);
-                    scroll_timeout = 0;
-                }
-
-                isRectSelection = false;
-                if (BinWindow != null) {
-                    BinWindow.InvalidateRect (rect_select, false);
-                    BinWindow.ProcessUpdates (true);
-                }
-                rect_select = new Rectangle();
-            } else if (!isDragDrop) {
-                int cell_num = CellAtPosition ((int) evnt.X, (int) evnt.Y);
-                if (cell_num != -1) {
-                    if ((evnt.State & ModifierType.ControlMask) != 0) {
-                        Selection.ToggleCell (cell_num);
-                    } else if ((evnt.State & ModifierType.ShiftMask) != 0) {
-                        Selection.Add (FocusCell, cell_num);
-                    } else {
-                        Selection.Clear ();
-                        Selection.Add (cell_num);
-                    }
-                    FocusCell = cell_num;
-                }
-            }
-            isDragDrop = false;
-
-            return true;
-        }
-
-        // rectangle of dragging selection
-        private Rectangle rect_select;
-        private Point selection_start;
-        private Point selection_end;
-        private ModifierType selection_modifier;
-
-        private bool isRectSelection = false;
-        private bool isDragDrop = false;
-
-        // initial selection
-        private int[] start_select_selection;
-        // initial event used to detect drag&drop
-        private EventButton start_select_event;
-        // timer using when scrolling selection
-        private uint scroll_timeout = 0;
-
-        private Rectangle BoundedRectangle (Point p1, Point p2)
-        {
-            return new Rectangle (Math.Min (p1.X, p2.X),
-                                  Math.Min (p1.Y, p2.Y),
-                                  Math.Abs (p1.X - p2.X) + 1,
-                                  Math.Abs (p1.Y- p2.Y) + 1);
-        }
-
-        protected Point GetPointer ()
-        {
-            int x, y;
-            GetPointer (out x, out y);
-
-            return new Point (x + (int) Hadjustment.Value, y + (int) Vadjustment.Value);
-        }
-
-        // during pointer motion, select/toggle pictures between initial x/y (param)
-        // and current x/y (get pointer)
-        private void UpdateRubberband ()
-        {
-            // determine old and new selection
-            var old_selection = rect_select;
-            selection_end = GetPointer ();
-            var new_selection = BoundedRectangle (selection_start, selection_end);
-
-            // determine region to invalidate
-            var region = Region.Rectangle (old_selection);
-            region.Xor (Region.Rectangle (new_selection));
-            region.Shrink (-1, -1);
-
-            BinWindow.InvalidateRegion (region, true);
-
-            rect_select = new_selection;
-            UpdateRubberbandSelection ();
-        }
-
-        private void UpdateRubberbandSelection ()
-        {
-            var selected_area = BoundedRectangle (selection_start, selection_end);
-
-            // Restore initial selection
-            var initial_selection = Selection.ToBitArray();
-            Selection.Clear (false);
-            foreach (int i in start_select_selection)
-                Selection.Add (i, false);
-
-            // Set selection
-            int first = -1;
-            foreach (var cell_num in CellsInRect (selected_area)) {
-                if (first == -1)
-                    first = cell_num;
-
-                if ((selection_modifier & ModifierType.ControlMask) == 0)
-                    Selection.Add (cell_num, false);
-                else
-                    Selection.ToggleCell (cell_num, false);
-            }
-            if (first != -1)
-                FocusCell = first;
-
-            // fire events for cells which have changed selection flag
-            var new_selection = Selection.ToBitArray();
-            var selection_changed = initial_selection.Xor (new_selection);
-            var changed = new List<int>();
-            for (int i = 0; i < selection_changed.Length; i++)
-                if (selection_changed.Get(i))
-                    changed.Add (i);
-            if (changed.Count != 0)
-                Selection.SignalChange (changed.ToArray());
-        }
-
-        // if scroll is required, a timeout is fired
-        // until the button is release or the pointer is
-        // in window again
-        private int deltaVscroll;
-        private bool HandleMotionTimeout ()
-        {
-            int new_x, new_y;
-
-           // do scroll
-            double newVadj = Vadjustment.Value;
-            if (deltaVscroll < 130)
-                deltaVscroll += 15;
-
-            Gdk.ModifierType new_mod;
-            Display.GetPointer (out new_x, out new_y, out new_mod);
-            GetPointer (out new_x, out new_y);
-
-            if (new_y <= 0) {
-                newVadj -= deltaVscroll;
-                if (newVadj < 0)
-                    newVadj = 0;
-            } else if ((new_y > Allocation.Height) &&
-                   (newVadj < Vadjustment.Upper - Allocation.Height - deltaVscroll))
-                newVadj += deltaVscroll;
-            Vadjustment.Value = newVadj;
-
-            UpdateRubberband ();// (new Point (new_x + (int) Hadjustment.Value, new_y + (int) Vadjustment.Value));
-
-            Vadjustment.ChangeValue ();
-
-            // stop firing timeout when no button pressed
-            return (new_mod & (ModifierType.Button1Mask | ModifierType.Button3Mask)) != 0;
-        }
-
-        protected override bool OnMotionNotifyEvent (EventMotion evnt)
-        {
-            if ((evnt.State & (ModifierType.Button1Mask | ModifierType.Button3Mask)) == 0)
-                return false;
-
-            if (! Gtk.Drag.CheckThreshold (this, selection_start.X, selection_start.Y,
-                                       (int) evnt.X, (int) evnt.Y))
-                return false;
-
-            if (isRectSelection) {
-                // scroll if out of window
-                double d_x, d_y;
-                deltaVscroll = 30;
-
-                if (EventHelper.GetCoords (evnt, out d_x, out d_y)) {
-                    int new_y = (int) d_y;
-                    if ((new_y <= 0) || (new_y >= Allocation.Height)) {
-                        if (scroll_timeout == 0)
-                            scroll_timeout = GLib.Timeout.Add (100, new GLib.TimeoutHandler (HandleMotionTimeout));
-                    } else if (scroll_timeout != 0) {
-                        GLib.Source.Remove (scroll_timeout);
-                        scroll_timeout = 0;
-                    }
-                } else if (scroll_timeout != 0) {
-                    GLib.Source.Remove (scroll_timeout);
-                    scroll_timeout = 0;
-                }
-
-                // handle selection
-                UpdateRubberband ();
-                //SelectMotion (new Point ((int) args.Event.X, (int) args.Event.Y));
-            } else  {
-                int cell_num = CellAtPosition (selection_start);
-
-                if (Selection.Contains (cell_num)) {
-                    // on a selected cell : do drag&drop
-                    isDragDrop = true;
-                    if (StartDrag != null) {
-                        uint but;
-                        if ((evnt.State & ModifierType.Button1Mask) != 0)
-                            but = 1;
-                        else
-                            but = 3;
-                        StartDrag (this, new StartDragArgs(but, start_select_event));
-                    }
-                } else {
-                    // not on a selected cell : do rectangular select
-                    isRectSelection = true;
-
-                    // ctrl : toggle selected, shift : keep selected
-                    if ((evnt.State & (ModifierType.ShiftMask | ModifierType.ControlMask)) == 0)
-                        Selection.Clear ();
-
-                    start_select_selection = Selection.Ids; // keep initial selection
-                    // no rect draw at beginning
-                    rect_select = Rectangle.Zero;
-
-                    return false;
-                }
-            }
-
-            return true;
-        }
-
-        protected override bool OnKeyPressEvent (EventKey evnt)
-        {
-            int focus_old = FocusCell;
-
-            bool shift = ModifierType.ShiftMask == (evnt.State & ModifierType.ShiftMask);
-            bool control = ModifierType.ControlMask == (evnt.State & ModifierType.ControlMask);
-
-            switch (evnt.Key) {
-            case Gdk.Key.Down:
-            case Gdk.Key.J:
-            case Gdk.Key.j:
-                FocusCell += VisibleColums;
-                break;
-
-            case Gdk.Key.Left:
-            case Gdk.Key.H:
-            case Gdk.Key.h:
-                if (control && shift)
-                    FocusCell -= FocusCell % VisibleColums;
-                else
-                    FocusCell--;
-                break;
-
-            case Gdk.Key.Right:
-            case Gdk.Key.L:
-            case Gdk.Key.l:
-                if (control && shift)
-                    FocusCell += VisibleColums - (FocusCell % VisibleColums) - 1;
-                else
-                    FocusCell++;
-                break;
-
-            case Gdk.Key.Up:
-            case Gdk.Key.K:
-            case Gdk.Key.k:
-                FocusCell -= VisibleColums;
-                break;
-
-            case Gdk.Key.Page_Up:
-                FocusCell -= VisibleColums * VisibleRows;
-                break;
-
-            case Gdk.Key.Page_Down:
-                FocusCell += VisibleColums * VisibleRows;
-                break;
-
-            case Gdk.Key.Home:
-                FocusCell = 0;
-                break;
-
-            case Gdk.Key.End:
-                FocusCell = Collection.Count - 1;
-                break;
-
-            case Gdk.Key.R:
-            case Gdk.Key.r:
-                FocusCell = new Random().Next(0, Collection.Count - 1);
-                break;
-
-            case Gdk.Key.space:
-                Selection.ToggleCell (FocusCell);
-                break;
-
-            case Gdk.Key.Return:
-                if (DoubleClicked != null)
-                    DoubleClicked (this, new BrowsableEventArgs (FocusCell, null));
-                break;
-
-            default:
-                return false;
-            }
-
-            if (shift) {
-                if (focus_old != FocusCell && Selection.Contains (focus_old) && Selection.Contains (FocusCell))
-                    Selection.Remove (FocusCell, focus_old);
-                else
-                    Selection.Add (focus_old, FocusCell);
-
-            } else if (!control) {
-                Selection.Clear ();
-                Selection.Add (FocusCell);
-            }
-
-            ScrollTo (FocusCell);
-            return true;
-        }
+		// TODO: the following code need to be cleaned up.
+		// TODO: rubberband selection behaves different than Gtk.IconView. This needs to be fixed.
+		// TODO: selection by clicks behaves different than Gtk.IconView. This needs to be fixed.
+
+		protected override bool OnButtonPressEvent (EventButton evnt)
+		{
+			int cell_num = CellAtPosition ((int) evnt.X, (int) evnt.Y);
+
+			start_select_event = evnt;
+
+			selection_start = new Point ((int) evnt.X, (int) evnt.Y);
+			selection_modifier = evnt.State;
+
+			isRectSelection = false;
+			isDragDrop = false;
+
+			switch (evnt.Type) {
+			case EventType.TwoButtonPress:
+				if (evnt.Button != 1 ||
+					(evnt.State &  (ModifierType.ControlMask | ModifierType.ShiftMask)) != 0)
+					return false;
+				if (DoubleClicked != null)
+					DoubleClicked (this, new BrowsableEventArgs (cell_num, null));
+				return true;
+
+			case EventType.ButtonPress:
+				GrabFocus ();
+				// on a cell : context menu if button 3
+				// cell selection is done on button release
+				if (evnt.Button == 3) {
+					ContextMenu (evnt, cell_num);
+					return true;
+				}
+				return false;
+			}
+
+			return false;
+		}
+
+		protected override bool OnButtonReleaseEvent (EventButton evnt)
+		{
+			if (isRectSelection) {
+				// remove scrolling and rectangular selection
+				if (scroll_timeout != 0) {
+					GLib.Source.Remove (scroll_timeout);
+					scroll_timeout = 0;
+				}
+
+				isRectSelection = false;
+				if (BinWindow != null) {
+					BinWindow.InvalidateRect (rect_select, false);
+					BinWindow.ProcessUpdates (true);
+				}
+				rect_select = new Rectangle();
+			} else if (!isDragDrop) {
+				int cell_num = CellAtPosition ((int) evnt.X, (int) evnt.Y);
+				if (cell_num != -1) {
+					if ((evnt.State & ModifierType.ControlMask) != 0) {
+						Selection.ToggleCell (cell_num);
+					} else if ((evnt.State & ModifierType.ShiftMask) != 0) {
+						Selection.Add (FocusCell, cell_num);
+					} else {
+						Selection.Clear ();
+						Selection.Add (cell_num);
+					}
+					FocusCell = cell_num;
+				}
+			}
+			isDragDrop = false;
+
+			return true;
+		}
+
+		// rectangle of dragging selection
+		private Rectangle rect_select;
+		private Point selection_start;
+		private Point selection_end;
+		private ModifierType selection_modifier;
+
+		private bool isRectSelection = false;
+		private bool isDragDrop = false;
+
+		// initial selection
+		private int[] start_select_selection;
+		// initial event used to detect drag&drop
+		private EventButton start_select_event;
+		// timer using when scrolling selection
+		private uint scroll_timeout = 0;
+
+		private Rectangle BoundedRectangle (Point p1, Point p2)
+		{
+			return new Rectangle (Math.Min (p1.X, p2.X),
+								  Math.Min (p1.Y, p2.Y),
+								  Math.Abs (p1.X - p2.X) + 1,
+								  Math.Abs (p1.Y- p2.Y) + 1);
+		}
+
+		protected Point GetPointer ()
+		{
+			int x, y;
+			GetPointer (out x, out y);
+
+			return new Point (x + (int) Hadjustment.Value, y + (int) Vadjustment.Value);
+		}
+
+		// during pointer motion, select/toggle pictures between initial x/y (param)
+		// and current x/y (get pointer)
+		private void UpdateRubberband ()
+		{
+			// determine old and new selection
+			var old_selection = rect_select;
+			selection_end = GetPointer ();
+			var new_selection = BoundedRectangle (selection_start, selection_end);
+
+			// determine region to invalidate
+			var region = Region.Rectangle (old_selection);
+			region.Xor (Region.Rectangle (new_selection));
+			region.Shrink (-1, -1);
+
+			BinWindow.InvalidateRegion (region, true);
+
+			rect_select = new_selection;
+			UpdateRubberbandSelection ();
+		}
+
+		private void UpdateRubberbandSelection ()
+		{
+			var selected_area = BoundedRectangle (selection_start, selection_end);
+
+			// Restore initial selection
+			var initial_selection = Selection.ToBitArray();
+			Selection.Clear (false);
+			foreach (int i in start_select_selection)
+				Selection.Add (i, false);
+
+			// Set selection
+			int first = -1;
+			foreach (var cell_num in CellsInRect (selected_area)) {
+				if (first == -1)
+					first = cell_num;
+
+				if ((selection_modifier & ModifierType.ControlMask) == 0)
+					Selection.Add (cell_num, false);
+				else
+					Selection.ToggleCell (cell_num, false);
+			}
+			if (first != -1)
+				FocusCell = first;
+
+			// fire events for cells which have changed selection flag
+			var new_selection = Selection.ToBitArray();
+			var selection_changed = initial_selection.Xor (new_selection);
+			var changed = new List<int>();
+			for (int i = 0; i < selection_changed.Length; i++)
+				if (selection_changed.Get(i))
+					changed.Add (i);
+			if (changed.Count != 0)
+				Selection.SignalChange (changed.ToArray());
+		}
+
+		// if scroll is required, a timeout is fired
+		// until the button is release or the pointer is
+		// in window again
+		private int deltaVscroll;
+		private bool HandleMotionTimeout ()
+		{
+			int new_x, new_y;
+
+		   // do scroll
+			double newVadj = Vadjustment.Value;
+			if (deltaVscroll < 130)
+				deltaVscroll += 15;
+
+			Gdk.ModifierType new_mod;
+			Display.GetPointer (out new_x, out new_y, out new_mod);
+			GetPointer (out new_x, out new_y);
+
+			if (new_y <= 0) {
+				newVadj -= deltaVscroll;
+				if (newVadj < 0)
+					newVadj = 0;
+			} else if ((new_y > Allocation.Height) &&
+				   (newVadj < Vadjustment.Upper - Allocation.Height - deltaVscroll))
+				newVadj += deltaVscroll;
+			Vadjustment.Value = newVadj;
+
+			UpdateRubberband ();// (new Point (new_x + (int) Hadjustment.Value, new_y + (int) Vadjustment.Value));
+
+			Vadjustment.ChangeValue ();
+
+			// stop firing timeout when no button pressed
+			return (new_mod & (ModifierType.Button1Mask | ModifierType.Button3Mask)) != 0;
+		}
+
+		protected override bool OnMotionNotifyEvent (EventMotion evnt)
+		{
+			if ((evnt.State & (ModifierType.Button1Mask | ModifierType.Button3Mask)) == 0)
+				return false;
+
+			if (! Gtk.Drag.CheckThreshold (this, selection_start.X, selection_start.Y,
+									   (int) evnt.X, (int) evnt.Y))
+				return false;
+
+			if (isRectSelection) {
+				// scroll if out of window
+				double d_x, d_y;
+				deltaVscroll = 30;
+
+				if (EventHelper.GetCoords (evnt, out d_x, out d_y)) {
+					int new_y = (int) d_y;
+					if ((new_y <= 0) || (new_y >= Allocation.Height)) {
+						if (scroll_timeout == 0)
+							scroll_timeout = GLib.Timeout.Add (100, new GLib.TimeoutHandler (HandleMotionTimeout));
+					} else if (scroll_timeout != 0) {
+						GLib.Source.Remove (scroll_timeout);
+						scroll_timeout = 0;
+					}
+				} else if (scroll_timeout != 0) {
+					GLib.Source.Remove (scroll_timeout);
+					scroll_timeout = 0;
+				}
+
+				// handle selection
+				UpdateRubberband ();
+				//SelectMotion (new Point ((int) args.Event.X, (int) args.Event.Y));
+			} else  {
+				int cell_num = CellAtPosition (selection_start);
+
+				if (Selection.Contains (cell_num)) {
+					// on a selected cell : do drag&drop
+					isDragDrop = true;
+					if (StartDrag != null) {
+						uint but;
+						if ((evnt.State & ModifierType.Button1Mask) != 0)
+							but = 1;
+						else
+							but = 3;
+						StartDrag (this, new StartDragArgs(but, start_select_event));
+					}
+				} else {
+					// not on a selected cell : do rectangular select
+					isRectSelection = true;
+
+					// ctrl : toggle selected, shift : keep selected
+					if ((evnt.State & (ModifierType.ShiftMask | ModifierType.ControlMask)) == 0)
+						Selection.Clear ();
+
+					start_select_selection = Selection.Ids; // keep initial selection
+					// no rect draw at beginning
+					rect_select = Rectangle.Zero;
+
+					return false;
+				}
+			}
+
+			return true;
+		}
+
+		protected override bool OnKeyPressEvent (EventKey evnt)
+		{
+			int focus_old = FocusCell;
+
+			bool shift = ModifierType.ShiftMask == (evnt.State & ModifierType.ShiftMask);
+			bool control = ModifierType.ControlMask == (evnt.State & ModifierType.ControlMask);
+
+			switch (evnt.Key) {
+			case Gdk.Key.Down:
+			case Gdk.Key.J:
+			case Gdk.Key.j:
+				FocusCell += VisibleColums;
+				break;
+
+			case Gdk.Key.Left:
+			case Gdk.Key.H:
+			case Gdk.Key.h:
+				if (control && shift)
+					FocusCell -= FocusCell % VisibleColums;
+				else
+					FocusCell--;
+				break;
+
+			case Gdk.Key.Right:
+			case Gdk.Key.L:
+			case Gdk.Key.l:
+				if (control && shift)
+					FocusCell += VisibleColums - (FocusCell % VisibleColums) - 1;
+				else
+					FocusCell++;
+				break;
+
+			case Gdk.Key.Up:
+			case Gdk.Key.K:
+			case Gdk.Key.k:
+				FocusCell -= VisibleColums;
+				break;
+
+			case Gdk.Key.Page_Up:
+				FocusCell -= VisibleColums * VisibleRows;
+				break;
+
+			case Gdk.Key.Page_Down:
+				FocusCell += VisibleColums * VisibleRows;
+				break;
+
+			case Gdk.Key.Home:
+				FocusCell = 0;
+				break;
+
+			case Gdk.Key.End:
+				FocusCell = Collection.Count - 1;
+				break;
+
+			case Gdk.Key.R:
+			case Gdk.Key.r:
+				FocusCell = new Random().Next(0, Collection.Count - 1);
+				break;
+
+			case Gdk.Key.space:
+				Selection.ToggleCell (FocusCell);
+				break;
+
+			case Gdk.Key.Return:
+				if (DoubleClicked != null)
+					DoubleClicked (this, new BrowsableEventArgs (FocusCell, null));
+				break;
+
+			default:
+				return false;
+			}
+
+			if (shift) {
+				if (focus_old != FocusCell && Selection.Contains (focus_old) && Selection.Contains (FocusCell))
+					Selection.Remove (FocusCell, focus_old);
+				else
+					Selection.Add (focus_old, FocusCell);
+
+			} else if (!control) {
+				Selection.Clear ();
+				Selection.Add (FocusCell);
+			}
+
+			ScrollTo (FocusCell);
+			return true;
+		}
 
 #endregion
 
-    }
+	}
 }
 
diff --git a/src/Clients/MainApp/FSpot.Widgets/Sidebar.cs b/src/Clients/MainApp/FSpot.Widgets/Sidebar.cs
index 9e4f040..8386b7e 100644
--- a/src/Clients/MainApp/FSpot.Widgets/Sidebar.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/Sidebar.cs
@@ -60,9 +60,7 @@ namespace FSpot.Widgets
 		}
 
 		public string PageForContext (ViewContext context) {
-			string name = Preferences.Get<string> (PrefKeyForContext (context));
-			if (name == null)
-				name = DefaultForContext (context);
+			string name = Preferences.Get<string> (PrefKeyForContext (context)) ?? DefaultForContext (context);
 			return name;
 		}
 
@@ -94,13 +92,9 @@ namespace FSpot.Widgets
 		public event IBrowsableCollectionChangedHandler SelectionChanged;
 		public event IBrowsableCollectionItemsChangedHandler SelectionItemsChanged;
 
-		// The photos selected.
-		private IBrowsableCollection selection;
-		public IBrowsableCollection Selection {
-			get { return selection; }
-			private set { selection = value; }
-		}
-
+		// The photos selected.
+		public IBrowsableCollection Selection { get; private set; }
+
 		public event EventHandler ContextChanged;
 
 		private ViewContext view_context = ViewContext.Unknown;
@@ -115,7 +109,7 @@ namespace FSpot.Widgets
 
 		private readonly ISidebarContextSwitchStrategy ContextSwitchStrategy;
 
-		public Sidebar () : base ()
+		public Sidebar ()
 		{
 			ContextSwitchStrategy = new MRUSidebarContextSwitchStrategy ();
 			ContextChanged += HandleContextChanged;
@@ -173,7 +167,7 @@ namespace FSpot.Widgets
 			AppendPage (new SidebarPage (widget, label, icon_name));
 		}
 
-        public void AppendPage (SidebarPage page)
+		public void AppendPage (SidebarPage page)
 		{
 			page.Sidebar = this;
 			page.CanSelectChanged += HandleCanSelectChanged;
diff --git a/src/Clients/MainApp/FSpot.Widgets/SlideShow.cs b/src/Clients/MainApp/FSpot.Widgets/SlideShow.cs
index 47b58c4..cd11570 100644
--- a/src/Clients/MainApp/FSpot.Widgets/SlideShow.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/SlideShow.cs
@@ -55,7 +55,7 @@ namespace FSpot.Widgets
 		{
 		}
 
-		public SlideShow (BrowsablePointer item, uint interval_ms, bool init) : base ()
+		public SlideShow (BrowsablePointer item, uint interval_ms, bool init)
 		{
 			this.item = item;
 			DoubleBuffered = false;
diff --git a/src/Clients/MainApp/FSpot.Widgets/SoftFocus.cs b/src/Clients/MainApp/FSpot.Widgets/SoftFocus.cs
index 03698e4..e5e3c56 100644
--- a/src/Clients/MainApp/FSpot.Widgets/SoftFocus.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/SoftFocus.cs
@@ -33,33 +33,30 @@ using System;
 
 using Cairo;
 
-using Pinta.Core;
-
+using Pinta.Core;
+using Point = Gdk.Point;
+
 namespace FSpot.Widgets {
 
 	public class SoftFocus : IDisposable {
 
 		ImageInfo info;
 		double radius;
-		double amount;
-		Gdk.Point center;
+		double amount;
 		ImageInfo blur;
 		Pattern mask;
 
 		public SoftFocus (ImageInfo info)
 		{
 			this.info = info;
-			center.X = info.Bounds.Width / 2;
-			center.Y = info.Bounds.Height / 2;
+			Center.X = info.Bounds.Width / 2;
+			Center.Y = info.Bounds.Height / 2;
 			Amount = 3;
 			Radius = .5;
-		}
-
-		public Gdk.Point Center {
-			get { return center; }
-			set { center = value; }
-		}
-
+		}
+
+		public Point Center { get; set; }
+
 		public double Amount {
 			get { return amount; }
 			set {
@@ -128,8 +125,8 @@ namespace FSpot.Widgets {
 
 			RadialGradient circle;
 
-			circle = new RadialGradient (center.X * scale, center.Y * scale, radius * max * .7,
-							 center.X * scale, center.Y * scale, radius * max + max * .2);
+			circle = new RadialGradient (Center.X * scale, Center.Y * scale, radius * max * .7,
+							 Center.X * scale, Center.Y * scale, radius * max + max * .2);
 
 			circle.AddColorStop (0, new Cairo.Color (0.0, 0.0, 0.0, 0.0));
 			circle.AddColorStop (1.0, new Cairo.Color (1.0, 1.0, 1.0, 1.0));
diff --git a/src/Clients/MainApp/FSpot.Widgets/TagEntry.cs b/src/Clients/MainApp/FSpot.Widgets/TagEntry.cs
index e5d039c..13322c7 100644
--- a/src/Clients/MainApp/FSpot.Widgets/TagEntry.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/TagEntry.cs
@@ -33,6 +33,7 @@
 //
 
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 
 using FSpot.Core;
@@ -48,18 +49,14 @@ namespace FSpot.Widgets
 		public event TagsAttachedHandler TagsAttached;
 		public event TagsRemovedHandler TagsRemoved;
 
-		TagStore tag_store;
-
-		public TagEntry (TagStore tag_store) : this (tag_store, true)
-		{
-		}
-
+		TagStore tag_store;
+
 		protected TagEntry (System.IntPtr raw)
 		{
 			Raw = raw;
 		}
 
-		public TagEntry (TagStore tag_store, bool update_on_focus_out) : base ()
+		public TagEntry (TagStore tag_store, bool update_on_focus_out = true)
 		{
 			this.tag_store = tag_store;
 			this.KeyPressEvent += HandleKeyPressEvent;
@@ -97,7 +94,7 @@ namespace FSpot.Widgets
 			Update ();
 		}
 
-		public void UpdateFromTagNames (string [] tagnames)
+		public void UpdateFromTagNames (IEnumerable<string> tagnames)
 		{
 			selected_photos_tagnames = new List<string> ();
 			foreach (string tagname in tagnames)
@@ -130,16 +127,9 @@ namespace FSpot.Widgets
 
 		public string [] GetTypedTagNames ()
 		{
-			string [] tagnames = Text.Split (new char [] {','});
-
-			List<string> list = new List<string> ();
-			for (int i = 0; i < tagnames.Length; i ++) {
-				string s = tagnames [i].Trim ();
-
-				if (s.Length > 0)
-					list.Add (s);
-			}
-			return list.ToArray ();
+			string [] tagnames = Text.Split (new char [] {','});
+
+			return tagnames.Select(t => t.Trim()).Where(s => s.Length > 0).ToArray();
 		}
 
 		int tag_completion_index = -1;
@@ -216,7 +206,7 @@ namespace FSpot.Widgets
 					return;
 
 				tag_completion_typed_so_far = Text.Substring (last_comma + 1).TrimStart (new char [] {' '});
-				if (tag_completion_typed_so_far == null || tag_completion_typed_so_far.Length == 0)
+				if (string.IsNullOrEmpty(tag_completion_typed_so_far))
 					return;
 
 				tag_completions = tag_store.GetTagsByNameStart (tag_completion_typed_so_far);
@@ -299,14 +289,11 @@ namespace FSpot.Widgets
 				TagsRemoved (this, remove_tags.ToArray ());
 		}
 
-		private static bool IsTagInList (string [] tags, string tag)
-		{
-			foreach (string t in tags)
-				if (t == tag)
-					return true;
-			return false;
-		}
-
+		private static bool IsTagInList (IEnumerable<string> tags, string tag)
+		{
+			return tags.Any(t => t == tag);
+		}
+
 		private void HandleFocusOutEvent (object o, Gtk.FocusOutEventArgs args)
 		{
 			Update ();
diff --git a/src/Clients/MainApp/FSpot.Widgets/TagMenu.cs b/src/Clients/MainApp/FSpot.Widgets/TagMenu.cs
index 2abdc99..9262b7f 100644
--- a/src/Clients/MainApp/FSpot.Widgets/TagMenu.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/TagMenu.cs
@@ -133,7 +133,7 @@ public class TagMenu : Menu {
 		}
 	}
 
-		public void PopulateFlat (Category cat, Gtk.Menu parent)
+	public void PopulateFlat (Category cat, Gtk.Menu parent)
 	{
 		foreach (Tag t in cat.Children) {
 			TagMenuItem item = TagMenuItem.IndentedItem (t);
diff --git a/src/Clients/MainApp/FSpot.Widgets/ThumbnailCaptionRenderer.cs b/src/Clients/MainApp/FSpot.Widgets/ThumbnailCaptionRenderer.cs
index 3d5e0c4..9d70414 100644
--- a/src/Clients/MainApp/FSpot.Widgets/ThumbnailCaptionRenderer.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/ThumbnailCaptionRenderer.cs
@@ -41,14 +41,6 @@ namespace FSpot.Widgets
     public abstract class ThumbnailCaptionRenderer
     {
 
-#region Constructor
-
-        public ThumbnailCaptionRenderer ()
-        {
-        }
-
-#endregion
-
 #region Drawing Methods
 
         public abstract int GetHeight (Widget widget, int width);
diff --git a/src/Clients/MainApp/FSpot.Widgets/ThumbnailDateCaptionRenderer.cs b/src/Clients/MainApp/FSpot.Widgets/ThumbnailDateCaptionRenderer.cs
index f34db67..5934d8d 100644
--- a/src/Clients/MainApp/FSpot.Widgets/ThumbnailDateCaptionRenderer.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/ThumbnailDateCaptionRenderer.cs
@@ -47,15 +47,7 @@ namespace FSpot.Widgets
 
 #region Private Fields
 
-        private Dictionary <string, Pango.Layout> cache = new Dictionary <string, Pango.Layout> ();
-
-#endregion
-
-#region Constructor
-
-        public ThumbnailDateCaptionRenderer ()
-        {
-        }
+        private readonly Dictionary <string, Pango.Layout> cache = new Dictionary <string, Pango.Layout> ();
 
 #endregion
 
diff --git a/src/Clients/MainApp/FSpot.Widgets/ThumbnailDecorationRenderer.cs b/src/Clients/MainApp/FSpot.Widgets/ThumbnailDecorationRenderer.cs
index 7f6a067..6249838 100644
--- a/src/Clients/MainApp/FSpot.Widgets/ThumbnailDecorationRenderer.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/ThumbnailDecorationRenderer.cs
@@ -42,14 +42,6 @@ namespace FSpot.Widgets
     public abstract class ThumbnailDecorationRenderer
     {
 
-#region Constructor
-
-        public ThumbnailDecorationRenderer ()
-        {
-        }
-
-#endregion
-
 #region Drawing Methods
 
         public abstract void Render (Drawable window,
diff --git a/src/Clients/MainApp/FSpot.Widgets/ThumbnailFilenameCaptionRenderer.cs b/src/Clients/MainApp/FSpot.Widgets/ThumbnailFilenameCaptionRenderer.cs
index 5e93fcd..d023f77 100644
--- a/src/Clients/MainApp/FSpot.Widgets/ThumbnailFilenameCaptionRenderer.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/ThumbnailFilenameCaptionRenderer.cs
@@ -36,13 +36,6 @@ namespace FSpot.Widgets
 
     public class ThumbnailFilenameCaptionRenderer : ThumbnailTextCaptionRenderer
     {
-#region Constructor
-
-        public ThumbnailFilenameCaptionRenderer ()
-        {
-        }
-
-#endregion
 
 #region Drawing Methods
 
diff --git a/src/Clients/MainApp/FSpot.Widgets/ThumbnailRatingDecorationRenderer.cs b/src/Clients/MainApp/FSpot.Widgets/ThumbnailRatingDecorationRenderer.cs
index 91da990..8d99f8a 100644
--- a/src/Clients/MainApp/FSpot.Widgets/ThumbnailRatingDecorationRenderer.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/ThumbnailRatingDecorationRenderer.cs
@@ -47,14 +47,6 @@ namespace FSpot.Widgets
 
 #endregion
 
-#region Constructor
-
-        public ThumbnailRatingDecorationRenderer ()
-        {
-        }
-
-#endregion
-
 #region Drawing Methods
 
         public override void Render (Drawable window,
diff --git a/src/Clients/MainApp/FSpot.Widgets/ThumbnailTextCaptionRenderer.cs b/src/Clients/MainApp/FSpot.Widgets/ThumbnailTextCaptionRenderer.cs
index a77b7e7..b49f9ed 100644
--- a/src/Clients/MainApp/FSpot.Widgets/ThumbnailTextCaptionRenderer.cs
+++ b/src/Clients/MainApp/FSpot.Widgets/ThumbnailTextCaptionRenderer.cs
@@ -41,13 +41,6 @@ namespace FSpot.Widgets
     /// </summary>
     public abstract class ThumbnailTextCaptionRenderer : ThumbnailCaptionRenderer
     {
-#region Constructor
-
-        public ThumbnailTextCaptionRenderer ()
-        {
-        }
-
-#endregion
 
 #region Drawing Methods
 
diff --git a/src/Clients/MainApp/FSpot/Accelerometer.cs b/src/Clients/MainApp/FSpot/Accelerometer.cs
index 2ddb061..83540ad 100644
--- a/src/Clients/MainApp/FSpot/Accelerometer.cs
+++ b/src/Clients/MainApp/FSpot/Accelerometer.cs
@@ -37,6 +37,7 @@ using System;
 using System.IO;
 
 using Hyena;
+
 using TagLib.Image;
 
 namespace FSpot {
@@ -146,8 +147,6 @@ namespace FSpot {
 
 					x -= base_x;
 					y -= base_y;
-
-					return;
 				}
 			} catch (IOException) {
 				x = 0;
diff --git a/src/Clients/MainApp/FSpot/App.cs b/src/Clients/MainApp/FSpot/App.cs
index 3584190..dd01e6c 100644
--- a/src/Clients/MainApp/FSpot/App.cs
+++ b/src/Clients/MainApp/FSpot/App.cs
@@ -239,18 +239,18 @@ namespace FSpot
 			}
 		}
 
-        void HandleImport (string path)
-        {
-            // Some users get wonky URIs here, trying to work around below.
-            // https://bugzilla.gnome.org/show_bug.cgi?id=629248
-            if (path != null && path.StartsWith ("gphoto2:usb:")) {
-                path = String.Format ("gphoto2://[{0}]", path.Substring (8));
-            }
-
-            Hyena.Log.DebugFormat ("Importing from {0}", path);
-            Organizer.Window.Present ();
-            Organizer.ImportFile (path == null ? null : new SafeUri(path));
-        }
+		void HandleImport (string path)
+		{
+			// Some users get wonky URIs here, trying to work around below.
+			// https://bugzilla.gnome.org/show_bug.cgi?id=629248
+			if (path != null && path.StartsWith ("gphoto2:usb:")) {
+				path = String.Format ("gphoto2://[{0}]", path.Substring (8));
+			}
+
+			Hyena.Log.DebugFormat ("Importing from {0}", path);
+			Organizer.Window.Present ();
+			Organizer.ImportFile (path == null ? null : new SafeUri(path));
+		}
 
 		void HandleOrganize ()
 		{
@@ -318,13 +318,13 @@ namespace FSpot
 				if (tag != null) {
 					msg = String.Format (Catalog.GetString ("No photos matching {0} found"), tag.Name);
 					long_msg = String.Format (Catalog.GetString ("The tag \"{0}\" is not applied to any photos. Try adding\n" +
-										     "the tag to some photos or selecting a different tag in the\n" +
-										     "F-Spot preference dialog."), tag.Name);
+											 "the tag to some photos or selecting a different tag in the\n" +
+											 "F-Spot preference dialog."), tag.Name);
 				} else {
 					msg = Catalog.GetString ("Search returned no results");
 					long_msg = Catalog.GetString ("The tag F-Spot is looking for does not exist. Try\n" +
-								      "selecting a different tag in the F-Spot preference\n" +
-								      "dialog.");
+									  "selecting a different tag in the F-Spot preference\n" +
+									  "dialog.");
 				}
 
 				Gtk.Label label = new Gtk.Label (msg);
diff --git a/src/Clients/MainApp/FSpot/ExportStore.cs b/src/Clients/MainApp/FSpot/ExportStore.cs
index 871e456..19cb4ad 100644
--- a/src/Clients/MainApp/FSpot/ExportStore.cs
+++ b/src/Clients/MainApp/FSpot/ExportStore.cs
@@ -86,10 +86,10 @@ namespace FSpot
 		private ExportItem LoadItem (IDataReader reader)
 		{
 			return new ExportItem (Convert.ToUInt32 (reader ["id"]),
-				       Convert.ToUInt32 (reader ["image_id"]),
-				       Convert.ToUInt32 (reader ["image_version_id"]),
-				       reader ["export_type"].ToString (),
-				       reader ["export_token"].ToString ());
+					   Convert.ToUInt32 (reader ["image_id"]),
+					   Convert.ToUInt32 (reader ["image_version_id"]),
+					   reader ["export_type"].ToString (),
+					   reader ["export_token"].ToString ());
 		}
 
 		private void LoadAllItems ()
@@ -119,7 +119,7 @@ namespace FSpot
 		public override void Commit (ExportItem item)
 		{
 			Database.Execute (new HyenaSqliteCommand ("UPDATE exports SET image_id = ?, image_version_id = ?, export_type = ? SET export_token = ? WHERE id = ?",
-                    item.ImageId, item.ImageVersionId, item.ExportType, item.ExportToken, item.Id));
+					item.ImageId, item.ImageVersionId, item.ExportType, item.ExportToken, item.Id));
 
 			EmitChanged (item);
 		}
@@ -134,7 +134,7 @@ namespace FSpot
 		{
 
 			IDataReader reader = Database.Query (new HyenaSqliteCommand ("SELECT id, image_id, image_version_id, export_type, export_token FROM exports WHERE image_id = ? AND image_version_id = ?",
-                    image_id, image_version_id));
+					image_id, image_version_id));
 
 			List<ExportItem> export_items = new List<ExportItem> ();
 			while (reader.Read ()) {
diff --git a/src/Clients/MainApp/FSpot/FolderQueryWidget.cs b/src/Clients/MainApp/FSpot/FolderQueryWidget.cs
index 3aeccd7..8da4449 100644
--- a/src/Clients/MainApp/FSpot/FolderQueryWidget.cs
+++ b/src/Clients/MainApp/FSpot/FolderQueryWidget.cs
@@ -46,7 +46,7 @@ namespace FSpot
 		PhotoQuery query;
 		FolderSet folder_set;
 
-		public FolderQueryWidget (PhotoQuery query) : base ()
+		public FolderQueryWidget (PhotoQuery query)
 		{
 			folder_set = new FolderSet ();
 			this.query = query;
diff --git a/src/Clients/MainApp/FSpot/FullScreenView.cs b/src/Clients/MainApp/FSpot/FullScreenView.cs
index b2f749a..c54ca85 100644
--- a/src/Clients/MainApp/FSpot/FullScreenView.cs
+++ b/src/Clients/MainApp/FSpot/FullScreenView.cs
@@ -45,8 +45,7 @@ using Mono.Unix;
 namespace FSpot {
 	[Binding(Gdk.Key.Escape, "Quit")]
 	public class FullScreenView : Gtk.Window {
-		private ScrolledView scroll;
-		private PhotoImageView view;
+		private ScrolledView scroll;
 		private Notebook notebook;
 		private ControlOverlay controls;
 		private SlideShow display;
@@ -120,15 +119,15 @@ namespace FSpot {
 
 				scroll = new ScrolledView ();
 				scroll.ScrolledWindow.SetPolicy (PolicyType.Never, PolicyType.Never);
-				view = new PhotoImageView (collection);
+				View = new PhotoImageView (collection);
 				// FIXME this should be handled by the new style setting code
-				view.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
+				View.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
 				this.Add (notebook);
-				view.Show ();
-				view.MotionNotifyEvent += HandleViewMotion;
-				view.PointerMode = PointerMode.Scroll;
+				View.Show ();
+				View.MotionNotifyEvent += HandleViewMotion;
+				View.PointerMode = PointerMode.Scroll;
 
-				scroll.ScrolledWindow.Add (view);
+				scroll.ScrolledWindow.Add (View);
 
 				Toolbar tbar = new Toolbar ();
 				tbar.ToolbarStyle = Gtk.ToolbarStyle.BothHoriz;
@@ -140,14 +139,14 @@ namespace FSpot {
 				t_item.IsImportant = true;
 				tbar.Insert (t_item, -1);
 
-				Gtk.Action action = new PreviousPictureAction (view.Item);
+				Gtk.Action action = new PreviousPictureAction (View.Item);
 				actions.Add (action);
 				tbar.Insert (action.CreateToolItem () as ToolItem, -1);
 
 				play_pause_button = (actions [SlideShow]).CreateToolItem () as ToolButton;
 				tbar.Insert (play_pause_button, -1);
 
-				action = new NextPictureAction (view.Item);
+				action = new NextPictureAction (View.Item);
 				actions.Add (action);
 				tbar.Insert (action.CreateToolItem () as ToolItem, -1);
 
@@ -155,7 +154,7 @@ namespace FSpot {
 				t_item.Child = new Label (Catalog.GetString ("Slide transition:"));
 				tbar.Insert (t_item, -1);
 
-				display = new SlideShow (view.Item);
+				display = new SlideShow (View.Item);
 				display.AddEvents ((int) (Gdk.EventMask.PointerMotionMask));
 				display.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
 				display.MotionNotifyEvent += HandleViewMotion;
@@ -170,11 +169,11 @@ namespace FSpot {
 				t_item.Child = combo;
 				tbar.Insert (t_item, -1);
 
-				action = new RotateLeftAction (view.Item);
+				action = new RotateLeftAction (View.Item);
 				actions.Add (action);
 				tbar.Insert (action.CreateToolItem () as ToolItem, -1);
 
-				action = new RotateRightAction (view.Item);
+				action = new RotateRightAction (View.Item);
 				actions.Add (action);
 				tbar.Insert (action.CreateToolItem () as ToolItem, -1);
 
@@ -193,8 +192,8 @@ namespace FSpot {
 				this.Fullscreen ();
 				this.ButtonPressEvent += HandleButtonPressEvent;
 
-				view.Item.Changed += HandleItemChanged;
-				view.GrabFocus ();
+				View.Item.Changed += HandleItemChanged;
+				View.GrabFocus ();
 
 				hide_cursor_delay = new DelayedOperation (3000, new GLib.IdleHandler (HideCursor));
 				hide_cursor_delay.Start ();
@@ -212,7 +211,7 @@ namespace FSpot {
 		private Gdk.Cursor empty_cursor;
 		private bool HideCursor ()
 		{
-			if (view.InPanMotion) {
+			if (View.InPanMotion) {
 				return false;
 			}
 
@@ -220,13 +219,13 @@ namespace FSpot {
 				empty_cursor = GdkUtils.CreateEmptyCursor (GdkWindow.Display);
 
 			this.GdkWindow.Cursor = empty_cursor;
-			view.GdkWindow.Cursor = empty_cursor;
+			View.GdkWindow.Cursor = empty_cursor;
 			return false;
 		}
 
 		private void ShowCursor ()
 		{
-			view.PointerMode = PointerMode.Scroll;
+			View.PointerMode = PointerMode.Scroll;
 			this.GdkWindow.Cursor = null;
 		}
 
@@ -287,7 +286,7 @@ namespace FSpot {
 				active = (sender as ToggleAction).Active;
 
 			if (info == null) {
-				info = new InfoOverlay (this, view.Item);
+				info = new InfoOverlay (this, View.Item);
 			}
 
 			info.Visibility = active ?
@@ -309,14 +308,10 @@ namespace FSpot {
 				controls.Visibility = ControlOverlay.VisibilityType.Partial;
 				scroll.ShowControls ();
 			}
-		}
-
-		public PhotoImageView View {
-			get {
-				return view;
-			}
-		}
-
+		}
+
+		public PhotoImageView View { get; private set; }
+
 		private void HandleButtonPressEvent (object sender, Gtk.ButtonPressEventArgs args)
 		{
 			if (args.Event.Type == Gdk.EventType.ButtonPress
@@ -368,10 +363,10 @@ namespace FSpot {
 				InfoAction (info_button, null);
 				return true;
 			case Gdk.Key.bracketleft:
-				new RotateLeftAction (view.Item).Activate ();
+				new RotateLeftAction (View.Item).Activate ();
 				return true;
 			case Gdk.Key.bracketright:
-				new RotateRightAction (view.Item).Activate ();
+				new RotateRightAction (View.Item).Activate ();
 				return true;
 			}
 
diff --git a/src/Clients/MainApp/FSpot/GroupSelector.cs b/src/Clients/MainApp/FSpot/GroupSelector.cs
index 0e6803b..1cfc4b1 100644
--- a/src/Clients/MainApp/FSpot/GroupSelector.cs
+++ b/src/Clients/MainApp/FSpot/GroupSelector.cs
@@ -295,15 +295,17 @@ namespace FSpot {
 		private bool BoxXHit (double x, out int position)
 		{
 			x -= BoxX (0);
-			position = (int) (x / BoxWidth);
+			position = (int) (x / BoxWidth);
+			bool result = true;
+
 			if (position < 0) {
 				position = 0;
-				return false;
+				result = false;
 			} else if (position >= box_counts.Length) {
 				position = box_counts.Length -1;
-				return false;
-			}
-			return true;
+				result = false;
+			}
+			return result;
 		}
 
 		private bool BoxHit (double x, double y, out int position)
@@ -590,12 +592,9 @@ namespace FSpot {
 						selector.GdkWindow.InvalidateRect (now, false);
 					}
 				}
-				get {
-					if (Dragging)
-						return drag_offset;
-					else
-						return 0;
-				}
+				get {
+					return Dragging ? drag_offset : 0;
+				}
 			}
 
 			public virtual void StartDrag (double x, double y, uint time)
@@ -618,14 +617,11 @@ namespace FSpot {
 				return true;
 			}
 
-			protected bool PositionValid (int position)
-			{
-				if (position < 0 || position > selector.box_counts.Length - 1)
-					return false;
-
-				return true;
-			}
-
+			protected bool PositionValid (int position)
+			{
+				return position >= 0 && position <= selector.box_counts.Length - 1;
+			}
+
 			public virtual void UpdateDrag (double x, double y)
 			{
 				Rectangle bounds = Bounds ();
@@ -698,7 +694,7 @@ namespace FSpot {
 					return;
 
 				Rectangle then = Bounds ();
-				this.position = position;
+				this.Position = position;
 				Rectangle now = Bounds ();
 
 				if (selector.Visible) {
@@ -709,15 +705,10 @@ namespace FSpot {
 
 				if (update)
 					PositionChanged ();
-			}
-
-			private int position;
-			public int Position {
-				get {
-					return position;
-				}
-			}
-
+			}
+
+			public int Position { get; private set; }
+
 			public abstract void Draw (Rectangle area);
 
 			public abstract void PositionChanged ();
@@ -1119,6 +1110,7 @@ namespace FSpot {
 			if (event_window != null)
 				event_window.MoveResize (action.X, action.Y, action.Width, action.Height);
 
+			// FIXME: What?!?!?!
 			this.Offset = this.Offset;
 
 			UpdateButtons ();
@@ -1177,8 +1169,6 @@ namespace FSpot {
 
 			Mode = RangeType.Min;
 			UpdateButtons ();
-		}
-
-		public GroupSelector (IntPtr raw) : base (raw) {}
+		}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot/JobStore.cs b/src/Clients/MainApp/FSpot/JobStore.cs
index 6f2330f..79c02a0 100644
--- a/src/Clients/MainApp/FSpot/JobStore.cs
+++ b/src/Clients/MainApp/FSpot/JobStore.cs
@@ -71,21 +71,16 @@ namespace FSpot {
     				if (Finished != null)
     					Finished (this, new EventArgs ());
     				break;
-    			default:
-    				break;
     			}
     		}
     	}
     
-    	public void Run ()
-    	{
-    		Status = JobStatus.Running;
-    		if (Execute ())
-    			Status = JobStatus.Finished;
-    		else
-    			Status = JobStatus.Failed;
-    	}
-    
+    	public void Run ()
+    	{
+    		Status = JobStatus.Running;
+    		Status = Execute () ? JobStatus.Finished : JobStatus.Failed;
+    	}
+
     	protected abstract bool Execute ();
     }
 
@@ -193,7 +188,7 @@ namespace FSpot {
     	{
     		RemoveFromCache (item);
     
-    		if ((item as Job).Persistent)
+    		if (item.Persistent)
     			Database.Execute (new HyenaSqliteCommand ("DELETE FROM jobs WHERE id = ?", item.Id));
     
     		EmitRemoved (item);
diff --git a/src/Clients/MainApp/FSpot/MainWindow.cs b/src/Clients/MainApp/FSpot/MainWindow.cs
index ee3f44b..5668ca7 100644
--- a/src/Clients/MainApp/FSpot/MainWindow.cs
+++ b/src/Clients/MainApp/FSpot/MainWindow.cs
@@ -206,20 +206,20 @@ namespace FSpot
 		public MainSelection Selection { get; private set; }
 		public InfoBox InfoBox { get; private set; }
 
-        private static TargetList iconSourceTargetList = new TargetList();
-        private static TargetList iconDestTargetList = new TargetList();
+		private static readonly TargetList iconSourceTargetList = new TargetList();
+		private static readonly TargetList iconDestTargetList = new TargetList();
 
-        static MainWindow()
-        {
-            iconSourceTargetList.AddTargetEntry(DragDropTargets.PhotoListEntry);
-            iconSourceTargetList.AddTargetEntry(DragDropTargets.TagQueryEntry);
-            iconSourceTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
-            iconSourceTargetList.AddTargetEntry(DragDropTargets.RootWindowEntry);
+		static MainWindow()
+		{
+			iconSourceTargetList.AddTargetEntry(DragDropTargets.PhotoListEntry);
+			iconSourceTargetList.AddTargetEntry(DragDropTargets.TagQueryEntry);
+			iconSourceTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
+			iconSourceTargetList.AddTargetEntry(DragDropTargets.RootWindowEntry);
 
-            iconDestTargetList.AddTargetEntry(DragDropTargets.PhotoListEntry);
-            iconDestTargetList.AddTargetEntry(DragDropTargets.TagListEntry);
-            iconDestTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
-        }
+			iconDestTargetList.AddTargetEntry(DragDropTargets.PhotoListEntry);
+			iconDestTargetList.AddTargetEntry(DragDropTargets.TagListEntry);
+			iconDestTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
+		}
 
 		//
 		// Constructor
@@ -565,24 +565,19 @@ namespace FSpot
 		}
 
 		private Photo CurrentPhoto {
-			get {
-				int active = ActiveIndex ();
-				if (active >= 0)
-					return query [active] as Photo;
-				else
-					return null;
-			}
+			get
+			{
+				int active = ActiveIndex ();
+				return active >= 0 ? query[active] as Photo : null;
+			}
 		}
 
 		// Index into the PhotoQuery.  If -1, no photo is selected or multiple photos are selected.
-		private int ActiveIndex ()
-		{
-			if (Selection.Count == 1)
-				return SelectedIds() [0];
-			else
-				return PHOTO_IDX_NONE;
-		}
-
+		private int ActiveIndex ()
+		{
+			return Selection.Count == 1 ? SelectedIds() [0] : PHOTO_IDX_NONE;
+		}
+
 		// Switching mode.
 		public enum ModeType {
 			IconView,
@@ -674,22 +669,20 @@ namespace FSpot
 
 		private void HandleExportActivated (object o, EventArgs e)
 		{
-			FSpot.Extensions.ExportMenuItemNode.SelectedImages = delegate () {return new PhotoList (SelectedPhotos ()); };
+			FSpot.Extensions.ExportMenuItemNode.SelectedImages = () => new PhotoList(SelectedPhotos());
 		}
 
-		private void HandleDbItemsChanged (object sender, DbItemEventArgs<Photo> args)
-		{
-			foreach (Photo p in args.Items) {
-				if (p == null)
-					continue;
-				if (write_metadata)
-					FSpot.Jobs.SyncMetadataJob.Create (Database.Jobs, p);
-			}
-
+		private void HandleDbItemsChanged (object sender, DbItemEventArgs<Photo> args)
+		{
+			foreach (Photo p in args.Items.Where(p => p != null).Where(p => write_metadata))
+			{
+				FSpot.Jobs.SyncMetadataJob.Create (Database.Jobs, p);
+			}
+
 			if (args is PhotoEventArgs && (args as PhotoEventArgs).Changes.TimeChanged)
-				query.RequestReload ();
-		}
-
+				query.RequestReload ();
+		}
+
 		private void HandleTagsChanged (object sender, DbItemEventArgs<Tag> args)
 		{
 			icon_view.QueueDraw ();
@@ -718,8 +711,8 @@ namespace FSpot
 				case ModeType.IconView:
 					ids = icon_view.Selection.Ids;
 					break;
-				default:
 				case ModeType.PhotoView:
+				default:
 					if (photo_view.Item.IsValid)
 						ids = new int [] { photo_view.Item.Index };
 					break;
@@ -768,7 +761,7 @@ namespace FSpot
 			{
 				switch (win.ViewMode) {
 				case ModeType.PhotoView:
-					return item == win.photo_view.Item.Current ? true : false;
+					return item == win.photo_view.Item.Current;
 				case ModeType.IconView:
 					return win.icon_view.Selection.Contains (item);
 				}
@@ -878,9 +871,9 @@ namespace FSpot
 		// Selection Interface
 		//
 
-		private Photo [] SelectedPhotos (int [] selected_ids)
+		private Photo [] SelectedPhotos (ICollection<int> selected_ids)
 		{
-			Photo [] photo_list = new Photo [selected_ids.Length];
+			Photo [] photo_list = new Photo [selected_ids.Count];
 
 			int i = 0;
 			foreach (int num in selected_ids)
@@ -1101,19 +1094,14 @@ namespace FSpot
 		void HandleIconViewDragDataGet (object sender, DragDataGetArgs args)
 		{
 			if (args.Info == (uint)DragDropTargets.TargetType.UriList) {
-                var uris = from p in SelectedPhotos () select p.DefaultVersion.Uri;
+				var uris = from p in SelectedPhotos () select p.DefaultVersion.Uri;
 				args.SelectionData.SetUriListData (new UriList (uris), args.Context.Targets[0]);
-				return;
 			}
-
-			if (args.Info == DragDropTargets.PhotoListEntry.Info) {
+			else if (args.Info == DragDropTargets.PhotoListEntry.Info) {
 				args.SelectionData.SetPhotosData (SelectedPhotos (), args.Context.Targets[0]);
-				return;
 			}
-
-			if (args.Info == DragDropTargets.RootWindowEntry.Info) {
+			else if (args.Info == DragDropTargets.RootWindowEntry.Info) {
 				HandleSetAsBackgroundCommand (null, null);
-				return;
 			}
 		}
 
@@ -1132,15 +1120,11 @@ namespace FSpot
 		{
 			// Drag'n drop import.
 			var controller = new ImportController (false);
-			controller.StatusEvent += (evnt) => {
-				ThreadAssist.ProxyToMain (() => {
-					if (evnt == ImportEvent.ImportFinished) {
-						if (controller.PhotosImported > 0) {
-							query.RollSet = new RollSet (Database.Rolls.GetRolls (1));
-						}
-					}
-				});
-			};
+			controller.StatusEvent += (evnt) => ThreadAssist.ProxyToMain (() => {
+			        if (evnt == ImportEvent.ImportFinished && controller.PhotosImported > 0)
+			                query.RollSet = new RollSet (Database.Rolls.GetRolls (1));
+			        }
+			);
 
 			var source = new MultiFileImportSource (list.ToArray ());
 			controller.ActiveSource = source;
@@ -1169,11 +1153,8 @@ namespace FSpot
 		{
 			var controller = new ImportController (true);
 			controller.StatusEvent += (evnt) => {
-				if (evnt == ImportEvent.ImportFinished) {
-					if (controller.PhotosImported > 0) {
+				if (evnt == ImportEvent.ImportFinished && controller.PhotosImported > 0)
 						query.RollSet = new RollSet (Database.Rolls.GetRolls (1));
-					}
-				}
 			};
 			var import_window = new ImportDialog (controller, Window);
 			import_window.Show ();
@@ -1189,7 +1170,7 @@ namespace FSpot
 				// drag events use the viewport.  Owen sends his regrets.
 				//
 				int item = icon_view.CellAtPosition (args.X + (int) icon_view.Hadjustment.Value,
-								     args.Y + (int) icon_view.Vadjustment.Value);
+									 args.Y + (int) icon_view.Vadjustment.Value);
 
 				//Console.WriteLine ("Drop cell = {0} ({1},{2})", item, args.X, args.Y);
 				if (item >= 0) {
@@ -1220,7 +1201,7 @@ namespace FSpot
 
 			if (args.Info == DragDropTargets.PhotoListEntry.Info) {
 				int p_item = icon_view.CellAtPosition (args.X + (int) icon_view.Hadjustment.Value,
-								     args.Y + (int) icon_view.Vadjustment.Value);
+									 args.Y + (int) icon_view.Vadjustment.Value);
 
 				if (p_item >= 0) {
 					if (icon_view.Selection.Contains (p_item)) //We don't want to reparent ourselves!
@@ -1430,10 +1411,9 @@ namespace FSpot
 
 		public void HandleTagMenuActivate (object sender, EventArgs args)
 		{
-
-			MenuItem parent = sender as MenuItem;
-			if (parent == null) // We have a Gtk.Action for UI menus, so the "Edit > Remove tag" item needs special treatment
-				parent = uimanager.GetWidget("/ui/menubar1/edit2/remove_tag") as MenuItem;
+			// We have a Gtk.Action for UI menus, so the "Edit > Remove tag" item needs special treatment
+			MenuItem parent = sender as MenuItem ?? uimanager.GetWidget("/ui/menubar1/edit2/remove_tag") as MenuItem;
+			
 			if (parent != null && parent.Submenu is PhotoTagMenu) {
 				PhotoTagMenu menu = (PhotoTagMenu) parent.Submenu;
 				menu.Populate (SelectedPhotos ());
@@ -1738,7 +1718,7 @@ namespace FSpot
 
 			// Translators, The singular case will never happen here.
 			string header = Catalog.GetPluralString ("Merge the selected tag",
-									    "Merge the {0} selected tags?", tags.Length);
+										"Merge the {0} selected tags?", tags.Length);
 			header = String.Format (header, tags.Length);
 
 			// If a tag with children tags is selected for merging, we
@@ -2100,8 +2080,8 @@ namespace FSpot
 
 			Photo[] photos = SelectedPhotos();
 			string header = Catalog.GetPluralString ("Delete the selected photo permanently?",
-									    "Delete the {0} selected photos permanently?",
-									    photos.Length);
+										"Delete the {0} selected photos permanently?",
+										photos.Length);
 			header = String.Format (header, photos.Length);
 			string msg = Catalog.GetPluralString ("This deletes all versions of the selected photo from your drive.",
 									 "This deletes all versions of the selected photos from your drive.",
@@ -2143,8 +2123,8 @@ namespace FSpot
 				return;
 
 			string header = Catalog.GetPluralString ("Remove the selected photo from F-Spot?",
-									    "Remove the {0} selected photos from F-Spot?",
-									    photos.Length);
+										"Remove the {0} selected photos from F-Spot?",
+										photos.Length);
 
 			header = String.Format (header, photos.Length);
 			string msg = Catalog.GetString("If you remove photos from the F-Spot catalog all tag information will be lost. The photos remain on your computer and can be imported into F-Spot again.");
@@ -2256,9 +2236,9 @@ namespace FSpot
 									   e.Tag.Name.Replace ("_", "__"));
 
 					HigMessageDialog md = new HigMessageDialog (main_window, DialogFlags.DestroyWithParent,
-										    Gtk.MessageType.Error, ButtonsType.Ok,
-										    error_msg,
-										    error_desc);
+											Gtk.MessageType.Error, ButtonsType.Ok,
+											error_msg,
+											error_desc);
 					md.Run ();
 					md.Destroy ();
 				}
@@ -2306,40 +2286,40 @@ namespace FSpot
 				return;
 			}
 
-            TargetList targetList = new TargetList();
-            targetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText);
-            targetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
-            targetList.Add(
-                           DragDropTargets.CopyFilesEntry.Target,
-                           (uint)DragDropTargets.CopyFilesEntry.Flags,
-                           (uint)DragDropTargets.CopyFilesEntry.Info);
+			TargetList targetList = new TargetList();
+			targetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText);
+			targetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
+			targetList.Add(
+						   DragDropTargets.CopyFilesEntry.Target,
+						   (uint)DragDropTargets.CopyFilesEntry.Flags,
+						   (uint)DragDropTargets.CopyFilesEntry.Info);
 
-            // use eager evaluation, because we want to copy the photos which are currently selected ...
-            var uris = new UriList (from p in SelectedPhotos () select p.DefaultVersion.Uri);
-            var paths = String.Join (" ",
-                                     (from p in SelectedPhotos ()
-                                      select p.DefaultVersion.Uri.LocalPath).ToArray ()
-                                     );
+			// use eager evaluation, because we want to copy the photos which are currently selected ...
+			var uris = new UriList (from p in SelectedPhotos () select p.DefaultVersion.Uri);
+			var paths = String.Join (" ",
+									 (from p in SelectedPhotos ()
+									  select p.DefaultVersion.Uri.LocalPath).ToArray ()
+									 );
 
-            clipboard.SetWithData ((TargetEntry[])targetList, delegate (Clipboard clip, SelectionData data, uint info) {
+			clipboard.SetWithData ((TargetEntry[])targetList, delegate (Clipboard clip, SelectionData data, uint info) {
 
-                if (info == (uint)DragDropTargets.TargetType.PlainText) {
-                    data.Text = paths;
-                    return;
-                }
+				if (info == (uint)DragDropTargets.TargetType.PlainText) {
+					data.Text = paths;
+					return;
+				}
 
-                if (info == (uint)DragDropTargets.TargetType.UriList) {
-                     data.SetUriListData (uris);
-                    return;
-                }
+				if (info == (uint)DragDropTargets.TargetType.UriList) {
+					 data.SetUriListData (uris);
+					return;
+				}
 
-                if (info == DragDropTargets.CopyFilesEntry.Info) {
-                    data.SetCopyFiles (uris);
-                    return;
-                }
+				if (info == DragDropTargets.CopyFilesEntry.Info) {
+					data.SetCopyFiles (uris);
+					return;
+				}
 
-                Log.DebugFormat ("Unknown Selection Data Target (info: {0})", info);
-            }, delegate {});
+				Log.DebugFormat ("Unknown Selection Data Target (info: {0})", info);
+			}, delegate {});
 
 			primary.Text = paths;
 		}
@@ -2481,7 +2461,10 @@ namespace FSpot
 
 						if (photo != null)
 							JumpTo (query.IndexOf (photo));
-					} catch (Exception) {}
+					} catch (Exception ex)
+					{
+						Log.DebugException(ex);
+					}
 				}
 
 				icon_view.GrabFocus ();
@@ -2517,7 +2500,7 @@ namespace FSpot
 
 		void UpdateForVersionChange (IPhotoVersion version)
 		{
-			IPhotoVersionable versionable = CurrentPhoto as IPhotoVersionable;
+			IPhotoVersionable versionable = CurrentPhoto;
 
 			if (versionable != null) {
 				versionable.SetDefaultVersion (version);
@@ -2607,7 +2590,7 @@ namespace FSpot
 			// account for All and separator menu items
 			item_pos -= 2;
 
-			FSpot.Term parent_term = (FSpot.Term) FSpot.LogicWidget.Root.SubTerms [item_pos];
+			FSpot.Term parent_term = FSpot.LogicWidget.Root.SubTerms [item_pos];
 
 			if (FSpot.LogicWidget.Box != null) {
 				FSpot.Literal after = parent_term.Last as FSpot.Literal;
@@ -2655,8 +2638,8 @@ namespace FSpot
 				versions_submenu.VersionChanged += delegate (PhotoVersionMenu menu) { UpdateForVersionChange (menu.Version);};
 				version_menu_item.Submenu = versions_submenu;
 
-				sharpen.Sensitive = (ViewMode == ModeType.IconView ? false : true);
-				loupe_menu_item.Sensitive = (ViewMode == ModeType.IconView ? false : true);
+				sharpen.Sensitive = (ViewMode != ModeType.IconView);
+				loupe_menu_item.Sensitive = (ViewMode != ModeType.IconView);
 			}
 
 			set_as_background.Sensitive = single_active;
@@ -2704,7 +2687,7 @@ namespace FSpot
 					rl_button.Sensitive = true;
 
 					string msg = Catalog.GetPluralString ("Rotate selected photo left",
-									      "Rotate selected photos left", Selection.Count);
+										  "Rotate selected photos left", Selection.Count);
 					rl_button.TooltipText = String.Format (msg, Selection.Count);
 				}
 			}
@@ -2717,7 +2700,7 @@ namespace FSpot
 					rr_button.Sensitive = true;
 
 					string msg = Catalog.GetPluralString ("Rotate selected photo right",
-									      "Rotate selected photos right", Selection.Count);
+										  "Rotate selected photos right", Selection.Count);
 					rr_button.TooltipText = String.Format (msg, Selection.Count);
 				}
 			}
@@ -2780,8 +2763,8 @@ namespace FSpot
 
 			// FIXME add cancel button? add help button?
 			HigMessageDialog hmd = new HigMessageDialog(GetToplevel (sender), DialogFlags.DestroyWithParent,
-								    MessageType.Question, Gtk.ButtonsType.None,
-								    header, msg);
+									MessageType.Question, Gtk.ButtonsType.None,
+									header, msg);
 
 			hmd.AddButton (Gtk.Stock.No, Gtk.ResponseType.No, false);
 			//hmd.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
@@ -2851,7 +2834,7 @@ namespace FSpot
 
 			try {
 				application.LaunchUris (uri_list, null);
-			} catch (System.Exception) {
+			} catch (Exception) {
 				Log.ErrorFormat ("Failed to lauch {0}", application.Name);
 			}
 		}
@@ -2890,12 +2873,12 @@ namespace FSpot
 		// "Activate" means the user pressed the enter key
 		public void HandleTagEntryActivate (object sender, EventArgs args)
 		{
-		       if (ViewMode == ModeType.IconView) {
-			       icon_view.GrabFocus ();
-		       } else {
-			       photo_view.QueueDraw ();
-			       photo_view.View.GrabFocus ();
-		       }
+			   if (ViewMode == ModeType.IconView) {
+				   icon_view.GrabFocus ();
+			   } else {
+				   photo_view.QueueDraw ();
+				   photo_view.View.GrabFocus ();
+			   }
 		}
 
 		private void HandleTagEntryTagsAttached (object o, string [] new_tags)
@@ -2918,7 +2901,7 @@ namespace FSpot
 			foreach (string tagname in new_tags) {
 				Tag t = Database.Tags.GetTagByName (tagname);
 				if (t == null) {
-					t = Database.Tags.CreateCategory (default_category, tagname, true) as Tag;
+					t = Database.Tags.CreateCategory (default_category, tagname, true);
 					Database.Tags.Commit (t);
 				}
 				tags [i++] = t;
@@ -2999,8 +2982,7 @@ namespace FSpot
 				find_bar.Hide ();
 			}
 
-			query_widget.ShowBar ();
-			return;
+			query_widget.ShowBar ();
 		}
 
 		public void HideSidebar (object o, EventArgs args) {
diff --git a/src/Clients/MainApp/FSpot/MetaStore.cs b/src/Clients/MainApp/FSpot/MetaStore.cs
index cded2be..b0d958d 100644
--- a/src/Clients/MainApp/FSpot/MetaStore.cs
+++ b/src/Clients/MainApp/FSpot/MetaStore.cs
@@ -32,8 +32,9 @@
 using System;
 
 using FSpot.Core;
-using FSpot.Database;
-
+using FSpot.Database;
+
+using Hyena;
 using Hyena.Data.Sqlite;
 
 namespace FSpot {
@@ -100,7 +101,10 @@ namespace FSpot {
     		try {
     			string id = Database.Query<string> ("SELECT id FROM tags WHERE name = 'Hidden'");
     			Create (hidden, id);
-    		} catch (Exception) {}
+    		} catch (Exception ex)
+    		{
+    			Log.DebugException(ex);
+    		}
     	}
     
     	private void LoadAllItems ()
diff --git a/src/Clients/MainApp/FSpot/Photo.cs b/src/Clients/MainApp/FSpot/Photo.cs
index 773c69a..6c199b3 100644
--- a/src/Clients/MainApp/FSpot/Photo.cs
+++ b/src/Clients/MainApp/FSpot/Photo.cs
@@ -213,7 +213,7 @@ namespace FSpot
 
 		public bool VersionNameExists (string version_name)
 		{
-			return Versions.Where ((v) => v.Name == version_name).Any ();
+			return Versions.Any(v => v.Name == version_name);
 		}
 
 		public SafeUri VersionUri (uint version_id)
@@ -222,10 +222,7 @@ namespace FSpot
 				return null;
 
 			PhotoVersion v = versions [version_id];
-			if (v != null)
-				return v.Uri;
-
-			return null;
+			return v != null ? v.Uri : null;
 		}
 
 		public IPhotoVersion DefaultVersion {
@@ -264,7 +261,7 @@ namespace FSpot
 					var versionUri = VersionUri (version);
 
 					PixbufUtils.CreateDerivedVersion (DefaultVersion.Uri, versionUri, 95, buffer);
-					(GetVersion (version) as PhotoVersion).ImportMD5 = HashUtils.GenerateMD5 (VersionUri (version));
+					GetVersion (version).ImportMD5 = HashUtils.GenerateMD5 (VersionUri (version));
 					DefaultVersionId = version;
 				} catch (System.Exception e) {
 					Log.Exception (e);
@@ -276,19 +273,14 @@ namespace FSpot
 			}
 
 			return version;
-		}
-
-		public void DeleteVersion (uint version_id)
-		{
-			DeleteVersion (version_id, false, false);
-		}
-
+		}
+
 		public void DeleteVersion (uint version_id, bool remove_original)
 		{
 			DeleteVersion (version_id, remove_original, false);
 		}
 
-		public void DeleteVersion (uint version_id, bool remove_original, bool keep_file)
+		public void DeleteVersion (uint version_id, bool remove_original = false, bool keep_file = false)
 		{
 			if (version_id == OriginalVersionId && !remove_original)
 				throw new Exception ("Cannot delete original version");
@@ -363,6 +355,8 @@ namespace FSpot
 			uint count = 0;
 			GLib.FileEnumerator list = directory.EnumerateChildren ("standard::name",
 				GLib.FileQueryInfoFlags.None, null);
+
+			// FIXME: There has to be a better way to do this?
 			foreach (var item in list) {
 				count++;
 			}
@@ -371,15 +365,10 @@ namespace FSpot
 
 		public uint CreateVersion (string name, uint base_version_id, bool create)
 		{
-			return CreateVersion (name, null, base_version_id, create, false);
-		}
-
-		private uint CreateVersion (string name, string extension, uint base_version_id, bool create)
-		{
-			return CreateVersion (name, extension, base_version_id, create, false);
-		}
-
-		private uint CreateVersion (string name, string extension, uint base_version_id, bool create, bool is_protected)
+			return CreateVersion (name, null, base_version_id, create);
+		}
+
+		private uint CreateVersion (string name, string extension, uint base_version_id, bool create, bool is_protected = false)
 		{
 			extension = extension ?? VersionUri (base_version_id).GetExtension ();
 			SafeUri new_base_uri = DefaultVersion.BaseUri;
@@ -489,7 +478,7 @@ namespace FSpot
 				throw new Exception ("This name already exists");
 
 
-			(GetVersion (version_id) as PhotoVersion).Name = new_name;
+			GetVersion (version_id).Name = new_name;
 			changes.ChangeVersion (version_id);
 
 			//TODO: rename file too ???
@@ -550,14 +539,14 @@ namespace FSpot
 			changes.RemoveTag (tag);
 		}
 
-		public void RemoveTag (Tag []taglist)
+		public void RemoveTag (IEnumerable<Tag> taglist)
 		{
 			foreach (Tag tag in taglist) {
 				RemoveTag (tag);
 			}
 		}
 
-		public void RemoveCategory (IList<Tag> taglist)
+		public void RemoveCategory (IEnumerable<Tag> taglist)
 		{
 			foreach (Tag tag in taglist) {
 				Category cat = tag as Category;
@@ -597,25 +586,24 @@ namespace FSpot
 		#endregion
 
 		#region IComparable implementation
-		public int CompareTo (object obj)
-		{
+		public int CompareTo (object obj)
+		{
 			if (this.GetType () == obj.GetType ())
-				return this.Compare((Photo)obj);
-			else if (obj is DateTime)
-				return this.time.CompareTo ((DateTime)obj);
-			else
-				throw new Exception ("Object must be of type Photo");
-		}
-
-		public int CompareTo (Photo photo)
-		{
-			int result = Id.CompareTo (photo.Id);
-
-			if (result == 0)
-				return 0;
-			else
-				return (this as IPhoto).Compare (photo);
-		}
+				return this.Compare((Photo)obj);
+
+			if (obj is DateTime)
+				return this.time.CompareTo ((DateTime)obj);
+
+			throw new Exception ("Object must be of type Photo");
+		}
+
+		public int CompareTo (Photo photo)
+		{
+			int result = Id.CompareTo (photo.Id);
+
+			return result == 0 ? 0 : this.Compare (photo);
+		}
+
 		#endregion
 	}
 }
diff --git a/src/Clients/MainApp/FSpot/PhotoPopup.cs b/src/Clients/MainApp/FSpot/PhotoPopup.cs
index 13f5ec9..45b275d 100644
--- a/src/Clients/MainApp/FSpot/PhotoPopup.cs
+++ b/src/Clients/MainApp/FSpot/PhotoPopup.cs
@@ -52,19 +52,14 @@ namespace FSpot
 		{
 		}
 
-		public PhotoPopup (Widget parent) : base ()
+		public PhotoPopup (Widget parent)
 		{
 			foreach (MenuNode node in AddinManager.GetExtensionNodes ("/FSpot/Menus/PhotoPopup"))
 				Append (node.GetMenuItem (parent));
 			ShowAll ();
-		}
-
-		public void Activate (Widget toplevel)
-		{
-			Activate (toplevel, null);
-		}
-
-		public void Activate (Widget toplevel, Gdk.EventButton eb)
+		}
+
+		public void Activate (Widget toplevel, Gdk.EventButton eb = null)
 		{
 			if (eb != null)
 				Popup (null, null, null, eb.Button, eb.Time);
diff --git a/src/Clients/MainApp/FSpot/PhotoQuery.cs b/src/Clients/MainApp/FSpot/PhotoQuery.cs
index 1ed8600..c8626c3 100644
--- a/src/Clients/MainApp/FSpot/PhotoQuery.cs
+++ b/src/Clients/MainApp/FSpot/PhotoQuery.cs
@@ -84,8 +84,7 @@ namespace FSpot {
 			}
 		}
 
-		PhotoCache cache;
-		private PhotoStore store;
+		PhotoCache cache;
 		private Term terms;
 
 		static int query_count = 0;
@@ -102,8 +101,8 @@ namespace FSpot {
 		// Constructor
 		public PhotoQuery (PhotoStore store, params IQueryCondition [] conditions)
 		{
-			this.store = store;
-			this.store.ItemsChanged += MarkChanged;
+			this.Store = store;
+			this.Store.ItemsChanged += MarkChanged;
 			cache = new PhotoCache (store, temp_table);
 			reverse_lookup = new Dictionary<uint, int> ();
 			SetCondition (OrderByTime.OrderByTimeDesc);
@@ -117,7 +116,7 @@ namespace FSpot {
 		public int Count {
 			get {
 				if (count < 0)
-					count = store.Count (temp_table);
+					count = Store.Count (temp_table);
 				return count;
 			}
 		}
@@ -136,26 +135,20 @@ namespace FSpot {
 
 		[Obsolete ("DO NOT USE THIS, IT'S TOO SLOW")]
 		public Photo [] Photos {
-			get { return store.QueryFromTemp (temp_table); }
+			get { return Store.QueryFromTemp (temp_table); }
 		}
 
 		[Obsolete ("DO NOT USE Items on PhotoQuery")]
 		public IPhoto [] Items {
 			get { throw new NotImplementedException (); }
-		}
-
-		public PhotoStore Store {
-			get { return store; }
-		}
-
+		}
+
+		public PhotoStore Store { get; private set; }
+
 		//Query Conditions
 		private Dictionary<Type, IQueryCondition> conditions;
 		private Dictionary<Type, IQueryCondition> Conditions {
-			get {
-				if (conditions == null)
-					conditions = new Dictionary<Type, IQueryCondition> ();
-				return conditions;
-			}
+			get { return conditions ?? (conditions = new Dictionary<Type, IQueryCondition>()); }
 		}
 
 		internal bool SetCondition (IQueryCondition condition)
@@ -297,10 +290,10 @@ namespace FSpot {
 				i++;
 			}
 
-			store.QueryToTemp (temp_table, condition_array);
+			Store.QueryToTemp (temp_table, condition_array);
 
 			count = -1;
-			cache = new PhotoCache (store, temp_table);
+			cache = new PhotoCache (Store, temp_table);
 			reverse_lookup = new Dictionary<uint,int> ();
 
 			if (Changed != null)
@@ -313,10 +306,10 @@ namespace FSpot {
 		{
 			if (photo == null || !(photo is Photo))
 				return -1;
-			return store.IndexOf (temp_table, photo as Photo);
+			return Store.IndexOf (temp_table, photo as Photo);
 		}
 
-		private int [] IndicesOf (DbItem [] dbitems)
+		private int [] IndicesOf (IEnumerable<DbItem> dbitems)
 		{
 			uint timer = Log.DebugTimerStart ();
 			List<int> indices = new List<int> ();
@@ -330,7 +323,7 @@ namespace FSpot {
 			}
 
 			if (items_to_search.Count > 0)
-				indices.AddRange (store.IndicesOf (temp_table, items_to_search.ToArray ()));
+				indices.AddRange (Store.IndicesOf (temp_table, items_to_search.ToArray ()));
 			Log.DebugTimerPrint (timer, "IndicesOf took {0}");
 			return indices.ToArray ();
 		}
@@ -356,7 +349,7 @@ namespace FSpot {
 					//the item we're looking for is not in the cache
 					//a binary search could take up to ln2 (N/cache.SIZE) request
 					//lets reduce that number to 1
-					return store.IndexOf (temp_table, date, asc);
+					return Store.IndexOf (temp_table, date, asc);
 
 				int comp = this [mid].Time.CompareTo (date);
 				if (!asc && comp < 0 || asc && comp > 0)
@@ -385,7 +378,7 @@ namespace FSpot {
 				to_commit.Add (this [index] as Photo);
 				reverse_lookup [(this [index] as Photo).Id] = index;
 			}
-			store.Commit (to_commit.ToArray ());
+			Store.Commit (to_commit.ToArray ());
 		}
 
 		private void MarkChanged (object sender, DbItemEventArgs<Photo> args)
diff --git a/src/Clients/MainApp/FSpot/PhotoStore.cs b/src/Clients/MainApp/FSpot/PhotoStore.cs
index c4c1c31..8830cc6 100644
--- a/src/Clients/MainApp/FSpot/PhotoStore.cs
+++ b/src/Clients/MainApp/FSpot/PhotoStore.cs
@@ -48,896 +48,899 @@ using Hyena.Data.Sqlite;
 using Mono.Unix;
 
 namespace FSpot {
-        public class PhotoStore : DbStore<Photo> {
-         public int TotalPhotos {
-                 get {
-                         IDataReader reader = Database.Query("SELECT COUNT(*) AS photo_count FROM photos");
-                         reader.Read ();
-                         int total = Convert.ToInt32 (reader ["photo_count"]);
-                         reader.Dispose ();
-                         return total;
-                 }
-         }
-        
-         // FIXME this is a hack.  Since we don't have Gnome.ThumbnailFactory.SaveThumbnail() in
-         // GTK#, and generate them by ourselves directly with Gdk.Pixbuf, we have to make sure here
-         // that the "large" thumbnail directory exists.
-         private static void EnsureThumbnailDirectory ()
-         {
-                 string large_thumbnail_file_name_template = Gnome.Thumbnail.PathForUri ("file:///boo", Gnome.ThumbnailSize.Large);
-                 string large_thumbnail_directory_path = System.IO.Path.GetDirectoryName (large_thumbnail_file_name_template);
-        
-                 if (! System.IO.File.Exists (large_thumbnail_directory_path))
-                         System.IO.Directory.CreateDirectory (large_thumbnail_directory_path);
-         }
+		public class PhotoStore : DbStore<Photo> {
+		 public int TotalPhotos {
+				 get {
+						 IDataReader reader = Database.Query("SELECT COUNT(*) AS photo_count FROM photos");
+						 reader.Read ();
+						 int total = Convert.ToInt32 (reader ["photo_count"]);
+						 reader.Dispose ();
+						 return total;
+				 }
+		 }
+		
+		 // FIXME this is a hack.  Since we don't have Gnome.ThumbnailFactory.SaveThumbnail() in
+		 // GTK#, and generate them by ourselves directly with Gdk.Pixbuf, we have to make sure here
+		 // that the "large" thumbnail directory exists.
+		 private static void EnsureThumbnailDirectory ()
+		 {
+				 string large_thumbnail_file_name_template = Gnome.Thumbnail.PathForUri ("file:///boo", Gnome.ThumbnailSize.Large);
+				 string large_thumbnail_directory_path = System.IO.Path.GetDirectoryName (large_thumbnail_file_name_template);
+		
+				 if (! System.IO.File.Exists (large_thumbnail_directory_path))
+						 System.IO.Directory.CreateDirectory (large_thumbnail_directory_path);
+		 }
 
-         // Constructor
-         public PhotoStore (FSpotDatabaseConnection database, bool is_new)
-                 : base (database, false)
-         {
-                 EnsureThumbnailDirectory ();
-        
-                 if (! is_new)
-                         return;
-        
-                 Database.Execute (
-                         "CREATE TABLE photos (\n" +
-                         "       id                      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \n" +
-                         "       time                    INTEGER NOT NULL, \n" +
-                         "       base_uri                STRING NOT NULL, \n" +
-                     "   filename                STRING NOT NULL, \n" +
-                         "       description             TEXT NOT NULL, \n" +
-                         "       roll_id                 INTEGER NOT NULL, \n" +
-                         "       default_version_id      INTEGER NOT NULL, \n" +
-                         "       rating                  INTEGER NULL \n" +
-                         ")");
-        
-                 Database.Execute (
-                         "CREATE TABLE photo_tags (\n" +
-                         "       photo_id        INTEGER, \n" +
-                         "       tag_id          INTEGER, \n" +
-                         "       UNIQUE (photo_id, tag_id)\n" +
-                         ")");
-        
-                 Database.Execute (
-                         "CREATE TABLE photo_versions (\n"+
-                         "       photo_id        INTEGER, \n" +
-                         "       version_id      INTEGER, \n" +
-                         "       name            STRING, \n" +
-                         "       base_uri                STRING NOT NULL, \n" +
-                     "   filename                STRING NOT NULL, \n" +
-                         "       import_md5              TEXT NULL, \n" +
-                         "       protected       BOOLEAN, \n" +
-                         "       UNIQUE (photo_id, version_id)\n" +
-                         ")");
-        
-                 Database.Execute ("CREATE INDEX idx_photo_versions_id ON photo_versions(photo_id)");
-                 Database.Execute ("CREATE INDEX idx_photo_versions_import_md5 ON photo_versions(import_md5)");
-                 Database.Execute ("CREATE INDEX idx_photos_roll_id ON photos(roll_id)");
-         }
-        
-         public bool HasDuplicate (IPhoto item) {
-                 var uri = item.DefaultVersion.Uri;
-        
-                 // Check if the exact given uri already exists.
-                 var query = "SELECT COUNT(*) AS count FROM photo_versions WHERE base_uri = ? AND filename = ?";
-                 var reader = Database.Query (new HyenaSqliteCommand (query, uri.GetBaseUri ().ToString (), uri.GetFilename ()));
-                 reader.Read ();
-                 int count = Convert.ToInt32 (reader ["count"]);
-                 reader.Dispose();
-                 if (count > 0)
-                         return true;
-        
-                 // Check by MD5. Won't import if there are photos with the same ImportMD5.
-                 string hash = item.DefaultVersion.ImportMD5;
-                 var condition = new ConditionWrapper (String.Format ("import_md5 = \"{0}\"", hash));
-                 var dupes_by_hash = Count ("photo_versions", condition);
-                 if (dupes_by_hash > 0)
-                         return true;
-        
-                 // This is a very lame check to overcome the lack of duplicate detect data right after transition.
-                 //
-                 // Does filename matching if there are files with no hash for the original version.
-                 condition = new ConditionWrapper ("version_id = 1 AND (import_md5 = \"\" OR import_md5 IS NULL)");
-                 var have_no_hashes = Count ("photo_versions", condition);
-                 if (have_no_hashes > 0) {
-                         var name = uri.GetFilename ();
-                         DateTime? time = null;
-        
-                         // Look for a filename match.
-                         reader = Database.Query (new HyenaSqliteCommand ("SELECT photos.id, photos.time, pv.filename FROM photos LEFT JOIN photo_versions AS pv ON pv.photo_id = photos.id WHERE pv.filename = ?", name));
-                         while (reader.Read ()) {
-                                 Log.DebugFormat ("Found one possible duplicate for {0}", reader["filename"].ToString ());
-                                 if (!time.HasValue) {
-                                         // Only read time when needed
-                                         time = item.Time;
-                                 }
-        
-                                 if (reader["time"].ToString () == DateTimeUtil.FromDateTime (time.Value).ToString ()) {
-                                         Log.Debug ("Skipping duplicate", uri);
-        
-                                         // Schedule a hash calculation job on the existing file.
-                                         CalculateHashJob.Create (FSpot.App.Instance.Database.Jobs, Convert.ToUInt32 (reader["id"]));
-        
-                                         return true;
-                                 }
-                         }
-                         reader.Dispose ();
-                 }
-        
-                 // No matches
-                 return false;
-         }
-        
-         public Photo CreateFrom (IPhoto item, uint roll_id)
-         {
-                 Photo photo;
-        
-                 long unix_time = DateTimeUtil.FromDateTime (item.Time);
-                 string description = item.Description ?? String.Empty;
-        
-                 uint id = (uint) Database.Execute (
-                         new HyenaSqliteCommand (
-                                 "INSERT INTO photos (time, base_uri, filename, description, roll_id, default_version_id, rating) "      +
-                                 "VALUES (?, ?, ?, ?, ?, ?, ?)",
-                                 unix_time,
-                                 item.DefaultVersion.BaseUri.ToString (),
-                                 item.DefaultVersion.Filename,
-                                 description,
-                                 roll_id,
-                                 Photo.OriginalVersionId,
-                                 "0"
-                         )
-                 );
-        
-                 photo = new Photo (id, unix_time);
-                 photo.AddVersionUnsafely (Photo.OriginalVersionId, item.DefaultVersion.BaseUri, item.DefaultVersion.Filename, item.DefaultVersion.ImportMD5, Catalog.GetString ("Original"), true);
-                 photo.AllVersionsLoaded = true;
-        
-                 InsertVersion (photo, photo.DefaultVersion as PhotoVersion);
-                 EmitAdded (photo);
-                 return photo;
-         }
-        
-         private void InsertVersion (Photo photo, PhotoVersion version)
-         {
-                 Database.Execute (new HyenaSqliteCommand (
-                         "INSERT OR IGNORE INTO photo_versions (photo_id, version_id, name, base_uri, filename, protected, import_md5) " +
-                         "VALUES (?, ?, ?, ?, ?, ?, ?)",
-                         photo.Id,
-                         version.VersionId,
-                         version.Name,
-                         version.BaseUri.ToString (),
-                         version.Filename,
-                         version.IsProtected,
-                         (version.ImportMD5 != String.Empty ? version.ImportMD5 : null)));
-         }
-        
-        
-         private void GetVersions (Photo photo)
-         {
-                 IDataReader reader = Database.Query(
-                         new HyenaSqliteCommand("SELECT version_id, name, base_uri, filename, import_md5, protected " +
-                                       "FROM photo_versions " +
-                                       "WHERE photo_id = ?",
-                                       photo.Id
-                         )
-                 );
-        
-                 while (reader.Read ()) {
-                         uint version_id = Convert.ToUInt32 (reader ["version_id"]);
-                         string name = reader["name"].ToString ();
-                         var base_uri = new SafeUri (reader ["base_uri"].ToString (), true);
-                         var filename = reader ["filename"].ToString ();
-                         string import_md5 = reader["import_md5"] != null ? reader ["import_md5"].ToString () : null;
-                         bool is_protected = Convert.ToBoolean (reader["protected"]);
-        
-                         photo.AddVersionUnsafely (version_id, base_uri, filename, import_md5, name, is_protected);
-                 }
-                 reader.Dispose();
-         }
-        
-         private void GetTags (Photo photo)
-         {
-                 IDataReader reader = Database.Query(new HyenaSqliteCommand("SELECT tag_id FROM photo_tags WHERE photo_id = ?", photo.Id));
-        
-                 while (reader.Read ()) {
-                         uint tag_id = Convert.ToUInt32 (reader ["tag_id"]);
-                         Tag tag = App.Instance.Database.Tags.Get (tag_id) as Tag;
-                         photo.AddTagUnsafely (tag);
-                 }
-                 reader.Dispose();
-         }
-        
-         private void GetAllVersions  (string ids) {
-                 IDataReader reader = Database.Query ("SELECT photo_id, version_id, name, base_uri, filename, import_md5, protected FROM photo_versions WHERE photo_id IN " + ids);
-        
-                 while (reader.Read ()) {
-                         uint id = Convert.ToUInt32 (reader ["photo_id"]);
-                         Photo photo = LookupInCache (id);
-        
-                         if (photo == null) {
-                                 //Console.WriteLine ("Photo {0} not found", id);
-                                 continue;
-                         }
-        
-                         if (photo.AllVersionsLoaded) {
-                                 //Console.WriteLine ("Photo {0} already Loaded", photo);
-                                 continue;
-                         }
-        
-                         if (reader ["version_id"] != null) {
-                                 uint version_id = Convert.ToUInt32 (reader ["version_id"]);
-                                 string name = reader["name"].ToString ();
-                                 var base_uri = new SafeUri (reader ["base_uri"].ToString (), true);
-                                 var filename = reader ["filename"].ToString ();
-                                 string import_md5 = reader["import_md5"] != null ? reader ["import_md5"].ToString () : null;
-                                 bool is_protected = Convert.ToBoolean (reader["protected"]);
-        
-                                 photo.AddVersionUnsafely (version_id, base_uri, filename, import_md5, name, is_protected);
-                         }
-        
-                         /*
-                         string directory_path = null;
-                         if (reader [3] != null)
-                                 directory_path = reader [3].ToString ();
-                         System.Console.WriteLine ("directory_path = {0}", directory_path);
-                         */
-                 }
-                 reader.Dispose();
-         }
-        
-         private void GetAllTags (string ids) {
-                 IDataReader reader = Database.Query ("SELECT photo_id, tag_id FROM photo_tags WHERE photo_id IN " + ids);
-        
-                 while (reader.Read ()) {
-                         uint id = Convert.ToUInt32 (reader ["photo_id"]);
-                         Photo photo = LookupInCache (id);
-        
-                         if (photo == null) {
-                                 //Console.WriteLine ("Photo {0} not found", id);
-                                 continue;
-                         }
-        
-                         if (photo.AllVersionsLoaded) {
-                                 //Console.WriteLine ("Photo {0} already Loaded", photo.Id);
-                                 continue;
-                         }
-        
-                         if (reader [1] != null) {
-                                 uint tag_id = Convert.ToUInt32 (reader ["tag_id"]);
-                                 Tag tag = App.Instance.Database.Tags.Get (tag_id) as Tag;
-                                 photo.AddTagUnsafely (tag);
-                         }
-                 }
-                 reader.Dispose();
-         }
-        
-         public override Photo Get (uint id)
-         {
-                 Photo photo = LookupInCache (id);
-                 if (photo != null)
-                         return photo;
-        
-                 IDataReader reader = Database.Query(
-                         new HyenaSqliteCommand("SELECT time, description, roll_id, default_version_id, rating " +
-                                       "FROM photos " +
-                                       "WHERE id = ?", id
-                                      )
-                 );
-        
-                 if (reader.Read ()) {
-                         photo = new Photo (id, Convert.ToInt64 (reader ["time"]));
-                         photo.Description = reader["description"].ToString ();
-                         photo.RollId = Convert.ToUInt32 (reader["roll_id"]);
-                         photo.DefaultVersionId = Convert.ToUInt32 (reader["default_version_id"]);
-                         photo.Rating = Convert.ToUInt32 (reader ["rating"]);
-                         AddToCache (photo);
-                 }
-                 reader.Dispose();
-        
-                 if (photo == null)
-                         return null;
-        
-                 GetTags (photo);
-                 GetVersions (photo);
-        
-                 return photo;
-         }
-        
-         public Photo GetByUri (SafeUri uri)
-         {
-                 Photo photo = null;
-        
-                 var base_uri = uri.GetBaseUri ();
-                 var filename = uri.GetFilename ();
-        
-                 IDataReader reader =
-                         Database.Query (new HyenaSqliteCommand ("SELECT id, time, description, roll_id, default_version_id, rating " +
-                                                        " FROM photos " +
-                                                        " LEFT JOIN photo_versions AS pv ON photos.id = pv.photo_id" +
-                                                        " WHERE (photos.base_uri = ? AND photos.filename = ?)" +
-                                                        " OR (pv.base_uri = ? AND pv.filename = ?)",
-                                                        base_uri.ToString (), filename,
-                                                        base_uri.ToString (), filename));
-        
-                 if (reader.Read ()) {
-                         photo = new Photo (Convert.ToUInt32 (reader ["id"]),
-                                            Convert.ToInt64 (reader ["time"]));
-        
-                         photo.Description = reader["description"].ToString ();
-                         photo.RollId = Convert.ToUInt32 (reader["roll_id"]);
-                         photo.DefaultVersionId = Convert.ToUInt32 (reader["default_version_id"]);
-                         photo.Rating = Convert.ToUInt32 (reader ["rating"]);
-                 }
-        
-                 reader.Dispose();
-        
-                 if (photo == null)
-                         return null;
-        
-                 Photo cached = LookupInCache (photo.Id);
-        
-                 if (cached != null)
-                         return cached;
-        
-                 AddToCache (photo);
-        
-                 GetTags (photo);
-                 GetVersions (photo);
-        
-                 return photo;
-         }
-        
-         public void Remove (Tag []tags)
-         {
-                 Photo [] photos = Query (tags, String.Empty, null, null);
-        
-                 foreach (Photo photo in photos)
-                         photo.RemoveCategory (tags);
-                 Commit (photos);
-        
-                 foreach (Tag tag in tags)
-                         App.Instance.Database.Tags.Remove (tag);
-        
-         }
-        
-         public void Remove (Photo []items)
-         {
-                 EmitRemoved (items);
-        
-                 List<string> query_builder = new List<string> (items.Length);
-                 for (int i = 0; i < items.Length; i++) {
-                         query_builder.Add (String.Format ("{0}", items[i].Id));
-                         RemoveFromCache (items[i]);
-                 }
-        
-                 String id_list = String.Join ("','", query_builder.ToArray ());
-                 Database.Execute (String.Format ("DELETE FROM photos WHERE id IN ('{0}')", id_list));
-                 Database.Execute (String.Format ("DELETE FROM photo_tags WHERE photo_id IN ('{0}')", id_list));
-                 Database.Execute (String.Format ("DELETE FROM photo_versions WHERE photo_id IN ('{0}')", id_list));
-        
-         }
-        
-         public override void Remove (Photo item)
-         {
-                 Remove (new Photo [] { (Photo)item });
-         }
-        
-         public override void Commit (Photo item)
-         {
-                 Commit (new Photo [] {item});
-         }
-        
-         public void Commit (Photo [] items)
-         {
-                 uint timer = Log.DebugTimerStart ();
-                 // Only use a transaction for multiple saves. Avoids recursive transactions.
-        
-                 // TODO.
-                 bool use_transactions = true; //!Database.InTransaction && items.Length > 1;
-        
-                 //if (use_transactions)
-                 //      Database.BeginTransaction ();
-        
-                 // FIXME: this hack is used, because HyenaSqliteConnection does not support
-                 // the InTransaction propery
-                 try {
-                         Database.BeginTransaction ();
-                 } catch {
-                         use_transactions = false;
-                 }
-        
-                 PhotosChanges changes = new PhotosChanges ();
-                 foreach (DbItem item in items)
-                         changes |= Update ((Photo)item);
-        
-                 if (use_transactions)
-                         Database.CommitTransaction ();
-        
-                 EmitChanged (items, new PhotoEventArgs (items, changes));
-                 Log.DebugTimerPrint (timer, "Commit took {0}");
-         }
-        
-         private PhotoChanges Update (Photo photo) {
-                 PhotoChanges changes = photo.Changes;
-                 // Update photo.
-                 if (changes.DescriptionChanged || changes.DefaultVersionIdChanged || changes.TimeChanged || changes.UriChanged || changes.RatingChanged || changes.MD5SumChanged )
-        
-                         Database.Execute (
-                                 new HyenaSqliteCommand (
-                                         "UPDATE photos " +
-                                         "SET description = ?, " +
-                                         "    default_version_id = ?, " +
-                                         "    time = ?, " +
-                                         "    base_uri = ?, " +
-                                         "    filename = ?, " +
-                                         "    rating = ? " +
-                                         "WHERE id = ? ",
-                                         photo.Description,
-                                         photo.DefaultVersionId,
-                                         DateTimeUtil.FromDateTime (photo.Time),
-                                         photo.VersionUri (Photo.OriginalVersionId).GetBaseUri ().ToString (),
-                                         photo.VersionUri (Photo.OriginalVersionId).GetFilename (),
-                                         String.Format ("{0}", photo.Rating),
-                                         photo.Id
-                                 )
-                         );
-        
-                 // Update tags.
-                 if (changes.TagsRemoved != null)
-                         foreach (Tag tag in changes.TagsRemoved)
-                                 Database.Execute (new HyenaSqliteCommand (
-                                         "DELETE FROM photo_tags WHERE photo_id = ? AND tag_id = ?",
-                                         photo.Id,
-                                         tag.Id));
-        
-                 if (changes.TagsAdded != null)
-                         foreach (Tag tag in changes.TagsAdded)
-                                 Database.Execute (new HyenaSqliteCommand (
-                                         "INSERT OR IGNORE INTO photo_tags (photo_id, tag_id) " +
-                                         "VALUES (?, ?)",
-                                         photo.Id,
-                                         tag.Id));
-        
-                 // Update versions.
-                 if (changes.VersionsRemoved != null)
-                         foreach (uint version_id in changes.VersionsRemoved)
-                                 Database.Execute (new HyenaSqliteCommand (
-                                         "DELETE FROM photo_versions WHERE photo_id = ? AND version_id = ?",
-                                         photo.Id,
-                                         version_id));
-        
-                 if (changes.VersionsAdded != null)
-                         foreach (uint version_id in changes.VersionsAdded) {
-                                 PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
-                                 InsertVersion (photo, version);
-                         }
-                 if (changes.VersionsModified != null)
-                         foreach (uint version_id in changes.VersionsModified) {
-                                 PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
-                                 Database.Execute (new HyenaSqliteCommand (
-                                         "UPDATE photo_versions SET name = ?, " +
-                                         "base_uri = ?, filename = ?, protected = ?, import_md5 = ? " +
-                                         "WHERE photo_id = ? AND version_id = ?",
-                                         version.Name,
-                                         version.BaseUri.ToString (),
-                                         version.Filename,
-                                         version.IsProtected,
-                                         (version.ImportMD5 != String.Empty ? version.ImportMD5 : null),
-                                         photo.Id,
-                                         version_id));
-                         }
-                 photo.Changes = null;
-                 return changes;
-         }
-        
-         public void CalculateMD5Sum (Photo photo) {
-                 foreach (uint version_id in photo.VersionIds) {
-                         PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
-        
-                         // Don't overwrite MD5 sums that are already calculated.
-                         if (version.ImportMD5 != String.Empty && version.ImportMD5 != null)
-                                 continue;
-        
-                         string version_md5_sum = HashUtils.GenerateMD5 (version.Uri);
-                         version.ImportMD5 = version_md5_sum;
-                         photo.Changes.ChangeVersion (version_id);
-                 }
-        
-                 Commit (photo);
-         }
-        
-         public int Count (string table_name, params IQueryCondition [] conditions)
-         {
-                 StringBuilder query_builder = new StringBuilder ("SELECT COUNT(*) AS count FROM " + table_name + " ");
-                 bool where_added = false;
-                 foreach (IQueryCondition condition in conditions) {
-                         if (condition == null)
-                                 continue;
-                         if (condition is IOrderCondition)
-                                 continue;
-                         query_builder.Append (where_added ? " AND " : " WHERE ");
-                         query_builder.Append (condition.SqlClause ());
-                         where_added = true;
-                 }
-        
-                 IDataReader reader = Database.Query (query_builder.ToString());
-                 reader.Read ();
-                 int count = Convert.ToInt32 (reader ["count"]);
-                 reader.Dispose();
-                 return count;
-         }
-        
-         public int [] IndicesOf (string table_name, uint [] items)
-         {
-                 StringBuilder query_builder = new StringBuilder ("SELECT ROWID AS row_id FROM ");
-                 query_builder.Append (table_name);
-                 query_builder.Append (" WHERE id IN (");
-                 for (int i = 0; i < items.Length; i++) {
-                         query_builder.Append (items [i]);
-                         query_builder.Append ((i != items.Length - 1) ? ", " : ")" );
-                 }
-                 return IndicesOf (query_builder.ToString ());
-         }
-        
-         public int IndexOf (string table_name, Photo photo)
-         {
-                 string query = String.Format ("SELECT ROWID AS row_id FROM {0} WHERE id = {1}", table_name, photo.Id);
-                 return IndexOf (query);
-         }
-        
-         public int IndexOf (string table_name, DateTime time, bool asc)
-         {
-                 string query = String.Format ("SELECT ROWID AS row_id FROM {0} WHERE time {2} {1} ORDER BY time {3} LIMIT 1",
-                                 table_name,
-                                 DateTimeUtil.FromDateTime (time),
-                                 asc ? ">=" : "<=",
-                                 asc ? "ASC" : "DESC");
-                 return IndexOf (query);
-         }
-        
-         private int IndexOf (string query)
-         {
-                 uint timer = Log.DebugTimerStart ();
-                 IDataReader reader = Database.Query (query);
-                 int index = - 1;
-                 if (reader.Read ())
-                         index = Convert.ToInt32 (reader ["row_id"]);
-                 reader.Dispose();
-                 Log.DebugTimerPrint (timer, "IndexOf took {0} : " + query);
-                 return index - 1; //ROWID starts counting at 1
-         }
-        
-         int [] IndicesOf (string query)
-         {
-                 uint timer = Log.DebugTimerStart ();
-                 List<int> list = new List<int> ();
-                 IDataReader reader = Database.Query (query);
-                 while (reader.Read ())
-                         list.Add (Convert.ToInt32 (reader ["row_id"]) - 1);
-                 reader.Dispose ();
-                 Log.DebugTimerPrint (timer, "IndicesOf took {0} : " + query);
-                 return list.ToArray ();
-         }
-        
-         public Dictionary<int,int[]> PhotosPerMonth (params IQueryCondition [] conditions)
-         {
-                 uint timer = Log.DebugTimerStart ();
-                 Dictionary<int, int[]> val = new Dictionary<int, int[]> ();
-        
-                 //Sqlite is way more efficient querying to a temp then grouping than grouping at once
-                 Database.Execute ("DROP TABLE IF EXISTS population");
-                 StringBuilder query_builder = new StringBuilder ("CREATE TEMPORARY TABLE population AS SELECT strftime('%Y%m', datetime(time, 'unixepoch')) AS month FROM photos");
-                 bool where_added = false;
-                 foreach (IQueryCondition condition in conditions) {
-                         if (condition == null)
-                                 continue;
-                         if (condition is IOrderCondition)
-                                 continue;
-                         query_builder.Append (where_added ? " AND " : " WHERE ");
-                         query_builder.Append (condition.SqlClause ());
-                         where_added = true;
-                 }
-                 Database.Execute (query_builder.ToString ());
+		 // Constructor
+		 public PhotoStore (FSpotDatabaseConnection database, bool is_new)
+				 : base (database, false)
+		 {
+				 EnsureThumbnailDirectory ();
+		
+				 if (! is_new)
+						 return;
+		
+				 Database.Execute (
+						 "CREATE TABLE photos (\n" +
+						 "       id                      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \n" +
+						 "       time                    INTEGER NOT NULL, \n" +
+						 "       base_uri                STRING NOT NULL, \n" +
+					 "   filename                STRING NOT NULL, \n" +
+						 "       description             TEXT NOT NULL, \n" +
+						 "       roll_id                 INTEGER NOT NULL, \n" +
+						 "       default_version_id      INTEGER NOT NULL, \n" +
+						 "       rating                  INTEGER NULL \n" +
+						 ")");
+		
+				 Database.Execute (
+						 "CREATE TABLE photo_tags (\n" +
+						 "       photo_id        INTEGER, \n" +
+						 "       tag_id          INTEGER, \n" +
+						 "       UNIQUE (photo_id, tag_id)\n" +
+						 ")");
+		
+				 Database.Execute (
+						 "CREATE TABLE photo_versions (\n"+
+						 "       photo_id        INTEGER, \n" +
+						 "       version_id      INTEGER, \n" +
+						 "       name            STRING, \n" +
+						 "       base_uri                STRING NOT NULL, \n" +
+					 "   filename                STRING NOT NULL, \n" +
+						 "       import_md5              TEXT NULL, \n" +
+						 "       protected       BOOLEAN, \n" +
+						 "       UNIQUE (photo_id, version_id)\n" +
+						 ")");
+		
+				 Database.Execute ("CREATE INDEX idx_photo_versions_id ON photo_versions(photo_id)");
+				 Database.Execute ("CREATE INDEX idx_photo_versions_import_md5 ON photo_versions(import_md5)");
+				 Database.Execute ("CREATE INDEX idx_photos_roll_id ON photos(roll_id)");
+		 }
+		
+		 public bool HasDuplicate (IPhoto item) {
+				 var uri = item.DefaultVersion.Uri;
+		
+				 // Check if the exact given uri already exists.
+				 var query = "SELECT COUNT(*) AS count FROM photo_versions WHERE base_uri = ? AND filename = ?";
+				 var reader = Database.Query (new HyenaSqliteCommand (query, uri.GetBaseUri ().ToString (), uri.GetFilename ()));
+				 reader.Read ();
+				 int count = Convert.ToInt32 (reader ["count"]);
+				 reader.Dispose();
+				 if (count > 0)
+						 return true;
+		
+				 // Check by MD5. Won't import if there are photos with the same ImportMD5.
+				 string hash = item.DefaultVersion.ImportMD5;
+				 var condition = new ConditionWrapper (String.Format ("import_md5 = \"{0}\"", hash));
+				 var dupes_by_hash = Count ("photo_versions", condition);
+				 if (dupes_by_hash > 0)
+						 return true;
+		
+				 // This is a very lame check to overcome the lack of duplicate detect data right after transition.
+				 //
+				 // Does filename matching if there are files with no hash for the original version.
+				 condition = new ConditionWrapper ("version_id = 1 AND (import_md5 = \"\" OR import_md5 IS NULL)");
+				 var have_no_hashes = Count ("photo_versions", condition);
+				 if (have_no_hashes > 0) {
+						 var name = uri.GetFilename ();
+						 DateTime? time = null;
+		
+						 // Look for a filename match.
+						 reader = Database.Query (new HyenaSqliteCommand ("SELECT photos.id, photos.time, pv.filename FROM photos LEFT JOIN photo_versions AS pv ON pv.photo_id = photos.id WHERE pv.filename = ?", name));
+						 while (reader.Read ()) {
+								 Log.DebugFormat ("Found one possible duplicate for {0}", reader["filename"].ToString ());
+								 if (!time.HasValue) {
+										 // Only read time when needed
+										 time = item.Time;
+								 }
+		
+								 if (reader["time"].ToString () == DateTimeUtil.FromDateTime (time.Value).ToString ()) {
+										 Log.Debug ("Skipping duplicate", uri);
+		
+										 // Schedule a hash calculation job on the existing file.
+										 CalculateHashJob.Create (FSpot.App.Instance.Database.Jobs, Convert.ToUInt32 (reader["id"]));
+		
+										 return true;
+								 }
+						 }
+						 reader.Dispose ();
+				 }
+		
+				 // No matches
+				 return false;
+		 }
+		
+		 public Photo CreateFrom (IPhoto item, uint roll_id)
+		 {
+				 Photo photo;
+		
+				 long unix_time = DateTimeUtil.FromDateTime (item.Time);
+				 string description = item.Description ?? String.Empty;
+		
+				 uint id = (uint) Database.Execute (
+						 new HyenaSqliteCommand (
+								 "INSERT INTO photos (time, base_uri, filename, description, roll_id, default_version_id, rating) "      +
+								 "VALUES (?, ?, ?, ?, ?, ?, ?)",
+								 unix_time,
+								 item.DefaultVersion.BaseUri.ToString (),
+								 item.DefaultVersion.Filename,
+								 description,
+								 roll_id,
+								 Photo.OriginalVersionId,
+								 "0"
+						 )
+				 );
+		
+				 photo = new Photo (id, unix_time);
+				 photo.AddVersionUnsafely (Photo.OriginalVersionId, item.DefaultVersion.BaseUri, item.DefaultVersion.Filename, item.DefaultVersion.ImportMD5, Catalog.GetString ("Original"), true);
+				 photo.AllVersionsLoaded = true;
+		
+				 InsertVersion (photo, photo.DefaultVersion as PhotoVersion);
+				 EmitAdded (photo);
+				 return photo;
+		 }
+		
+		 private void InsertVersion (Photo photo, PhotoVersion version)
+		 {
+				 Database.Execute (new HyenaSqliteCommand (
+						 "INSERT OR IGNORE INTO photo_versions (photo_id, version_id, name, base_uri, filename, protected, import_md5) " +
+						 "VALUES (?, ?, ?, ?, ?, ?, ?)",
+						 photo.Id,
+						 version.VersionId,
+						 version.Name,
+						 version.BaseUri.ToString (),
+						 version.Filename,
+						 version.IsProtected,
+						 (version.ImportMD5 != String.Empty ? version.ImportMD5 : null)));
+		 }
+		
+		
+		 private void GetVersions (Photo photo)
+		 {
+				 IDataReader reader = Database.Query(
+						 new HyenaSqliteCommand("SELECT version_id, name, base_uri, filename, import_md5, protected " +
+									   "FROM photo_versions " +
+									   "WHERE photo_id = ?",
+									   photo.Id
+						 )
+				 );
+		
+				 while (reader.Read ()) {
+						 uint version_id = Convert.ToUInt32 (reader ["version_id"]);
+						 string name = reader["name"].ToString ();
+						 var base_uri = new SafeUri (reader ["base_uri"].ToString (), true);
+						 var filename = reader ["filename"].ToString ();
+						 string import_md5 = reader["import_md5"] != null ? reader ["import_md5"].ToString () : null;
+						 bool is_protected = Convert.ToBoolean (reader["protected"]);
+		
+						 photo.AddVersionUnsafely (version_id, base_uri, filename, import_md5, name, is_protected);
+				 }
+				 reader.Dispose();
+		 }
+		
+		 private void GetTags (Photo photo)
+		 {
+				 IDataReader reader = Database.Query(new HyenaSqliteCommand("SELECT tag_id FROM photo_tags WHERE photo_id = ?", photo.Id));
+		
+				 while (reader.Read ()) {
+						 uint tag_id = Convert.ToUInt32 (reader ["tag_id"]);
+						 Tag tag = App.Instance.Database.Tags.Get (tag_id);
+						 photo.AddTagUnsafely (tag);
+				 }
+				 reader.Dispose();
+		 }
+		
+		 private void GetAllVersions  (string ids) {
+				 IDataReader reader = Database.Query ("SELECT photo_id, version_id, name, base_uri, filename, import_md5, protected FROM photo_versions WHERE photo_id IN " + ids);
+		
+				 while (reader.Read ()) {
+						 uint id = Convert.ToUInt32 (reader ["photo_id"]);
+						 Photo photo = LookupInCache (id);
+		
+						 if (photo == null) {
+								 //Console.WriteLine ("Photo {0} not found", id);
+								 continue;
+						 }
+		
+						 if (photo.AllVersionsLoaded) {
+								 //Console.WriteLine ("Photo {0} already Loaded", photo);
+								 continue;
+						 }
+		
+						 if (reader ["version_id"] != null) {
+								 uint version_id = Convert.ToUInt32 (reader ["version_id"]);
+								 string name = reader["name"].ToString ();
+								 var base_uri = new SafeUri (reader ["base_uri"].ToString (), true);
+								 var filename = reader ["filename"].ToString ();
+								 string import_md5 = reader["import_md5"] != null ? reader ["import_md5"].ToString () : null;
+								 bool is_protected = Convert.ToBoolean (reader["protected"]);
+		
+								 photo.AddVersionUnsafely (version_id, base_uri, filename, import_md5, name, is_protected);
+						 }
+		
+						 /*
+						 string directory_path = null;
+						 if (reader [3] != null)
+								 directory_path = reader [3].ToString ();
+						 System.Console.WriteLine ("directory_path = {0}", directory_path);
+						 */
+				 }
+				 reader.Dispose();
+		 }
+		
+		 private void GetAllTags (string ids) {
+				 IDataReader reader = Database.Query ("SELECT photo_id, tag_id FROM photo_tags WHERE photo_id IN " + ids);
+		
+				 while (reader.Read ()) {
+						 uint id = Convert.ToUInt32 (reader ["photo_id"]);
+						 Photo photo = LookupInCache (id);
+		
+						 if (photo == null) {
+								 //Console.WriteLine ("Photo {0} not found", id);
+								 continue;
+						 }
+		
+						 if (photo.AllVersionsLoaded) {
+								 //Console.WriteLine ("Photo {0} already Loaded", photo.Id);
+								 continue;
+						 }
+		
+						 if (reader [1] != null) {
+								 uint tag_id = Convert.ToUInt32 (reader ["tag_id"]);
+								 Tag tag = App.Instance.Database.Tags.Get (tag_id) as Tag;
+								 photo.AddTagUnsafely (tag);
+						 }
+				 }
+				 reader.Dispose();
+		 }
+		
+		 public override Photo Get (uint id)
+		 {
+				 Photo photo = LookupInCache (id);
+				 if (photo != null)
+						 return photo;
+		
+				 IDataReader reader = Database.Query(
+						 new HyenaSqliteCommand("SELECT time, description, roll_id, default_version_id, rating " +
+									   "FROM photos " +
+									   "WHERE id = ?", id
+									  )
+				 );
+		
+				 if (reader.Read ()) {
+						 photo = new Photo (id, Convert.ToInt64 (reader ["time"]));
+						 photo.Description = reader["description"].ToString ();
+						 photo.RollId = Convert.ToUInt32 (reader["roll_id"]);
+						 photo.DefaultVersionId = Convert.ToUInt32 (reader["default_version_id"]);
+						 photo.Rating = Convert.ToUInt32 (reader ["rating"]);
+						 AddToCache (photo);
+				 }
+				 reader.Dispose();
+		
+				 if (photo == null)
+						 return null;
+		
+				 GetTags (photo);
+				 GetVersions (photo);
+		
+				 return photo;
+		 }
+		
+		 public Photo GetByUri (SafeUri uri)
+		 {
+				 Photo photo = null;
+		
+				 var base_uri = uri.GetBaseUri ();
+				 var filename = uri.GetFilename ();
+		
+				 IDataReader reader =
+						 Database.Query (new HyenaSqliteCommand ("SELECT id, time, description, roll_id, default_version_id, rating " +
+														" FROM photos " +
+														" LEFT JOIN photo_versions AS pv ON photos.id = pv.photo_id" +
+														" WHERE (photos.base_uri = ? AND photos.filename = ?)" +
+														" OR (pv.base_uri = ? AND pv.filename = ?)",
+														base_uri.ToString (), filename,
+														base_uri.ToString (), filename));
+		
+				 if (reader.Read ()) {
+						 photo = new Photo (Convert.ToUInt32 (reader ["id"]),
+											Convert.ToInt64 (reader ["time"]));
+		
+						 photo.Description = reader["description"].ToString ();
+						 photo.RollId = Convert.ToUInt32 (reader["roll_id"]);
+						 photo.DefaultVersionId = Convert.ToUInt32 (reader["default_version_id"]);
+						 photo.Rating = Convert.ToUInt32 (reader ["rating"]);
+				 }
+		
+				 reader.Dispose();
+		
+				 if (photo == null)
+						 return null;
+		
+				 Photo cached = LookupInCache (photo.Id);
+		
+				 if (cached != null)
+						 return cached;
+		
+				 AddToCache (photo);
+		
+				 GetTags (photo);
+				 GetVersions (photo);
+		
+				 return photo;
+		 }
+		
+		 public void Remove (Tag []tags)
+		 {
+				 Photo [] photos = Query (tags, String.Empty, null, null);
+		
+				 foreach (Photo photo in photos)
+						 photo.RemoveCategory (tags);
+				 Commit (photos);
+		
+				 foreach (Tag tag in tags)
+						 App.Instance.Database.Tags.Remove (tag);
+		
+		 }
+		
+		 public void Remove (Photo []items)
+		 {
+				 EmitRemoved (items);
+		
+				 List<string> query_builder = new List<string> (items.Length);
+				 foreach (Photo t in items)
+				 {
+				 	query_builder.Add (String.Format ("{0}", t.Id));
+				 	RemoveFromCache (t);
+				 }
+		
+				 String id_list = String.Join ("','", query_builder.ToArray ());
+				 Database.Execute (String.Format ("DELETE FROM photos WHERE id IN ('{0}')", id_list));
+				 Database.Execute (String.Format ("DELETE FROM photo_tags WHERE photo_id IN ('{0}')", id_list));
+				 Database.Execute (String.Format ("DELETE FROM photo_versions WHERE photo_id IN ('{0}')", id_list));
+		
+		 }
+		
+		 public override void Remove (Photo item)
+		 {
+				 Remove (new Photo [] { item });
+		 }
+		
+		 public override void Commit (Photo item)
+		 {
+				 Commit (new Photo [] {item});
+		 }
+		
+		 public void Commit (Photo [] items)
+		 {
+				 uint timer = Log.DebugTimerStart ();
+				 // Only use a transaction for multiple saves. Avoids recursive transactions.
+		
+				 // TODO.
+				 bool use_transactions = true; //!Database.InTransaction && items.Length > 1;
+		
+				 //if (use_transactions)
+				 //      Database.BeginTransaction ();
+		
+				 // FIXME: this hack is used, because HyenaSqliteConnection does not support
+				 // the InTransaction propery
+				 try {
+						 Database.BeginTransaction ();
+				 } catch {
+						 use_transactions = false;
+				 }
+		
+				 PhotosChanges changes = new PhotosChanges ();
+				 foreach (DbItem item in items)
+						 changes |= Update ((Photo)item);
+		
+				 if (use_transactions)
+						 Database.CommitTransaction ();
+		
+				 EmitChanged (items, new PhotoEventArgs (items, changes));
+				 Log.DebugTimerPrint (timer, "Commit took {0}");
+		 }
+		
+		 private PhotoChanges Update (Photo photo) {
+				 PhotoChanges changes = photo.Changes;
+				 // Update photo.
+				 if (changes.DescriptionChanged || changes.DefaultVersionIdChanged || changes.TimeChanged || changes.UriChanged || changes.RatingChanged || changes.MD5SumChanged )
+		
+						 Database.Execute (
+								 new HyenaSqliteCommand (
+										 "UPDATE photos " +
+										 "SET description = ?, " +
+										 "    default_version_id = ?, " +
+										 "    time = ?, " +
+										 "    base_uri = ?, " +
+										 "    filename = ?, " +
+										 "    rating = ? " +
+										 "WHERE id = ? ",
+										 photo.Description,
+										 photo.DefaultVersionId,
+										 DateTimeUtil.FromDateTime (photo.Time),
+										 photo.VersionUri (Photo.OriginalVersionId).GetBaseUri ().ToString (),
+										 photo.VersionUri (Photo.OriginalVersionId).GetFilename (),
+										 String.Format ("{0}", photo.Rating),
+										 photo.Id
+								 )
+						 );
+		
+				 // Update tags.
+				 if (changes.TagsRemoved != null)
+						 foreach (Tag tag in changes.TagsRemoved)
+								 Database.Execute (new HyenaSqliteCommand (
+										 "DELETE FROM photo_tags WHERE photo_id = ? AND tag_id = ?",
+										 photo.Id,
+										 tag.Id));
+		
+				 if (changes.TagsAdded != null)
+						 foreach (Tag tag in changes.TagsAdded)
+								 Database.Execute (new HyenaSqliteCommand (
+										 "INSERT OR IGNORE INTO photo_tags (photo_id, tag_id) " +
+										 "VALUES (?, ?)",
+										 photo.Id,
+										 tag.Id));
+		
+				 // Update versions.
+				 if (changes.VersionsRemoved != null)
+						 foreach (uint version_id in changes.VersionsRemoved)
+								 Database.Execute (new HyenaSqliteCommand (
+										 "DELETE FROM photo_versions WHERE photo_id = ? AND version_id = ?",
+										 photo.Id,
+										 version_id));
+		
+				 if (changes.VersionsAdded != null)
+						 foreach (uint version_id in changes.VersionsAdded) {
+								 PhotoVersion version = photo.GetVersion (version_id);
+								 InsertVersion (photo, version);
+						 }
+				 if (changes.VersionsModified != null)
+						 foreach (uint version_id in changes.VersionsModified) {
+								 PhotoVersion version = photo.GetVersion (version_id);
+								 Database.Execute (new HyenaSqliteCommand (
+										 "UPDATE photo_versions SET name = ?, " +
+										 "base_uri = ?, filename = ?, protected = ?, import_md5 = ? " +
+										 "WHERE photo_id = ? AND version_id = ?",
+										 version.Name,
+										 version.BaseUri.ToString (),
+										 version.Filename,
+										 version.IsProtected,
+										 (version.ImportMD5 != String.Empty ? version.ImportMD5 : null),
+										 photo.Id,
+										 version_id));
+						 }
+				 photo.Changes = null;
+				 return changes;
+		 }
+		
+		 public void CalculateMD5Sum (Photo photo) {
+				 foreach (uint version_id in photo.VersionIds) {
+						 PhotoVersion version = photo.GetVersion (version_id);
+		
+					 // FIXME: What's this for?  Pointless?
+						 // Don't overwrite MD5 sums that are already calculated.
+						 if (!string.IsNullOrEmpty(version.ImportMD5))
+								 continue;
+		
+						 string version_md5_sum = HashUtils.GenerateMD5 (version.Uri);
+						 version.ImportMD5 = version_md5_sum;
+						 photo.Changes.ChangeVersion (version_id);
+				 }
+		
+				 Commit (photo);
+		 }
+		
+		 public int Count (string table_name, params IQueryCondition [] conditions)
+		 {
+				 StringBuilder query_builder = new StringBuilder ("SELECT COUNT(*) AS count FROM " + table_name + " ");
+				 bool where_added = false;
+				 foreach (IQueryCondition condition in conditions) {
+					 // FIXME: What's the point of this?
+						 if (condition == null)
+								 continue;
+						 if (condition is IOrderCondition)
+								 continue;
+						 query_builder.Append (where_added ? " AND " : " WHERE ");
+						 query_builder.Append (condition.SqlClause ());
+						 where_added = true;
+				 }
+		
+				 IDataReader reader = Database.Query (query_builder.ToString());
+				 reader.Read ();
+				 int count = Convert.ToInt32 (reader ["count"]);
+				 reader.Dispose();
+				 return count;
+		 }
+		
+		 public int [] IndicesOf (string table_name, uint [] items)
+		 {
+				 StringBuilder query_builder = new StringBuilder ("SELECT ROWID AS row_id FROM ");
+				 query_builder.Append (table_name);
+				 query_builder.Append (" WHERE id IN (");
+				 for (int i = 0; i < items.Length; i++) {
+						 query_builder.Append (items [i]);
+						 query_builder.Append ((i != items.Length - 1) ? ", " : ")" );
+				 }
+				 return IndicesOf (query_builder.ToString ());
+		 }
+		
+		 public int IndexOf (string table_name, Photo photo)
+		 {
+				 string query = String.Format ("SELECT ROWID AS row_id FROM {0} WHERE id = {1}", table_name, photo.Id);
+				 return IndexOf (query);
+		 }
+		
+		 public int IndexOf (string table_name, DateTime time, bool asc)
+		 {
+				 string query = String.Format ("SELECT ROWID AS row_id FROM {0} WHERE time {2} {1} ORDER BY time {3} LIMIT 1",
+								 table_name,
+								 DateTimeUtil.FromDateTime (time),
+								 asc ? ">=" : "<=",
+								 asc ? "ASC" : "DESC");
+				 return IndexOf (query);
+		 }
+		
+		 private int IndexOf (string query)
+		 {
+				 uint timer = Log.DebugTimerStart ();
+				 IDataReader reader = Database.Query (query);
+				 int index = - 1;
+				 if (reader.Read ())
+						 index = Convert.ToInt32 (reader ["row_id"]);
+				 reader.Dispose();
+				 Log.DebugTimerPrint (timer, "IndexOf took {0} : " + query);
+				 return index - 1; //ROWID starts counting at 1
+		 }
+		
+		 int [] IndicesOf (string query)
+		 {
+				 uint timer = Log.DebugTimerStart ();
+				 List<int> list = new List<int> ();
+				 IDataReader reader = Database.Query (query);
+				 while (reader.Read ())
+						 list.Add (Convert.ToInt32 (reader ["row_id"]) - 1);
+				 reader.Dispose ();
+				 Log.DebugTimerPrint (timer, "IndicesOf took {0} : " + query);
+				 return list.ToArray ();
+		 }
+		
+		 public Dictionary<int,int[]> PhotosPerMonth (params IQueryCondition [] conditions)
+		 {
+				 uint timer = Log.DebugTimerStart ();
+				 Dictionary<int, int[]> val = new Dictionary<int, int[]> ();
+		
+				 //Sqlite is way more efficient querying to a temp then grouping than grouping at once
+				 Database.Execute ("DROP TABLE IF EXISTS population");
+				 StringBuilder query_builder = new StringBuilder ("CREATE TEMPORARY TABLE population AS SELECT strftime('%Y%m', datetime(time, 'unixepoch')) AS month FROM photos");
+				 bool where_added = false;
+				 foreach (IQueryCondition condition in conditions) {
+						 if (condition == null)
+								 continue;
+						 if (condition is IOrderCondition)
+								 continue;
+						 query_builder.Append (where_added ? " AND " : " WHERE ");
+						 query_builder.Append (condition.SqlClause ());
+						 where_added = true;
+				 }
+				 Database.Execute (query_builder.ToString ());
 
-                 int minyear = Int32.MaxValue;
-                 int maxyear = Int32.MinValue;
+				 int minyear = Int32.MaxValue;
+				 int maxyear = Int32.MinValue;
 
 		// FIXME: There appears to be a race condition here where it tries to query the population
 		// table before Database.Execute (query_builder.ToString ()); creates it.
-                 IDataReader reader = Database.Query ("SELECT COUNT (*) as count, month from population GROUP BY month");
-                 while (reader.Read ()) {
-                         string yyyymm = reader ["month"].ToString ();
-                         int count = Convert.ToInt32 (reader ["count"]);
-                         int year = Convert.ToInt32 (yyyymm.Substring (0,4));
-                         maxyear = Math.Max (year, maxyear);
-                         minyear = Math.Min (year, minyear);
-                         int month = Convert.ToInt32 (yyyymm.Substring (4));
-                         if (!val.ContainsKey (year))
-                                 val.Add (year, new int[12]);
-                         val[year][month-1] = count;
-                 }
-                 reader.Dispose ();
-        
-                 //Fill the blank
-                 for (int i = minyear; i <= maxyear; i++)
-                         if (!val.ContainsKey (i))
-                                 val.Add (i, new int[12]);
-        
-                 Log.DebugTimerPrint (timer, "PhotosPerMonth took {0}");
-                 return val;
-         }
-        
-         // Queries.
-         [Obsolete ("drop this, use IQueryCondition correctly instead")]
-         public Photo [] Query (Tag [] tags) {
-                 return Query (tags, null, null, null, null);
-         }
-        
-         private string BuildQuery (params IQueryCondition [] conditions)
-         {
-                 StringBuilder query_builder = new StringBuilder ("SELECT * FROM photos ");
-        
-                 bool where_added = false;
-                 bool hidden_contained = false;
-                 foreach (IQueryCondition condition in conditions) {
-        
-                         if (condition == null)
-                                 continue;
-        
-                         if (condition is HiddenTag)
-                                 hidden_contained = true;
-        
-                         if (condition is IOrderCondition)
-                                 continue;
-        
-                         string sql_clause = condition.SqlClause ();
-        
-                         if (sql_clause == null || sql_clause.Trim () == String.Empty)
-                                 continue;
-                         query_builder.Append (where_added ? " AND " : " WHERE ");
-                         query_builder.Append (sql_clause);
-                         where_added = true;
-                 }
-        
-                 /* if a HiddenTag condition is not explicitly given, we add one */
-                 if ( ! hidden_contained) {
-                         string sql_clause = HiddenTag.HideHiddenTag.SqlClause ();
-        
-                         if (sql_clause != null && sql_clause.Trim () != String.Empty) {
-                                 query_builder.Append (where_added ? " AND " : " WHERE ");
-                                 query_builder.Append (sql_clause);
-                         }
-                 }
-        
-                 bool order_added = false;
-                 foreach (IQueryCondition condition in conditions) {
-                         if (condition == null)
-                                 continue;
-        
-                         if (!(condition is IOrderCondition))
-                                 continue;
-        
-                         string sql_clause = condition.SqlClause ();
-        
-                         if (sql_clause == null || sql_clause.Trim () == String.Empty)
-                                 continue;
-                         query_builder.Append (order_added ? " , " : "ORDER BY ");
-                         query_builder.Append (sql_clause);
-                         order_added = true;
-                 }
-        
-                 return query_builder.ToString ();
-         }
-        
-         public Photo [] Query (params IQueryCondition [] conditions)
-         {
-                 return Query (BuildQuery (conditions));
-         }
-        
-         public void QueryToTemp (string temp_table, params IQueryCondition [] conditions)
-         {
-                 QueryToTemp (temp_table, BuildQuery (conditions));
-         }
-        
-         public void QueryToTemp(string temp_table, string query)
-         {
-                 uint timer = Log.DebugTimerStart ();
-                 Log.DebugFormat ("Query Started : {0}", query);
-                 Database.BeginTransaction ();
-                 Database.Execute (String.Format ("DROP TABLE IF EXISTS {0}", temp_table));
-                 Database.Execute (String.Format ("CREATE TEMPORARY TABLE {0} AS {1}", temp_table, query));
-                 // For Hyena.Data.Sqlite, we need to call Execute. Calling Query here does fail.
-                 //Database.Query (String.Format ("CREATE TEMPORARY TABLE {0} AS {1}", temp_table, query)).Close ();
-                 Database.CommitTransaction ();
-                 Log.DebugTimerPrint (timer, "QueryToTemp took {0} : " + query);
-         }
-        
-         public Photo [] QueryFromTemp (string temp_table)
-         {
-                 return QueryFromTemp (temp_table, 0, -1);
-         }
-        
-         public Photo [] QueryFromTemp (string temp_table, int offset, int limit)
-         {
-                 return Query (String.Format ("SELECT * FROM {0} LIMIT {1} OFFSET {2}", temp_table, limit, offset));
-         }
-        
-         public Photo [] Query (string query)
-         {
-                 return Query (new HyenaSqliteCommand (query));
-         }
-        
-         private Photo [] Query (HyenaSqliteCommand query)
-         {
-                 uint timer = Log.DebugTimerStart ();
-                 IDataReader reader = Database.Query(query);
-        
-                 List<Photo> new_photos = new List<Photo> ();
-                 List<Photo> query_result = new List<Photo> ();
-                 while (reader.Read ()) {
-                         uint id = Convert.ToUInt32 (reader ["id"]);
-                         Photo photo = LookupInCache (id);
-        
-                         if (photo == null) {
-                                 photo = new Photo (id, Convert.ToInt64 (reader ["time"]));
-                                 photo.Description = reader["description"].ToString ();
-                                 photo.RollId = Convert.ToUInt32 (reader["roll_id"]);
-                                 photo.DefaultVersionId = Convert.ToUInt32 (reader["default_version_id"]);
-                                 photo.Rating = Convert.ToUInt32 (reader ["rating"]);
-                                 new_photos.Add (photo);
-                         }
-        
-                         query_result.Add (photo);
-                 }
-                 reader.Dispose();
-        
-                 bool need_load = false;
-                 string photo_ids = "(";
-                 foreach (Photo photo in new_photos) {
-                         AddToCache (photo);
-                         photo_ids = photo_ids + Convert.ToString(photo.Id) + ",";
-                         need_load |= !photo.AllVersionsLoaded;
-                 }
-        
-                 photo_ids = photo_ids + "-1)";
-        
-                 if (need_load) {
-                         GetAllTags (photo_ids);
-                         GetAllVersions (photo_ids);
-                         foreach (Photo photo in new_photos)
-                                 photo.AllVersionsLoaded = true;
-                 } else {
-                         //Console.WriteLine ("Skipped Loading Data");
-                 }
-        
-                 foreach (Photo photo in new_photos)
-                         photo.Changes = null;
-        
-                 Log.DebugTimerPrint (timer, "Query took {0} : " + query.Text);
-                 return query_result.ToArray ();
-         }
-        
-         public Photo [] Query (SafeUri uri)
-         {
-                 string filename = uri.GetFilename ();
-        
-                 /* query by file */
-                 if ( ! String.IsNullOrEmpty (filename)) {
-                         return Query (new HyenaSqliteCommand (
-                         "SELECT id, "                   +
-                                 "time, "                        +
-                                 "base_uri, "            +
-                                 "filename, "            +
-                                 "description, "         +
-                                 "roll_id, "             +
-                                 "default_version_id, "  +
-                                 "rating "               +
-                         "FROM photos "                          +
-                         "WHERE base_uri LIKE ?"         +
-                         "AND filename LIKE ?",
-                          uri.GetBaseUri ().ToString (),
-                         filename));
-                 }
-        
-                 /* query by directory */
-                 return Query (new HyenaSqliteCommand (
-                         "SELECT id, "                   +
-                                 "time, "                        +
-                                 "base_uri, "            +
-                                 "filename, "            +
-                                 "description, "         +
-                                 "roll_id, "             +
-                                 "default_version_id, "  +
-                                 "rating "               +
-                         "FROM photos "                          +
-                         "WHERE base_uri LIKE ?"         +
-                         "AND base_uri NOT LIKE ?",
-                         uri.ToString () + "%",
-                         uri.ToString () + "/%/%"));
-         }
-        
-         [Obsolete ("drop this, use IQueryCondition correctly instead")]
-         public Photo [] Query (Tag [] tags, string extra_condition, DateRange range, RollSet importidrange)
-         {
-                 return Query (FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, null);
-         }
-        
-         [Obsolete ("drop this, use IQueryCondition correctly instead")]
-         public Photo [] Query (Tag [] tags, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange)
-         {
-                 return Query (FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, ratingrange);
-         }
-        
-         [Obsolete ("drop this, use IQueryCondition correctly instead")]
-         public Photo [] Query (Term searchexpression, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange)
-         {
-                 bool hide = (extra_condition == null);
-        
-                 // The SQL query that we want to construct is:
-                 //
-                 // SELECT photos.id
-                 //        photos.time
-                 //        photos.uri,
-                 //        photos.description,
-                 //        photos.roll_id,
-                 //        photos.default_version_id
-                 //        photos.rating
-                 //                  FROM photos, photo_tags
-                 //                  WHERE photos.time >= time1 AND photos.time <= time2
-                 //                              AND photos.rating >= rat1 AND photos.rating <= rat2
-                 //                              AND photos.id NOT IN (select photo_id FROM photo_tags WHERE tag_id = HIDDEN)
-                 //                              AND photos.id IN (select photo_id FROM photo_tags where tag_id IN (tag1, tag2..)
-                 //                              AND extra_condition_string
-                 //                  GROUP BY photos.id
-        
-                 StringBuilder query_builder = new StringBuilder ();
-                 List<string> where_clauses = new List<string> ();
-                 query_builder.Append ("SELECT id, "                     +
-                                              "time, "                   +
-                                              "base_uri, "                       +
-                                              "filename, "                       +
-                                              "description, "            +
-                                              "roll_id, "                +
-                                              "default_version_id, "     +
-                                              "rating "                  +
-                                       "FROM photos ");
-        
-                 if (range != null) {
-                         where_clauses.Add (String.Format ("time >= {0} AND time <= {1}",
-                                                           DateTimeUtil.FromDateTime (range.Start),
-                                                           DateTimeUtil.FromDateTime (range.End)));
-        
-                 }
-        
-                 if (ratingrange != null) {
-                         where_clauses.Add (ratingrange.SqlClause ());
-                 }
-        
-                 if (importidrange != null) {
-                         where_clauses.Add (importidrange.SqlClause ());
-                 }
-        
-                 if (hide && App.Instance.Database.Tags.Hidden != null) {
-                         where_clauses.Add (String.Format ("id NOT IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0})",
-                                                           App.Instance.Database.Tags.Hidden.Id));
-                 }
-        
-                 if (searchexpression != null) {
-                         where_clauses.Add (searchexpression.SqlCondition ());
-                 }
-        
-                 if (extra_condition != null && extra_condition.Trim () != String.Empty) {
-                         where_clauses.Add (extra_condition);
-                 }
-        
-                 if (where_clauses.Count > 0) {
-                         query_builder.Append (" WHERE ");
-                         query_builder.Append (String.Join (" AND ", where_clauses.ToArray ()));
-                 }
-                 query_builder.Append (" ORDER BY time");
-                 return Query (query_builder.ToString ());
-         }
-        }
+				 IDataReader reader = Database.Query ("SELECT COUNT (*) as count, month from population GROUP BY month");
+				 while (reader.Read ()) {
+						 string yyyymm = reader ["month"].ToString ();
+						 int count = Convert.ToInt32 (reader ["count"]);
+						 int year = Convert.ToInt32 (yyyymm.Substring (0,4));
+						 maxyear = Math.Max (year, maxyear);
+						 minyear = Math.Min (year, minyear);
+						 int month = Convert.ToInt32 (yyyymm.Substring (4));
+						 if (!val.ContainsKey (year))
+								 val.Add (year, new int[12]);
+						 val[year][month-1] = count;
+				 }
+				 reader.Dispose ();
+		
+				 //Fill the blank
+				 for (int i = minyear; i <= maxyear; i++)
+						 if (!val.ContainsKey (i))
+								 val.Add (i, new int[12]);
+		
+				 Log.DebugTimerPrint (timer, "PhotosPerMonth took {0}");
+				 return val;
+		 }
+		
+		 // Queries.
+		 [Obsolete ("drop this, use IQueryCondition correctly instead")]
+		 public Photo [] Query (Tag [] tags) {
+				 return Query (tags, null, null, null, null);
+		 }
+		
+		 private string BuildQuery (params IQueryCondition [] conditions)
+		 {
+				 StringBuilder query_builder = new StringBuilder ("SELECT * FROM photos ");
+		
+				 bool where_added = false;
+				 bool hidden_contained = false;
+				 foreach (IQueryCondition condition in conditions) {
+		
+						 if (condition == null)
+								 continue;
+		
+						 if (condition is HiddenTag)
+								 hidden_contained = true;
+		
+						 if (condition is IOrderCondition)
+								 continue;
+		
+						 string sql_clause = condition.SqlClause ();
+		
+						 if (sql_clause == null || sql_clause.Trim () == String.Empty)
+								 continue;
+						 query_builder.Append (where_added ? " AND " : " WHERE ");
+						 query_builder.Append (sql_clause);
+						 where_added = true;
+				 }
+		
+				 /* if a HiddenTag condition is not explicitly given, we add one */
+				 if ( ! hidden_contained) {
+						 string sql_clause = HiddenTag.HideHiddenTag.SqlClause ();
+		
+						 if (sql_clause != null && sql_clause.Trim () != String.Empty) {
+								 query_builder.Append (where_added ? " AND " : " WHERE ");
+								 query_builder.Append (sql_clause);
+						 }
+				 }
+		
+				 bool order_added = false;
+				 foreach (IQueryCondition condition in conditions) {
+						 if (condition == null)
+								 continue;
+		
+						 if (!(condition is IOrderCondition))
+								 continue;
+		
+						 string sql_clause = condition.SqlClause ();
+		
+						 if (sql_clause == null || sql_clause.Trim () == String.Empty)
+								 continue;
+						 query_builder.Append (order_added ? " , " : "ORDER BY ");
+						 query_builder.Append (sql_clause);
+						 order_added = true;
+				 }
+		
+				 return query_builder.ToString ();
+		 }
+		
+		 public Photo [] Query (params IQueryCondition [] conditions)
+		 {
+				 return Query (BuildQuery (conditions));
+		 }
+		
+		 public void QueryToTemp (string temp_table, params IQueryCondition [] conditions)
+		 {
+				 QueryToTemp (temp_table, BuildQuery (conditions));
+		 }
+		
+		 public void QueryToTemp(string temp_table, string query)
+		 {
+				 uint timer = Log.DebugTimerStart ();
+				 Log.DebugFormat ("Query Started : {0}", query);
+				 Database.BeginTransaction ();
+				 Database.Execute (String.Format ("DROP TABLE IF EXISTS {0}", temp_table));
+				 Database.Execute (String.Format ("CREATE TEMPORARY TABLE {0} AS {1}", temp_table, query));
+				 // For Hyena.Data.Sqlite, we need to call Execute. Calling Query here does fail.
+				 //Database.Query (String.Format ("CREATE TEMPORARY TABLE {0} AS {1}", temp_table, query)).Close ();
+				 Database.CommitTransaction ();
+				 Log.DebugTimerPrint (timer, "QueryToTemp took {0} : " + query);
+		 }
+		
+		 public Photo [] QueryFromTemp (string temp_table)
+		 {
+				 return QueryFromTemp (temp_table, 0, -1);
+		 }
+		
+		 public Photo [] QueryFromTemp (string temp_table, int offset, int limit)
+		 {
+				 return Query (String.Format ("SELECT * FROM {0} LIMIT {1} OFFSET {2}", temp_table, limit, offset));
+		 }
+		
+		 public Photo [] Query (string query)
+		 {
+				 return Query (new HyenaSqliteCommand (query));
+		 }
+		
+		 private Photo [] Query (HyenaSqliteCommand query)
+		 {
+				 uint timer = Log.DebugTimerStart ();
+				 IDataReader reader = Database.Query(query);
+		
+				 List<Photo> new_photos = new List<Photo> ();
+				 List<Photo> query_result = new List<Photo> ();
+				 while (reader.Read ()) {
+						 uint id = Convert.ToUInt32 (reader ["id"]);
+						 Photo photo = LookupInCache (id);
+		
+						 if (photo == null) {
+								 photo = new Photo (id, Convert.ToInt64 (reader ["time"]));
+								 photo.Description = reader["description"].ToString ();
+								 photo.RollId = Convert.ToUInt32 (reader["roll_id"]);
+								 photo.DefaultVersionId = Convert.ToUInt32 (reader["default_version_id"]);
+								 photo.Rating = Convert.ToUInt32 (reader ["rating"]);
+								 new_photos.Add (photo);
+						 }
+		
+						 query_result.Add (photo);
+				 }
+				 reader.Dispose();
+		
+				 bool need_load = false;
+				 string photo_ids = "(";
+				 foreach (Photo photo in new_photos) {
+						 AddToCache (photo);
+						 photo_ids = photo_ids + Convert.ToString(photo.Id) + ",";
+						 need_load |= !photo.AllVersionsLoaded;
+				 }
+		
+				 photo_ids = photo_ids + "-1)";
+		
+				 if (need_load) {
+						 GetAllTags (photo_ids);
+						 GetAllVersions (photo_ids);
+						 foreach (Photo photo in new_photos)
+								 photo.AllVersionsLoaded = true;
+				 } else {
+						 //Console.WriteLine ("Skipped Loading Data");
+				 }
+		
+				 foreach (Photo photo in new_photos)
+						 photo.Changes = null;
+		
+				 Log.DebugTimerPrint (timer, "Query took {0} : " + query.Text);
+				 return query_result.ToArray ();
+		 }
+		
+		 public Photo [] Query (SafeUri uri)
+		 {
+				 string filename = uri.GetFilename ();
+		
+				 /* query by file */
+				 if ( ! String.IsNullOrEmpty (filename)) {
+						 return Query (new HyenaSqliteCommand (
+						 "SELECT id, "                   +
+								 "time, "                        +
+								 "base_uri, "            +
+								 "filename, "            +
+								 "description, "         +
+								 "roll_id, "             +
+								 "default_version_id, "  +
+								 "rating "               +
+						 "FROM photos "                          +
+						 "WHERE base_uri LIKE ?"         +
+						 "AND filename LIKE ?",
+						  uri.GetBaseUri ().ToString (),
+						 filename));
+				 }
+		
+				 /* query by directory */
+				 return Query (new HyenaSqliteCommand (
+						 "SELECT id, "                   +
+								 "time, "                        +
+								 "base_uri, "            +
+								 "filename, "            +
+								 "description, "         +
+								 "roll_id, "             +
+								 "default_version_id, "  +
+								 "rating "               +
+						 "FROM photos "                          +
+						 "WHERE base_uri LIKE ?"         +
+						 "AND base_uri NOT LIKE ?",
+						 uri.ToString () + "%",
+						 uri.ToString () + "/%/%"));
+		 }
+		
+		 [Obsolete ("drop this, use IQueryCondition correctly instead")]
+		 public Photo [] Query (Tag [] tags, string extra_condition, DateRange range, RollSet importidrange)
+		 {
+				 return Query (FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, null);
+		 }
+		
+		 [Obsolete ("drop this, use IQueryCondition correctly instead")]
+		 public Photo [] Query (Tag [] tags, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange)
+		 {
+				 return Query (FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, ratingrange);
+		 }
+		
+		 [Obsolete ("drop this, use IQueryCondition correctly instead")]
+		 public Photo [] Query (Term searchexpression, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange)
+		 {
+				 bool hide = (extra_condition == null);
+		
+				 // The SQL query that we want to construct is:
+				 //
+				 // SELECT photos.id
+				 //        photos.time
+				 //        photos.uri,
+				 //        photos.description,
+				 //        photos.roll_id,
+				 //        photos.default_version_id
+				 //        photos.rating
+				 //                  FROM photos, photo_tags
+				 //                  WHERE photos.time >= time1 AND photos.time <= time2
+				 //                              AND photos.rating >= rat1 AND photos.rating <= rat2
+				 //                              AND photos.id NOT IN (select photo_id FROM photo_tags WHERE tag_id = HIDDEN)
+				 //                              AND photos.id IN (select photo_id FROM photo_tags where tag_id IN (tag1, tag2..)
+				 //                              AND extra_condition_string
+				 //                  GROUP BY photos.id
+		
+				 StringBuilder query_builder = new StringBuilder ();
+				 List<string> where_clauses = new List<string> ();
+				 query_builder.Append ("SELECT id, "                     +
+											  "time, "                   +
+											  "base_uri, "                       +
+											  "filename, "                       +
+											  "description, "            +
+											  "roll_id, "                +
+											  "default_version_id, "     +
+											  "rating "                  +
+									   "FROM photos ");
+		
+				 if (range != null) {
+						 where_clauses.Add (String.Format ("time >= {0} AND time <= {1}",
+														   DateTimeUtil.FromDateTime (range.Start),
+														   DateTimeUtil.FromDateTime (range.End)));
+		
+				 }
+		
+				 if (ratingrange != null) {
+						 where_clauses.Add (ratingrange.SqlClause ());
+				 }
+		
+				 if (importidrange != null) {
+						 where_clauses.Add (importidrange.SqlClause ());
+				 }
+		
+				 if (hide && App.Instance.Database.Tags.Hidden != null) {
+						 where_clauses.Add (String.Format ("id NOT IN (SELECT photo_id FROM photo_tags WHERE tag_id = {0})",
+														   App.Instance.Database.Tags.Hidden.Id));
+				 }
+		
+				 if (searchexpression != null) {
+						 where_clauses.Add (searchexpression.SqlCondition ());
+				 }
+		
+				 if (extra_condition != null && extra_condition.Trim () != String.Empty) {
+						 where_clauses.Add (extra_condition);
+				 }
+		
+				 if (where_clauses.Count > 0) {
+						 query_builder.Append (" WHERE ");
+						 query_builder.Append (String.Join (" AND ", where_clauses.ToArray ()));
+				 }
+				 query_builder.Append (" ORDER BY time");
+				 return Query (query_builder.ToString ());
+		 }
+		}
 }
diff --git a/src/Clients/MainApp/FSpot/PhotoView.cs b/src/Clients/MainApp/FSpot/PhotoView.cs
index 1f16e5d..a2a8066 100644
--- a/src/Clients/MainApp/FSpot/PhotoView.cs
+++ b/src/Clients/MainApp/FSpot/PhotoView.cs
@@ -46,7 +46,7 @@ namespace FSpot {
 	public class PhotoView : EventBox {
 		DelayedOperation commit_delay;
 
-                private ScrolledWindow photo_view_scrolled;
+				private ScrolledWindow photo_view_scrolled;
 		private EventBox background;
 
 		private Filmstrip filmstrip;
@@ -75,11 +75,11 @@ namespace FSpot {
 			get { return filmstrip.Orientation; }
 		}
 
-                // was photo_view
+				// was photo_view
 		public PhotoImageView View { get; private set; }
 
 		public BrowsablePointer Item {
-                        get { return View.Item; }
+						get { return View.Item; }
 		}
 
 		public IBrowsableCollection Query { get; set; }
@@ -157,12 +157,13 @@ namespace FSpot {
 		private void HandleButtonPressEvent (object sender, ButtonPressEventArgs args)
 		{
 			if (args.Event.Type == EventType.TwoButtonPress && args.Event.Button == 1 && DoubleClicked != null)
-				    DoubleClicked (this, null);
-			if (args.Event.Type == EventType.ButtonPress
-			    && args.Event.Button == 3) {
-				PhotoPopup popup = new PhotoPopup ();
-				popup.Activate (this.Toplevel, args.Event);
-			}
+					DoubleClicked (this, null);
+
+			if (args.Event.Type != EventType.ButtonPress || args.Event.Button != 3)
+				return;
+
+			PhotoPopup popup = new PhotoPopup ();
+			popup.Activate (this.Toplevel, args.Event);
 		}
 
 		protected override bool OnPopupMenu ()
@@ -252,14 +253,9 @@ namespace FSpot {
 				PlaceFilmstrip ((Orientation) Preferences.Get<int> (key));
 				break;
 			}
-		}
-
-		public void PlaceFilmstrip (Orientation pos)
-		{
-			PlaceFilmstrip (pos, false);
-		}
-
-		public void PlaceFilmstrip (Orientation pos, bool force)
+		}
+
+		public void PlaceFilmstrip (Orientation pos, bool force = false)
 		{
 			if (!force && filmstrip.Orientation == pos)
 				return;
@@ -295,8 +291,7 @@ namespace FSpot {
 			set { filmstrip.Visible = value; }
 		}
 
-		public PhotoView (IBrowsableCollection query)
-			: base ()
+		public PhotoView (IBrowsableCollection query)
 		{
 			Query = query;
 
@@ -307,7 +302,7 @@ namespace FSpot {
 			Box vbox = new VBox (false, 6);
 			Add (vbox);
 
-		        background = new EventBox ();
+				background = new EventBox ();
 			Frame frame = new Frame ();
 			background.Add (frame);
 
@@ -352,10 +347,10 @@ namespace FSpot {
 			lower_hbox.PackStart (description_entry, true, true, 0);
 			description_entry.Changed += HandleDescriptionChanged;
 
-            rating = new RatingEntry () {
-                HasFrame = false,
-                AlwaysShowEmptyStars = true
-            };
+			rating = new RatingEntry () {
+				HasFrame = false,
+				AlwaysShowEmptyStars = true
+			};
 			lower_hbox.PackStart (rating, false, false, 0);
 			rating.Changed += HandleRatingChanged;
 
@@ -365,7 +360,7 @@ namespace FSpot {
 
 			vbox.ShowAll ();
 
-			Realized += delegate (object o, EventArgs e) {SetColors ();};
+			Realized += (o, e) => SetColors();
 			Preferences.SettingChanged += OnPreferencesChanged;
 		}
 
diff --git a/src/Clients/MainApp/FSpot/PixbufCache.cs b/src/Clients/MainApp/FSpot/PixbufCache.cs
index 8a630a1..01f4736 100644
--- a/src/Clients/MainApp/FSpot/PixbufCache.cs
+++ b/src/Clients/MainApp/FSpot/PixbufCache.cs
@@ -63,7 +63,7 @@ namespace FSpot
 
 		public void HandleThumbnailLoaded (ImageLoaderThread loader, ImageLoaderThread.RequestItem result)
 		{
-                        Reload (result.Uri);
+						Reload (result.Uri);
 		}
 
 		public void Request (SafeUri uri, object closure, int width, int height)
@@ -214,7 +214,6 @@ namespace FSpot
 			} catch (GLib.GException){
 				if (loaded != null)
 					loaded.Dispose ();
-				return;
 			}
 		}
 
@@ -292,7 +291,7 @@ namespace FSpot
 				Uri = uri;
 				Width = width;
 				Height = height;
-                                // Should this be this.data or Data?
+								// Should this be this.data or Data?
 				this.data = closure;
 				Reload = true;
 				this.cache = cache;
diff --git a/src/Clients/MainApp/FSpot/PrintOperation.cs b/src/Clients/MainApp/FSpot/PrintOperation.cs
index 2e0b081..8880d24 100644
--- a/src/Clients/MainApp/FSpot/PrintOperation.cs
+++ b/src/Clients/MainApp/FSpot/PrintOperation.cs
@@ -209,7 +209,7 @@ namespace FSpot
 
 		private static void DrawComment (Gtk.PrintContext context, double x, double y, double h, string comment, bool rotated)
 		{
-			if (comment == null || comment == String.Empty)
+			if (string.IsNullOrEmpty(comment))
 				return;
 
 			Context cr = context.CairoContext;
diff --git a/src/Clients/MainApp/FSpot/ProgressItem.cs b/src/Clients/MainApp/FSpot/ProgressItem.cs
index 1879151..25fba74 100644
--- a/src/Clients/MainApp/FSpot/ProgressItem.cs
+++ b/src/Clients/MainApp/FSpot/ProgressItem.cs
@@ -28,10 +28,7 @@
 //
 
 namespace FSpot {
-	public class ProgressItem {
-		public ProgressItem () {
-		}
-
+	public class ProgressItem {
 		public delegate void ChangedHandler (ProgressItem item);
 		public event ChangedHandler Changed;
 
diff --git a/src/Clients/MainApp/FSpot/RollStore.cs b/src/Clients/MainApp/FSpot/RollStore.cs
index 55e35ca..f2c6c3a 100644
--- a/src/Clients/MainApp/FSpot/RollStore.cs
+++ b/src/Clients/MainApp/FSpot/RollStore.cs
@@ -111,14 +111,9 @@ namespace FSpot
 				reader.Dispose ();
 			}
 			return number_of_photos;
-		}
-
-		public Roll [] GetRolls ()
-		{
-			return GetRolls (-1);
-		}
-
-		public Roll [] GetRolls (int limit)
+		}
+
+		public Roll [] GetRolls (int limit = -1)
 		{
 			List<Roll> rolls = new List<Roll> ();
 
@@ -130,7 +125,7 @@ namespace FSpot
 				while (reader.Read ()) {
 					uint id = Convert.ToUInt32 (reader ["roll_id"]);
 
-					Roll roll = LookupInCache (id) as Roll;
+					Roll roll = LookupInCache (id);
 					if (roll == null) {
 						roll = new Roll (id, Convert.ToUInt32 (reader ["roll_time"]));
 						AddToCache (roll);
diff --git a/src/Clients/MainApp/FSpot/RotateCommand.cs b/src/Clients/MainApp/FSpot/RotateCommand.cs
index 2af0150..4bc412b 100644
--- a/src/Clients/MainApp/FSpot/RotateCommand.cs
+++ b/src/Clients/MainApp/FSpot/RotateCommand.cs
@@ -49,7 +49,7 @@ using Mono.Unix;
 namespace FSpot {
 	public class RotateException : ApplicationException {
 
-                public bool ReadOnly = false;
+				public bool ReadOnly = false;
 		public string Path { get; private set; }
 
 		public RotateException (string msg, string path) : this (msg, path, false) {}
@@ -77,49 +77,49 @@ namespace FSpot {
 			done = false;
 		}
 
-	        private static void RotateOrientation (string original_path, RotateDirection direction)
-	        {
-                    try {
-                        var uri = new SafeUri (original_path);
-                        using (var metadata = Metadata.Parse (uri)) {
-                            metadata.EnsureAvailableTags ();
-                            var tag = metadata.ImageTag;
-                            var orientation = direction == RotateDirection.Clockwise
-                                ? FSpot.Utils.PixbufUtils.Rotate90 (tag.Orientation)
-                                : FSpot.Utils.PixbufUtils.Rotate270 (tag.Orientation);
-        
-                            tag.Orientation = orientation;
-                            var always_sidecar = Preferences.Get<bool> (Preferences.METADATA_ALWAYS_USE_SIDECAR);
-                            metadata.SaveSafely (uri, always_sidecar);
-                            XdgThumbnailSpec.RemoveThumbnail (uri);
-                        }
-                    } catch (Exception e) {
-                        Log.DebugException (e);
-                        throw new RotateException (Catalog.GetString ("Unable to rotate this type of photo"), original_path);
-                    }
-                }
-
-                private void Rotate (string original_path, RotateDirection dir)
-                {
-                    RotateOrientation (original_path, dir);
-                }
-        
-                public bool Step ()
-                {
-                    if (done)
-                        return false;
-        
-                    GLib.FileInfo info = GLib.FileFactory.NewForUri (item.DefaultVersion.Uri).QueryInfo ("access::can-write", GLib.FileQueryInfoFlags.None, null);
-                    if (!info.GetAttributeBoolean("access::can-write")) {
-                        throw new RotateException (Catalog.GetString ("Unable to rotate readonly file"), item.DefaultVersion.Uri, true);
-                    }
-        
-                    Rotate (item.DefaultVersion.Uri, direction);
-
-                    done = true;
-                    return !done;
-                }
-        }
+			private static void RotateOrientation (string original_path, RotateDirection direction)
+			{
+					try {
+						var uri = new SafeUri (original_path);
+						using (var metadata = Metadata.Parse (uri)) {
+							metadata.EnsureAvailableTags ();
+							var tag = metadata.ImageTag;
+							var orientation = direction == RotateDirection.Clockwise
+								? FSpot.Utils.PixbufUtils.Rotate90 (tag.Orientation)
+								: FSpot.Utils.PixbufUtils.Rotate270 (tag.Orientation);
+		
+							tag.Orientation = orientation;
+							var always_sidecar = Preferences.Get<bool> (Preferences.METADATA_ALWAYS_USE_SIDECAR);
+							metadata.SaveSafely (uri, always_sidecar);
+							XdgThumbnailSpec.RemoveThumbnail (uri);
+						}
+					} catch (Exception e) {
+						Log.DebugException (e);
+						throw new RotateException (Catalog.GetString ("Unable to rotate this type of photo"), original_path);
+					}
+				}
+
+				private void Rotate (string original_path, RotateDirection dir)
+				{
+					RotateOrientation (original_path, dir);
+				}
+		
+				public bool Step ()
+				{
+					if (done)
+						return false;
+		
+					GLib.FileInfo info = GLib.FileFactory.NewForUri (item.DefaultVersion.Uri).QueryInfo ("access::can-write", GLib.FileQueryInfoFlags.None, null);
+					if (!info.GetAttributeBoolean("access::can-write")) {
+						throw new RotateException (Catalog.GetString ("Unable to rotate readonly file"), item.DefaultVersion.Uri, true);
+					}
+		
+					Rotate (item.DefaultVersion.Uri, direction);
+
+					done = true;
+					return !done;
+				}
+		}
 
 	public class RotateMultiple {
 		RotateDirection direction;
@@ -145,12 +145,11 @@ namespace FSpot {
 				op = new RotateOperation (Items [Index], direction);
 
 			if (op.Step ())
-				return true;
-			else {
-				Index++;
-				op = null;
-			}
-
+				return true;
+			
+			Index++;
+			op = null;
+
 			return (Index < Items.Length);
 		}
 	}
@@ -170,10 +169,10 @@ public class RotateCommand {
 
 		if (items.Length > 1)
 			progress_dialog = new ProgressDialog (Catalog.GetString ("Rotating photos"),
-							      ProgressDialog.CancelButtonType.Stop,
-							      items.Length, parent_window);
+								  ProgressDialog.CancelButtonType.Stop,
+								  items.Length, parent_window);
 
-	        RotateMultiple op = new RotateMultiple (items, direction);
+			RotateMultiple op = new RotateMultiple (items, direction);
 		int readonly_count = 0;
 		bool done = false;
 		int index = 0;
@@ -224,11 +223,11 @@ public class RotateCommand {
 		desc = String.Format (desc, readonly_count);
 
 		HigMessageDialog md = new HigMessageDialog (parent_window,
-							    DialogFlags.DestroyWithParent,
-							    MessageType.Error,
-							    ButtonsType.Close,
-							    notice,
-							    desc);
+								DialogFlags.DestroyWithParent,
+								MessageType.Error,
+								ButtonsType.Close,
+								notice,
+								desc);
 		md.Run();
 		md.Destroy();
 	}
@@ -246,9 +245,9 @@ public class RotateCommand {
 						msg, System.IO.Path.GetFileName (path));
 
 		HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent,
-							    MessageType.Warning, ButtonsType.Ok,
-							    Catalog.GetString ("Error while rotating photo."),
-							    longmsg);
+								MessageType.Warning, ButtonsType.Ok,
+								Catalog.GetString ("Error while rotating photo."),
+								longmsg);
 		md.Run ();
 		md.Destroy ();
 	}
diff --git a/src/Clients/MainApp/FSpot/SelectionDataExtensions.cs b/src/Clients/MainApp/FSpot/SelectionDataExtensions.cs
index 2398aee..ad39e72 100644
--- a/src/Clients/MainApp/FSpot/SelectionDataExtensions.cs
+++ b/src/Clients/MainApp/FSpot/SelectionDataExtensions.cs
@@ -132,22 +132,22 @@ namespace FSpot
 			selection_data.Set (target, 8, data, data.Length);
 		}
 
-                public static void SetUriListData (this SelectionData selection_data, UriList uri_list)
-                {
-                    selection_data.SetUriListData (uri_list, Atom.Intern ("text/uri-list", true));
-                }
-        
+				public static void SetUriListData (this SelectionData selection_data, UriList uri_list)
+				{
+					selection_data.SetUriListData (uri_list, Atom.Intern ("text/uri-list", true));
+				}
+		
 		public static UriList GetUriListData (this SelectionData selection_data)
 		{
 			return new UriList (GetStringData (selection_data));
 		}
 
-                public static void SetCopyFiles (this SelectionData selection_data, UriList uri_list)
-                {
-                    var uris = (from p in uri_list select p.ToString ()).ToArray ();
-                    var data = Encoding.UTF8.GetBytes ("copy\n" + String.Join ("\n", uris));
-        
-                    selection_data.Set (Atom.Intern ("x-special/gnome-copied-files", true), 8, data, data.Length);
-                }
+				public static void SetCopyFiles (this SelectionData selection_data, UriList uri_list)
+				{
+					var uris = (from p in uri_list select p.ToString ()).ToArray ();
+					var data = Encoding.UTF8.GetBytes ("copy\n" + String.Join ("\n", uris));
+		
+					selection_data.Set (Atom.Intern ("x-special/gnome-copied-files", true), 8, data, data.Length);
+				}
 	}
 }
diff --git a/src/Clients/MainApp/FSpot/SendEmail.cs b/src/Clients/MainApp/FSpot/SendEmail.cs
index 933a668..6f88298 100644
--- a/src/Clients/MainApp/FSpot/SendEmail.cs
+++ b/src/Clients/MainApp/FSpot/SendEmail.cs
@@ -99,8 +99,7 @@ namespace FSpot
 					case 2 :  small_size.Active = true; break;
 					case 3 :  medium_size.Active = true; break;
 					case 4 :  large_size.Active = true; break;
-					case 5 :  x_large_size.Active = true; break;
-					default: break;
+					case 5 :  x_large_size.Active = true; break;
 				}
 
 
diff --git a/src/Clients/MainApp/FSpot/SingleView.cs b/src/Clients/MainApp/FSpot/SingleView.cs
index 4529b86..b62c0f3 100644
--- a/src/Clients/MainApp/FSpot/SingleView.cs
+++ b/src/Clients/MainApp/FSpot/SingleView.cs
@@ -216,7 +216,7 @@ namespace FSpot {
 
 		void HandleExportActivated (object o, EventArgs e)
 		{
-			FSpot.Extensions.ExportMenuItemNode.SelectedImages = delegate () {return new PhotoList (directory_view.Selection.Items); };
+			FSpot.Extensions.ExportMenuItemNode.SelectedImages = () => new PhotoList(directory_view.Selection.Items);
 		}
 
 		public void HandleCollectionChanged (IBrowsableCollection collection)
@@ -486,8 +486,6 @@ namespace FSpot {
 				collection.LoadItems (list.ToArray());
 
 				Gtk.Drag.Finish (args.Context, true, false, args.Time);
-
-				return;
 			}
 		}
 
diff --git a/src/Clients/MainApp/FSpot/TagQueryWidget.cs b/src/Clients/MainApp/FSpot/TagQueryWidget.cs
index 012e559..bbd8098 100644
--- a/src/Clients/MainApp/FSpot/TagQueryWidget.cs
+++ b/src/Clients/MainApp/FSpot/TagQueryWidget.cs
@@ -64,20 +64,20 @@ namespace FSpot
 
 			if (literal.IsNegated) {
 				GtkUtil.MakeMenuItem (popup_menu,
-						      String.Format (Catalog.GetString ("Include Photos Tagged \"{0}\""), literal.Tag.Name),
-						      new EventHandler (literal.HandleToggleNegatedCommand),
-						      true);
+							  String.Format (Catalog.GetString ("Include Photos Tagged \"{0}\""), literal.Tag.Name),
+							  new EventHandler (literal.HandleToggleNegatedCommand),
+							  true);
 			} else {
 				GtkUtil.MakeMenuItem (popup_menu,
-						      String.Format (Catalog.GetString ("Exclude Photos Tagged \"{0}\""), literal.Tag.Name),
-						      new EventHandler (literal.HandleToggleNegatedCommand),
-						      true);
+							  String.Format (Catalog.GetString ("Exclude Photos Tagged \"{0}\""), literal.Tag.Name),
+							  new EventHandler (literal.HandleToggleNegatedCommand),
+							  true);
 			}
 
 			GtkUtil.MakeMenuItem (popup_menu, Catalog.GetString ("Remove From Search"),
-					      "gtk-remove",
-					      new EventHandler (literal.HandleRemoveCommand),
-					      true);
+						  "gtk-remove",
+						  new EventHandler (literal.HandleRemoveCommand),
+						  true);
 
 			if (is_popup) {
 				if (eb != null)
@@ -88,6 +88,7 @@ namespace FSpot
 		}
 	}
 
+	// FIXME: This class is never used
 	public class LiteralMenu : Menu
 	{
 		private LiteralPopup popup;
@@ -140,33 +141,33 @@ namespace FSpot
 			if (LogicWidget.Root == null || LogicWidget.Root.SubTerms.Count == 0) {
 				//Console.WriteLine ("root is null or has no terms");
 				return null;
-			} else {
-				//Console.WriteLine ("root is not null and has terms");
-				Gtk.Menu m = new Gtk.Menu ();
+			}
+
+			//Console.WriteLine ("root is not null and has terms");
+			Gtk.Menu m = new Gtk.Menu ();
 
-				Gtk.MenuItem all_item = GtkUtil.MakeMenuItem (m, Catalog.GetString ("All"), new EventHandler (App.Instance.Organizer.HandleRequireTag));
-				GtkUtil.MakeMenuSeparator (m);
+			Gtk.MenuItem all_item = GtkUtil.MakeMenuItem (m, Catalog.GetString ("All"), new EventHandler (App.Instance.Organizer.HandleRequireTag));
+			GtkUtil.MakeMenuSeparator (m);
 
-				int sensitive_items = 0;
-				foreach (Term term in LogicWidget.Root.SubTerms) {
-					List<string> term_parts = new List<string> ();
+			int sensitive_items = 0;
+			foreach (Term term in LogicWidget.Root.SubTerms) {
+				List<string> term_parts = new List<string> ();
 
-					bool contains_tag = AppendTerm (term_parts, term, single_tag);
+				bool contains_tag = AppendTerm (term_parts, term, single_tag);
 
-					string name = "_" + String.Join (", ", term_parts.ToArray ());
+				string name = "_" + String.Join (", ", term_parts.ToArray ());
 
-					Gtk.MenuItem item = GtkUtil.MakeMenuItem (m, name, new EventHandler (App.Instance.Organizer.HandleAddTagToTerm));
-					item.Sensitive = !contains_tag;
+				Gtk.MenuItem item = GtkUtil.MakeMenuItem (m, name, new EventHandler (App.Instance.Organizer.HandleAddTagToTerm));
+				item.Sensitive = !contains_tag;
 
-					if (!contains_tag)
-						sensitive_items++;
-				}
+				if (!contains_tag)
+					sensitive_items++;
+			}
 
-				if (sensitive_items == 0)
-					all_item.Sensitive = false;
+			if (sensitive_items == 0)
+				all_item.Sensitive = false;
 
-				return m;
-			}
+			return m;
 		}
 
 		private static bool AppendTerm (List<string> parts, Term term, Tag single_tag)
@@ -207,19 +208,15 @@ namespace FSpot
 	}
 
 	public class GrabHandle : DrawingArea {
-		public GrabHandle (int w, int h) : base ()
+		public GrabHandle (int w, int h)
 		{
 			Size (w, h);
 			Orientation = Gtk.Orientation.Horizontal;
 			Show ();
-		}
-
-		private Gtk.Orientation orientation;
-		public Gtk.Orientation Orientation {
-			get { return orientation; }
-			set { orientation = value; }
-		}
-
+		}
+
+		public Orientation Orientation { get; set; }
+
 		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
 		{
 			bool ret = base.OnExposeEvent(evnt);
@@ -229,7 +226,7 @@ namespace FSpot
 			}
 
 			Gtk.Style.PaintHandle(Style, GdkWindow, State, ShadowType.In,
-					      evnt.Area, this, "entry", 0, 0, Allocation.Width, Allocation.Height, Orientation);
+						  evnt.Area, this, "entry", 0, 0, Allocation.Width, Allocation.Height, Orientation);
 
 			//(Style, GdkWindow, StateType.Normal, ShadowType.In,
 			//evnt.Area, this, "entry", 0, y_mid - y_offset, Allocation.Width,
@@ -273,7 +270,7 @@ namespace FSpot
 				DragDropTargets.TagQueryEntry
 			};
 
-		public LogicWidget (PhotoQuery query, TagStore tag_store) : base ()
+		public LogicWidget (PhotoQuery query, TagStore tag_store)
 		{
 			//SetFlag (WidgetFlags.NoWindow);
 			this.query = query;
@@ -345,16 +342,16 @@ namespace FSpot
 		private void HandleTagChanged (object sender, DbItemEventArgs<Tag> args)
 		{
 			foreach (Tag t in args.Items)
-                foreach (Literal term in rootTerm.FindByTag (t))
-                    term.Update ();
+				foreach (Literal term in rootTerm.FindByTag (t))
+					term.Update ();
 		}
 
 		// If the user deletes a tag that is in use in the query, remove it from the query too.
 		private void HandleTagDeleted (object sender, DbItemEventArgs<Tag> args)
 		{
 			foreach (Tag t in args.Items)
-                foreach (Literal term in rootTerm.FindByTag (t))
-                    term.RemoveSelf ();
+				foreach (Literal term in rootTerm.FindByTag (t))
+					term.RemoveSelf ();
 		}
 
 		private void HandleDragMotion (object o, DragMotionArgs args)
@@ -415,13 +412,13 @@ namespace FSpot
 		private void HandleRemoving (Literal term)
 		{
 			foreach (Widget w in HangersOn (term))
-			Remove (w);
+				Remove (w);
 
 			// Remove the term's widget
 			Remove (term.Widget);
 		}
 
-		public List<Gtk.Widget> HangersOn (Literal term)
+		public IEnumerable<Widget> HangersOn (Literal term)
 		{
 			List<Gtk.Widget> w = new List<Gtk.Widget> ();
 
@@ -471,8 +468,6 @@ namespace FSpot
 
 				// Prevent them from being removed again
 				Literal.FocusedLiterals = null;
-
-				return;
 			}
 		}
 
diff --git a/src/Clients/MainApp/FSpot/TagSelectionWidget.cs b/src/Clients/MainApp/FSpot/TagSelectionWidget.cs
index 62e1cff..f86ead7 100644
--- a/src/Clients/MainApp/FSpot/TagSelectionWidget.cs
+++ b/src/Clients/MainApp/FSpot/TagSelectionWidget.cs
@@ -95,7 +95,7 @@ namespace FSpot {
 			Model.GetValue (iter, IdColumn, ref val);
 			uint tag_id = (uint) val;
 
-			return tag_store.Get (tag_id) as Tag;
+			return tag_store.Get (tag_id);
 		}
 
 		// Loading up the store.
@@ -225,7 +225,7 @@ namespace FSpot {
 			Model.GetValue (iter, IdColumn, ref value);
 			uint tag_id = (uint) value;
 
-			Tag tag = tag_store.Get (tag_id) as Tag;
+			Tag tag = tag_store.Get (tag_id);
 			if (tag == null)
 				return;
 
@@ -265,10 +265,7 @@ namespace FSpot {
 			Model.GetValue (parent, IdColumn, ref value);
 			iter = parent;
 
-			if (tag.Id == (uint) value)
-				return true;
-
-			return false;
+			return tag.Id == (uint) value;
 		}
 
 		// Copy a branch of the tree to a new parent
@@ -281,7 +278,7 @@ namespace FSpot {
 			bool valid;
 
 			store.GetValue (src, IdColumn, ref value);
-			Tag tag = (Tag) tag_store.Get ((uint)value);
+			Tag tag = tag_store.Get ((uint)value);
 			if (is_parent) {
 				// we need to figure out where to insert it in the correct order
 				copy = InsertInOrder(dest, is_root, tag);
@@ -359,8 +356,8 @@ namespace FSpot {
 					TreeIterForTag (tag.Category, out iter);
 
 				InsertInOrder (iter,
-					       tag.Category.Name == tag_store.RootCategory.Name,
-					       tag);
+						   tag.Category.Name == tag_store.RootCategory.Name,
+						   tag);
 			}
 		}
 
@@ -500,7 +497,7 @@ namespace FSpot {
 			GLib.Value value = new GLib.Value ();
 			Model.GetValue (iter, IdColumn, ref value);
 			uint tag_id = (uint) value;
-			Tag tag = tag_store.Get (tag_id) as Tag;
+			Tag tag = tag_store.Get (tag_id);
 
 			// Ignore if it hasn't changed
 			if (tag.Name == args.NewText)
@@ -508,7 +505,7 @@ namespace FSpot {
 
 			// Check that the tag doesn't already exist
 			if (String.Compare (args.NewText, tag.Name, true) != 0 &&
-			    tag_store.GetTagByName (args.NewText) != null) {
+				tag_store.GetTagByName (args.NewText) != null) {
 				HigMessageDialog md = new HigMessageDialog (App.Instance.Organizer.Window,
 					DialogFlags.DestroyWithParent,
 					MessageType.Warning, ButtonsType.Ok,
@@ -527,20 +524,19 @@ namespace FSpot {
 			text_render.Edited -= HandleTagNameEdited;
 
 			args.RetVal = true;
-			return;
 		}
 
-        private static TargetList tagSourceTargetList = new TargetList();
-        private static TargetList tagDestTargetList = new TargetList();
+		private static TargetList tagSourceTargetList = new TargetList();
+		private static TargetList tagDestTargetList = new TargetList();
 
-        static TagSelectionWidget()
-        {
-            tagSourceTargetList.AddTargetEntry(DragDropTargets.TagListEntry);
+		static TagSelectionWidget()
+		{
+			tagSourceTargetList.AddTargetEntry(DragDropTargets.TagListEntry);
 
-            tagDestTargetList.AddTargetEntry(DragDropTargets.PhotoListEntry);
-            tagDestTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
-            tagDestTargetList.AddTargetEntry(DragDropTargets.TagListEntry);
-        }
+			tagDestTargetList.AddTargetEntry(DragDropTargets.PhotoListEntry);
+			tagDestTargetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);
+			tagDestTargetList.AddTargetEntry(DragDropTargets.TagListEntry);
+		}
 
 		CellRendererPixbuf pix_render;
 		TreeViewColumn complete_column;
@@ -597,17 +593,17 @@ namespace FSpot {
 			DragBegin += HandleDragBegin;
 
 			Gtk.Drag.SourceSet (this,
-			           Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
-			           (TargetEntry[])tagSourceTargetList,
-			           DragAction.Copy | DragAction.Move);
+					   Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
+					   (TargetEntry[])tagSourceTargetList,
+					   DragAction.Copy | DragAction.Move);
 
 			DragDataReceived += HandleDragDataReceived;
 			DragMotion += HandleDragMotion;
 
 			Gtk.Drag.DestSet (this,
-			                  DestDefaults.All,
-			                  (TargetEntry[])tagDestTargetList,
-			                  DragAction.Copy | DragAction.Move);
+							  DestDefaults.All,
+							  (TargetEntry[])tagDestTargetList,
+							  DragAction.Copy | DragAction.Move);
 		}
 
 		void HandleDragBegin (object sender, DragBeginArgs args)
@@ -647,7 +643,6 @@ namespace FSpot {
 		{
 			if (args.Info == DragDropTargets.TagListEntry.Info) {
 				args.SelectionData.SetTagsData (TagHighlight, args.Context.Targets[0]);
-				return;
 			}
 		}
 
@@ -659,41 +654,41 @@ namespace FSpot {
 		public void HandleDragMotion (object o, DragMotionArgs args)
 		{
 			TreePath path;
-	        TreeViewDropPosition position = TreeViewDropPosition.IntoOrAfter;
+			TreeViewDropPosition position = TreeViewDropPosition.IntoOrAfter;
 			GetPathAtPos (args.X, args.Y, out path);
 
-	        if (path == null)
-	            return;
+			if (path == null)
+				return;
 
-	        // Tags can be dropped before, after, or into another tag
-	        if (args.Context.Targets[0].Name == "application/x-fspot-tags") {
-	            Gdk.Rectangle rect = GetCellArea(path, Columns[0]);
-	            double vpos = Math.Abs(rect.Y - args.Y) / (double)rect.Height;
-	            if (vpos < 0.2) {
-	                position = TreeViewDropPosition.Before;
-	            } else if (vpos > 0.8) {
-	                position = TreeViewDropPosition.After;
-	            }
-	        }
+			// Tags can be dropped before, after, or into another tag
+			if (args.Context.Targets[0].Name == "application/x-fspot-tags") {
+				Gdk.Rectangle rect = GetCellArea(path, Columns[0]);
+				double vpos = Math.Abs(rect.Y - args.Y) / (double)rect.Height;
+				if (vpos < 0.2) {
+					position = TreeViewDropPosition.Before;
+				} else if (vpos > 0.8) {
+					position = TreeViewDropPosition.After;
+				}
+			}
 
 			SetDragDestRow (path, position);
 
 			// Scroll if within 20 pixels of the top or bottom of the tag list
 			if (args.Y < 20)
 				Vadjustment.Value -= 30;
-	        else if (((o as Gtk.Widget).Allocation.Height - args.Y) < 20)
+			else if (((o as Gtk.Widget).Allocation.Height - args.Y) < 20)
 				Vadjustment.Value += 30;
 		}
 
 		public void HandleDragDataReceived (object o, DragDataReceivedArgs args)
 		{
-	        TreePath path;
-	        TreeViewDropPosition position;
+			TreePath path;
+			TreeViewDropPosition position;
 
-	        if ( ! GetDestRowAtPos ((int)args.X, (int)args.Y, out path, out position))
-	            return;
+			if ( ! GetDestRowAtPos ((int)args.X, (int)args.Y, out path, out position))
+				return;
 
-	        Tag tag = path == null ? null : TagByPath (path);
+			Tag tag = path == null ? null : TagByPath (path);
 			if (tag == null)
 				return;
 
@@ -746,35 +741,34 @@ namespace FSpot {
 
 			if (args.Info == DragDropTargets.TagListEntry.Info) {
 				Category parent;
-	            if (position == TreeViewDropPosition.Before || position == TreeViewDropPosition.After) {
-	                parent = tag.Category;
-	            } else {
-	                parent = tag as Category;
-	            }
+				if (position == TreeViewDropPosition.Before || position == TreeViewDropPosition.After) {
+					parent = tag.Category;
+				} else {
+					parent = tag as Category;
+				}
 
 				if (parent == null || TagHighlight.Length < 1) {
-	                args.RetVal = false;
+					args.RetVal = false;
 					return;
-	            }
+				}
 
-	            int moved_count = 0;
-	            Tag [] highlighted_tags = TagHighlight;
+				int moved_count = 0;
+				Tag [] highlighted_tags = TagHighlight;
 				foreach (Tag child in TagHighlight) {
-	                // FIXME with this reparenting via dnd, you cannot move a tag to root.
-	                if (child != parent && child.Category != parent && !child.IsAncestorOf(parent)) {
-	                    child.Category = parent as Category;
-
-	                    // Saving changes will automatically cause the TreeView to be updated
-	                    database.Tags.Commit (child);
-	                    moved_count++;
-	                }
-	            }
+					// FIXME with this reparenting via dnd, you cannot move a tag to root.
+					if (child != parent && child.Category != parent && !child.IsAncestorOf(parent)) {
+						child.Category = parent;
+
+						// Saving changes will automatically cause the TreeView to be updated
+						database.Tags.Commit (child);
+						moved_count++;
+					}
+				}
 
-	            // Reselect the same tags
-	            TagHighlight = highlighted_tags;
+				// Reselect the same tags
+				TagHighlight = highlighted_tags;
 
-	            args.RetVal = moved_count > 0;
-				return;
+				args.RetVal = moved_count > 0;
 			}
 		}
 
diff --git a/src/Clients/MainApp/FSpot/TagStore.cs b/src/Clients/MainApp/FSpot/TagStore.cs
index 5f5a2ff..ba65bb0 100644
--- a/src/Clients/MainApp/FSpot/TagStore.cs
+++ b/src/Clients/MainApp/FSpot/TagStore.cs
@@ -67,15 +67,14 @@ namespace FSpot {
 			return Compare (t1, t2);
 		}
 	
-		public int Compare (Tag t1, Tag t2)
-		{
+		public int Compare (Tag t1, Tag t2)
+		{
 			if (t1.IsAncestorOf (t2))
-				return 1;
-			else if (t2.IsAncestorOf (t1))
-				return -1;
-			else
-				return 0;
-		}
+				return 1;
+			if (t2.IsAncestorOf (t1))
+				return -1;
+			return 0;
+		}
 	}
 	
 	public class TagStore : DbStore<Tag> {
@@ -127,7 +126,7 @@ namespace FSpot {
 			if (l.Count == 0)
 				return null;
 	
-			l.Sort (delegate (Tag t1, Tag t2) {return t2.Popularity.CompareTo (t1.Popularity); });
+			l.Sort ((t1, t2) => t2.Popularity.CompareTo(t1.Popularity));
 	
 			return l.ToArray ();
 		}
@@ -174,7 +173,7 @@ namespace FSpot {
 				uint id = Convert.ToUInt32 (reader ["id"]);
 				uint category_id = Convert.ToUInt32 (reader ["category_id"]);
 	
-				Tag tag = Get (id) as Tag;
+				Tag tag = Get (id);
 				if (tag == null)
 					throw new Exception (String.Format ("Cannot find tag {0}", id));
 				if (category_id == 0)
@@ -191,14 +190,14 @@ namespace FSpot {
 			//Pass 3, set popularity
 			reader = Database.Query ("SELECT tag_id, COUNT (*) AS popularity FROM photo_tags GROUP BY tag_id");
 			while (reader.Read ()) {
-				Tag t = Get (Convert.ToUInt32 (reader ["tag_id"])) as Tag;
+				Tag t = Get (Convert.ToUInt32 (reader ["tag_id"]));
 				if (t != null)
 					t.Popularity = Convert.ToInt32 (reader ["popularity"]);
 			}
 			reader.Dispose ();
 	
 			if (FSpot.App.Instance.Database.Meta.HiddenTagId.Value != null)
-				Hidden = LookupInCache ((uint) FSpot.App.Instance.Database.Meta.HiddenTagId.ValueAsInt) as Tag;
+				Hidden = LookupInCache ((uint) FSpot.App.Instance.Database.Meta.HiddenTagId.ValueAsInt);
 		}
 	
 	
@@ -311,14 +310,11 @@ namespace FSpot {
 			return new_category;
 		}
 	
-		public override Tag Get (uint id)
-		{
-			if (id == 0)
-				return RootCategory;
-			else
-				return LookupInCache (id);
-		}
-	
+		public override Tag Get (uint id)
+		{
+			return id == 0 ? RootCategory : LookupInCache (id);
+		}
+
 		public override void Remove (Tag tag)
 		{
 			Category category = tag as Category;
diff --git a/src/Clients/MainApp/FSpot/Term.cs b/src/Clients/MainApp/FSpot/Term.cs
index da70b29..0775aba 100644
--- a/src/Clients/MainApp/FSpot/Term.cs
+++ b/src/Clients/MainApp/FSpot/Term.cs
@@ -83,12 +83,10 @@ namespace FSpot
 		/// last Literal in term, else null
 		/// </value>
 		public Term Last {
-			get {
-				if (SubTerms.Count > 0)
-					return SubTerms [SubTerms.Count - 1];
-else
-					return null;
-			}
+			get
+			{
+				return SubTerms.Count > 0 ? SubTerms [SubTerms.Count - 1] : null;
+			}
 		}
 
 		public int Count {
@@ -150,14 +148,9 @@ else
 else
 					subterm.Parent = this;
 			}
-		}
-
-		public List<Term> FindByTag (Tag t)
-		{
-			return FindByTag (t, true);
-		}
-
-		public List<Term> FindByTag (Tag t, bool recursive)
+		}
+
+		public List<Term> FindByTag (Tag t, bool recursive = true)
 		{
 			List<Term> results = new List<Term> ();
 
@@ -288,7 +281,7 @@ else
 			StringBuilder condition = new StringBuilder ("(");
 
 			for (int i = 0; i < SubTerms.Count; i++) {
-				Term term = SubTerms [i] as Term;
+				Term term = SubTerms [i];
 				condition.Append (term.SqlCondition ());
 
 				if (i != SubTerms.Count - 1)
@@ -310,6 +303,7 @@ else
 			return String.Empty;
 		}
 
+		// FIXME: The base class shouldn't know about its derived classes?
 		public static Term TermFromOperator (string op, Term parent, Literal after)
 		{
 			//Console.WriteLine ("finding type for operator {0}", op);
@@ -318,11 +312,12 @@ else
 
 			if (AndTerm.Operators.Contains (op))
 				//Console.WriteLine ("AND!");
-				return new AndTerm (parent, after);
-			else if (OrTerm.Operators.Contains (op))
+				return new AndTerm (parent, after);
+			
+			if (OrTerm.Operators.Contains (op))
 				//Console.WriteLine ("OR!");
-				return new OrTerm (parent, after);
-
+				return new OrTerm (parent, after);
+
 			Log.DebugFormat ("Do not have Term for operator {0}", op);
 			return null;
 		}
diff --git a/src/Clients/MainApp/FSpot/ThumbnailCache.cs b/src/Clients/MainApp/FSpot/ThumbnailCache.cs
index e493b85..43952a9 100644
--- a/src/Clients/MainApp/FSpot/ThumbnailCache.cs
+++ b/src/Clients/MainApp/FSpot/ThumbnailCache.cs
@@ -43,6 +43,7 @@ using Hyena;
 
 namespace FSpot
 {
+	// FIXME: This class is never called
 	public class ThumbnailCache : IDisposable {
 	
 		#region Types
@@ -59,8 +60,8 @@ namespace FSpot
 		private const int DEFAULT_CACHE_SIZE = 2;
 		private int max_count;
 		private List<Thumbnail> pixbuf_mru;
-		private Dictionary<SafeUri,Thumbnail> pixbuf_hash;
-		static private ThumbnailCache defaultcache = new ThumbnailCache (DEFAULT_CACHE_SIZE);
+		private Dictionary<SafeUri,Thumbnail> pixbuf_hash;
+
 		#endregion
 	
 		#region Public API
@@ -69,14 +70,15 @@ namespace FSpot
 			this.max_count = max_count;
 			pixbuf_mru = new List<Thumbnail> (max_count);
 			pixbuf_hash = new Dictionary<SafeUri, Thumbnail> ();
-		}
-	
-		static public ThumbnailCache Default {
-			get {
-				return defaultcache;
-			}
-		}
-	
+		}
+
+		static ThumbnailCache()
+		{
+			Default = new ThumbnailCache (DEFAULT_CACHE_SIZE);
+		}
+
+		public static ThumbnailCache Default { get; private set; }
+
 		public void AddThumbnail (SafeUri uri, Pixbuf pixbuf)
 		{
 			Thumbnail thumbnail = new Thumbnail ();
@@ -102,9 +104,7 @@ namespace FSpot
 			pixbuf_mru.Remove (item);
 			pixbuf_mru.Insert (0, item);
 	
-		        if (item.pixbuf == null)
-		            return null;
-		        return item.pixbuf.ShallowCopy ();
+		        return item.pixbuf == null ? null : item.pixbuf.ShallowCopy ();
 		}
 	
 		public void RemoveThumbnailForUri (SafeUri uri)
@@ -123,8 +123,8 @@ namespace FSpot
 	
 		public void Dispose ()
 		{
-			foreach (object item in pixbuf_mru) {
-				Thumbnail thumb = item as Thumbnail;
+			foreach (Thumbnail item in pixbuf_mru) {
+				Thumbnail thumb = item;
 				pixbuf_hash.Remove (thumb.uri);
 				thumb.pixbuf.Dispose ();
 			}
@@ -135,8 +135,8 @@ namespace FSpot
 		~ThumbnailCache ()
 		{
 			Log.DebugFormat ("Finalizer called on {0}. Should be Disposed", GetType ());
-			foreach (object item in pixbuf_mru) {
-				Thumbnail thumb = item as Thumbnail;
+			foreach (Thumbnail item in pixbuf_mru) {
+				Thumbnail thumb = item;
 				pixbuf_hash.Remove (thumb.uri);
 				thumb.pixbuf.Dispose ();
 			}
@@ -147,7 +147,7 @@ namespace FSpot
 		private void MaybeExpunge ()
 		{
 			while (pixbuf_mru.Count > max_count) {
-				Thumbnail thumbnail = pixbuf_mru [pixbuf_mru.Count - 1] as Thumbnail;
+				Thumbnail thumbnail = pixbuf_mru [pixbuf_mru.Count - 1];
 	
 				pixbuf_hash.Remove (thumbnail.uri);
 				pixbuf_mru.RemoveAt (pixbuf_mru.Count - 1);
diff --git a/src/Clients/MainApp/FSpot/ThumbnailGenerator.cs b/src/Clients/MainApp/FSpot/ThumbnailGenerator.cs
index f91b40d..dcd5fae 100644
--- a/src/Clients/MainApp/FSpot/ThumbnailGenerator.cs
+++ b/src/Clients/MainApp/FSpot/ThumbnailGenerator.cs
@@ -38,7 +38,7 @@ using Hyena;
 namespace FSpot {
     public class ThumbnailLoader : ImageLoaderThread {
 
-        static public ThumbnailLoader Default = new ThumbnailLoader ();
+        static public readonly ThumbnailLoader Default = new ThumbnailLoader ();
 
         public void Request (SafeUri uri, ThumbnailSize size, int order)
         {
diff --git a/src/Clients/MainApp/FSpot/TimeAdaptor.cs b/src/Clients/MainApp/FSpot/TimeAdaptor.cs
index 3e12207..cf8e4d3 100644
--- a/src/Clients/MainApp/FSpot/TimeAdaptor.cs
+++ b/src/Clients/MainApp/FSpot/TimeAdaptor.cs
@@ -61,10 +61,7 @@ namespace FSpot {
 
 			DateTime end = DateFromIndex(max);
 
-			if (order_ascending)
-				end = end.AddMonths (1);
-			else
-				end = end.AddMonths(-1);
+			end = order_ascending ? end.AddMonths (1) : end.AddMonths(-1);
 
 			SetLimits (start, end);
 		}
@@ -89,28 +86,25 @@ namespace FSpot {
 			DateTime start = DateFromIndex (item);
 
 			if ((start.Month == 12 && !order_ascending) || (start.Month == 1 && order_ascending))
-				return start.Year.ToString ();
-			else
-				return null;
+				return start.Year.ToString ();
+			
+			return null;
 		}
 
-		public override int Value (int item)
-		{
+		public override int Value (int item)
+		{
 			if (order_ascending)
-				return years [startyear + item/12][item % 12];
-			else
-				return years [endyear - item/12][11 - item % 12];
-		}
-
+				return years [startyear + item/12][item % 12];
+			
+			return years [endyear - item/12][11 - item % 12];
+		}
+
 		public DateTime DateFromIndex (int item)
 		{
 			item = Math.Max (item, 0);
 			item = Math.Min (years.Count * 12 - 1, item);
 
-			if (order_ascending)
-				return DateFromIndexAscending (item);
-
-			return DateFromIndexDescending (item);
+			return order_ascending ? DateFromIndexAscending (item) : DateFromIndexDescending (item);
 		}
 
 		private DateTime DateFromIndexAscending (int item)
@@ -184,7 +178,6 @@ namespace FSpot {
 		{
 			DateTime start = DateFromIndex (item);
 			return query [query.LookupItem (start)];
-
 		}
 
 		public override event ChangedHandler Changed;
diff --git a/src/Clients/MainApp/FSpot/UriCollection.cs b/src/Clients/MainApp/FSpot/UriCollection.cs
index 95e917e..45c3dc5 100644
--- a/src/Clients/MainApp/FSpot/UriCollection.cs
+++ b/src/Clients/MainApp/FSpot/UriCollection.cs
@@ -148,9 +148,7 @@ namespace FSpot {
 					if (ImageFile.HasLoader (i))
 						items.Add (new FilePhoto (i));
 				}
-				ThreadAssist.ProxyToMain (() => {
-					collection.Add (items.ToArray ());
-				});
+				ThreadAssist.ProxyToMain (() => collection.Add (items.ToArray ()));
 			}
 		}
 
diff --git a/src/Clients/MainApp/FSpot/XScreenSaverSlide.cs b/src/Clients/MainApp/FSpot/XScreenSaverSlide.cs
index 9824c85..d3a4213 100644
--- a/src/Clients/MainApp/FSpot/XScreenSaverSlide.cs
+++ b/src/Clients/MainApp/FSpot/XScreenSaverSlide.cs
@@ -74,7 +74,7 @@ namespace FSpot {
 					SizeAllocate (new Gdk.Rectangle (geom.X, geom.Y, geom.Width, geom.Height));
 					Resize (geom.Width, geom.Height);
 					return;
-				} catch (System.Exception e) {
+				} catch (Exception e) {
 					Hyena.Log.Exception (e);
 				}
 			} else {
diff --git a/src/Clients/MainApp/FSpot/main.cs b/src/Clients/MainApp/FSpot/main.cs
index 9684022..fb16380 100644
--- a/src/Clients/MainApp/FSpot/main.cs
+++ b/src/Clients/MainApp/FSpot/main.cs
@@ -299,7 +299,10 @@ namespace FSpot
 					GtkUtil.TryLoadIcon (FSpot.Core.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0),
 					GtkUtil.TryLoadIcon (FSpot.Core.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0)
 				};
-			} catch {}
+			} catch (Exception ex)
+			{
+				Log.DebugException(ex);
+			}
 
 			CleanRoomStartup.Startup (Startup);
 
diff --git a/src/Clients/MainApp/ImageLoaderThread.cs b/src/Clients/MainApp/ImageLoaderThread.cs
index 80c9cbc..4368429 100644
--- a/src/Clients/MainApp/ImageLoaderThread.cs
+++ b/src/Clients/MainApp/ImageLoaderThread.cs
@@ -63,12 +63,10 @@ public class ImageLoaderThread
 		private Pixbuf result;
 
 		public Pixbuf Result {
-			get {
-				if (result == null) {
-					return null;
-				}
-				return result.ShallowCopy ();
-			}
+			get
+			{
+				return result == null ? null : result.ShallowCopy ();
+			}
 			set { result = value; }
 		}
 
@@ -99,7 +97,7 @@ public class ImageLoaderThread
 
 
 	#region Private members.
-	static List<ImageLoaderThread> instances = new List<ImageLoaderThread> ();
+	static readonly List<ImageLoaderThread> instances = new List<ImageLoaderThread> ();
 
 	/* The thread used to handle the requests.  */
 	private Thread worker_thread;
@@ -192,14 +190,9 @@ public class ImageLoaderThread
 		foreach (var thread in instances) {
 			thread.Cleanup ();
 		}
-	}
-
-	public void Request (SafeUri uri, int order)
-	{
-		Request (uri, order, 0, 0);
-	}
-
-	public virtual void Request (SafeUri uri, int order, int width, int height)
+	}
+
+	public virtual void Request (SafeUri uri, int order, int width = 0, int height = 0)
 	{
 		lock (queue) {
 			if (InsertRequest (uri, order, width, height)) {
@@ -312,7 +305,7 @@ public class ImageLoaderThread
 
 					int pos = queue.Count - 1;
 
-					current_request = queue [pos] as RequestItem;
+					current_request = queue [pos];
 					queue.RemoveAt (pos);
 					requests_by_uri.Remove (current_request.Uri);
 				}
diff --git a/src/Clients/MainApp/MainApp.csproj b/src/Clients/MainApp/MainApp.csproj
index 8cd79b0..4dcaac7 100644
--- a/src/Clients/MainApp/MainApp.csproj
+++ b/src/Clients/MainApp/MainApp.csproj
@@ -327,6 +327,7 @@
     <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <Reference Include="System.Data" />
     <Reference Include="Mono.Posix" />
     <Reference Include="Mono.Addins, Version=0.4.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
diff --git a/src/Clients/MainApp/PhotoTagMenu.cs b/src/Clients/MainApp/PhotoTagMenu.cs
index 43a0c39..4c482f0 100644
--- a/src/Clients/MainApp/PhotoTagMenu.cs
+++ b/src/Clients/MainApp/PhotoTagMenu.cs
@@ -41,7 +41,8 @@ public class PhotoTagMenu : Menu {
 	public delegate void TagSelectedHandler (Tag t);
 	public event TagSelectedHandler TagSelected;
 
-	public PhotoTagMenu () : base () {
+	public PhotoTagMenu ()
+	{
 	}
 
 	protected PhotoTagMenu (IntPtr raw) : base (raw) {}
diff --git a/src/Clients/MainApp/PixbufUtils.cs b/src/Clients/MainApp/PixbufUtils.cs
index ff35366..dd4a9c6 100644
--- a/src/Clients/MainApp/PixbufUtils.cs
+++ b/src/Clients/MainApp/PixbufUtils.cs
@@ -78,9 +78,9 @@ public static class PixbufUtils
 	}
 
 	public static double Fit (int orig_width, int orig_height,
-				  int dest_width, int dest_height,
-				  bool upscale_smaller,
-				  out int fit_width, out int fit_height)
+							  int dest_width, int dest_height,
+							  bool upscale_smaller,
+							  out int fit_width, out int fit_height)
 	{
 		if (orig_width == 0 || orig_height == 0) {
 			fit_width = 0;
@@ -368,15 +368,10 @@ public static class PixbufUtils
 		}
 		
 		return newsurf;
-	}
-
-	public unsafe static Gdk.Pixbuf RemoveRedeye (Gdk.Pixbuf src, Gdk.Rectangle area)
-	{
-		return RemoveRedeye (src, area, -15);
-	}
-
+	}
+
 	//threshold, factors and comparisons borrowed from the gimp plugin 'redeye.c' by Robert Merkel
-	public unsafe static Gdk.Pixbuf RemoveRedeye (Gdk.Pixbuf src, Gdk.Rectangle area, int threshold)
+	public unsafe static Gdk.Pixbuf RemoveRedeye (Gdk.Pixbuf src, Gdk.Rectangle area, int threshold = -15)
 	{
 		Gdk.Pixbuf copy = src.Copy ();
 		Gdk.Pixbuf selection = new Gdk.Pixbuf (copy, area.X, area.Y, area.Width, area.Height);
@@ -528,14 +523,9 @@ public static class PixbufUtils
 		else
 			ret = (Gdk.Pixbuf)GLib.Object.GetObject (raw_ret, true);
 		return ret;
-	}
-
-	public static void CreateDerivedVersion (SafeUri source, SafeUri destination)
-	{
-		CreateDerivedVersion (source, destination, 95);
-	}
-
-	public static void CreateDerivedVersion (SafeUri source, SafeUri destination, uint jpeg_quality)
+	}
+
+	public static void CreateDerivedVersion (SafeUri source, SafeUri destination, uint jpeg_quality = 95)
 	{
 		if (source.GetExtension () == destination.GetExtension ()) {
 			// Simple copy will do!
diff --git a/src/Clients/MainApp/TagCommands.cs b/src/Clients/MainApp/TagCommands.cs
index 03f17de..adc726b 100644
--- a/src/Clients/MainApp/TagCommands.cs
+++ b/src/Clients/MainApp/TagCommands.cs
@@ -141,18 +141,19 @@ public class TagCommands {
 			}
 		}
 
+		// FIXME:  This is never used?  Should this be connected to something?
 		private void HandleTagNameEntryChanged (object sender, EventArgs args)
 		{
 			Update ();
 		}
 
 		private Category Category {
-			get {
+			get
+			{
 				if (categories.Count == 0)
-					return tag_store.RootCategory;
-				else
-					return categories [category_option_menu.Active] as Category;
-			}
+					return tag_store.RootCategory;
+				return categories [category_option_menu.Active] as Category;
+			}
 			set {
 				if ((value != null) && (categories.Count > 0)) {
 					//System.Console.WriteLine("TagCreateCommand.set_Category(" + value.Name + ")");
@@ -204,7 +205,7 @@ public class TagCommands {
 					Category parent_category = Category;
 
 					if (type == TagType.Category)
-						new_tag = tag_store.CreateCategory (parent_category, tag_name_entry.Text, autoicon) as Tag;
+						new_tag = tag_store.CreateCategory (parent_category, tag_name_entry.Text, autoicon);
 					else
 						new_tag = tag_store.CreateTag (parent_category, tag_name_entry.Text, autoicon);
 				} catch (Exception ex) {
@@ -213,7 +214,7 @@ public class TagCommands {
 				}
 			}
 
-			this.Destroy ();
+			Destroy ();
 			return new_tag;
 		}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]