Partially fixed ConstructQuery for the case when query entities are modified to compute count() for example.
Fixed bug in relative sub-queries, which were able to produce queries with in_ operator containing empty list. Thanks to brabadu.