Thanks for reporting this problem. I have logged it to our defect base as issue #1198. We will fix it in the next release which will be published in a few weeks.
I have just realized that there are actually two methods for retrieving HeaderFooter from HeaderFooters collection: get(int index) and getByHeaderFooterType(int headerFooterType).
You have used the first but should probably use the second. That way you will get the header/footer of the specified type correctly.