changed server thread to be daemonized, added more robust error handling in stop()