Implemented text output.
Improved the state manager.