Refactoring state from singleton.