better stop logic for HeartbeatThread, and better naming for master client.