Added a FSM to the ZGE library, restructed code