Use memcpy in more places.
Add optimized bitwise operations for unsigned integers.
Fixes #9243.
Refs #9231.