made heartbeat thread resilient to failures