Clean up state machine for internal support

Take a look @aniket486