Fix warnings caused by -Wsign-conversion.
Fix warning caused by -Wshadow-ivar.