Bug fix for wrong entries in CastEnv.