Added heartbeat and auto disconnect