Fixed downcasting that Windows really does not like.