WIP: Rewrite assign_candidates() for speed.