small changes to reduce function

add comment about type size vs extent
loop index type of int and explicit up case to size_t