Tidy up CmsObject query implementation to reduce overhead