Add simple heartbeat handle. Code refacotr.