Basic implementation of casts