Performance improvements: avoid slow queries