Created a thread object to use for client communication
Added thread wrapper for outgoing client connections.
Grouped functions and rearranged them for better readability