improved support for subqueries (MARMOTTA-540) and UNION (MARMOTTA-538)