Fix bug where the cast cache would insert with wrong key.