Better handling of tab state, refactored
reworking to align with query results driving table creation