Better handling of ties during optimization.