Fix a NPE on the CastContext