Added new cache sysem. Adjusted previous functions towards using new caching system.