Converted the types all counting variables from int to size_t