Minor algorithmic changes in State Pattern.