Added a StateMachine which is based on a Stack.
Bugfixes.
JavaDoc fixed.
Merge pull request #2181 from nooone/statemachine