Slight algorithm changes