Moved heartbeat to separate class and file. The Heartbeat class is now an object which is only instantiated as a private part of the endpoint class. When the Heartbeat is initialized the caller must provide a callback function to be called on network failure as detected by timeout.