Fix race condition. TODO: Parallelize
Nicer weights.