Added a state pattern.