Casting issues fixed