Cleanup some invalid conversion errors

Running with flags -g -O2 -Wall -Wextra a number of invalid conversion errors cropped up.  The changes in this pull request fix the errors.