fix clocking
fix bug in tracking the clock
add recovery code