The URLs generated for linking to headings and subheadings are generated using only the contents of the heading itself. This means that the following structure, #Heading1 ##SubHeading #Heading2 ##SubHeading has the same link to the first and second subheading. Easiest solution: add the headings above in the tree as a prefix to URL name. So the two subheading url's in the example above would become #heading1_subheading and #heading2_subheading, instead of the current #subheading for both.
Forgot to preview, here is the example structure nicely formatted.
#Heading1 ##SubHeading #Heading2 ##SubHeading