Fixed the partition algorithm.