Clock sync code rewrite.