clean up casts and types to fix warnings in a cleaner way