Refactored from bean injection to state container