bug fix: leave flag should be set before joining heartbeat thread. That
thread may block for too long and the leaving host might miss ACK