diff --git a/src/nano.c b/src/nano.c
index 08b3650755207d7d78f79fc32e5df643a9bef938..b6a55783bac5f08ef927a23d5170b32fde3c31f5 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1420,9 +1420,9 @@ bool do_int_spell_fix(const char *word)
 {
     char *save_search;
     char *save_replace;
-    size_t current_x_save = current_x;
-    filestruct *current_save = current;
+    size_t current_x_save = current_x, pww_save = placewewant;
     filestruct *edittop_save = edittop;
+    filestruct *current_save = current;
 	/* Save where we are. */
     bool accepted = TRUE;
 	/* The return value. */
@@ -1463,8 +1463,10 @@ bool do_int_spell_fix(const char *word)
     last_replace = mallocstrcpy(NULL, word);
 
     /* Start from the top of the file. */
+    edittop = fileage;
     current = fileage;
     current_x = -1;
+    placewewant = 0;
 
     search_last_line = FALSE;
 
@@ -1500,9 +1502,10 @@ bool do_int_spell_fix(const char *word)
     last_replace = save_replace;
 
     /* Restore where we were. */
+    edittop = edittop_save;
     current = current_save;
     current_x = current_x_save;
-    edittop = edittop_save;
+    placewewant = pww_save;
 
     /* Restore case sensitivity setting. */
     if (!case_sens_set)
diff --git a/src/search.c b/src/search.c
index d2f0105ced68eaca902acb9b94f44e7c933b2400..3be177367ffd44513f311cc9a46d2d9de3426061 100644
--- a/src/search.c
+++ b/src/search.c
@@ -299,7 +299,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
 		break;
 	}
 
-	/* Finished processing file, get out. */
+	/* We've finished processing the file, so get out. */
 	if (search_last_line) {
 	    if (can_display_wrap)
 		not_found_msg(needle);
@@ -318,7 +318,7 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
 	}
 #endif
 
-	/* Start or end of buffer reached; wrap around. */
+	/* Start or end of buffer reached, so wrap around. */
 	if (fileptr == NULL) {
 	    if (!can_display_wrap)
 		return FALSE;
@@ -626,7 +626,14 @@ int do_replace_loop(const char *needle, filestruct *real_current, size_t
 
     if (old_mark_set) {
 	/* Save the locations where the mark begins and ends. */
+	filestruct *old_current = current;
+	size_t old_current_x = current_x;
+
+	current = real_current;
+	current_x = *real_current_x;
 	mark_order(&top, &top_x, &bot, &bot_x);
+	current = old_current;
+	current_x = old_current_x;
 
 	UNSET(MARK_ISSET);
 	edit_refresh();
@@ -747,22 +754,6 @@ int do_replace_loop(const char *needle, filestruct *real_current, size_t
 		*real_current_x += length_change;
 	    }
 
-#ifndef NANO_SMALL
-	    /* Since the locations where the mark begins and ends may
-	     * have changed, keep our saved locations in sync with
-	     * them. */
-	    if (old_mark_set) {
-		filestruct *old_current = current;
-		size_t old_current_x = current_x;
-
-		current = real_current;
-		current_x = *real_current_x;
-		mark_order(&top, &top_x, &bot, &bot_x);
-		current = old_current;
-		current_x = old_current_x;
-	    }
-#endif
-
 	    /* Set the cursor at the last character of the replacement
 	     * text, so searching will resume after the replacement
 	     * text.  Note that current_x might be set to -1 here. */
@@ -788,6 +779,19 @@ int do_replace_loop(const char *needle, filestruct *real_current, size_t
 	    set_modified();
 	    numreplaced++;
 	}
+
+	/* Save the locations where the mark begins and ends again,
+	 * since they may have changed. */
+	if (old_mark_set) {
+	    filestruct *old_current = current;
+	    size_t old_current_x = current_x;
+
+	    current = real_current;
+	    current_x = *real_current_x;
+	    mark_order(&top, &top_x, &bot, &bot_x);
+	    current = old_current;
+	    current_x = old_current_x;
+	}
     }
 
     /* If text has been added to the magicline, make a new magicline. */