Bug fixes for QueryBuilder