Fix a bug in partition.