Seperating and making minor improvements to query builder
Merging query separation work