Missing num_roots check in roots optimization.