Problem when editing Animator in play mode

I have StateMachineBehaviours on my animator, and when I edit my animator in the editor on play mode (ie. change speed, move nodes, connect/disconnect transitions, etc) the references I have on my StateMachineBehaviours are missing. Though stopping and playing it again will fix it, I hope there is a way to avoid this.

UPDATE: I found out that when I change something on the animator, OnStateEnter is getting recalled every change. Is this intended?

Changing the Animator will reset the whole state machine (and call all the various OnEnter callbacks).
It will also recreate the SMB instances, so yes, that’s expected.