Added state pattern.