Improve handling of generics in query object model