Refactor Shell state.