Enhanced Table support to support newpage

+ cleaned messy code