getting rid of endless casts between int and size_t. Should be all consistent now