Refactored some casts