Close sockets that have errors. Check for errors in plot_results. Fix other merge conflicts