Adding support for having multiple caches on the same host and a few bugfixes

I intentionally left all the separate commits there, so all individual fixes or additions could be seen (and judged) easily...