some fixes in cache and improved the demo script