Fixed more index problems and added ALI loop, but is wrong.

The interplay between grid indices and ray indices is extremely tricky.
When doing ray-related operations like the formal solution, I picked a
particular ray index i, as well as its two neighbors i-1 and i+1, using
get_ray_index_for_grid_point(). However, this is wrong: I should pick
only the ray index i using get_ray_index_for_grid_point(); the other two
I should just increment with +/- 1.

Along a ray, the quantitiy

    get_ray_index_for_grid_point(ray, l) - 1

means "the point on the ray just behind the one corresponding to the
grid point l." This is what we want. What I was doing before was

    get_ray_index_for_grid_point(ray, l-1)

which means "the point on the ray physically higher than the one
corresponding to the grind point l." These two meanings are synonymous
for downward-pointing rays, but not for upward-pointing rays. It's no
surprise, in retrospect, that all of my problems so far have been
related to upward-pointing rays.