Improves query generation (tries to)

still temporary :-/