Refactor sending of heartbeat.
Merge pull request #32 from wjdix/master

Refactor sending of heartbeat.