diff --git a/Inst_eddies/complete_ssh.f90 b/Inst_eddies/complete_ssh.f90
index 0eb922ef6814d1646e2d173db58444975335ee41..ee4bc4bce9727203c93f678875e6b73176f79953 100644
--- a/Inst_eddies/complete_ssh.f90
+++ b/Inst_eddies/complete_ssh.f90
@@ -15,11 +15,16 @@ contains
     ! Sorts ssh_lev in ascending order.
 
     real, intent(inout):: ssh_lev(:) ! (n_max_cont)
+    ! Defined only for subscripts 1:n_cont.
+
     integer, intent(inout):: n_cont
+    ! On entry, 2 <= n_cont <= n_max_cont - 1. On return, 2 <= n_cont
+    ! <= n_max_cont.
 
     ! Local:
-    real delta_ssh(size(sort_ssh) - 1) ! (n_max_cont - 1)
-    integer i, n_max_cont
+    real delta_ssh(size(ssh_lev) - 1) ! (n_max_cont - 1)
+    integer i
+    integer n_max_cont ! >= 3
     real delta_ssh_new
     real, parameter:: delta_ssh_min = 1e-3 ! in m
 
@@ -32,6 +37,7 @@ contains
        sort_ssh(:n_cont) = [(i, i = 1, n_cont)]
        i = 1
     else
+       ! Anticyclone
        sort_ssh(:n_cont) = [(i, i = n_cont, 1, - 1)]
        i = n_cont - 1
     end if
diff --git a/Inst_eddies/get_1_outerm.f90 b/Inst_eddies/get_1_outerm.f90
index 597d08cc7bbb2d56e01638ac74412b33c3f9716d..e2f0a4e659a907f9b383abb104d55bcf7812da35 100644
--- a/Inst_eddies/get_1_outerm.f90
+++ b/Inst_eddies/get_1_outerm.f90
@@ -26,7 +26,9 @@ contains
     ! extremum is a maximum. The area is only computed for the
     ! outermost contour. On return, the array
     ! abs(ediff1d(cont_list(:n_cont)%ssh)) is in descending
-    ! order. (See notes for a proof.)
+    ! order. (See notes for a proof.) On return, n_cont == 1 means we
+    ! have only found one good contour at innermost_level_2 and it has
+    ! sufficient area.
 
     ! Method: dichotomy on level of ssh.
 
@@ -57,7 +59,7 @@ contains
     ! 1) are not oriented.
 
     integer, intent(out):: n_cont
-    ! number of good contours found and stored, >= 0
+    ! number of good contours found and stored, 0 <= n_cont <= n_max_cont - 1
 
     logical, intent(in):: cyclone
     real, intent(in):: coord_extr(:) ! (2)
@@ -86,7 +88,7 @@ contains
     real level_try, level_good, level_bad ! in m
     real, parameter:: precision = 5e-4 ! in m
     logical mask(size(ssh, 1), size(ssh, 2))
-    integer n_max_cont
+    integer n_max_cont ! >= 3
 
     !-----------------------------------------------------------------
 
@@ -142,6 +144,7 @@ contains
              ! level_good) and cont_list(n_cont)%%n_points /= 0 and
              ! no good contour at level_bad
           end do
+          ! Assertion: n_cont <= n_max_cont - 1
        end if
 
        cont_list(n_cont)%area = spher_polyline_area(cont_list(n_cont)%polyline)
diff --git a/Inst_eddies/set_all_contours.f90 b/Inst_eddies/set_all_contours.f90
index ab60cd1dfd281fd20176b7537557979f7e88205f..53a966da614ef5976fdd4394bb6773d5b7ddc018 100644
--- a/Inst_eddies/set_all_contours.f90
+++ b/Inst_eddies/set_all_contours.f90
@@ -6,8 +6,7 @@ contains
 
   subroutine set_all_contours(s, step, periodic, ssh, u, v, corner)
 
-    ! This procedure sets all outermost contours in the snapshot
-    ! "s".
+    ! This procedure sets all contours in the snapshot "s".
 
     ! Libraries:
     use contour_531, only: convert_to_ind
@@ -22,9 +21,9 @@ contains
     use set_max_speed_m, only: set_max_speed
 
     type(snapshot), intent(inout):: s
-    ! Define s%list%out_cont. s%number_extr, s%list%cyclone,
-    ! s%list%extr, s%list%innermost_level, s%extr_map should be
-    ! defined on entry.
+    ! Define s%list%out_cont, s%list%speed_cont and
+    ! s%list%max_speed. s%number_extr, s%list%cyclone, s%list%extr,
+    ! s%list%innermost_level, s%extr_map should be defined on entry.
 
     real, intent(in):: step(:) ! (2) longitude and latitude steps, in rad
     logical, intent(in):: periodic ! grid is periodic in longitude
@@ -66,7 +65,7 @@ contains
     ! latitude, in rad, of all the significant extrema, except the
     ! target extremum
 
-    integer, parameter:: n_max_cont = 31
+    integer, parameter:: n_max_cont = 31 ! must be >= 3
 
     type(ssh_contour) cont_list(n_max_cont)
     ! Contour list. Defined only for subscripts 1:n_cont. If n_cont >=
@@ -75,7 +74,9 @@ contains
     ! cont_list(:n_cont - 1)%area are missing and cont_list(:n_cont -
     ! 1) are not oriented.
 
-    integer n_cont ! number of good contours found and stored in cont_list, >= 0
+    integer n_cont
+    ! number of good contours found and stored in cont_list, 0 <=
+    ! n_cont <= n_max_cont
 
     !--------------------------------------------------------------
 
diff --git a/Inst_eddies/set_max_speed.f90 b/Inst_eddies/set_max_speed.f90
index 9dc0341fdbb3625fe13d90028b76f45b458d6244..bda863ba21f6a8ba03e58d2bd7597050ea284827 100644
--- a/Inst_eddies/set_max_speed.f90
+++ b/Inst_eddies/set_max_speed.f90
@@ -24,19 +24,20 @@ contains
     use spher_polyline_area_m, only: spher_polyline_area
 
     type(eddy), intent(inout):: e
-    ! e%out_cont, e%cyclone, e%extr%ssh and e%extr%coord
-    ! should be defined on input.
+    ! e%extr%coord should be defined on input.
 
     type(ssh_contour), intent(inout):: cont_list(:) ! (n_max_cont)
-    ! Contour list. Defined only for subscripts 1:n_cont. The
-    ! outermost contour is element with subscript n_cont. The contours
-    ! are in monotonic order of ssh. If n_cont >= 2, cont_list(:n_cont
-    ! - 1)%area are missing and cont_list(:n_cont - 1) are not
-    ! oriented.
+    ! Contour list. Defined only for subscripts 1:n_cont. On entry,
+    ! the outermost contour is element with subscript n_cont. The
+    ! contours between 1 and i_outer are in monotonic order of
+    ! ssh. For i /= i_outer, cont_list(i)%area is missing and
+    ! cont_list(i) is not oriented.
 
     integer, intent(inout):: n_cont
-    ! number of good contours found and stored in cont_list, 1 <=
-    ! n_cont <= n_max_cont
+    ! Number of good contours found and stored in cont_list. On entry,
+    ! 1 <= n_cont <= n_max_cont - 1 (not 0 because set_max_speed is
+    ! only called when there is an outermost contour). On return, 1 <=
+    ! n_cont <= n_max_cont.
 
     real, intent(in):: ssh(:, :), u(:, :), v(:, :)
     ! The domain should be the bounding box of out_cont, because we do