Fix bugs in random partitioner