Fix next section calculation.

Partial revert of a9f924975fbd78d67c8edc185767c9f2f19d6c27