diff --git a/ChangeLog b/ChangeLog
index c71c7fde7c3bb130efe05ec603a1cae64bced0ac..d514f9a8549a6148b69f9ea3d2ffe21b45245600 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
 2015-12-08  Benno Schulenberg  <bensberg@justemail.net>
-	* src/nano.c (splice_node): Make this function update 'filebot',
-	instead of doing it in four different places.
+	* src/nano.c (splice_node, unlink_node): Let these functions update
+	'filebot', instead of doing it in four different places each.
 
 2015-12-07  Benno Schulenberg  <bensberg@justemail.net>
 	* src/winio.c (edit_draw): Quit the loop when there is no end match.
diff --git a/src/nano.c b/src/nano.c
index 310616ed0a61575619e268c9a250b07057f03437..18302e708476d0b550aaa83537aab7c2cf92158c 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -110,7 +110,7 @@ void splice_node(filestruct *afterthis, filestruct *newnode)
 	openfile->filebot = newnode;
 }
 
-/* Unlink a node from the rest of the filestruct and delete it. */
+/* Disconnect a node from a linked list of filestructs and delete it. */
 void unlink_node(filestruct *fileptr)
 {
     assert(fileptr != NULL);
@@ -120,10 +120,14 @@ void unlink_node(filestruct *fileptr)
     if (fileptr->next != NULL)
 	fileptr->next->prev = fileptr->prev;
 
+    /* Update filebot when removing a node at the end of file. */
+    if (openfile && openfile->filebot == fileptr)
+	openfile->filebot = fileptr->prev;
+
     delete_node(fileptr);
 }
 
-/* Delete a node from the filestruct. */
+/* Free the data structures in the given node. */
 void delete_node(filestruct *fileptr)
 {
     assert(fileptr != NULL && fileptr->data != NULL);
diff --git a/src/text.c b/src/text.c
index d1871da4c66d07cc3185baf91e9eac5a31713658..da8900c2a8881a6f44c4e75db22f8cb9d5a5d73b 100644
--- a/src/text.c
+++ b/src/text.c
@@ -144,8 +144,6 @@ void do_deletion(undo_type action)
 	    openfile->mark_begin_x += openfile->current_x;
 	}
 #endif
-	if (openfile->filebot == foo)
-	    openfile->filebot = openfile->current;
 
 	unlink_node(foo);
 	renumber(openfile->current);
@@ -566,8 +564,6 @@ void do_undo(void)
 	f->data = charealloc(f->data, strlen(f->data) +
 				strlen(&f->next->data[u->mark_begin_x]) + 1);
 	strcat(f->data, &f->next->data[u->mark_begin_x]);
-	if (openfile->filebot == f->next)
-	    openfile->filebot = f;
 	unlink_node(f->next);
 	goto_line_posx(u->lineno, u->begin);
 	break;
@@ -707,8 +703,6 @@ void do_redo(void)
 	}
 	f->data = charealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
 	strcat(f->data, u->strdata);
-	if (f->next == openfile->filebot)
-	    openfile->filebot = f;
 	unlink_node(f->next);
 	renumber(f);
 	goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
@@ -2098,11 +2092,9 @@ void do_justify(bool full_justify)
 	    strcat(openfile->current->data, next_line->data +
 		indent_len);
 
-	    /* Don't destroy edittop or filebot! */
+	    /* Don't destroy edittop! */
 	    if (next_line == openfile->edittop)
 		openfile->edittop = openfile->current;
-	    if (next_line == openfile->filebot)
-		openfile->filebot = openfile->current;
 
 #ifndef NANO_TINY
 	    /* Adjust the mark coordinates to compensate for the change