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