Shared lib, thread manager, bug fixes

Added shared library to be used by both server and client
Added thread manager to help manage threads used by both client and
server
Added extra exception handling to avoid crashing the server on client
disconnect
Moved client disconnection code into its own function