Remove unnecessary casts

Remove unnecessary casts when possible.