Reworked on StateManager.