Remove unnecessary casts. Patch by Ragnor.