To me these seem necessary, and I'm not sure what one would do in their place. The assert very much seems worth keeping, since I wasn't at all sure that it was correct otherwise, not having knowledge of all possible code paths. I suggest these are fine as is.