Change type of various capacity and length variables to size_t to increase possible values.