Fixed minor error in the implementation of higher order casts.