Partially integrated the caches.

Massive speedups for some operations.