Add comments on new layer.
Refactor FSM.

Add state enum to make improve readabitity.
Double tap on insert changes layer.
Refactor exec code.
Use the ragel state machine compiler.

Ragel makes it easy to maintain the state machine for input parsing.