Remove unnecessary casts and fix style issues