Definitions for final, initial, undef states.

Also, let typing of states depend on the name of the main function.