Implement new state and type filters.

Fixes #5906
Update documentation for the ExternalCommandListener class.

Fixes #5953