Silence notice on Windows
detect dead connection
send hardbeat 5 seconds early, not 5 seconds too late
simplified code (removed redundant code)