This seems to generate a good bit of `unsafe` blocks. Did you not see the common idioms optimized to essentially what the unsafe blocks are doing?

If necessary, it would be nice to have some comments about why unsafe is necessary in these locations.