fix some errors with casts