Made the query system more modular