Rework query struct for table (fixes #24)