More robust kmeans. Fixed bug in random point selection.