Table Foot now output at bottom of table

The tfoot was not being output in the correct order.
Code formatting, Footer output location corrected

Footer was not being output in the bottom of the table in generated
html. Also updated code formatting.