Fix typecasting for upclass