Fixed compilation error with casts