fixed some incorrect casts