Pass identity map to query, some fixes