Removed many unnecessary casts.