Fix next section calculation.

Partial revert of a9f924975fbd78d67c8edc185767c9f2f19d6c27
Merge pull request #31 from martinjones/master

Fix next section calculation.