Intermediary commit

Got things working as an FSM. Some ugly code and shortcuts, but returns
the correct output for 'normal' keylists.