Rewrite caching code and change XML structure