fix user agent and add dead connection detection