diff --git a/ChangeLog b/ChangeLog
index d4f76f33767d2822d808d66bbc9449be34ed444e..559b0fc198f82e98cb619221a2cbfb22f9898c70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
+2014-07-16  Mark Majeres  <mark@engine12.com>
+	* src/text.c (do_undo): Make sure renumbering starts far enough back
+	after undoing a cut or paste.  This fixes a segmentation fault when
+	undoing a repeated cutting and pasting of the first line of a file.
+	* src/nano.c (move_to_filestruct, copy_from_filestruct): Fix two leaks.
+
 2014-07-13  David Lawrence Ramsey  <pooka109@gmail.com>
-	* ChangeLog: Typo fix
+	* ChangeLog: Typo fix.
 
 2014-07-12  Benno Schulenberg  <bensberg@justemail.net>
 	* configure.ac: The warning about datarootdir being ignored is
diff --git a/src/nano.c b/src/nano.c
index 07c87cff8c6982982d0d9b3f2dcff5e417659ce9..4b14852a8840b2fda7035536401b5a20ba9927f8 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -360,6 +360,9 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
 	    *file_bot = openfile->filebot;
 	}
 
+	openfile->fileage->next = NULL;
+	free_filestruct(openfile->fileage);
+
 	/* Renumber starting with the line after the original
 	 * file_bot. */
 	if (file_bot_save->next != NULL)
@@ -447,6 +450,7 @@ void copy_from_filestruct(filestruct *somebuffer)
 
     /* Put the top and bottom of the current filestruct at the top and
      * bottom of a copy of the passed buffer. */
+    free_filestruct(openfile->fileage);
     openfile->fileage = copy_filestruct(somebuffer);
     openfile->filebot = openfile->fileage;
     while (openfile->filebot->next != NULL)
diff --git a/src/text.c b/src/text.c
index e5315eb63b524ed47df4cdf412524ee330856b34..87e8a58b7ef8f356412b46a4a53ffb3ed360a813 100644
--- a/src/text.c
+++ b/src/text.c
@@ -504,10 +504,12 @@ void do_undo(void)
     case CUT:
 	undidmsg = _("text cut");
         undo_cut(u);
+	f = fsfromline(u->lineno);
 	break;
     case PASTE:
 	undidmsg = _("text uncut");
 	undo_paste(u);
+	f = fsfromline(u->lineno);
 	break;
     case ENTER:
 	undidmsg = _("line break");