Fix wrong state handling.