Heartbeat counter moved to EndFrame() function