fix bad query class patching
add caching