Fixed issues with db caching, added options for xml or binary