Also update core.py to use randomly selected ports.