Fix subqueries