Fixed bug in cast.