Tidy table name handling

Signed-off-by: Gawain Lynch <gawain.lynch@gmail.com>