Fix class casting