fix duplicate headings for more than one affected item (fixes #757)