Fixed performance issues in normalized version of queries.