Fixed Casting Bugs