are these casts needed? I don't think they are. I think your code compiles without them.