Added state pattern to singleton.