I'm not sure on the purpose of all these casts. They should be converted automagically by the compiler without the cast.