Remove unused vars & unnecessary casts