Fix incorrect indexes used when unpacking the result of locate_resource().
Use running average of the size of the expiration container
when deciding if it should be packed.

* The point of doint this is to release the memory ealier
* Previosly a constant value (100 default) was used, which obviously can
be either right choice or not, depending on how the container is used.