Optimized some xpath on the entity query functionality.