diff --git a/src/files.c b/src/files.c
index 7438db90bbd4e16075f925e769af7de9dfd9248e..95bd45aa770e557a523ebaf251fac78210603085 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2020,7 +2020,6 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
  * the buffer is to be discarded. */
 int do_writeout(bool exiting, bool withprompt)
 {
-    int i = 0;
     bool result = FALSE;
     kind_of_writing_type method = OVERWRITE;
     char *given;
@@ -2042,18 +2041,18 @@ int do_writeout(bool exiting, bool withprompt)
 
     while (TRUE) {
 	const char *msg;
+	int i = 0;
+	functionptrtype func;
 #ifndef NANO_TINY
 	const char *formatstr, *backupstr;
 
 	formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
 			(openfile->fmt == MAC_FILE) ? _(" [Mac Format]") : "";
-
 	backupstr = ISSET(BACKUP_FILE) ? _(" [Backup]") : "";
 
-	/* If we're using restricted mode, don't display the "Write
-	 * Selection to File" prompt.  This function is disabled, since
-	 * it allows reading from or writing to files not specified on
-	 * the command line. */
+	/* When the mark is on, offer to write the selection to disk, but
+	 * not when in restricted mode, because it would allow writing to
+	 * a file not specified on the command line. */
 	if (openfile->mark && !exiting && !ISSET(RESTRICTED))
 	    /* TRANSLATORS: The next six strings are prompts. */
 	    msg = (method == PREPEND) ? _("Prepend Selection to File") :
@@ -2089,8 +2088,9 @@ int do_writeout(bool exiting, bool withprompt)
 	if (i < 0) {
 	    statusbar(_("Cancelled"));
 	    break;
-	} else {
-	    functionptrtype func = func_from_key(&i);
+	}
+
+	func = func_from_key(&i);
 
 	    /* Upon request, abandon the buffer. */
 	    if (func == discard_buffer) {
@@ -2107,7 +2107,6 @@ int do_writeout(bool exiting, bool withprompt)
 		if (chosen == NULL)
 		    continue;
 
-		/* We have a file now.  Indicate this. */
 		free(answer);
 		answer = chosen;
 	    } else
@@ -2130,12 +2129,11 @@ int do_writeout(bool exiting, bool withprompt)
 	    } else if (func == append_void) {
 		method = (method == APPEND) ? OVERWRITE : APPEND;
 		continue;
-	    } else
+	    }
 #endif /* !NANO_TINY */
 	    if (func == do_help_void) {
 		continue;
 	    }
-
 #ifdef ENABLE_EXTRA
 	    /* If the current file has been modified, we've pressed
 	     * Ctrl-X at the edit window to exit, we've pressed "y" at
@@ -2253,7 +2251,6 @@ int do_writeout(bool exiting, bool withprompt)
 		result = write_file(answer, NULL, FALSE, method, FALSE);
 
 	    break;
-	}
     }
 
     free(given);
diff --git a/src/text.c b/src/text.c
index d3db6b09d9209502190179f7c77f68b9fea237bd..6b9399ef3c9fbfb7c73400b82f6f6f7cf08f2ffd 100644
--- a/src/text.c
+++ b/src/text.c
@@ -2242,7 +2242,7 @@ void do_justify(bool full_justify)
 	 * current and filebot if filebot is the last line in the
 	 * paragraph.  Set filebot_inpar to TRUE if this is the case. */
 	filebot_inpar = (openfile->current->lineno + par_len ==
-		openfile->filebot->lineno + 1);
+				openfile->filebot->lineno + 1);
 
 	/* If we haven't already done it, move the original paragraph(s)
 	 * to the justify buffer, splice a copy of the original
@@ -2335,8 +2335,8 @@ void do_justify(bool full_justify)
 	     * this line again. */
 	    i--;
 
-	    par_len--;
 	    openfile->totsize--;
+	    par_len--;
 	}
 
 	/* Call justify_format() on the paragraph, which will remove
@@ -2381,8 +2381,8 @@ void do_justify(bool full_justify)
 	    strcpy(openfile->current->next->data + indent_len,
 		openfile->current->data + break_pos);
 
-	    par_len++;
 	    openfile->totsize += indent_len + 1;
+	    par_len++;
 
 #ifndef NANO_TINY
 	    /* Adjust the mark coordinates to compensate for the change
@@ -2393,8 +2393,7 @@ void do_justify(bool full_justify)
 		openfile->mark_x -= break_pos - indent_len;
 	    }
 #endif
-
-	    /* Break the current line. */
+	    /* When requested, snip all trailing blanks. */
 	    if (ISSET(JUSTIFY_TRIM)) {
 		while (break_pos > 0 &&
 			is_blank_mbchar(&openfile->current->data[break_pos - 1])) {
@@ -2402,11 +2401,13 @@ void do_justify(bool full_justify)
 		    openfile->totsize--;
 		}
 	    }
+
+	    /* Break the current line. */
 	    null_at(&openfile->current->data, break_pos);
 
 	    /* Go to the next line. */
-	    par_len--;
 	    openfile->current = openfile->current->next;
+	    par_len--;
 	}
 
 	/* We're done breaking lines, so we don't need indent_string