LGTM, apart possibly the inline comments.
I've made the changes, amended the previous commit with it and force-pushed the result.
Sad we have to do that in several functions, but makes sense.
The crash itself would probably not require all the places but better to have it handled everywhere so we don't run into it in the future.