changes to updateClock()
added heartbeat management
minor corrections (to make it work)