Update cast functions to more efficient implementations.