Fix dup heartbeat issue.

Adding hooks in MD to verify HB integrity.
Fix build flag issue.
Merge pull request #197 from sunyc/master

Fix #195