Added basic data analysis

Initial code for doing top and side heading analysis and rendering
Removed old cross-tabulation check
Added profiling and performance improvements

Nearly 30% fewer function calls under specific conditions (eg. large
cross-tabulated tables). 8th table in demo originally took 9521 function
calls to analyse, now takes 6788 calls.