Shorten and improve table export code a bit