diff --git a/src/global.c b/src/global.c
index c7f8ea1ee7a729dc99d036bc14d031addd70e14f..a2f3979e7a85b534cf0d2d4d25b8df18e20e4772 100644
--- a/src/global.c
+++ b/src/global.c
@@ -66,6 +66,8 @@ WINDOW *bottomwin;
 	 * messages, the statusbar prompt, and a list of shortcuts. */
 int editwinrows = 0;
 	/* How many rows does the edit window take up? */
+int maxrows = 0;
+	/* How many usable lines are there (due to soft wrapping) */
 
 filestruct *cutbuffer = NULL;
 	/* The buffer where we store cut text. */
diff --git a/src/move.c b/src/move.c
index ebea8817717242184accd1a9c3c3ac6d70149413..f22e6fea9d532a0c5020874e9d3f8636df48f092 100644
--- a/src/move.c
+++ b/src/move.c
@@ -29,7 +29,7 @@
 /* Move to the first line of the file. */
 void do_first_line(void)
 {
-    openfile->current = openfile->fileage;
+    openfile->current = openfile->edittop = openfile->fileage;
     openfile->current_x = 0;
     openfile->placewewant = 0;
 
@@ -90,7 +90,7 @@ void do_page_down(void)
     /* If there's less than a page of text left on the screen, put the
      * cursor at the beginning of the last line of the file, and then
      * update the edit window. */
-    if (openfile->current->lineno + editwinrows - 2 >=
+    if (openfile->current->lineno + maxrows - 2 >=
 	openfile->filebot->lineno) {
 	do_last_line();
 	return;
@@ -107,15 +107,24 @@ void do_page_down(void)
     }
 #endif
 
-    for (i = editwinrows - 2; i > 0 && openfile->current !=
-	openfile->filebot; i--)
+#ifdef DEBUG
+    fprintf(stderr, "do_page_down: maxrows = %d\n", maxrows);
+#endif
+
+    for (i = maxrows - 2; i > 0 && openfile->current !=
+	openfile->filebot; i--) {
 	openfile->current = openfile->current->next;
+#ifdef DEBUG
+    fprintf(stderr, "do_page_down: moving to line %d\n", openfile->current->lineno);
+#endif
+
+    }
 
     openfile->current_x = actual_x(openfile->current->data,
 	openfile->placewewant);
 
     /* Scroll the edit window down a page. */
-    edit_scroll(DOWN_DIR, editwinrows - 2);
+    edit_scroll(DOWN_DIR, maxrows - 2);
 }
 
 #ifndef DISABLE_JUSTIFY
diff --git a/src/proto.h b/src/proto.h
index 740ba8091786ebe915ef97026a77a7cf9c6c7d0b..436b15c4ecb805c94e78e455eb096e5dd745fbbc 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -46,6 +46,7 @@ extern WINDOW *topwin;
 extern WINDOW *edit;
 extern WINDOW *bottomwin;
 extern int editwinrows;
+extern int maxrows;
 
 extern filestruct *cutbuffer;
 extern filestruct *cutbottom;
diff --git a/src/winio.c b/src/winio.c
index 96d25fc924f4382ec63c447fc4345dc346510232..2bbb1758f808bf0829fd76bd6e8f49160176b3ff 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -41,9 +41,6 @@ static bool disable_cursorpos = FALSE;
 	/* Should we temporarily disable constant cursor position
 	 * display? */
 
-static int maxrows = 0;
-	/* With soft wrapping, how many lines really fit on the curent page */
-
 /* Control character compatibility:
  *
  * - NANO_BACKSPACE_KEY is Ctrl-H, which is Backspace under ASCII, ANSI,
@@ -2945,16 +2942,23 @@ void compute_maxrows(void)
     int n;
     filestruct *foo = openfile->edittop;
 
+    if (!ISSET(SOFTWRAP)) {
+	maxrows = editwinrows;
+	return;
+    }
+
     maxrows = 0;
     for (n = 0; n < editwinrows && foo; n++) {
 	maxrows += 1 - strlenpt(foo->data) / COLS;
 	foo = foo->next;
     }
 
+    if (n < editwinrows)
+	maxrows += editwinrows - n;
+
 #ifdef DEBUG
     fprintf(stderr, "compute_maxrows(): maxrows = %ld\n", maxrows);
 #endif
-
 }
 
 /* Scroll the edit window in the given direction and the given number
@@ -3035,6 +3039,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
 	}
     }
 
+    compute_maxrows();
     /* Limit nlines to the number of lines we could scroll. */
     nlines -= i;
 
@@ -3173,8 +3178,6 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
 	else
 	    edit_scroll(DOWN_DIR, nlines);
 
-        compute_maxrows();
-
 #ifndef NANO_TINY
 	/* If the mark is on, update all the lines between the old first
 	 * line or old last line of the edit window (depending on
@@ -3224,12 +3227,16 @@ void edit_refresh(void)
     int nlines;
 
     /* Figure out what maxrows should really be */
-    if (openfile->current->lineno > openfile->edittop->lineno)
-	compute_maxrows();
+    compute_maxrows();
 
     if (openfile->current->lineno < openfile->edittop->lineno ||
 	openfile->current->lineno >= openfile->edittop->lineno +
-	maxrows)
+	maxrows) {
+
+#ifdef DEBUG
+    fprintf(stderr, "edit_refresh(): line = %d, edittop %d + maxrows %d\n", openfile->current->lineno, openfile->edittop->lineno, maxrows);
+#endif
+
 	/* Put the top line of the edit window in range of the current
 	 * line. */
 	edit_update(
@@ -3237,6 +3244,7 @@ void edit_refresh(void)
 		ISSET(SMOOTH_SCROLL) ? NONE :
 #endif
 		CENTER);
+    }
 
     foo = openfile->edittop;
 
@@ -3275,21 +3283,22 @@ void edit_update(update_type location)
      * screen as before, or at the top or bottom of the screen if
      * edittop is beyond either. */
     if (location == CENTER)
-	goal = editwinrows / 2;
+	goal = maxrows / 2;
     else {
 	goal = openfile->current_y;
 
 	/* Limit goal to (editwinrows - 1) lines maximum. */
-	if (goal > editwinrows - 1)
-	    goal = editwinrows - 1;
+	if (goal > maxrows - 1)
+	    goal = maxrows - 1;
     }
 
     for (; goal > 0 && foo->prev != NULL; goal--) {
 	if (ISSET(SOFTWRAP))
-	    goal -= strlenpt(foo->data) / COLS;
+	    goal -= 1 + strlenpt(foo->data) / COLS;
 	foo = foo->prev;
     }
     openfile->edittop = foo;
+    compute_maxrows();
 }
 
 /* Unconditionally redraw the entire screen. */