Some minor fixes of clock.py
Refactor main loop to implement stepping properly