Algorithm fixes.