Added support for nested queries.