fix wrong cast to unsigned int, should be size_t

Should fix crashes for ArrayVector.size() >= 2**32
fix ever-increasing buffer
Merge remote-tracking branch 'thorben/fix_arrayvector_64bit'