Revert "Remove uses of unsafe that were *actually* unsafe."

This reverts commit 5af0d4d0d8f026a7bb266a552888939ba93d80f0.
Revert "Revert "Remove uses of unsafe that were *actually* unsafe.""

This reverts commit e17340ea2876b2a38bbd31f8834390d27bfa06ab.
Adding some undocumented functions for performance reasons.