Cross-platform threading, sockets updates, and control stream implementation, and various other fixes