Replace some unsafe code with a safe stdlib wrapper.