Revamp heartbeat implementation

fix #33