Cleaned up query UI code.