Add more Javadocs, especially in the StateMachine.