Optimizing kernel caching

Moved kernel caches to local static variables where appropriate