Refactoring and initial_state implementation