Refactor genecache code and support building cache from xml file