Refactoring of the GCS heartbeat logic.

Should fix issue #432. And it's a continuation of the work on #432.