Fix all the horrible code I wrote when I apparently didn't understand sockets