Fsm rewrite

Erroneous pull. Don't merge