Added state model and state manager function.