Fixed possible overflow on Sort variable i, type int assigned size_t - 1
Changed Sort for loop to use pre-decrement
Changed all increments except one to pre-increment.
Fixed possible overflow in Sort() on vector counts, type was int instead of size_t but counted values could increment size_t times