For the moment I changed the line in creating the footnotes to:
$data = $data."<hr><ol class='footnotes' start='$start_number'>"; // Before the footnotes
Works for me but I don’t use decimal formatted footnotes so I’m not sure this is the most correct way to do it. Thanks again.