Added Cachesettings object and refactored Caching code