fixing heartbeat and expire bugs, and adding more logging.