Fix bug #49 as well as correct the number of headings being displayed.