A set of fixes around heartbeats and state transitioning in HA