Finished base implementation of FSM generation.