Fixed performance issues and redid the TCP sockets