diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java
index cc4cf6a800d098f6dd70550830e8f3f08c6f4a71..e28e4eeb299e46b4c6f9cb2b85ede43593294ae6 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java
@@ -185,7 +185,7 @@ public void init(final ServletConfig config) throws ServletException {
 
 		initialized = true;
 
-		if (uploadPackFactory != ReceivePackFactory.DISABLED) {
+		if (uploadPackFactory != UploadPackFactory.DISABLED) {
 			serve("*/git-upload-pack")//
 					.with(new UploadPackServlet(uploadPackFactory));
 		}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AsIsServiceTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AsIsServiceTest.java
index ea937481d4bea9acdf553826da00037482d2b439..2650db2fa865bfe5d618505b306f8c40ce444183 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AsIsServiceTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AsIsServiceTest.java
@@ -112,7 +112,7 @@ public void testCreate_Enabled() throws ServiceNotEnabledException,
 		service.access(new R("bob", "1.2.3.4"), db);
 	}
 
-	private final class R extends HttpServletRequestWrapper {
+	private static final class R extends HttpServletRequestWrapper {
 		private final String user;
 
 		private final String host;
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java
index 5338caaa488b3d4edc367834836103584d8f69a8..4d05a085c68c0ec8081d32b2b3a8f76a66408536 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java
@@ -174,7 +174,7 @@ public void testCreate_Enabled() throws ServiceNotEnabledException,
 		assertNotNull("have ReceivePack", rp);
 	}
 
-	private final class R extends HttpServletRequestWrapper {
+	private static final class R extends HttpServletRequestWrapper {
 		private final String user;
 
 		private final String host;
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultUploadPackFactoryTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultUploadPackFactoryTest.java
index 8f57d40afe8f09a7adbb2d4e9855873ef3b223b7..423361e06b72f2c116357df8963bd4c29522d928 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultUploadPackFactoryTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultUploadPackFactoryTest.java
@@ -136,7 +136,7 @@ public void testCreate_Enabled() throws ServiceNotEnabledException,
 		assertSame(db, up.getRepository());
 	}
 
-	private final class R extends HttpServletRequestWrapper {
+	private static final class R extends HttpServletRequestWrapper {
 		private final String user;
 
 		private final String host;
diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java
index 28df8b7f53119a856086e61d9ea6b48c7dc110f6..f64c3298478efbaab857c75f1b29507e8743d75d 100644
--- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java
+++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java
@@ -236,36 +236,40 @@ private void loadCommitters(Repository repo) throws IOException {
 		SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		File list = new File(repo.getDirectory(), "gerrit_committers");
 		BufferedReader br = new BufferedReader(new FileReader(list));
-		String line;
-
-		while ((line = br.readLine()) != null) {
-			String[] field = line.trim().split(" *\\| *");
-			String user = field[1];
-			String name = field[2];
-			String email = field[3];
-			Date begin = parseDate(dt, field[4]);
-			Date end = parseDate(dt, field[5]);
-
-			if (user.startsWith("username:"))
-				user = user.substring("username:".length());
-
-			Committer who = committersById.get(user);
-			if (who == null) {
-				who = new Committer(user);
-				int sp = name.indexOf(' ');
-				if (0 < sp) {
-					who.setFirstName(name.substring(0, sp).trim());
-					who.setLastName(name.substring(sp + 1).trim());
-				} else {
-					who.setFirstName(name);
-					who.setLastName(null);
+		try {
+			String line;
+
+			while ((line = br.readLine()) != null) {
+				String[] field = line.trim().split(" *\\| *");
+				String user = field[1];
+				String name = field[2];
+				String email = field[3];
+				Date begin = parseDate(dt, field[4]);
+				Date end = parseDate(dt, field[5]);
+
+				if (user.startsWith("username:"))
+					user = user.substring("username:".length());
+
+				Committer who = committersById.get(user);
+				if (who == null) {
+					who = new Committer(user);
+					int sp = name.indexOf(' ');
+					if (0 < sp) {
+						who.setFirstName(name.substring(0, sp).trim());
+						who.setLastName(name.substring(sp + 1).trim());
+					} else {
+						who.setFirstName(name);
+						who.setLastName(null);
+					}
+					committersById.put(who.getID(), who);
 				}
-				committersById.put(who.getID(), who);
-			}
 
-			who.addEmailAddress(email);
-			who.addActiveRange(new ActiveRange(begin, end));
-			committersByEmail.put(email, who);
+				who.addEmailAddress(email);
+				who.addActiveRange(new ActiveRange(begin, end));
+				committersByEmail.put(email, who);
+			}
+		} finally {
+			br.close();
 		}
 	}
 
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
index 38df04101754fbb173d0b98aeeddeb9478b554b5..1681dbc96e39c069d4e8bb9e78168c96d606e32d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
@@ -96,7 +96,7 @@
  * <p>
  */
 class RebuildCommitGraph extends TextBuiltin {
-	private final String REALLY = "--destroy-this-repository";
+	private static final String REALLY = "--destroy-this-repository";
 
 	@Option(name = REALLY, usage = "usage_approveDestructionOfRepository")
 	boolean really;
diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java
index effe6e5756d418d9791e5ce98a75317fbdd52d08..13d408f19f442fc47df49af487e751321553d4b5 100644
--- a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java
+++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java
@@ -176,7 +176,7 @@ PersonIdent authorFor(final PlotCommit<SwingLane> c) {
 		}
 	}
 
-	class NameCellRender extends DefaultTableCellRenderer {
+	static class NameCellRender extends DefaultTableCellRenderer {
 		private static final long serialVersionUID = 1L;
 
 		public Component getTableCellRendererComponent(final JTable table,
@@ -194,7 +194,7 @@ public Component getTableCellRendererComponent(final JTable table,
 		}
 	}
 
-	class DateCellRender extends DefaultTableCellRenderer {
+	static class DateCellRender extends DefaultTableCellRenderer {
 		private static final long serialVersionUID = 1L;
 
 		private final DateFormat fmt = new SimpleDateFormat(
@@ -215,7 +215,7 @@ public Component getTableCellRendererComponent(final JTable table,
 		}
 	}
 
-	class GraphCellRender extends DefaultTableCellRenderer {
+	static class GraphCellRender extends DefaultTableCellRenderer {
 		private static final long serialVersionUID = 1L;
 
 		private final AWTPlotRenderer renderer = new AWTPlotRenderer(this);
diff --git a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java
index 4a1196447331cf2a8df202462e2517bd79355fd7..b58547a9e139c3c45f3ea62783795f7cd4a3c8e3 100644
--- a/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java
+++ b/org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/SwingCommitList.java
@@ -83,5 +83,9 @@ protected void recycleLane(final SwingLane lane) {
 
 	static class SwingLane extends PlotLane {
 		Color color;
+		@Override
+		public boolean equals(Object o) {
+			return super.equals(o) && color.equals(((SwingLane)o).color);
+		}
 	}
 }
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
index 2d552d40d9400d5e26c2530a951e5d2485c50edc..c40d3b70006c4032324d0c39876dabf72a99eacb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
@@ -139,15 +139,15 @@ public void formatEdits(final OutputStream out, final RawText a,
 
 			while (aCur < aEnd || bCur < bEnd) {
 				if (aCur < curEdit.getBeginA() || endIdx + 1 < curIdx) {
-					writeLine(out, ' ', a, aCur);
+					writeContextLine(out, a, aCur, isEndOfLineMissing(a, aCur));
 					aCur++;
 					bCur++;
-
 				} else if (aCur < curEdit.getEndA()) {
-					writeLine(out, '-', a, aCur++);
-
+					writeRemovedLine(out, a, aCur, isEndOfLineMissing(a, aCur));
+					aCur++;
 				} else if (bCur < curEdit.getEndB()) {
-					writeLine(out, '+', b, bCur++);
+					writeAddedLine(out, b, bCur, isEndOfLineMissing(b, bCur));
+					bCur++;
 				}
 
 				if (end(curEdit, aCur, bCur) && ++curIdx < edits.size())
@@ -156,12 +156,85 @@ public void formatEdits(final OutputStream out, final RawText a,
 		}
 	}
 
-	private void writeHunkHeader(final OutputStream out, int aCur, int aEnd,
-			int bCur, int bEnd) throws IOException {
+	/**
+	 * Output a line of diff context
+	 *
+	 * @param out
+	 *            OutputStream
+	 * @param text
+	 *            RawText for accessing raw data
+	 * @param line
+	 *            the line number within text
+	 * @param endOfLineMissing
+	 *            true if we should add the GNU end of line missing warning
+	 * @throws IOException
+	 */
+	protected void writeContextLine(final OutputStream out, final RawText text,
+			final int line, boolean endOfLineMissing) throws IOException {
+		writeLine(out, ' ', text, line, endOfLineMissing);
+	}
+
+	private boolean isEndOfLineMissing(final RawText text, final int line) {
+		return line + 1 == text.size() && text.isMissingNewlineAtEnd();
+	}
+
+	/**
+	 * Output an added line
+	 *
+	 * @param out
+	 *            OutputStream
+	 * @param text
+	 *            RawText for accessing raw data
+	 * @param line
+	 *            the line number within text
+	 * @param endOfLineMissing
+	 *            true if we should add the gnu end of line missing warning
+	 * @throws IOException
+	 */
+	protected void writeAddedLine(final OutputStream out, final RawText text, final int line, boolean endOfLineMissing)
+			throws IOException {
+		writeLine(out, '+', text, line, endOfLineMissing);
+	}
+
+	/**
+	 * Output a removed line
+	 *
+	 * @param out
+	 *            OutputStream
+	 * @param text
+	 *            RawText for accessing raw data
+	 * @param line
+	 *            the line number within text
+	 * @param endOfLineMissing
+	 *            true if we should add the gnu end of line missing warning
+	 * @throws IOException
+	 */
+	protected void writeRemovedLine(final OutputStream out, final RawText text,
+			final int line, boolean endOfLineMissing) throws IOException {
+		writeLine(out, '-', text, line, endOfLineMissing);
+	}
+
+	/**
+	 * Output a hunk header
+	 *
+	 * @param out
+	 *            OutputStream
+	 * @param aStartLine
+	 *            within first source
+	 * @param aEndLine
+	 *            within first source
+	 * @param bStartLine
+	 *            within second source
+	 * @param bEndLine
+	 *            within second source
+	 * @throws IOException
+	 */
+	protected void writeHunkHeader(final OutputStream out, int aStartLine, int aEndLine,
+			int bStartLine, int bEndLine) throws IOException {
 		out.write('@');
 		out.write('@');
-		writeRange(out, '-', aCur + 1, aEnd - aCur);
-		writeRange(out, '+', bCur + 1, bEnd - bCur);
+		writeRange(out, '-', aStartLine + 1, aEndLine - aStartLine);
+		writeRange(out, '+', bStartLine + 1, bEndLine - bStartLine);
 		out.write(' ');
 		out.write('@');
 		out.write('@');
@@ -199,12 +272,17 @@ private static void writeRange(final OutputStream out, final char prefix,
 	}
 
 	private static void writeLine(final OutputStream out, final char prefix,
-			final RawText text, final int cur) throws IOException {
+			final RawText text, final int cur, boolean noNewLineIndicator) throws IOException {
 		out.write(prefix);
 		text.writeLine(out, cur);
 		out.write('\n');
-		if (cur + 1 == text.size() && text.isMissingNewlineAtEnd())
-			out.write(noNewLine);
+		if (noNewLineIndicator)
+			writeNoNewLine(out);
+	}
+
+	private static void writeNoNewLine(final OutputStream out)
+			throws IOException {
+		out.write(noNewLine);
 	}
 
 	private int findCombinedEnd(final List<Edit> edits, final int i) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java
index d5cab0e4c6a6ffbb45a14f7c495d04bba84bebe5..5da33fd6bbcb15cdbb57f5e9bd49dbd13e993c0e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java
@@ -353,7 +353,8 @@ private boolean config_filemode() {
 		if (filemode != null)
 			return filemode.booleanValue();
 		RepositoryConfig config = db.getConfig();
-		return config.getBoolean("core", null, "filemode", true);
+		filemode = Boolean.valueOf(config.getBoolean("core", null, "filemode", true));
+		return filemode.booleanValue();
 	}
 
 	/** An index entry */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java
index ee782028689f2ab9e747962a22114f011edc4bb8..cead0f2b443be15573d78f3874a94a0d8e11b368 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WorkDirCheckout.java
@@ -64,8 +64,6 @@
  * Three-way merges are no performed. See {@link #setFailOnConflict(boolean)}.
  */
 public class WorkDirCheckout {
-	Repository repo;
-
 	File root;
 
 	GitIndex index;
@@ -87,7 +85,6 @@ public void setFailOnConflict(boolean failOnConflict) {
 
 	WorkDirCheckout(Repository repo, File workDir,
 			GitIndex oldIndex, GitIndex newIndex) throws IOException {
-		this.repo = repo;
 		this.root = workDir;
 		this.index = oldIndex;
 		this.merge = repo.mapTree(newIndex.writeTree());
@@ -103,7 +100,6 @@ public void setFailOnConflict(boolean failOnConflict) {
 	 */
 	public WorkDirCheckout(Repository repo, File root,
 			GitIndex index, Tree merge) {
-		this.repo = repo;
 		this.root = root;
 		this.index = index;
 		this.merge = merge;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
index 61eed3fa9a9d9ad43baf01075439945cdf6d3bd8..55d0206c027c989c372b71a6cfce21950e102348 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
@@ -139,7 +139,6 @@ protected void enter(final int index, final PlotCommit<L> currCommit) {
 				rObj.addPassingLane(c.lane);
 			}
 			currCommit.lane = c.lane;
-			currCommit.lane.parent = currCommit;
 		} else {
 			// More than one child, or our child is a merge.
 			// Use a different lane.
@@ -154,7 +153,6 @@ protected void enter(final int index, final PlotCommit<L> currCommit) {
 			}
 
 			currCommit.lane = nextFreeLane();
-			currCommit.lane.parent = currCommit;
 			activeLanes.add(currCommit.lane);
 
 			int remaining = nChildren;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotLane.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotLane.java
index 9d08455ce9128cf0ed7ad55663a604f639a3cf2d..ff22b6473dd95c57e8003f0a363adf55850e64e7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotLane.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotLane.java
@@ -49,8 +49,6 @@
  * Commits are strung onto a lane. For many UIs a lane represents a column.
  */
 public class PlotLane {
-	PlotCommit parent;
-
 	int position;
 
 	/**