Add some additional checks for valid state.
(cherry picked from commit 3c342ffce43546667f59bb16db373061724e1b0f)
1 file changed