Finite State Machine

Signed-off-by: DeK