PopulationQuery refactored and commented