Some minor changes to tcp error handling for more robust server.