cleanup/refactor in client heartbeat implementation