Add restart action

This commit implies an important refactoring of the code, to isolate
the different actions in independant functions.