Better QueryBuilder

Fixed also some bugs