Lots of clock bugfixes; prepare for merge