fixed caching bug and related issues