Fix function calling.

Before, sometimes more values were being returned than necessary.
This was due to the `top` variable only being set higher than its
previous value.