Fixed exit+maxinst termination bug. Added caches.