Modifications to population function to improve robustness.