Merge "Fix segfault with --cpu-used >= 3 and ext-refs." into nextgenv2