Fix class cast error.