Refactoring
Bug fixes for tab queries