There's something worrying about our generics and all this casting. I see you've cleaned up some of the casts; I wonder if it is possible to do it "properly" so we don't cast at all!