Fixed bug that caused random_by_dist() to return None and thereby the program to crash.