Query refactor + Extra API/Query functions