Cache the sizes of vectors instead of calculating them all over the place.