Fix dup heartbeat issue.

Adding hooks in MD to verify HB integrity.
Fix build flag issue.