Fix a few downcast issues.