Table: Simplify the way headers are retrieved

This also speeds things up: http://jsperf.com/table-header-selector
Table: Stop querying the table for "thead tr" in a loop