Refactoring State manager to extract functionality useful for history manager.