Replace complex "safe" code with clearer "unsafe" code.

There's probably a better way to do this.