Bug fixes for population calculation