add more optimizations to 'tables' implementation