Refactoring of the threading. + clock-input example added.