Refactored state diagram. Smoother graphics.