Robustness improvements to algorithm.