Optimisation : chain from iterable

Use the method from_iterable of chain of itertools instead
of chain(*(list of iterables))
Correct a bug

Correct a bug from the Timer class.
Refactor
Add locks

Change the transition evaluation in the state machine to add the locks